GtkUndo

Name

GtkUndo -- The GtkUndo library

Synopsis



struct      GtkUndo;
void        gtk_undo_initialize             (void);
gint        gtk_undo_register_action_type   (GUndoActionType type);
GtkUndo*    gtk_undo_new                    (void);
void        gtk_undo_set_maxlen             (GtkUndo *undo,
                                             gint maxlen);
gboolean    gtk_undo_add_widget             (GtkUndo *undo,
                                             GtkWidget *widget,
                                             gint type);
gboolean    gtk_undo_add_glade_built_widget (GtkUndo *undo,
                                             GtkWidget *parent,
                                             gchar *widget_name,
                                             gint type);
enum        GtkUndoTriggerType;
void        gtk_undo_add_trigger            (GtkUndo *undo,
                                             GtkWidget *trigger,
                                             GtkUndoTriggerType trigger_type);
void        gtk_undo_add_trigger_pair       (GtkUndo *undo,
                                             GtkWidget *undo_trigger,
                                             GtkWidget *redo_trigger);
void        gtk_undo_add_glade_built_trigger_pair
                                            (GtkUndo *undo,
                                             GtkWidget *parent,
                                             gchar *undo_trigger_name,
                                             gchar *redo_trigger_name);


Object Hierarchy


  GObject
   +----GtkUndo

Signal Prototypes


"redone"    void        user_function      (GtkUndo *undo,
                                            GObject *arg1,
                                            gpointer user_data);
"undone"    void        user_function      (GtkUndo *undo,
                                            GObject *arg1,
                                            gpointer user_data);

Description

GtkUndo is a library which helps you to give undo/redo capacities to your GTK+ programs.

Details

struct GtkUndo

struct GtkUndo;

This structure is an opaque structure and its fields should never be accessed directly.


gtk_undo_initialize ()

void        gtk_undo_initialize             (void);

Initializes GtkUndo library.


gtk_undo_register_action_type ()

gint        gtk_undo_register_action_type   (GUndoActionType type);

Adds an action type to the GtkUndo supported action types. See GtkUndo-custom for more details.

type : A GUndoActionType structure.
Returns : The number of registered types.


gtk_undo_new ()

GtkUndo*    gtk_undo_new                    (void);

Creates a new GtkUndo.

Returns : A newly allocated GtkUndo instance.


gtk_undo_set_maxlen ()

void        gtk_undo_set_maxlen             (GtkUndo *undo,
                                             gint maxlen);

Sets the maximum length of the Undo list. 0 means infinite.

undo : The GtkUndo object to modify
maxlen : The maximum number of operations to store.


gtk_undo_add_widget ()

gboolean    gtk_undo_add_widget             (GtkUndo *undo,
                                             GtkWidget *widget,
                                             gint type);

Registers a widget for undo operations. If the widget's type is not supported and no custom action type is provided, gtk_undo_add_widget() returns FALSE. The predefined types are listed in GtkUndoAction.

If the type is -1, then the default action for the widget is assumed. If the type is provided, the custom action type is used, even if a default action is defined for that kinda widget.

When a widget has a grouping capacity (especially GtkRadioButton), passing one element will set up the whole group for undo/redo facilities.

undo : A GtkUndo object
widget : The widget to add
type : The type of action to associate with the widget (this -must- be a register'd action type or -1).
Returns : TRUE if widget could be added, FALSE if if failed.


gtk_undo_add_glade_built_widget ()

gboolean    gtk_undo_add_glade_built_widget (GtkUndo *undo,
                                             GtkWidget *parent,
                                             gchar *widget_name,
                                             gint type);

This is a convenience function for <ulink url="http://glade.gnome.org/">Glade (http://glade.gnome.org/)</ulink> users. In a Glade generated source tree, a function wraps all the widget's creation, and it is quite boring to use "lookup_widget" all the time to set up the GtkUndo object. So, This function is a shortcut.

If @ conception time, you've added a GtkEntry named "entry1" in a window "window1", after calling from your main() window1=create_window1(), you can simply register your entry1 in a GtkUndo undo list with gtk_undo_add_glade_built_widget(undo,window1,"entry1",-1);

Please check gtk_undo_add_widget.

undo : A GtkUndo object
parent : A GtkWidget containing the triggers
widget_name : The widget-to-add's name, given at Glade UI conception time.
type : The type of action to associate with the widget (this -must- be a register'd action type or -1).
Returns :


enum GtkUndoTriggerType

typedef enum {
  GTK_UNDO_TRIGGER_UNDO=0,
  GTK_UNDO_TRIGGER_REDO
}GtkUndoTriggerType;


gtk_undo_add_trigger ()

void        gtk_undo_add_trigger            (GtkUndo *undo,
                                             GtkWidget *trigger,
                                             GtkUndoTriggerType trigger_type);

Associates trigger with undo so when trigger is activated, the action defined by trigger_type. You can connect signals to trigger anyway but it is strongly discouraged as it may disturb the GtkUndo work. Once a GtkButton or GtkMenuItem is associated with a GtkUndo object, everything is performed automagicaly.

undo : A GtkUndo object
trigger : A GtkButton or GtkMenuItem object
trigger_type : GTK_TRIGGER_TYPE_UNDO or GTK_TRIGGER_TYPE_REDO


gtk_undo_add_trigger_pair ()

void        gtk_undo_add_trigger_pair       (GtkUndo *undo,
                                             GtkWidget *undo_trigger,
                                             GtkWidget *redo_trigger);

This function is a wrapper for gtk_undo_add_trigger() which is called twice.

undo : A GtkUndo object
undo_trigger : A GtkButton or GtkMenuItem object
redo_trigger : A GtkButton or GtkMenuItem object


gtk_undo_add_glade_built_trigger_pair ()

void        gtk_undo_add_glade_built_trigger_pair
                                            (GtkUndo *undo,
                                             GtkWidget *parent,
                                             gchar *undo_trigger_name,
                                             gchar *redo_trigger_name);

Please check gtk_undo_add_trigger_pair.

undo : A GtkUndo object
parent : A GtkWidget containing the triggers
undo_trigger_name : The undo widget's name which was given to the undo trigger in Glade
redo_trigger_name : The redo widget's name which was given to the redo trigger in Glade

Signals

The "redone" signal

void        user_function                  (GtkUndo *undo,
                                            GObject *arg1,
                                            gpointer user_data);

Emitted when an action was redone.

undo :the object which received the signal.
arg1 :the GUndoAction which was redone.
user_data :user data set when the signal handler was connected.


The "undone" signal

void        user_function                  (GtkUndo *undo,
                                            GObject *arg1,
                                            gpointer user_data);

Emitted when an action was undone.

undo :the object which received the signal.
arg1 :the GUndoAction which was undone.
user_data :user data set when the signal handler was connected.

See Also

GUndo

GUndo is the library that GtkUndo relies on. It defines the GUndoAction, GUndoActionType & GUndo types. We could say that GtkUndo is a specific implementation of GUndo for GTK+, but in fact, I have splitted the GtkUndo project into several pieces to manage the library more easily.

GFifo

GFifo defines a First In First Out stack of data with maximum length and signals emission. The data in GtkUndo is stored in a GFifo.