ExoToolbarsModel

ExoToolbarsModel — The toolbars backend used by ExoToolbarsView

Synopsis

#include <exo/exo.h>

                    ExoToolbarsModel;
enum                ExoToolbarsModelFlags;
#define             EXO_TOOLBARS_ITEM_TYPE
ExoToolbarsModel *  exo_toolbars_model_new              (void);
void                exo_toolbars_model_set_actions      (ExoToolbarsModel *model,
                                                         gchar **actions,
                                                         guint n_actions);
gchar **            exo_toolbars_model_get_actions      (ExoToolbarsModel *model);
gboolean            exo_toolbars_model_load_from_file   (ExoToolbarsModel *model,
                                                         const gchar *filename,
                                                         GError **error);
gboolean            exo_toolbars_model_save_to_file     (ExoToolbarsModel *model,
                                                         const gchar *filename,
                                                         GError **error);
ExoToolbarsModelFlags exo_toolbars_model_get_flags      (ExoToolbarsModel *model,
                                                         gint toolbar_position);
void                exo_toolbars_model_set_flags        (ExoToolbarsModel *model,
                                                         ExoToolbarsModelFlags flags,
                                                         gint toolbar_position);
GtkToolbarStyle     exo_toolbars_model_get_style        (ExoToolbarsModel *model,
                                                         gint toolbar_position);
void                exo_toolbars_model_set_style        (ExoToolbarsModel *model,
                                                         GtkToolbarStyle style,
                                                         gint toolbar_position);
void                exo_toolbars_model_unset_style      (ExoToolbarsModel *model,
                                                         gint toolbar_position);
gchar *             exo_toolbars_model_get_item_type    (ExoToolbarsModel *model,
                                                         GdkAtom dnd_type);
gchar *             exo_toolbars_model_get_item_id      (ExoToolbarsModel *model,
                                                         const gchar *type,
                                                         const gchar *name);
gchar *             exo_toolbars_model_get_item_data    (ExoToolbarsModel *model,
                                                         const gchar *type,
                                                         const gchar *id);
gboolean            exo_toolbars_model_add_item         (ExoToolbarsModel *model,
                                                         gint toolbar_position,
                                                         gint item_position,
                                                         const gchar *id,
                                                         const gchar *type);
void                exo_toolbars_model_add_separator    (ExoToolbarsModel *model,
                                                         gint toolbar_position,
                                                         gint item_position);
gint                exo_toolbars_model_add_toolbar      (ExoToolbarsModel *model,
                                                         gint toolbar_position,
                                                         const gchar *name);
void                exo_toolbars_model_move_item        (ExoToolbarsModel *model,
                                                         gint toolbar_position,
                                                         gint item_position,
                                                         gint new_toolbar_position,
                                                         gint new_item_position);
void                exo_toolbars_model_remove_item      (ExoToolbarsModel *model,
                                                         gint toolbar_position,
                                                         gint item_position);
void                exo_toolbars_model_remove_toolbar   (ExoToolbarsModel *model,
                                                         gint toolbar_position);
gint                exo_toolbars_model_n_items          (ExoToolbarsModel *model,
                                                         gint toolbar_position);
void                exo_toolbars_model_item_nth         (ExoToolbarsModel *model,
                                                         gint toolbar_position,
                                                         gint item_position,
                                                         gboolean *is_separator,
                                                         const gchar **id,
                                                         const gchar **type);
gint                exo_toolbars_model_n_toolbars       (ExoToolbarsModel *model);
const gchar *       exo_toolbars_model_toolbar_nth      (ExoToolbarsModel *model,
                                                         gint toolbar_position);

Object Hierarchy

  GObject
   +----ExoToolbarsModel

Signals

  "get-item-data"                                  : Run First
  "get-item-id"                                    : Run First
  "get-item-type"                                  : Run First
  "item-added"                                     : Run Last
  "item-removed"                                   : Run Last
  "toolbar-added"                                  : Run Last
  "toolbar-changed"                                : Run Last
  "toolbar-removed"                                : Run Last

Description

The ExoToolbarsModel class includes the basic functionality to manage editable toolbars.

Details

ExoToolbarsModel

typedef struct _ExoToolbarsModel ExoToolbarsModel;

The ExoToolbarsModel struct contains only private fields and should not be directly accessed.


enum ExoToolbarsModelFlags

typedef enum {
  EXO_TOOLBARS_MODEL_NOT_REMOVABLE      = 1 << 0,
  EXO_TOOLBARS_MODEL_ACCEPT_ITEMS_ONLY  = 1 << 1,
  EXO_TOOLBARS_MODEL_OVERRIDE_STYLE     = 1 << 2,
} ExoToolbarsModelFlags;

