CuiWidget

Name

CuiWidget -- The base class for CUI Widgets.

Synopsis


#include <history.h>


            CuiWidget;
void        cui_widget_set_name             (CuiWidget *widget,
                                             const gchar *name);
gchar*      cui_widget_get_name             (CuiWidget *widget);
void        cui_widget_set_active           (CuiWidget *widget,
                                             gboolean active);
gboolean    cui_widget_get_active           (CuiWidget *widget);
void        cui_widget_set_directory        (CuiWidget *widget,
                                             const gchar *directory);
gchar*      cui_widget_get_directory        (CuiWidget *widget);
void        cui_widget_set_background       (CuiWidget *widget,
                                             const Background *background);
Background* cui_widget_get_background       (CuiWidget *widget);
void        cui_widget_set_terminal         (CuiWidget *widget,
                                             const Terminal *terminal);
Terminal*   cui_widget_get_terminal         (CuiWidget *widget);
void        cui_widget_set_appbar           (CuiWidget *widget,
                                             GtkWidget *appbar);
void        cui_widget_set_tooltip          (CuiWidget *widget,
                                             const gchar *tooltip);
void        cui_widget_set_active_style     (CuiWidget *widget,
                                             const gchar *style);
void        cui_widget_add_tag_by_name      (CuiWidget *widget,
                                             const gchar *tag);
void        cui_widget_set_area             (CuiWidget *widget,
                                             const GdkRectangle *rectangle);
void        cui_widget_move                 (CuiWidget *widget,
                                             gint dx,
                                             gint dy);
void        cui_widget_set_area_by_coord    (CuiWidget *widget,
                                             gint x,
                                             gint y,
                                             gint dx,
                                             gint dy);
void        cui_widget_set_area_by_marks    (CuiWidget *widget,
                                             GtkTextMark *begin,
                                             GtkTextMark *end);
void        cui_widget_set_width_by_percent (CuiWidget *widget,
                                             gdouble percent);
void        cui_widget_set_start_and_stop_by_percent
                                            (CuiWidget *widget,
                                             gdouble start,
                                             gdouble stop);
void        cui_widget_set_area_by_iter     (CuiWidget *widget,
                                             GtkTextIter *iter);
GdkRectangle* cui_widget_get_area           (CuiWidget *widget);
GdkRectangle* cui_widget_get_area_window_coords
                                            (CuiWidget *widget);
gint        cui_widget_get_size             (CuiWidget *widget);
gboolean    cui_widget_is_mouse_over        (CuiWidget *widget,
                                             gint x,
                                             gint y);
void        cui_widget_mouse_enter          (CuiWidget *widget);
void        cui_widget_mouse_leave          (CuiWidget *widget);
            CuiCommand;
void        cui_widget_append_file_command  (CuiWidget *widget,
                                             CuiCommandOpcode opcode,
                                             CuiFilename *file_arg);
void        cui_widget_append_file_command_with_arg
                                            (CuiWidget *widget,
                                             CuiCommandOpcode opcode,
                                             CuiFilename *file_arg,
                                             gpointer arg);
void        cui_widget_append_window_command
                                            (CuiWidget *widget,
                                             CuiCommandOpcode opcode,
                                             gpointer window);
void        cui_widget_append_window_command_with_arg
                                            (CuiWidget *widget,
                                             CuiCommandOpcode opcode,
                                             gpointer window,
                                             gpointer arg);
void        cui_widget_activate             (CuiWidget *widget);

Object Hierarchy


  GObject
   +----CuiWidget
         +----CuiActionArea
         +----CuiPixmap
         +----CuiEntry
         +----CuiCalendar
         +----CuiPopupMenu
         +----CuiRectangle

Properties


  "active"               gboolean              : Read / Write
  "active-style"         gchararray            : Read / Write
  "appbar"               gpointer              : Read / Write
  "area"                 gpointer              : Read / Write
  "background"           gpointer              : Read / Write
  "directory"            gchararray            : Read / Write
  "name"                 gchararray            : Read / Write
  "terminal"             gpointer              : Read / Write
  "tooltip"              gchararray            : Read / Write

Description

Details

CuiWidget

