## ExoToolbarsModel

ExoToolbarsModel — The toolbars backend used by ExoToolbarsView

## Functions

ExoToolbarsModel * | exo_toolbars_model_new ()
void | exo_toolbars_model_set_actions ()
gchar ** | exo_toolbars_model_get_actions ()
gboolean | exo_toolbars_model_load_from_file ()
gboolean | exo_toolbars_model_save_to_file ()
ExoToolbarsModelFlags | exo_toolbars_model_get_flags ()
void | exo_toolbars_model_set_flags ()
GtkToolbarStyle | exo_toolbars_model_get_style ()
void | exo_toolbars_model_set_style ()
void | exo_toolbars_model_unset_style ()
gchar * | exo_toolbars_model_get_item_type ()
gchar * | exo_toolbars_model_get_item_id ()
gchar * | exo_toolbars_model_get_item_data ()
gboolean | exo_toolbars_model_add_item ()
void | exo_toolbars_model_add_separator ()
gint | exo_toolbars_model_add_toolbar ()
void | exo_toolbars_model_move_item ()
void | exo_toolbars_model_remove_item ()
void | exo_toolbars_model_remove_toolbar ()
gint | exo_toolbars_model_n_items ()
void | exo_toolbars_model_item_nth ()
gint | exo_toolbars_model_n_toolbars ()
const gchar * | exo_toolbars_model_toolbar_nth ()

## Signals

gchar* | get-item-data | Run First
gchar* | get-item-id | Run First
gchar* | get-item-type | Run First
void | item-added | Run Last
void | item-removed | Run Last
void | toolbar-added | Run Last
void | toolbar-changed | Run Last
void | toolbar-removed | Run Last

## Types and Values

struct | ExoToolbarsModel
enum | ExoToolbarsModelFlags
#define | EXO_TOOLBARS_ITEM_TYPE

## Object Hierarchy

        GObject
        ╰── ExoToolbarsModel

## Includes

    #include <exo/exo.h>

## Description

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

## Functions

### 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` .

#### Parameters

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` .

#### Parameters

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` .

#### Parameters

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` .

#### Parameters

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` .

#### Parameters

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` .

#### Parameters

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.

#### Parameters

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()`.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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()`.

#### Parameters

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` .

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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` .

#### Parameters

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` .

#### Parameters

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` .

#### Parameters

model | An ExoToolbarsModel. |
toolbar_position | The index of a toolbar in `model` . |

#### Returns

The name of the toolbar at `toolbar_position` in `model` .

## Types and Values

### struct ExoToolbarsModel

    struct ExoToolbarsModel;

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

### enum ExoToolbarsModelFlags

#### Members

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.

## Signal Details

### The `“get-item-data”` signal

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

#### Parameters

user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“get-item-id”` signal

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

#### Parameters

user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“get-item-type”` signal

    gchar*
    user_function (ExoToolbarsModel *arg0,
                   gpointer          arg1,
                   gpointer          user_data)

#### Parameters

user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“item-added”` signal

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

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

#### Parameters

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. |

Flags: Run Last

### The `“item-removed”` signal

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

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

#### Parameters

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. |

Flags: Run Last

### The `“toolbar-added”` signal

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

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

#### Parameters

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. |

Flags: Run Last

### The `“toolbar-changed”` signal

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

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.

#### Parameters

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. |

Flags: Run Last

### The `“toolbar-removed”` signal

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

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

#### Parameters

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. |

Flags: Run Last

## See Also

ExoToolbarsView, ExoToolbarsEditor, ExoToolbarsEditorDialog