EXO_TOOLBARS_MODEL_NOT_REMOVABLE

Not possible to remove items from the model.

EXO_TOOLBARS_MODEL_ACCEPT_ITEMS_ONLY

Only accept new item, dragging items around is disabled.

EXO_TOOLBARS_MODEL_OVERRIDE_STYLE

If set, the ExoToolbarsModel accepts a custom GtkToolbarStyle. See exo_toolbars_model_set_style().

EXO_TOOLBARS_ITEM_TYPE

#define             EXO_TOOLBARS_ITEM_TYPE

The string used for drag-and-drop in the toolbars editor/model.


exo_toolbars_model_new ()

ExoToolbarsModel *  exo_toolbars_model_new              (void);

Creates a new ExoToolbarsModel with a reference count of one.

You need to call exo_toolbars_model_set_actions() first, after you created an ExoToolbarsModel to set the list of actions, that should be available from the toolbars.

Returns :

A newly created ExoToolbarsModel.

exo_toolbars_model_set_actions ()

void                exo_toolbars_model_set_actions      (ExoToolbarsModel *model,
                                                         gchar **actions,
                                                         guint n_actions);

Specifies the list of valid actions for model. model will only manage actions that are specified in this list. This function should be called right after you created model.

model :

An ExoToolbarsModel.

actions :

A string array with action names.

n_actions :

The number of strings in actions.

exo_toolbars_model_get_actions ()

gchar **            exo_toolbars_model_get_actions      (ExoToolbarsModel *model);

Returns the list of valid actions for model.

model :

An ExoToolbarsModel.

Returns :

The list of valid actions for model.

exo_toolbars_model_load_from_file ()

gboolean            exo_toolbars_model_load_from_file   (ExoToolbarsModel *model,
                                                         const gchar *filename,
                                                         GError **error);

Parses a file containing a toolbars UI definition and merges it with the current contents of model.

model :

An ExoToolbarsModel.

filename :

The name of the file to parse.

error :

Return location for an error or NULL.

Returns :

TRUE if the data was successfully loaded from the file specified by filename, else FALSE.

exo_toolbars_model_save_to_file ()

gboolean            exo_toolbars_model_save_to_file     (ExoToolbarsModel *model,
                                                         const gchar *filename,
                                                         GError **error);

Stores the UI definition of the contents of model to the file specified by filename.

model :

An ExoToolbarsModel.

filename :

The name of the file to save to.

error :

The return location for an error or NULL.

Returns :

TRUE if saving was successfully, else FALSE is returned.

exo_toolbars_model_get_flags ()

ExoToolbarsModelFlags exo_toolbars_model_get_flags      (ExoToolbarsModel *model,
                                                         gint toolbar_position);

Returns the ExoToolbarsModelFlags associated with the toolbar at toolbar_position.

model :

An ExoToolbarsModel.

toolbar_position :

The index of a toolbar in model.

Returns :

The ExoToolbarsModelFlags associated with toolbar_position.

exo_toolbars_model_set_flags ()

void                exo_toolbars_model_set_flags        (ExoToolbarsModel *model,
                                                         ExoToolbarsModelFlags flags,
                                                         gint toolbar_position);

Changes the ExoToolbarsModelFlags associated with the toolbar at toolbar_position to the value of flags.

model :

An ExoToolbarsModel.

flags :

The new flags for toolbar_position.

toolbar_position :

The index of a toolbar in model.

exo_toolbars_model_get_style ()

GtkToolbarStyle     exo_toolbars_model_get_style        (ExoToolbarsModel *model,
                                                         gint toolbar_position);

Returns the overridden GtkToolbarStyle for the toolbar at toolbar_position. Should only be used if EXO_TOOLBARS_MODEL_OVERRIDE_STYLE is set for the toolbar.

model :

An ExoToolbarsModel.

toolbar_position :

The index of a toolbar in model.

Returns :

The GtkToolbarStyle associated with toolbar_position.

exo_toolbars_model_set_style ()

void                exo_toolbars_model_set_style        (ExoToolbarsModel *model,
                                                         GtkToolbarStyle style,
                                                         gint toolbar_position);

Sets the style to use for a particular toolbar in model. You can undo the effect of this function by calling exo_toolbars_model_unset_style().

model :

An ExoToolbarsModel.

style :

A GtkToolbarStyle.

toolbar_position :

The index of a toolbar in model.