typedef struct {
	gchar            *name;        
	gchar            *groupname; 
	GdkRectangle     *area; 
	gboolean          active;    
	gchar            *tooltip;     
	gchar            *directory;   
	Background       *background;
	Terminal         *terminal; 
	GtkWidget        *appbar;  
	gboolean          visible;
	GList            *commands;
	GdkCursor        *mouse_cursor_active;
	GdkCursor        *mouse_cursor_inactive;
	gboolean          mouse_is_over;

	GtkTextMark      *begin_mark;
	GtkTextMark      *end_mark;
	gchar            *active_style;
} CuiWidget;

This is a base class for the widgets in the CUI environment. Currently I'm marking some fields as public since I didn't write the accessing functions for them.

gchar *name;

the name of the widget instance if any

gchar *groupname;

the name of the group if any

GdkRectangle *area;

the location and the size of the widget

gboolean active;

if the widget can be activated

gchar *tooltip;

some descriptive text for the user

gchar *directory;

the working directory of the command

Background *background;

the background this widgets belongs to

Terminal *terminal;

the terminal to send the commands to

GtkWidget *appbar;

for the tooltip information

gboolean visible;

if the widget is currently visible (FIXME: do we use this?)

GList *commands;

The list with the commands we want to execite when the widget is activated.

GdkCursor *mouse_cursor_active;

The mouse cursor we want to see over the widget.

GdkCursor *mouse_cursor_inactive;

The mouse cursor we want to see when the mouse leaves the widget.

gboolean mouse_is_over;

This field is TRUE if the mouse cursor is currently over the widget.

GtkTextMark *begin_mark;

GtkTextMark *end_mark;

gchar *active_style;


cui_widget_set_name ()

void        cui_widget_set_name             (CuiWidget *widget,
                                             const gchar *name);

Sets the name for this widget instance. The name appears in messages, help texts and several other places.

widget :

a CuiWidget

name :

the name of the widget


cui_widget_get_name ()

gchar*      cui_widget_get_name             (CuiWidget *widget);

Gets the name of this widget instance. The returned string should be freed.

widget :

a CuiWidget

Returns :

a newly allocated string


cui_widget_set_active ()

void        cui_widget_set_active           (CuiWidget *widget,
                                             gboolean active);

Sets is the widget can be activated by the mouse.

widget :

a CuiWidget

active :

sets if the widget is an active one


cui_widget_get_active ()

gboolean    cui_widget_get_active           (CuiWidget *widget);

Gets if the widget can be activated by the mouse.

widget :

a CuiWidget

Returns :

TRUE if the widget can be activated


cui_widget_set_directory ()

void        cui_widget_set_directory        (CuiWidget *widget,
                                             const gchar *directory);

Sets the directory for this widget instance. The directory shows what was the working directory when this widget has been created.

widget :

a CuiWidget

directory :

the working directory of the widget's creator


cui_widget_get_directory ()

gchar*      cui_widget_get_directory        (CuiWidget *widget);

Gets the working directory of this widget instance.

widget :

a CuiWidget

Returns :

a newly allocated string


cui_widget_set_background ()

void        cui_widget_set_background       (CuiWidget *widget,
                                             const Background *background);

Sets the background for this widget instance. The background is the place where we show the widget. This function also registers the widget calling cui_background_append_widget.

widget :

a CuiWidget

background :

the background this widget belongs to


cui_widget_get_background ()

Background* cui_widget_get_background       (CuiWidget *widget);

Gets the background this widget instance appears on.

widget :

a CuiWidget

Returns :

a pointer to the background


cui_widget_set_terminal ()

void        cui_widget_set_terminal         (CuiWidget *widget,
                                             const Terminal *terminal);

Sets the terminal for this widget instance. The terminal is a Terminal object we send the commands to execute.

widget :

a CuiWidget

terminal :

the terminal we use to send the commands to the shell


cui_widget_get_terminal ()

Terminal*   cui_widget_get_terminal         (CuiWidget *widget);

Gets the terminal of this widget. The terminal is a Terminal object we use to send the command to the shell.

widget :

a CuiWidget

Returns :

a pointer to the background


cui_widget_set_appbar ()

