diff options
author | Marco Pesenti Gritti <marco@gnome.org> | 2003-09-03 21:09:32 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <marco@src.gnome.org> | 2003-09-03 21:09:32 +0800 |
commit | 45f9b007f1a057866dc0a44fe498993ef5293bfd (patch) | |
tree | 909b7f9567ca4e9ff1c6cfddb7fa58fbc7014b0a /src/ephy-tabs-menu.c | |
parent | 85ab8f0a87cc2f05e49777756ffc861890b2e700 (diff) | |
download | gsoc2013-epiphany-45f9b007f1a057866dc0a44fe498993ef5293bfd.tar gsoc2013-epiphany-45f9b007f1a057866dc0a44fe498993ef5293bfd.tar.gz gsoc2013-epiphany-45f9b007f1a057866dc0a44fe498993ef5293bfd.tar.bz2 gsoc2013-epiphany-45f9b007f1a057866dc0a44fe498993ef5293bfd.tar.lz gsoc2013-epiphany-45f9b007f1a057866dc0a44fe498993ef5293bfd.tar.xz gsoc2013-epiphany-45f9b007f1a057866dc0a44fe498993ef5293bfd.tar.zst gsoc2013-epiphany-45f9b007f1a057866dc0a44fe498993ef5293bfd.zip |
Use the api for dynamic menus creation. Far cleaner.
2003-09-03 Marco Pesenti Gritti <marco@gnome.org>
* src/ephy-favorites-menu.c: (ephy_favorites_menu_rebuild):
* src/ephy-tabs-menu.c: (ephy_tabs_menu_update):
Use the api for dynamic menus creation. Far cleaner.
Diffstat (limited to 'src/ephy-tabs-menu.c')
-rw-r--r-- | src/ephy-tabs-menu.c | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/src/ephy-tabs-menu.c b/src/ephy-tabs-menu.c index 02bcd9b08..0dad11885 100644 --- a/src/ephy-tabs-menu.c +++ b/src/ephy-tabs-menu.c @@ -254,11 +254,9 @@ ephy_tabs_menu_update (EphyTabsMenu *menu) GtkUIManager *merge; EphyTab *tab; GtkAction *action; - GString *xml; guint i = 0; guint num = 0; GList *tabs = NULL, *l; - GError *error = NULL; g_return_if_fail (EPHY_IS_TABS_MENU (menu)); p = menu->priv; @@ -276,43 +274,32 @@ ephy_tabs_menu_update (EphyTabsMenu *menu) if (num == 0) return; p->action_group = gtk_action_group_new ("TabsActions"); - - /* it's faster to preallocate, MIN is sanity check */ - xml = g_string_sized_new (44 * MIN (num, 64) + 105); - - g_string_append (xml, "<ui><menubar><menu name=\"TabsMenu\">" - "<placeholder name=\"TabsOpen\">"); + p->ui_id = gtk_ui_manager_new_merge_id (merge); for (l = tabs; l != NULL; l = l->next) { const char *action_name; + char *name; + tab = (EphyTab *) l->data; action = GTK_ACTION (ephy_tab_get_action (tab)); action_name = gtk_action_get_name (action); + name = g_strdup_printf ("%sMenu", action_name); tab_set_action_accelerator (p->action_group, action, i); gtk_action_group_add_action (p->action_group, action); - g_string_append (xml, "<menuitem name=\""); - g_string_append (xml, action_name); - g_string_append (xml, "Menu\" action=\""); - g_string_append (xml, action_name); - g_string_append (xml, "\"/>\n"); - - ++i; + gtk_ui_manager_add_ui (merge, p->ui_id, + "/menubar/TabsMenu/TabsOpen", + name, action_name); + g_free (name); } g_list_free (tabs); - g_string_append (xml, "</placeholder></menu></menubar></ui>"); - gtk_ui_manager_insert_action_group (merge, p->action_group, 0); - p->ui_id = gtk_ui_manager_add_ui_from_string - (merge, xml->str, -1, &error); - - g_string_free (xml, TRUE); STOP_PROFILER ("Rebuilding tabs menu") } |