exo_toolbars_model_unset_style ()

void                exo_toolbars_model_unset_style      (ExoToolbarsModel *model,
                                                         gint toolbar_position);

Undoes the effect of exo_toolbars_model_unset_style() and resets the style of the specified toolbar to the system default.

model :

An ExoToolbarsModel.

toolbar_position :

The index of a toolbar in model.

exo_toolbars_model_get_item_type ()

gchar *             exo_toolbars_model_get_item_type    (ExoToolbarsModel *model,
                                                         GdkAtom dnd_type);

FIXME.

model :

An ExoToolbarsModel.

dnd_type :

FIXME.

Returns :

FIXME.

exo_toolbars_model_get_item_id ()

gchar *             exo_toolbars_model_get_item_id      (ExoToolbarsModel *model,
                                                         const gchar *type,
                                                         const gchar *name);

FIXME.

model :

An ExoToolbarsModel.

type :

FIXME.

name :

FIXME.

Returns :

FIXME.

exo_toolbars_model_get_item_data ()

gchar *             exo_toolbars_model_get_item_data    (ExoToolbarsModel *model,
                                                         const gchar *type,
                                                         const gchar *id);

FIXME.

model :

An ExoToolbarsModel.

type :

FIXME.

id :

FIXME.

Returns :

FIXME.

exo_toolbars_model_add_item ()

gboolean            exo_toolbars_model_add_item         (ExoToolbarsModel *model,
                                                         gint toolbar_position,
                                                         gint item_position,
                                                         const gchar *id,
                                                         const gchar *type);

Adds a new toolbar item with the specified type and id to model, where id has to be a valid action name for model, that was previously set with exo_toolbars_model_set_actions().

model :

An ExoToolbarsModel.

toolbar_position :

The index of toolbar in model.

item_position :

The position in the specified toolbar or -1.

id :

The identifier of the new item.

type :

The type of the new item.

Returns :

TRUE if the item was added successfully, else FALSE.

exo_toolbars_model_add_separator ()

void                exo_toolbars_model_add_separator    (ExoToolbarsModel *model,
                                                         gint toolbar_position,
                                                         gint item_position);

Adds a new separator item to the specified toolbar in model. If you specify -1 for item_position, the separator will be appended to the toolbar, else it will be inserted at the specified item_position.

model :

An ExoToolbarsModel.

toolbar_position :

The index of a toolbar in model.

item_position :

The position in the specified toolbar or -1.

exo_toolbars_model_add_toolbar ()

gint                exo_toolbars_model_add_toolbar      (ExoToolbarsModel *model,
                                                         gint toolbar_position,
                                                         const gchar *name);

Adds a new toolbar to model. If you specify -1 for toolbar_position, the toolbar will be appended to model; else the toolbar will be inserted at the specified position. Emits the ::toolbar-added signal.

model :

An ExoToolbarsModel.

toolbar_position :

Where to insert the new toolbar in model or -1 to append the toolbar.

name :

The name of the new toolbar.

Returns :

The real position of the new toolbar in model.

exo_toolbars_model_move_item ()

void                exo_toolbars_model_move_item        (ExoToolbarsModel *model,
                                                         gint toolbar_position,
                                                         gint item_position,
                                                         gint new_toolbar_position,
                                                         gint new_item_position);

Moves an item to another position. The move operation is done by first removing the specified item and afterwards readding the item at the new position. Therefore, this functions emits the ::item-removed and ::item-added signals.

model :

An ExoToolbarsModel.

toolbar_position :

Old toolbar index.

item_position :

Old item index.

new_toolbar_position :

New toolbar index.

new_item_position :

New item index.

exo_toolbars_model_remove_item ()

void                exo_toolbars_model_remove_item      (ExoToolbarsModel *model,
                                                         gint toolbar_position,
                                                         gint item_position);

Removes the toolbar item at item_position from the toolbar toolbar_position in model and emits the ::item-removed signal.

model :

An ExoToolbarsModel.

toolbar_position :

A toolbar index.

item_position :

The index of the item to remove.

exo_toolbars_model_remove_toolbar ()

void                exo_toolbars_model_remove_toolbar   (ExoToolbarsModel *model,
                                                         gint toolbar_position);

Removes the specified toolbar from model and emits the ::toolbar-removed signal.

model :

A ExoToolbarsModel.

toolbar_position :

The index of a toolbar in model.

exo_toolbars_model_n_items ()

gint                exo_toolbars_model_n_items          (ExoToolbarsModel *model,
                                                         gint toolbar_position);

Returns the number of items in the specified toolbar.