void        cui_widget_set_appbar           (CuiWidget *widget,
                                             GtkWidget *appbar);

Sets the appbar for this widget instance. The appbar is a widget where we send tooltip text when needed.

widget :

a CuiWidget

appbar :

the application bar we send the tooltip text


cui_widget_set_tooltip ()

void        cui_widget_set_tooltip          (CuiWidget *widget,
                                             const gchar *tooltip);

Sets the tooltip text for this widget instance. The tooltip text is a short remainder appears in a different GtkWidget.

widget :

a CuiWidget

tooltip :

the tooltip text of the widget


cui_widget_set_active_style ()

void        cui_widget_set_active_style     (CuiWidget *widget,
                                             const gchar *style);

Sets the active style name text for this widget instance. The active style is a text style used when the mouse is over the widget.

widget :

a CuiWidget

style :

the active style text of the widget


cui_widget_add_tag_by_name ()

void        cui_widget_add_tag_by_name      (CuiWidget *widget,
                                             const gchar *tag);

Convinient utility function to highlight the text belongs to the widget.

widget :

a CuiWidget widget

tag :

the name of the tag to apply


cui_widget_set_area ()

void        cui_widget_set_area             (CuiWidget *widget,
                                             const GdkRectangle *rectangle);

Sets the activation area for this widget instance. This function will copy the GdkRectangle to an allocated memory, so it can be freed.

widget :

a CuiWidget

rectangle :

the rectangle of the activation area for this widget


cui_widget_move ()

void        cui_widget_move                 (CuiWidget *widget,
                                             gint dx,
                                             gint dy);

Moves the widget by modifying its coordinates.

widget :

the widget to move

dx :

movement on the x axis

dy :

movement on the y axis


cui_widget_set_area_by_coord ()

void        cui_widget_set_area_by_coord    (CuiWidget *widget,
                                             gint x,
                                             gint y,
                                             gint dx,
                                             gint dy);

Sets the activation area for this widget instance.

widget :

a CuiWidget

x :

the x coordinate

y :

the y coordinate

dx :

the width

dy :

the height


cui_widget_set_area_by_marks ()

void        cui_widget_set_area_by_marks    (CuiWidget *widget,
                                             GtkTextMark *begin,
                                             GtkTextMark *end);

Sets the activation area for this widget instance. This function copy the marks so they can be eliminated.

widget :

a CuiWidget

begin :

the GtkTextMark of the upper left corner

end :

the GtkTextMark of the lower right corner


cui_widget_set_width_by_percent ()

void        cui_widget_set_width_by_percent (CuiWidget *widget,
                                             gdouble percent);

Sets the width of the widget as the fraction of the background text window.

widget :

a CuiWidget

percent :

the new width of the widget as a fraction of 100


cui_widget_set_start_and_stop_by_percent ()

void        cui_widget_set_start_and_stop_by_percent
                                            (CuiWidget *widget,
                                             gdouble start,
                                             gdouble stop);

Sets the left and right coordinates of the widget as the fraction of the background text window.

widget :

a CuiWidget

start :

stop :


cui_widget_set_area_by_iter ()

void        cui_widget_set_area_by_iter     (CuiWidget *widget,
                                             GtkTextIter *iter);

Sets the activation area of the widgets using a GtkTextIter to find a character. This function is usefull to create action areas for one given character on the user interface.

widget :

a CuiWidget to set

iter :

the GtkTextIter storing the place of the char


cui_widget_get_area ()

GdkRectangle* cui_widget_get_area           (CuiWidget *widget);

Gets the activation area of this widget. The return value should not be modified or freed.

widget :

a CuiWidget

Returns :

the rectangular area of the widget


cui_widget_get_area_window_coords ()

GdkRectangle* cui_widget_get_area_window_coords
                                            (CuiWidget *widget);

Gets the activation area of this widget relative to the text_view this widget is in. Note that the Background of the widget must be valid and the GtkTextView of the Background also must be set.

The return value of the function is a dinamically allocated area which should be freed.

widget :

a CuiWidget

Returns :

the rectangular area of the widget relative to the text_view


cui_widget_get_size ()

gint        cui_widget_get_size             (CuiWidget *widget);

