-void
-egg_toolbar_editor_add_action (EggToolbarEditor *editor,
- const char *action_name)
-{
- GtkAction *action;
-
- action = find_action (editor, action_name);
- g_return_if_fail (action != NULL);
-
- editor->priv->default_actions_list = g_list_insert_sorted
- (editor->priv->default_actions_list, action, compare_actions);
-}
-
-static void
-parse_item_list (EggToolbarEditor *t,
- xmlNodePtr child)
-{
- while (child)
- {
- if (xmlStrEqual (child->name, (const xmlChar*) "toolitem"))
- {
- xmlChar *name;
-
- name = xmlGetProp (child, (const xmlChar*) "name");
- egg_toolbar_editor_add_action (t, (const char*)name);
- xmlFree (name);
- }
- child = child->next;
- }
-}
-
-static gboolean
-model_has_action (EggToolbarsModel *model, GtkAction *action)
-{
- int i, l, n_items, n_toolbars;
-
- n_toolbars = egg_toolbars_model_n_toolbars (model);
- for (i = 0; i < n_toolbars; i++)
- {
- n_items = egg_toolbars_model_n_items (model, i);
- for (l = 0; l < n_items; l++)
- {
- const char *name;
- const char *action_name;
- gboolean sep;
-
- egg_toolbars_model_item_nth (model, i, l, &sep, &name, NULL);
- action_name = gtk_action_get_name (action);
- if (!sep && strcmp (name, action_name) == 0) return TRUE;
- }
- }
-
- return FALSE;
-}
-
-static void
-update_actions_list (EggToolbarEditor *editor)
-{
- GList *l;
-
- if (editor->priv->actions_list)
- g_list_free (editor->priv->actions_list);
-
- /* Remove the already used items */
- editor->priv->actions_list = NULL;
-
- for (l = editor->priv->default_actions_list; l != NULL; l = l->next)
- {
- GtkAction *action = GTK_ACTION (l->data);
-
- if (!model_has_action (editor->priv->model, action))
- {
- editor->priv->actions_list = g_list_insert_sorted
- (editor->priv->actions_list, action, compare_actions);
- }
- }
-}
-
-void
-egg_toolbar_editor_load_actions (EggToolbarEditor *editor,
- const char *xml_file)
-{
- xmlDocPtr doc;
- xmlNodePtr root;
- xmlNodePtr child;
-
- doc = xmlParseFile (xml_file);
- root = xmlDocGetRootElement (doc);
- child = root->children;
-
- while (child)
- {
- if (xmlStrEqual (child->name, (const xmlChar*) "available"))
- {
- parse_item_list (editor, child->children);
- }
- child = child->next;
- }
-
- xmlFreeDoc (doc);
-
- update_actions_list (editor);
- update_editor_sheet (editor);
-}