model :

An ExoToolbarsModel.

toolbar_position :

The index of a toolbar in model.

Returns :

The number of items in the specified toolbar.

exo_toolbars_model_item_nth ()

void                exo_toolbars_model_item_nth         (ExoToolbarsModel *model,
                                                         gint toolbar_position,
                                                         gint item_position,
                                                         gboolean *is_separator,
                                                         const gchar **id,
                                                         const gchar **type);

Queries the properites of the toolbar item at item_position in toolbar toolbar_position.

model :

An ExoToolbarsModel.

toolbar_position :

The index of a toolbar in model.

item_position :

The index of an item in the specified toolbar.

is_separator :

Return location for the separator setting or NULL.

id :

Return location for the item id or NULL.

type :

Return location for the item type or NULL.

exo_toolbars_model_n_toolbars ()

gint                exo_toolbars_model_n_toolbars       (ExoToolbarsModel *model);

Returns the number of toolbars currently managed by model.

model :

An ExoToolbarsModel.

Returns :

The number of toolbars in model.

exo_toolbars_model_toolbar_nth ()

const gchar *       exo_toolbars_model_toolbar_nth      (ExoToolbarsModel *model,
                                                         gint toolbar_position);

Returns the name of the toolbar at toolbar_position in model.

model :

An ExoToolbarsModel.

toolbar_position :

The index of a toolbar in model.

Returns :

The name of the toolbar at toolbar_position in model.

Signal Details

The "get-item-data" signal

gchar*              user_function                      (ExoToolbarsModel *arg0,
                                                        gchar            *arg1,
                                                        gchar            *arg2,
                                                        gpointer          user_data)      : Run First

user_data :

user data set when the signal handler was connected.

The "get-item-id" signal

gchar*              user_function                      (ExoToolbarsModel *arg0,
                                                        gchar            *arg1,
                                                        gchar            *arg2,
                                                        gpointer          user_data)      : Run First

user_data :

user data set when the signal handler was connected.

The "get-item-type" signal

gchar*              user_function                      (ExoToolbarsModel *arg0,
                                                        gpointer          arg1,
                                                        gpointer          user_data)      : Run First

user_data :

user data set when the signal handler was connected.

The "item-added" signal

void                user_function                      (ExoToolbarsModel *model,
                                                        gint              toolbar_position,
                                                        gint              item_position,
                                                        gpointer          user_data)             : Run Last

This signal is emitted whenever a new item is added to a toolbar managed by model.

model :

The ExoToolbarsModel to which an item was added.

toolbar_position :

The index of the toolbar in model to which the item was added.

item_position :

The index of the new item in the specified toolbar.

user_data :

user data set when the signal handler was connected.

The "item-removed" signal

void                user_function                      (ExoToolbarsModel *model,
                                                        gint              toolbar_position,
                                                        gint              item_position,
                                                        gpointer          user_data)             : Run Last

This signal is emitted whenever an item is removed from a toolbar managed by model.

model :

The ExoToolbarsModel from which an item was removed.

toolbar_position :

The index of the toolbar in model from which the item was removed.

item_position :

The index of the item in the specified toolbar.

user_data :

user data set when the signal handler was connected.

The "toolbar-added" signal

void                user_function                      (ExoToolbarsModel *model,
                                                        gint              toolbar_position,
                                                        gpointer          user_data)             : Run Last

This signal is emitted whenever a new toolbar is added to model.

model :

The ExoToolbarsModel to which a new toolbar was added.

toolbar_position :

The index of the new toolbar in model.

user_data :

user data set when the signal handler was connected.

The "toolbar-changed" signal

void                user_function                      (ExoToolbarsModel *model,
                                                        gint              toolbar_position,
                                                        gpointer          user_data)             : Run Last

This signal is emitted whenever the flags or the style of a toolbar change, which is managed by model. All views connected to model should then update their internal state of the specified toolbar.

model :

The ExoToolbarsModel that manages the changed toolbar.

toolbar_position :

The index of the changed toolbar in model.

user_data :

user data set when the signal handler was connected.

The "toolbar-removed" signal

void                user_function                      (ExoToolbarsModel *model,
                                                        gint              toolbar_position,
                                                        gpointer          user_data)             : Run Last

This signal is emitted whenever a toolbar is removed from model.

model :

The ExoToolbarsModel

toolbar_position :

The index of the toolbar in model that was removed.

user_data :

user data set when the signal handler was connected.

See Also

ExoToolbarsView, ExoToolbarsEditor, ExoToolbarsEditorDialog