widget :

Returns :


cui_widget_is_mouse_over ()

gboolean    cui_widget_is_mouse_over        (CuiWidget *widget,
                                             gint x,
                                             gint y);

Checks if the mouse is over the given widget, that is the given coordinates are inside the activation area.

This function gets x and y coordinate in the widget coordinate system. Use # gtk_text_view_window_to_buffer_coords to convert mouse coordinates to this coordinate system.

widget :

a CuiWidget

x :

the x coordinate of the mouse

y :

the y coordinate of the mouse

Returns :

TRUE if the given coordinates are inside the activation area


cui_widget_mouse_enter ()

void        cui_widget_mouse_enter          (CuiWidget *widget);

This function must be called when the mouse enters the area of the widget. I'm sure there is a better solution, but I have not found yet... yep, found we should use signals of course. FIXME: we really should use signals.

widget :

a CuiWidget widget


cui_widget_mouse_leave ()

void        cui_widget_mouse_leave          (CuiWidget *widget);

This function must be called when the mouse leaves the area of the widget. I'm sure there is a better solution, but I have not found yet...

widget :

a CuiWidget widget


CuiCommand

typedef struct {
	CuiCommandType     type;
	CuiCommandOpcode   opcode;
	gpointer           parg1;
	gpointer 	   parg2;
} CuiCommand;

CuiCommandType type;

the type of the command used to decide how to perform

CuiCommandOpcode opcode;

the operation code (what to do)

gpointer parg1;

a pointer argument

gpointer parg2;

an optional second argument


cui_widget_append_file_command ()

void        cui_widget_append_file_command  (CuiWidget *widget,
                                             CuiCommandOpcode opcode,
                                             CuiFilename *file_arg);

The functions appends a new command to the widget. The commands are instructions we have to execute when the user activates the widget. As it is obvious I'm not exactly sure how we have to develop this command feature, but it is essential to send lines to the shell.

This function handles only commands used to handle files.

widget :

a CuiWidget

opcode :

the code of this operation

file_arg :

the CuiFilename argument of the command


cui_widget_append_file_command_with_arg ()

void        cui_widget_append_file_command_with_arg
                                            (CuiWidget *widget,
                                             CuiCommandOpcode opcode,
                                             CuiFilename *file_arg,
                                             gpointer arg);

widget :

opcode :

file_arg :

arg :


cui_widget_append_window_command ()

void        cui_widget_append_window_command
                                            (CuiWidget *widget,
                                             CuiCommandOpcode opcode,
                                             gpointer window);

Appends a new window command to the widget.

widget :

a CuiWidget

opcode :

the opcode of the command

window :

a CuiWindow


cui_widget_append_window_command_with_arg ()

void        cui_widget_append_window_command_with_arg
                                            (CuiWidget *widget,
                                             CuiCommandOpcode opcode,
                                             gpointer window,
                                             gpointer arg);

Appends a new window command to the widget.

widget :

a CuiWidget

opcode :

the opcode of the command

window :

a CuiWindow

arg :

the argument


cui_widget_activate ()

void        cui_widget_activate             (CuiWidget *widget);

Emits the commands associated with the widget. This function should be called when the user activates the widget.

widget :

a CuiWidget

Properties

The "active" property

  "active"               gboolean              : Read / Write

If this widget is shown and working.

Default value: TRUE


The "active-style" property

  "active-style"         gchararray            : Read / Write

Text style for the active state if any.

Default value: ""


The "appbar" property

  "appbar"               gpointer              : Read / Write

The GtkWidget to send the tooltip information.


The "area" property

  "area"                 gpointer              : Read / Write

The place and the size of the widget.


The "background" property

  "background"           gpointer              : Read / Write

The background containing this widget.


The "directory" property

  "directory"            gchararray            : Read / Write

The working directory of the creator command.

Default value: ""


The "name" property

  "name"                 gchararray            : Read / Write

The name of this widget instance.

Default value: "unknown name"


The "terminal" property

  "terminal"             gpointer              : Read / Write

The terminal we send the commands to.


The "tooltip" property

  "tooltip"              gchararray            : Read / Write

Some descriptive text.

Default value: ""