Gnome User Interface Library Reference Manual
<<< Previous Page | Home | Up | Next Page >>>

# GnomeLess

## Name

GnomeLess -- Simple file content browser widget.

## Synopsis

    #include <gnome.h>

    struct      GnomeLess;
    GtkWidget*  gnome_less_new                  (void);
    void        gnome_less_clear                (GnomeLess *gl);
    gboolean    gnome_less_show_file            (GnomeLess *gl,
                                                 const gchar *path);
    gboolean    gnome_less_show_command         (GnomeLess *gl,
                                                 const gchar *command_line);
    void        gnome_less_show_string          (GnomeLess *gl,
                                                 const gchar *s);
    gboolean    gnome_less_show_filestream      (GnomeLess *gl,
                                                 FILE *f);
    gboolean    gnome_less_show_fd              (GnomeLess *gl,
                                                 int file_descriptor);
    gboolean    gnome_less_write_file           (GnomeLess *gl,
                                                 const gchar *path);
    gboolean    gnome_less_write_fd             (GnomeLess *gl,
                                                 int fd);
    void        gnome_less_set_font             (GnomeLess *gl,
                                                 GdkFont *font);
    void        gnome_less_set_fixed_font       (GnomeLess *gl,
                                                 gboolean fixed);
    void        gnome_less_reshow               (GnomeLess *gl);
    void        gnome_less_fixed_font           (GnomeLess *gl);

## Object Hierarchy

      GtkObject
       +----GtkWidget
             +----GtkContainer
                   +----GtkBox
                         +----GtkVBox
                               +----GnomeLess

## Description

This widget implements a graphical "more" command. It allows the user to view a text file. There are various possible ways to specify the contents to display: loading the data from a file (by providing a filename) or by loading it from an open C FILE data stream or from the output of a Unix command or from a Unix file descriptor.

The following is a simple example of its use. The code creates a GnomeLess widget, sets a custom font, and fills the widget with the contents of a file.

    GtkWidget *gl;
    GdkFont *font;

    /* create a new widget */
    gl = gnome_less_new();

    /* set our custom font */
    font = gdk_font_load("-adobe-helvetica-bold-o-normal-*-*-140-*-*-p-*-iso8859-1");
    gnome_less_set_font(GNOME_LESS(gl), font);

    /* display some text */
    gnome_less_show_file(GNOME_LESS(gl), "/home/user/file.txt");

## Details

### struct GnomeLess

    struct GnomeLess;

### gnome_less_new ()

    GtkWidget*  gnome_less_new                  (void);

Creates a new GnomeLess widget.

Returns : | &GtkWidget pointer to a new GNOME less widget

### gnome_less_clear ()

    void        gnome_less_clear                (GnomeLess *gl);

Clears all text from GnomeLess widget `gl`.

`gl` : | Pointer to GnomeLess widget

### gnome_less_show_file ()

    gboolean    gnome_less_show_file            (GnomeLess *gl,
                                                 const gchar *path);

Displays a file in a GnomeLess widget. Replaces any text already being displayed in the widget.

`gl` : | Pointer to GnomeLess widget
`path` : | Pathname of file to be displayed
Returns : | `TRUE` if successful, `FALSE` if not. Error stored in `errno`.

### gnome_less_show_command ()

    gboolean    gnome_less_show_command         (GnomeLess *gl,
                                                 const gchar *command_line);

Runs the shell command specified in `command_line`, and places the output of that command in the GnomeLess widget specified by `gl`. Replaces any text already being displayed in the widget.

`gl` : | Pointer to GnomeLess widget
`command_line` : | Command to be executed
Returns : | `TRUE` if successful, `FALSE` if not. Error stored in `errno`.

### gnome_less_show_string ()

    void        gnome_less_show_string          (GnomeLess *gl,
                                                 const gchar *s);

Displays a string in the GnomeLess widget `gl`. Replaces any text already being displayed.

`gl` : | Pointer to GnomeLess widget
`s` : | String to be displayed

### gnome_less_show_filestream ()

    gboolean    gnome_less_show_filestream      (GnomeLess *gl,
                                                 FILE *f);

Reads all of the text from filestream `f`, and places it in the GnomeLess widget `gl`. Replaces any text already being displayed.

`gl` : | Pointer to GnomeLess widget
`f` : | Filestream to be displayed in the widget
Returns : | `TRUE` if successful, `FALSE` if not. Error stored in `errno`.

### gnome_less_show_fd ()

    gboolean    gnome_less_show_fd              (GnomeLess *gl,
                                                 int file_descriptor);

Reads all of the text from file descriptor `file_descriptor`, and places it in the GnomeLess widget `gl`. Replaces any text already being displayed.

`gl` : | Pointer to GnomeLess widget
`file_descriptor` : | Filestream to be displayed in the widget
Returns : | `TRUE` if successful, `FALSE` if not. Error stored in `errno`.

### gnome_less_write_file ()

    gboolean    gnome_less_write_file           (GnomeLess *gl,
                                                 const gchar *path);

Writes the text displayed in the GnomeLess widget `gl` to the file specified by `path`.

`gl` : | Pointer to GnomeLess widget
`path` : | Path of file to be written
Returns : | `TRUE` if successful, `FALSE` if not. Error stored in `errno`.

### gnome_less_write_fd ()

    gboolean    gnome_less_write_fd             (GnomeLess *gl,
                                                 int fd);

Writes the text displayed in the GnomeLess widget `gl` to file descriptor `fd`.

`gl` : | Pointer to GnomeLess widget
`fd` : | File descriptor
Returns : | `TRUE` if successful, `FALSE` if not. Error stored in `errno`.

### gnome_less_set_font ()

    void        gnome_less_set_font             (GnomeLess *gl,
                                                 GdkFont *font);

Sets the font of the text to be displayed in the GnomeLess widget `gl` to `font`.

Note: This will not affect text already being displayed. If you use this function after adding text to the widget, you must show it again by using gnome_less_reshow or one of the gnome_less_show commands.

`gl` : | Pointer to GnomeLess widget
`font` : | Pointer to GdkFont

### gnome_less_set_fixed_font ()

    void        gnome_less_set_fixed_font       (GnomeLess *gl,
                                                 gboolean fixed);

Specifies whether or not new text should be displayed using a fixed font. Pass TRUE in `fixed` to use a fixed font, or FALSE to revert to the default GtkText font.

Note: This will not affect text already being displayed. If you use this function after adding text to the widget, you must show it again by using gnome_less_reshow or one of the gnome_less_show commands.

`gl` : | Pointer to GNOME Less widget
`fixed` : | Whether or not to use a fixed font

### gnome_less_reshow ()

    void        gnome_less_reshow               (GnomeLess *gl);

Re-displays all of the text in the GnomeLess widget `gl`. If the font has changed since the last show/reshow of text, it will update the current text to the new font.

`gl` : | Pointer to GnomeLess widget

### gnome_less_fixed_font ()

    void        gnome_less_fixed_font           (GnomeLess *gl);

This function is obsolete. Please use gnome_less_set_fixed_font instead.

`gl` : | Pointer to GnomeLess widget

<<< Previous Page | Home | Up | Next Page >>>
GnomeIconSelection | GnomeMDIChild