aboutsummaryrefslogtreecommitdiffstats
path: root/src/ephy-favorites-menu.c
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@gnome.org>2003-09-03 21:09:32 +0800
committerMarco Pesenti Gritti <marco@src.gnome.org>2003-09-03 21:09:32 +0800
commit45f9b007f1a057866dc0a44fe498993ef5293bfd (patch)
tree909b7f9567ca4e9ff1c6cfddb7fa58fbc7014b0a /src/ephy-favorites-menu.c
parent85ab8f0a87cc2f05e49777756ffc861890b2e700 (diff)
downloadgsoc2013-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-favorites-menu.c')
-rw-r--r--src/ephy-favorites-menu.c37
1 files changed, 9 insertions, 28 deletions
diff --git a/src/ephy-favorites-menu.c b/src/ephy-favorites-menu.c
index 99afe038c..89333809e 100644
--- a/src/ephy-favorites-menu.c
+++ b/src/ephy-favorites-menu.c
@@ -28,6 +28,7 @@
#include "ephy-debug.h"
#include <gtk/gtkuimanager.h>
+#include <glib/gprintf.h>
/**
* Private data
@@ -115,7 +116,6 @@ static void
ephy_favorites_menu_rebuild (EphyFavoritesMenu *wrhm)
{
EphyFavoritesMenuPrivate *p = wrhm->priv;
- GString *xml;
gint i;
EphyNode *fav;
GPtrArray *children;
@@ -130,21 +130,19 @@ ephy_favorites_menu_rebuild (EphyFavoritesMenu *wrhm)
fav = ephy_bookmarks_get_favorites (p->bookmarks);
children = ephy_node_get_children (fav);
- xml = g_string_new (NULL);
- g_string_append (xml, "<ui><menubar><menu name=\"GoMenu\">"
- "<placeholder name=\"GoFavorites\">"
- "<separator name=\"GoSep3\"/>");
-
p->action_group = gtk_action_group_new ("FavoritesActions");
gtk_ui_manager_insert_action_group (merge, p->action_group, 0);
+ p->ui_id = gtk_ui_manager_new_merge_id (merge);
for (i = 0; i < children->len; i++)
{
- char *verb;
+ char verb[20];
+ char name[20];
EphyNode *node;
GtkAction *action;
- verb = g_strdup_printf ("GoFav%d", i);
+ g_sprintf (verb, "GoFav%d", i);
+ g_sprintf (name, "GoFav%dMenu", i);
node = g_ptr_array_index (children, i);
@@ -155,29 +153,12 @@ ephy_favorites_menu_rebuild (EphyFavoritesMenu *wrhm)
g_signal_connect (action, "go_location",
G_CALLBACK (go_location_cb), p->window);
- g_string_append (xml, "<menuitem name=\"");
- g_string_append (xml, verb);
- g_string_append (xml, "Menu");
- g_string_append (xml, "\" action=\"");
- g_string_append (xml, verb);
- g_string_append (xml, "\"/>\n");
-
- g_free (verb);
+ gtk_ui_manager_add_ui (merge, p->ui_id,
+ "/menubar/GoMenu/GoFavorites",
+ name, verb);
}
ephy_node_thaw (fav);
- g_string_append (xml, "</placeholder></menu></menubar></ui>");
-
- if (children->len > 0)
- {
- GError *error = NULL;
- LOG ("Merging ui\n%s",xml->str);
- p->ui_id = gtk_ui_manager_add_ui_from_string
- (merge, xml->str, -1, &error);
- }
-
- g_string_free (xml, TRUE);
-
STOP_PROFILER ("Rebuild favorites menu")
}