aboutsummaryrefslogtreecommitdiffstats
path: root/lib/egg/egg-toolbars-model.c
diff options
context:
space:
mode:
authorPeter Harvey <pah06@uow.edu.au>2005-10-17 04:29:26 +0800
committerChristian Persch <chpe@src.gnome.org>2005-10-17 04:29:26 +0800
commitd21007362f8d0701d63e50fe6b219de067d95a87 (patch)
tree46326d5633d4f3c8504049476d0e72ae7ed0ca2c /lib/egg/egg-toolbars-model.c
parent35b9deda1f37ac0cc81d926b5295983de6b55dcf (diff)
downloadgsoc2013-epiphany-d21007362f8d0701d63e50fe6b219de067d95a87.tar
gsoc2013-epiphany-d21007362f8d0701d63e50fe6b219de067d95a87.tar.gz
gsoc2013-epiphany-d21007362f8d0701d63e50fe6b219de067d95a87.tar.bz2
gsoc2013-epiphany-d21007362f8d0701d63e50fe6b219de067d95a87.tar.lz
gsoc2013-epiphany-d21007362f8d0701d63e50fe6b219de067d95a87.tar.xz
gsoc2013-epiphany-d21007362f8d0701d63e50fe6b219de067d95a87.tar.zst
gsoc2013-epiphany-d21007362f8d0701d63e50fe6b219de067d95a87.zip
H18 patch, by Peter Harvey <pah06@uow.edu.au>.
2005-10-16 Peter Harvey <pah06@uow.edu.au> H18 patch, by Peter Harvey <pah06@uow.edu.au>. * data/ui/epiphany-bookmark-editor-ui.xml: * data/ui/epiphany-ui.xml: * lib/egg/egg-editable-toolbar.c: (get_dock_position), (get_toolbar_position), (get_toolbar_nth), (find_action), (drag_data_delete_cb), (drag_begin_cb), (drag_end_cb), (drag_data_get_cb), (move_item_cb), (set_dock_visible), (remove_item_cb), (remove_toolbar_cb), (toggle_visibility_cb), (egg_editable_toolbar_add_visibility_items), (egg_editable_toolbar_add_popup_items), (popup_context_menu_cb), (button_press_event_cb), (configure_item_sensitivity), (configure_item_cursor), (connect_widget_signals), (action_sensitive_cb), (create_item_from_action), (create_item_from_position), (toolbar_drag_data_received_cb), (toolbar_drag_drop_cb), (toolbar_drag_motion_cb), (toolbar_drag_leave_cb), (configure_drag_dest), (create_dock), (toolbar_changed_cb), (unparent_fixed), (update_fixed), (toolbar_added_cb), (toolbar_removed_cb), (item_added_cb), (item_removed_cb), (egg_editable_toolbar_construct), (egg_editable_toolbar_set_ui_manager), (egg_editable_toolbar_set_property), (egg_editable_toolbar_get_property), (egg_editable_toolbar_init), (egg_editable_toolbar_finalize), (egg_editable_toolbar_get_edit_mode), (egg_editable_toolbar_set_edit_mode), (egg_editable_toolbar_set_fixed): * lib/egg/egg-editable-toolbar.h: * lib/egg/egg-toolbar-editor.c: (compare_items), (item_added_or_removed_cb), (toolbar_removed_cb), (egg_toolbar_editor_set_model), (egg_toolbar_editor_finalize), (drag_begin_cb), (drag_end_cb), (drag_data_get_cb), (editor_create_item), (editor_create_item_from_name), (append_table), (update_editor_sheet), (egg_toolbar_editor_init): * lib/egg/egg-toolbar-editor.h: * lib/egg/egg-toolbars-model.c: (egg_toolbars_model_to_xml), (egg_toolbars_model_save), (toolbar_node_new), (item_node_new), (item_node_free), (toolbar_node_free), (egg_toolbars_model_get_flags), (egg_toolbars_model_set_flags), (egg_toolbars_model_get_data), (egg_toolbars_model_get_name), (impl_add_item), (egg_toolbars_model_add_item), (egg_toolbars_model_add_toolbar), (parse_data_list), (parse_item_list), (parse_toolbars), (egg_toolbars_model_load), (egg_toolbars_model_class_init), (egg_toolbars_model_init), (egg_toolbars_model_finalize), (egg_toolbars_model_remove_toolbar), (egg_toolbars_model_remove_item), (egg_toolbars_model_move_item), (egg_toolbars_model_n_items), (egg_toolbars_model_item_nth), (egg_toolbars_model_n_toolbars), (egg_toolbars_model_toolbar_nth), (egg_toolbars_model_get_types), (egg_toolbars_model_set_types), (fill_avail_array), (egg_toolbars_model_get_avail), (egg_toolbars_model_get_n_avail), (egg_toolbars_model_set_n_avail): * lib/egg/egg-toolbars-model.h: * src/bookmarks/Makefile.am: * src/bookmarks/ephy-bookmark-action-group.c: (smart_added_cb), (smart_removed_cb), (node_changed_cb), (node_added_cb), (node_removed_cb), (ephy_bookmark_group_new): * src/bookmarks/ephy-bookmark-action-group.h: * src/bookmarks/ephy-bookmark-action.c: (create_tool_item), (ephy_bookmark_action_sync_icon), (show_context_menu), (popup_menu_cb), (button_press_cb), (button_release_cb), (connect_proxy), (ephy_bookmark_action_updated), (ephy_bookmark_action_get_bookmark), (ephy_bookmark_action_set_bookmark), (ephy_bookmark_action_set_property), (ephy_bookmark_action_get_property), (ephy_bookmark_action_finalize), (ephy_bookmark_action_class_init), (ephy_bookmark_action_init), (ephy_bookmark_action_name), (ephy_bookmark_action_new): * src/bookmarks/ephy-bookmark-action.h: * src/bookmarks/ephy-bookmark-factory-action.c: (ephy_bookmark_factory_action_get_type), (activate_item_cb), (build_menu_for_topic), (build_menu), (remove_placeholder_cb), (activate_placeholder_cb), (clicked_placeholder_cb), (realize_placeholder_cb), (create_tool_item), (connect_proxy), (ephy_bookmark_factory_action_class_init), (ephy_bookmark_factory_action_new): * src/bookmarks/ephy-bookmark-factory-action.h: * src/bookmarks/ephy-bookmark-properties.c: (ephy_bookmark_properties_set_property), (ephy_bookmark_properties_get_property), (bookmark_properties_response_cb), (update_entry), (location_entry_changed_cb), (build_ui): * src/bookmarks/ephy-bookmarks-editor.c: (add_entry_monitor), (cmd_add_topic), (delete_topic_dialog_construct), (cmd_bookmarks_import), (ephy_bookmarks_editor_finalize), (ephy_bookmarks_editor_node_activated_cb), (ephy_bookmarks_editor_update_menu), (view_focus_cb), (add_focus_monitor), (remove_focus_monitor), (bookmarks_filter), (search_entry_search_cb), (ephy_bookmarks_editor_construct), (ephy_bookmarks_editor_set_parent), (ephy_bookmarks_editor_set_property), (ephy_bookmarks_editor_get_property), (ephy_bookmarks_editor_init): * src/bookmarks/ephy-bookmarks-menu.c: (append_bookmarks), (append_menu), (ephy_bookmarks_menu_build): * src/bookmarks/ephy-bookmarks-menu.h: * src/bookmarks/ephy-bookmarks-ui.c: (find_action), (activate_bookmarks_menu), (activate_favorites_menu), (erase_bookmarks_menu), (erase_favorites_menu), (tree_changed_cb), (node_added_cb), (node_changed_cb), (node_removed_cb), (ephy_bookmarks_ui_attach_window), (ephy_bookmarks_ui_detach_window), (toolbar_node_removed_cb), (topic_has_data), (topic_get_data), (topic_get_name), (bookmark_has_data), (bookmark_get_data), (bookmark_get_name), (bookmark_new_name), (ephy_bookmarks_ui_attach_toolbar_model), (ephy_bookmarks_ui_detach_toolbar_model): * src/bookmarks/ephy-bookmarks-ui.h: * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_get_type), (ephy_bookmarks_init_defaults), (ephy_bookmarks_class_init), (ephy_bookmarks_save_delayed), (add_to_favorites), (update_bookmark_keywords), (ephy_bookmarks_init), (ephy_bookmarks_finalize), (ephy_bookmarks_add), (ephy_bookmarks_set_address), (ephy_bookmarks_set_icon), (ephy_bookmarks_add_keyword), (ephy_bookmarks_show_bookmark_properties), (ephy_bookmarks_get_from_id), (ephy_bookmarks_compare_topics), (ephy_bookmarks_compare_topic_pointers), (ephy_bookmarks_compare_bookmarks), (ephy_bookmarks_compare_bookmark_pointers): * src/bookmarks/ephy-bookmarks.h: * src/bookmarks/ephy-bookmarksbar-model.c: * src/bookmarks/ephy-bookmarksbar-model.h: * src/bookmarks/ephy-bookmarksbar.c: * src/bookmarks/ephy-bookmarksbar.h: * src/bookmarks/ephy-favorites-menu.c: * src/bookmarks/ephy-favorites-menu.h: * src/bookmarks/ephy-new-bookmark.c: (ephy_new_bookmark_add), (build_editing_table), (ephy_new_bookmark_construct), (ephy_new_bookmark_set_property), (ephy_new_bookmark_get_property): * src/bookmarks/ephy-nodes-cover.c: (ephy_nodes_count_covered), (ephy_nodes_remove_covered), (ephy_nodes_remove_not_covered), (ephy_nodes_get_covered), (ephy_nodes_covered), (ephy_nodes_get_covering): * src/bookmarks/ephy-nodes-cover.h: * src/bookmarks/ephy-open-tabs-action.c: (activate_cb), (node_added_cb), (node_removed_cb), (ephy_open_tabs_group_new), (ephy_open_tabs_action_name): * src/bookmarks/ephy-open-tabs-action.h: * src/bookmarks/ephy-related-action.c: (node_changed), (node_destroyed), (open_link), (iface_init), (ephy_related_action_get_type), (ephy_related_action_new): * src/bookmarks/ephy-related-action.h: * src/bookmarks/ephy-topic-action-group.c: (node_changed_cb), (node_added_cb), (node_removed_cb), (ephy_topic_group_new): * src/bookmarks/ephy-topic-action-group.h: * src/bookmarks/ephy-topic-action.c: (ephy_topic_action_get_type), (create_tool_item), (ephy_topic_action_sync_label), (get_popup), (erase_popup), (child_added_cb), (child_changed_cb), (child_removed_cb), (menu_destroy_cb), (menu_init_cb), (button_deactivate_cb), (button_toggled_cb), (button_release_cb), (button_press_cb), (connect_proxy), (ephy_topic_action_updated), (ephy_topic_action_get_topic), (ephy_topic_action_set_topic), (ephy_topic_action_set_property), (ephy_topic_action_get_property), (ephy_topic_action_class_init), (ephy_topic_action_init), (ephy_topic_action_name), (ephy_topic_action_new): * src/bookmarks/ephy-topic-action.h: * src/bookmarks/ephy-topic-factory-action.c: (ephy_topic_factory_action_get_type), (sort_topics), (activate_item_cb), (build_menu), (remove_placeholder_cb), (activate_placeholder_cb), (clicked_placeholder_cb), (realize_placeholder_cb), (create_tool_item), (connect_proxy), (ephy_topic_factory_action_class_init), (ephy_topic_factory_action_new): * src/bookmarks/ephy-topic-factory-action.h: * src/ephy-link-action.c: (ephy_link_action_group_get_type), (ephy_link_action_group_new): * src/ephy-link-action.h: * src/ephy-lockdown.c: (find_name), (find_action_group), (update_window): * src/ephy-notebook.c: (move_tab_to_another_notebook), (ephy_notebook_switch_page_cb), (ephy_notebook_init), (tab_label_style_set_cb), (build_tab_label), (ephy_notebook_add_tab): * src/ephy-shell.c: (ephy_shell_get_toolbars_model): * src/ephy-toolbar-editor.c: (ephy_toolbar_editor_constructor), (ephy_toolbar_editor_finalize), (ephy_toolbar_editor_set_property), (ephy_toolbar_editor_class_init): * src/ephy-toolbar.c: (ephy_toolbar_realize), (ephy_toolbar_unrealize), (ephy_toolbar_finalize): * src/ephy-toolbars-model.c: (update_flags), (ephy_toolbars_model_load): * src/ephy-window.c: (ephy_window_get_type), (get_chromes_visibility), (sync_chromes_visibility), (ephy_window_key_press_event), (tool_item_enter_cb), (tool_item_leave_cb), (tool_item_drag_begin_cb), (connect_tool_item), (disconnect_tool_item), (disconnect_proxy_cb), (connect_proxy_cb), (update_chromes_actions), (show_embed_popup), (tab_added_cb), (tab_removed_cb), (ephy_window_set_chrome), (ephy_window_dispose), (ephy_window_class_init), (ephy_window_init), (ephy_window_finalize), (ephy_window_remove_tab), (ephy_window_set_zoom), (sync_prefs_with_chrome), (ephy_window_view_toolbar_cb): * src/ephy-window.h: Revision history: h18, released 2005/09/23, for Epiphany 1.8.0 * Just an update for 1.8.0. h17, released 2005/08/30, for Epiphany 1.7.6 or CVS HEAD * Mostly just an update for 1.7.6. * Topic menus on the toolbar now open without releasing the mouse button. * Topic menus on the toolbar are now also hierarchical (see if you like it. h16, released 2005/08/25, for Epiphany 1.7.5 or CVS HEAD * Just an update for 1.7.5. Sorry, I've been busy. :) h15, released 2005/07/19, for Epiphany 1.7.2 or CVS HEAD * Code cleanup h14, released 2005/07/9, for Epiphany 1.7.1 or CVS HEAD * Improved helpful tip when adding a bookmark * Improved toolbar context menu * Toolbar visibility state is now saved * Separated bookmark/topic action groups into separate files * Topics in the overflow menu now behave as submenus * Now importing old bookmarksbar, and saving to new filename * Incremented toolbar file format version number to 1.1 * Fixed the 'sticky' statusbar help * Fixed a crashing bug (dnd then open a topic on the toolbar) h13, released 2005/05/12, for CVS HEAD * Added middle-mouse drag-drop for the editable toolbar. * Fixed some warnings at compile and run time. * Added brief help for the user when adding a new bookmark. * Cleaned up the editable toolbar code a little. h12, released 2005/05/10, for CVS HEAD * Added new editing facilities for the editable toolbar. h11, released 2005/04/29, for CVS HEAD * Fixed bug in statusbar information for toolbar items. * Added an all-new 'Related' toolbar widget which changes to show the most related topic whenever a bookmark is activated. h10, released 2005/04/15, for Epiphany 1.6.2 or CVS HEAD * Added statusbar information for all toolbar items. * Empty toolbars are now only deleted when exiting edit mode. * Fixed regression of middle-click for bookmarks on toolbar. * Fixed regression of ellipsized bookmark names in menus. h9, released 2005/04/12, for Epiphany 1.6.1 * Updated patch for 1.6.1. Long time no see. * Now using EphyLink objects everywhere. h7, released 2004/10/21, for Epiphany 1.4.4 * Updated patch for 1.4.4. * Fixed bugs causing crashes when bookmarks were added (thanks Reinout). * Added "Open in Tabs" back into bookmark menus where suitable. h6, released 2004/09/20, for Epiphany 1.4.0 * Updated patch for 1.4.0. * Removed the bookmarks bar. * Generate shared XML string for bookmarks menu. * Slightly improve performance of node-cover code. * Delay adding bookmarks menu until it is first used. * Fixed bug(?) in ephy-node. h4, released 2004/08/08, for Epiphany 1.3.4 * Updated patch due to changes to topics selector. * Removed 'Most Visited' from the min-cover calculations. * Fixed Epiphany 1.3.4 bug where topics in selector aren't sorted. * Updated patch due to other changes in Epiphany 1.3.4 source. h3, released 2004/07/12, for Epiphany 1.3.2 * Simple update for Epiphany 1.3.2 h3, released 2004/05/24, for Epiphany 1.2.5 * Moved duplicated functions into a seperate file. * Improved topic selector. * Bookmarks toolbar topic menus now have subdivisions. * Topic names in menu now change if modified in the bookmarks editor. h2, released 2004/05/23, for Epiphany 1.2.5 * Significantly cleaned up the code. * 'Most Visited' no longer appears as a submenu. * Subtopics are selected much more intelligently, giving a better approximation to a true minimum cover. * Topic selector now shows suggestions with arrows, not bold font. h1, released 2004/05/19, for Epiphany 1.2.5 * Initial release.
Diffstat (limited to 'lib/egg/egg-toolbars-model.c')
-rwxr-xr-xlib/egg/egg-toolbars-model.c670
1 files changed, 343 insertions, 327 deletions
diff --git a/lib/egg/egg-toolbars-model.c b/lib/egg/egg-toolbars-model.c
index 56f4c8fbf..1d8c59476 100755
--- a/lib/egg/egg-toolbars-model.c
+++ b/lib/egg/egg-toolbars-model.c
@@ -31,7 +31,7 @@
#include <gdk/gdkproperty.h>
static void egg_toolbars_model_class_init (EggToolbarsModelClass *klass);
-static void egg_toolbars_model_init (EggToolbarsModel *t);
+static void egg_toolbars_model_init (EggToolbarsModel *model);
static void egg_toolbars_model_finalize (GObject *object);
enum
@@ -41,9 +41,6 @@ enum
TOOLBAR_ADDED,
TOOLBAR_CHANGED,
TOOLBAR_REMOVED,
- GET_ITEM_TYPE,
- GET_ITEM_ID,
- GET_ITEM_DATA,
LAST_SIGNAL
};
@@ -55,9 +52,7 @@ typedef struct
typedef struct
{
- char *id;
- char *type;
- gboolean separator;
+ char *name;
} EggToolbarsItem;
static guint signals[LAST_SIGNAL] = { 0 };
@@ -69,6 +64,8 @@ static GObjectClass *parent_class = NULL;
struct EggToolbarsModelPrivate
{
GNode *toolbars;
+ GList *types;
+ GHashTable *avail;
};
GType
@@ -103,45 +100,64 @@ egg_toolbars_model_get_type (void)
}
static xmlDocPtr
-egg_toolbars_model_to_xml (EggToolbarsModel *t)
+egg_toolbars_model_to_xml (EggToolbarsModel *model)
{
GNode *l1, *l2, *tl;
+ GList *l3;
xmlDocPtr doc;
- g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (t), NULL);
+ g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (model), NULL);
- tl = t->priv->toolbars;
+ tl = model->priv->toolbars;
xmlIndentTreeOutput = TRUE;
- doc = xmlNewDoc ((const xmlChar*) "1.0");
- doc->children = xmlNewDocNode (doc, NULL, (const xmlChar*) "toolbars", NULL);
+ doc = xmlNewDoc ("1.0");
+ doc->children = xmlNewDocNode (doc, NULL, "toolbars", NULL);
for (l1 = tl->children; l1 != NULL; l1 = l1->next)
{
xmlNodePtr tnode;
EggToolbarsToolbar *toolbar = l1->data;
- tnode = xmlNewChild (doc->children, NULL, (const xmlChar*) "toolbar", NULL);
- xmlSetProp (tnode, (const xmlChar*) "name", (const xmlChar*) toolbar->name);
+ tnode = xmlNewChild (doc->children, NULL, "toolbar", NULL);
+ xmlSetProp (tnode, "name", toolbar->name);
+ xmlSetProp (tnode, "hidden", (toolbar->flags&EGG_TB_MODEL_HIDDEN)?"true":"false");
for (l2 = l1->children; l2 != NULL; l2 = l2->next)
{
xmlNodePtr node;
EggToolbarsItem *item = l2->data;
- if (item->separator)
- {
- node = xmlNewChild (tnode, NULL, (const xmlChar*) "separator", NULL);
- }
- else
- {
- char *data;
-
- node = xmlNewChild (tnode, NULL, (const xmlChar*) "toolitem", NULL);
- data = egg_toolbars_model_get_item_data (t, item->type, item->id);
- xmlSetProp (node, (const xmlChar*) "type", (const xmlChar*) item->type);
- xmlSetProp (node, (const xmlChar*) "name", (const xmlChar*) data);
- g_free (data);
+ if (strcmp (item->name, "_separator") == 0)
+ {
+ node = xmlNewChild (tnode, NULL, "separator", NULL);
+ continue;
+ }
+
+ node = xmlNewChild (tnode, NULL, "toolitem", NULL);
+ xmlSetProp (node, "name", item->name);
+
+ /* Add 'data' nodes for each data type which can be written out for this
+ * item. Only write types which can be used to restore the data. */
+ for (l3 = model->priv->types; l3 != NULL; l3 = l3->next)
+ {
+ EggToolbarsItemType *type = l3->data;
+ if (type->get_name != NULL && type->get_data != NULL)
+ {
+ xmlNodePtr dnode;
+ char *tmp;
+
+ tmp = type->get_data (type, item->name);
+ if (tmp != NULL)
+ {
+ dnode = xmlNewTextChild (node, NULL, "data", tmp);
+ g_free (tmp);
+
+ tmp = gdk_atom_name (type->type);
+ xmlSetProp (dnode, "type", tmp);
+ g_free (tmp);
+ }
+ }
}
}
}
@@ -206,24 +222,24 @@ safe_save_xml (const char *xml_file, xmlDocPtr doc)
}
void
-egg_toolbars_model_save (EggToolbarsModel *t,
+egg_toolbars_model_save (EggToolbarsModel *model,
const char *xml_file,
const char *version)
{
xmlDocPtr doc;
xmlNodePtr root;
- g_return_if_fail (EGG_IS_TOOLBARS_MODEL (t));
+ g_return_if_fail (EGG_IS_TOOLBARS_MODEL (model));
- doc = egg_toolbars_model_to_xml (t);
+ doc = egg_toolbars_model_to_xml (model);
root = xmlDocGetRootElement (doc);
- xmlSetProp (root, (const xmlChar*) "version", (const xmlChar*) version);
+ xmlSetProp (root, "version", version);
safe_save_xml (xml_file, doc);
xmlFreeDoc (doc);
}
-static EggToolbarsToolbar *
-toolbars_toolbar_new (const char *name)
+static GNode *
+toolbar_node_new (const char *name)
{
EggToolbarsToolbar *toolbar;
@@ -231,58 +247,67 @@ toolbars_toolbar_new (const char *name)
toolbar->name = g_strdup (name);
toolbar->flags = 0;
- return toolbar;
+ return g_node_new (toolbar);
}
-static EggToolbarsItem *
-toolbars_item_new (const char *id,
- const char *type,
- gboolean separator)
+static GNode *
+item_node_new (const char *name, EggToolbarsModel *model)
{
EggToolbarsItem *item;
- g_return_val_if_fail (id != NULL, NULL);
- g_return_val_if_fail (type != NULL, NULL);
+ g_return_val_if_fail (name != NULL, NULL);
item = g_new (EggToolbarsItem, 1);
- item->id = g_strdup (id);
- item->type = g_strdup (type);
- item->separator = separator;
+ item->name = g_strdup (name);
+
+ gint count = (gint) g_hash_table_lookup (model->priv->avail, item->name);
+ if (count > G_MININT && count < G_MAXINT)
+ g_hash_table_insert (model->priv->avail,
+ g_strdup (item->name),
+ (gpointer) (count-1));
- return item;
+ return g_node_new (item);
}
static void
-free_toolbar_node (GNode *toolbar_node)
+item_node_free (GNode *item_node, EggToolbarsModel *model)
{
- EggToolbarsToolbar *toolbar = toolbar_node->data;
+ EggToolbarsItem *item = item_node->data;
- g_free (toolbar->name);
- g_free (toolbar);
+ gint count = (gint) g_hash_table_lookup (model->priv->avail, item->name);
+ if (count < G_MAXINT-1)
+ g_hash_table_insert (model->priv->avail,
+ g_strdup (item->name),
+ (gpointer) (count+1));
- g_node_destroy (toolbar_node);
+ g_free (item->name);
+ g_free (item);
+
+ g_node_destroy (item_node);
}
static void
-free_item_node (GNode *item_node)
+toolbar_node_free (GNode *toolbar_node, EggToolbarsModel *model)
{
- EggToolbarsItem *item = item_node->data;
+ EggToolbarsToolbar *toolbar = toolbar_node->data;
- g_free (item->id);
- g_free (item->type);
- g_free (item);
+ g_node_children_foreach (toolbar_node, G_TRAVERSE_ALL,
+ (GNodeForeachFunc) item_node_free, model);
+
+ g_free (toolbar->name);
+ g_free (toolbar);
- g_node_destroy (item_node);
+ g_node_destroy (toolbar_node);
}
EggTbModelFlags
-egg_toolbars_model_get_flags (EggToolbarsModel *t,
+egg_toolbars_model_get_flags (EggToolbarsModel *model,
int toolbar_position)
{
GNode *toolbar_node;
EggToolbarsToolbar *toolbar;
- toolbar_node = g_node_nth_child (t->priv->toolbars, toolbar_position);
+ toolbar_node = g_node_nth_child (model->priv->toolbars, toolbar_position);
g_return_val_if_fail (toolbar_node != NULL, 0);
toolbar = toolbar_node->data;
@@ -291,162 +316,262 @@ egg_toolbars_model_get_flags (EggToolbarsModel *t,
}
void
-egg_toolbars_model_set_flags (EggToolbarsModel *t,
+egg_toolbars_model_set_flags (EggToolbarsModel *model,
int toolbar_position,
EggTbModelFlags flags)
{
GNode *toolbar_node;
EggToolbarsToolbar *toolbar;
- toolbar_node = g_node_nth_child (t->priv->toolbars, toolbar_position);
+ toolbar_node = g_node_nth_child (model->priv->toolbars, toolbar_position);
g_return_if_fail (toolbar_node != NULL);
toolbar = toolbar_node->data;
toolbar->flags = flags;
- g_signal_emit (G_OBJECT (t), signals[TOOLBAR_CHANGED],
+ g_signal_emit (G_OBJECT (model), signals[TOOLBAR_CHANGED],
0, toolbar_position);
}
-void
-egg_toolbars_model_add_separator (EggToolbarsModel *t,
- int toolbar_position,
- int position)
+
+char *
+egg_toolbars_model_get_data (EggToolbarsModel *model,
+ GdkAtom type,
+ const char *name)
+{
+ EggToolbarsItemType *t;
+ char *data = NULL;
+ GList *l;
+
+ if (type == GDK_NONE || type == gdk_atom_intern (EGG_TOOLBAR_ITEM_TYPE, FALSE))
+ {
+ g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (*name != 0, NULL);
+ return strdup (name);
+ }
+
+ for (l = model->priv->types; l != NULL; l = l->next)
+ {
+ t = l->data;
+ if (t->type == type && t->get_data != NULL)
+ {
+ data = t->get_data (t, name);
+ if (data != NULL) break;
+ }
+ }
+
+ return data;
+}
+
+char *
+egg_toolbars_model_get_name (EggToolbarsModel *model,
+ GdkAtom type,
+ const char *data,
+ gboolean create)
+{
+ EggToolbarsItemType *t;
+ char *name = NULL;
+ GList *l;
+
+ if (type == GDK_NONE || type == gdk_atom_intern (EGG_TOOLBAR_ITEM_TYPE, FALSE))
+ {
+ g_return_val_if_fail (data, NULL);
+ g_return_val_if_fail (*data, NULL);
+ return strdup (data);
+ }
+
+ if (create)
+ {
+ for (l = model->priv->types; name == NULL && l != NULL; l = l->next)
+ {
+ t = l->data;
+ if (t->type == type && t->new_name != NULL)
+ name = t->new_name (t, data);
+ }
+
+ return name;
+ }
+ else
+ {
+ for (l = model->priv->types; name == NULL && l != NULL; l = l->next)
+ {
+ t = l->data;
+ if (t->type == type && t->get_name != NULL)
+ name = t->get_name (t, data);
+ }
+
+ return name;
+ }
+}
+
+static gboolean
+impl_add_item (EggToolbarsModel *model,
+ int toolbar_position,
+ int position,
+ const char *name)
{
GNode *parent_node;
- GNode *node;
- EggToolbarsItem *item;
+ GNode *child_node;
int real_position;
- g_return_if_fail (EGG_IS_TOOLBARS_MODEL (t));
+ g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (model), FALSE);
+ g_return_val_if_fail (name != NULL, FALSE);
- parent_node = g_node_nth_child (t->priv->toolbars, toolbar_position);
- item = toolbars_item_new ("separator", EGG_TOOLBAR_ITEM_TYPE, TRUE);
- node = g_node_new (item);
- g_node_insert (parent_node, position, node);
+ parent_node = g_node_nth_child (model->priv->toolbars, toolbar_position);
+ child_node = item_node_new (name, model);
+ g_node_insert (parent_node, position, child_node);
- real_position = g_node_child_position (parent_node, node);
+ real_position = g_node_child_position (parent_node, child_node);
- g_signal_emit (G_OBJECT (t), signals[ITEM_ADDED], 0,
+ g_signal_emit (G_OBJECT (model), signals[ITEM_ADDED], 0,
toolbar_position, real_position);
+
+ return TRUE;
}
-static gboolean
-impl_add_item (EggToolbarsModel *t,
- int toolbar_position,
- int position,
- const char *id,
- const char *type)
+gboolean
+egg_toolbars_model_add_item (EggToolbarsModel *model,
+ int toolbar_position,
+ int position,
+ const char *name)
+{
+ EggToolbarsModelClass *klass = EGG_TOOLBARS_MODEL_GET_CLASS (model);
+ return klass->add_item (model, toolbar_position, position, name);
+}
+
+int
+egg_toolbars_model_add_toolbar (EggToolbarsModel *model,
+ int position,
+ const char *name)
{
- GNode *parent_node;
GNode *node;
- EggToolbarsItem *item;
int real_position;
- g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (t), FALSE);
- g_return_val_if_fail (id != NULL, FALSE);
- g_return_val_if_fail (type != NULL, FALSE);
+ g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (model), -1);
- parent_node = g_node_nth_child (t->priv->toolbars, toolbar_position);
- item = toolbars_item_new (id, type, FALSE);
- node = g_node_new (item);
- g_node_insert (parent_node, position, node);
+ node = toolbar_node_new (name);
+ g_node_insert (model->priv->toolbars, position, node);
- real_position = g_node_child_position (parent_node, node);
+ real_position = g_node_child_position (model->priv->toolbars, node);
- g_signal_emit (G_OBJECT (t), signals[ITEM_ADDED], 0,
- toolbar_position, real_position);
+ g_signal_emit (G_OBJECT (model), signals[TOOLBAR_ADDED],
+ 0, real_position);
- return TRUE;
+ return g_node_child_position (model->priv->toolbars, node);
+}
+
+static char *
+parse_data_list (EggToolbarsModel *model,
+ xmlNodePtr child,
+ gboolean create)
+{
+ char *name = NULL;
+ while (child && name == NULL)
+ {
+ if (xmlStrEqual (child->name, "data"))
+ {
+ xmlChar *type = xmlGetProp (child, "type");
+ xmlChar *data = xmlNodeGetContent (child);
+
+ if (type != NULL)
+ {
+ GdkAtom atom = gdk_atom_intern (type, TRUE);
+ name = egg_toolbars_model_get_name (model, atom, data, create);
+ }
+
+ xmlFree (type);
+ xmlFree (data);
+ }
+
+ child = child->next;
+ }
+
+ return name;
}
static void
-parse_item_list (EggToolbarsModel *t,
+parse_item_list (EggToolbarsModel *model,
xmlNodePtr child,
int position)
{
while (child)
{
- if (xmlStrEqual (child->name, (const xmlChar*) "toolitem"))
+ if (xmlStrEqual (child->name, "toolitem"))
{
- xmlChar *name, *type;
- char *id;
+ char *name;
- name = xmlGetProp (child, (const xmlChar*) "name");
- type = xmlGetProp (child, (const xmlChar*) "type");
- if (type == NULL)
+ /* Try to get the name using the data elements first,
+ as they are more 'portable' or 'persistent'. */
+ name = parse_data_list (model, child->children, FALSE);
+ if (name == NULL)
{
- type = xmlCharStrdup (EGG_TOOLBAR_ITEM_TYPE);
+ name = parse_data_list (model, child->children, TRUE);
}
-
- if (name != NULL && name[0] != '\0' && type != NULL)
- {
- id = egg_toolbars_model_get_item_id (t, (const char*)type, (const char*)name);
- if (id != NULL)
- {
- egg_toolbars_model_add_item (t, position, -1, id, (const char*)type);
+
+ /* If that fails, try to use the name. */
+ if (name == NULL)
+ {
+ xmlChar *type = xmlGetProp (child, "type");
+ xmlChar *data = xmlGetProp (child, "name");
+ GdkAtom atom = type ? gdk_atom_intern (type, TRUE) : GDK_NONE;
+
+ /* If an old format, try to use it. */
+ name = egg_toolbars_model_get_name (model, atom, data, FALSE);
+ if (name == NULL)
+ {
+ name = egg_toolbars_model_get_name (model, atom, data, TRUE);
}
- g_free (id);
+
+ xmlFree (type);
+ xmlFree (data);
+ }
+
+ if (name != NULL)
+ {
+ egg_toolbars_model_add_item (model, position, -1, name);
+ g_free (name);
}
- xmlFree (name);
- xmlFree (type);
}
- else if (xmlStrEqual (child->name, (const xmlChar*) "separator"))
+ else if (xmlStrEqual (child->name, "separator"))
{
- egg_toolbars_model_add_separator (t, position, -1);
+ egg_toolbars_model_add_item (model, position, -1, "_separator");
}
child = child->next;
}
}
-int
-egg_toolbars_model_add_toolbar (EggToolbarsModel *t,
- int position,
- const char *name)
-{
- GNode *node;
- int real_position;
-
- g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (t), -1);
-
- node = g_node_new (toolbars_toolbar_new (name));
- g_node_insert (t->priv->toolbars, position, node);
-
- real_position = g_node_child_position (t->priv->toolbars, node);
-
- g_signal_emit (G_OBJECT (t), signals[TOOLBAR_ADDED],
- 0, real_position);
-
- return g_node_child_position (t->priv->toolbars, node);
-}
-
static void
-parse_toolbars (EggToolbarsModel *t,
+parse_toolbars (EggToolbarsModel *model,
xmlNodePtr child)
{
while (child)
{
- if (xmlStrEqual (child->name, (const xmlChar*) "toolbar"))
+ if (xmlStrEqual (child->name, "toolbar"))
{
- xmlChar *name;
- xmlChar *style;
+ xmlChar *string;
int position;
-
- name = xmlGetProp (child, (const xmlChar*) "name");
- position = egg_toolbars_model_add_toolbar (t, -1, (const char*) name);
- xmlFree (name);
-
- style = xmlGetProp (child, (const xmlChar*) "style");
- if (style && xmlStrEqual (style, (const xmlChar*) "icons-only"))
- {
- /* FIXME: use toolbar position instead of 0 */
- egg_toolbars_model_set_flags (t, 0, EGG_TB_MODEL_ICONS);
- }
- xmlFree (style);
-
- parse_item_list (t, child->children, position);
+ EggTbModelFlags flags;
+
+ string = xmlGetProp (child, "name");
+ position = egg_toolbars_model_add_toolbar (model, -1, string);
+ flags = egg_toolbars_model_get_flags (model, position);
+ xmlFree (string);
+
+ string = xmlGetProp (child, "hidden");
+ if (string && xmlStrEqual (string, "true"))
+ flags |= EGG_TB_MODEL_HIDDEN;
+ xmlFree (string);
+
+ string = xmlGetProp (child, "style");
+ if (string && xmlStrEqual (string, "icons-only"))
+ flags |= EGG_TB_MODEL_ICONS;
+ xmlFree (string);
+
+ egg_toolbars_model_set_flags (model, position, flags);
+
+ parse_item_list (model, child->children, position);
}
child = child->next;
@@ -454,13 +579,13 @@ parse_toolbars (EggToolbarsModel *t,
}
gboolean
-egg_toolbars_model_load (EggToolbarsModel *t,
+egg_toolbars_model_load (EggToolbarsModel *model,
const char *xml_file)
{
xmlDocPtr doc;
xmlNodePtr root;
- g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (t), FALSE);
+ g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (model), FALSE);
if (!xml_file || !g_file_test (xml_file, G_FILE_TEST_EXISTS)) return FALSE;
@@ -472,68 +597,13 @@ egg_toolbars_model_load (EggToolbarsModel *t,
}
root = xmlDocGetRootElement (doc);
- parse_toolbars (t, root->children);
+ parse_toolbars (model, root->children);
xmlFreeDoc (doc);
return TRUE;
}
-static char *
-impl_get_item_id (EggToolbarsModel *t,
- const char *type,
- const char *data)
-{
- if (strcmp (type, EGG_TOOLBAR_ITEM_TYPE) == 0)
- {
- return g_strdup (data);
- }
-
- return NULL;
-}
-
-static char *
-impl_get_item_data (EggToolbarsModel *t,
- const char *type,
- const char *id)
-{
- if (strcmp (type, EGG_TOOLBAR_ITEM_TYPE) == 0)
- {
- return g_strdup (id);
- }
-
- return NULL;
-}
-
-static char *
-impl_get_item_type (EggToolbarsModel *t,
- GdkAtom type)
-{
- if (gdk_atom_intern (EGG_TOOLBAR_ITEM_TYPE, FALSE) == type)
- {
- return g_strdup (EGG_TOOLBAR_ITEM_TYPE);
- }
-
- return NULL;
-}
-
-static gboolean
-_egg_accumulator_STRING (GSignalInvocationHint *ihint,
- GValue *return_accu,
- const GValue *handler_return,
- gpointer dummy)
-{
- gboolean continue_emission;
- const char *retval;
-
- retval = g_value_get_string (handler_return);
- g_value_set_string (return_accu, retval);
- continue_emission = !retval || !retval[0];
-
- return continue_emission;
-}
-
-
static void
egg_toolbars_model_class_init (EggToolbarsModelClass *klass)
{
@@ -544,9 +614,6 @@ egg_toolbars_model_class_init (EggToolbarsModelClass *klass)
object_class->finalize = egg_toolbars_model_finalize;
klass->add_item = impl_add_item;
- klass->get_item_id = impl_get_item_id;
- klass->get_item_data = impl_get_item_data;
- klass->get_item_type = impl_get_item_type;
signals[ITEM_ADDED] =
g_signal_new ("item_added",
@@ -583,58 +650,29 @@ egg_toolbars_model_class_init (EggToolbarsModelClass *klass)
G_STRUCT_OFFSET (EggToolbarsModelClass, toolbar_changed),
NULL, NULL, g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
- signals[GET_ITEM_TYPE] =
- g_signal_new ("get_item_type",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EggToolbarsModelClass, get_item_type),
- _egg_accumulator_STRING, NULL,
- _egg_marshal_STRING__POINTER,
- G_TYPE_STRING, 1, G_TYPE_POINTER);
- signals[GET_ITEM_ID] =
- g_signal_new ("get_item_id",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EggToolbarsModelClass, get_item_id),
- _egg_accumulator_STRING, NULL,
- _egg_marshal_STRING__STRING_STRING,
- G_TYPE_STRING, 2, G_TYPE_STRING, G_TYPE_STRING);
- signals[GET_ITEM_DATA] =
- g_signal_new ("get_item_data",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EggToolbarsModelClass, get_item_data),
- _egg_accumulator_STRING, NULL,
- _egg_marshal_STRING__STRING_STRING,
- G_TYPE_STRING, 2, G_TYPE_STRING, G_TYPE_STRING);
g_type_class_add_private (object_class, sizeof (EggToolbarsModelPrivate));
}
static void
-egg_toolbars_model_init (EggToolbarsModel *t)
+egg_toolbars_model_init (EggToolbarsModel *model)
{
- t->priv =EGG_TOOLBARS_MODEL_GET_PRIVATE (t);
-
- t->priv->toolbars = g_node_new (NULL);
-}
+ model->priv =EGG_TOOLBARS_MODEL_GET_PRIVATE (model);
-static void
-free_toolbar (GNode *toolbar_node)
-{
- g_node_children_foreach (toolbar_node, G_TRAVERSE_ALL,
- (GNodeForeachFunc) free_item_node, NULL);
- free_toolbar_node (toolbar_node);
+ model->priv->toolbars = g_node_new (NULL);
+ model->priv->avail = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ egg_toolbars_model_set_n_avail (model, "_separator", G_MAXINT);
}
static void
egg_toolbars_model_finalize (GObject *object)
{
- EggToolbarsModel *t = EGG_TOOLBARS_MODEL (object);
+ EggToolbarsModel *model = EGG_TOOLBARS_MODEL (object);
- g_node_children_foreach (t->priv->toolbars, G_TRAVERSE_ALL,
- (GNodeForeachFunc) free_toolbar, NULL);
- g_node_destroy (t->priv->toolbars);
+ g_node_children_foreach (model->priv->toolbars, G_TRAVERSE_ALL,
+ (GNodeForeachFunc) toolbar_node_free, model);
+ g_node_destroy (model->priv->toolbars);
+ g_hash_table_destroy (model->priv->avail);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -646,51 +684,51 @@ egg_toolbars_model_new (void)
}
void
-egg_toolbars_model_remove_toolbar (EggToolbarsModel *t,
+egg_toolbars_model_remove_toolbar (EggToolbarsModel *model,
int position)
{
GNode *node;
EggTbModelFlags flags;
- g_return_if_fail (EGG_IS_TOOLBARS_MODEL (t));
+ g_return_if_fail (EGG_IS_TOOLBARS_MODEL (model));
- flags = egg_toolbars_model_get_flags (t, position);
+ flags = egg_toolbars_model_get_flags (model, position);
if (!(flags & EGG_TB_MODEL_NOT_REMOVABLE))
{
- node = g_node_nth_child (t->priv->toolbars, position);
+ node = g_node_nth_child (model->priv->toolbars, position);
g_return_if_fail (node != NULL);
- free_toolbar_node (node);
+ toolbar_node_free (node, model);
- g_signal_emit (G_OBJECT (t), signals[TOOLBAR_REMOVED],
+ g_signal_emit (G_OBJECT (model), signals[TOOLBAR_REMOVED],
0, position);
}
}
void
-egg_toolbars_model_remove_item (EggToolbarsModel *t,
+egg_toolbars_model_remove_item (EggToolbarsModel *model,
int toolbar_position,
int position)
{
GNode *node, *toolbar;
- g_return_if_fail (EGG_IS_TOOLBARS_MODEL (t));
+ g_return_if_fail (EGG_IS_TOOLBARS_MODEL (model));
- toolbar = g_node_nth_child (t->priv->toolbars, toolbar_position);
+ toolbar = g_node_nth_child (model->priv->toolbars, toolbar_position);
g_return_if_fail (toolbar != NULL);
node = g_node_nth_child (toolbar, position);
g_return_if_fail (node != NULL);
- free_item_node (node);
+ item_node_free (node, model);
- g_signal_emit (G_OBJECT (t), signals[ITEM_REMOVED], 0,
+ g_signal_emit (G_OBJECT (model), signals[ITEM_REMOVED], 0,
toolbar_position, position);
}
void
-egg_toolbars_model_move_item (EggToolbarsModel *t,
+egg_toolbars_model_move_item (EggToolbarsModel *model,
int toolbar_position,
int position,
int new_toolbar_position,
@@ -698,12 +736,12 @@ egg_toolbars_model_move_item (EggToolbarsModel *t,
{
GNode *node, *toolbar, *new_toolbar;
- g_return_if_fail (EGG_IS_TOOLBARS_MODEL (t));
+ g_return_if_fail (EGG_IS_TOOLBARS_MODEL (model));
- toolbar = g_node_nth_child (t->priv->toolbars, toolbar_position);
+ toolbar = g_node_nth_child (model->priv->toolbars, toolbar_position);
g_return_if_fail (toolbar != NULL);
- new_toolbar = g_node_nth_child (t->priv->toolbars, new_toolbar_position);
+ new_toolbar = g_node_nth_child (model->priv->toolbars, new_toolbar_position);
g_return_if_fail (new_toolbar != NULL);
node = g_node_nth_child (toolbar, position);
@@ -711,74 +749,60 @@ egg_toolbars_model_move_item (EggToolbarsModel *t,
g_node_unlink (node);
- g_signal_emit (G_OBJECT (t), signals[ITEM_REMOVED], 0,
+ g_signal_emit (G_OBJECT (model), signals[ITEM_REMOVED], 0,
toolbar_position, position);
g_node_insert (new_toolbar, new_position, node);
- g_signal_emit (G_OBJECT (t), signals[ITEM_ADDED], 0,
+ g_signal_emit (G_OBJECT (model), signals[ITEM_ADDED], 0,
new_toolbar_position, new_position);
}
int
-egg_toolbars_model_n_items (EggToolbarsModel *t,
+egg_toolbars_model_n_items (EggToolbarsModel *model,
int toolbar_position)
{
GNode *toolbar;
- toolbar = g_node_nth_child (t->priv->toolbars, toolbar_position);
+ toolbar = g_node_nth_child (model->priv->toolbars, toolbar_position);
g_return_val_if_fail (toolbar != NULL, -1);
return g_node_n_children (toolbar);
}
-void
-egg_toolbars_model_item_nth (EggToolbarsModel *t,
+const char *
+egg_toolbars_model_item_nth (EggToolbarsModel *model,
int toolbar_position,
- int position,
- gboolean *is_separator,
- const char **id,
- const char **type)
+ int position)
{
GNode *toolbar;
GNode *item;
EggToolbarsItem *idata;
- toolbar = g_node_nth_child (t->priv->toolbars, toolbar_position);
- g_return_if_fail (toolbar != NULL);
+ toolbar = g_node_nth_child (model->priv->toolbars, toolbar_position);
+ g_return_val_if_fail (toolbar != NULL, NULL);
item = g_node_nth_child (toolbar, position);
- g_return_if_fail (item != NULL);
+ g_return_val_if_fail (item != NULL, NULL);
idata = item->data;
-
- *is_separator = idata->separator;
-
- if (id)
- {
- *id = idata->id;
- }
-
- if (type)
- {
- *type = idata->type;
- }
+ return idata->name;
}
int
-egg_toolbars_model_n_toolbars (EggToolbarsModel *t)
+egg_toolbars_model_n_toolbars (EggToolbarsModel *model)
{
- return g_node_n_children (t->priv->toolbars);
+ return g_node_n_children (model->priv->toolbars);
}
const char *
-egg_toolbars_model_toolbar_nth (EggToolbarsModel *t,
+egg_toolbars_model_toolbar_nth (EggToolbarsModel *model,
int position)
{
GNode *toolbar;
EggToolbarsToolbar *tdata;
- toolbar = g_node_nth_child (t->priv->toolbars, position);
+ toolbar = g_node_nth_child (model->priv->toolbars, position);
g_return_val_if_fail (toolbar != NULL, NULL);
tdata = toolbar->data;
@@ -786,48 +810,40 @@ egg_toolbars_model_toolbar_nth (EggToolbarsModel *t,
return tdata->name;
}
-gboolean
-egg_toolbars_model_add_item (EggToolbarsModel *t,
- int toolbar_position,
- int position,
- const char *id,
- const char *type)
+GList *
+egg_toolbars_model_get_types (EggToolbarsModel *model)
{
- EggToolbarsModelClass *klass = EGG_TOOLBARS_MODEL_GET_CLASS (t);
- return klass->add_item (t, toolbar_position, position, id, type);
+ return model->priv->types;
}
-char *
-egg_toolbars_model_get_item_id (EggToolbarsModel *t,
- const char *type,
- const char *name)
+void
+egg_toolbars_model_set_types (EggToolbarsModel *model, GList *types)
{
- char *retval;
-
- g_signal_emit (t, signals[GET_ITEM_ID], 0, type, name, &retval);
-
- return retval;
+ model->priv->types = types;
}
-char *
-egg_toolbars_model_get_item_data (EggToolbarsModel *t,
- const char *type,
- const char *id)
+static void
+fill_avail_array (gpointer key, gpointer value, GPtrArray *array)
{
- char *retval;
-
- g_signal_emit (t, signals[GET_ITEM_DATA], 0, type, id, &retval);
-
- return retval;
+ if (GPOINTER_TO_INT (value) > 0) g_ptr_array_add (array, key);
}
-char *
-egg_toolbars_model_get_item_type (EggToolbarsModel *t,
- GdkAtom type)
+GPtrArray *
+egg_toolbars_model_get_avail (EggToolbarsModel *model)
{
- char *retval;
+ GPtrArray *array = g_ptr_array_new ();
+ g_hash_table_foreach (model->priv->avail, (GHFunc) fill_avail_array, array);
+ return array;
+}
- g_signal_emit (t, signals[GET_ITEM_TYPE], 0, type, &retval);
+gint
+egg_toolbars_model_get_n_avail (EggToolbarsModel *model, const char *name)
+{
+ return (gint) g_hash_table_lookup (model->priv->avail, name);
+}
- return retval;
+void
+egg_toolbars_model_set_n_avail (EggToolbarsModel *model, const char *name, gint count)
+{
+ g_hash_table_insert (model->priv->avail, g_strdup (name), (gpointer) count);
}