aboutsummaryrefslogtreecommitdiffstats
path: root/src/ephy-favorites-menu.c
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-01-21 02:57:20 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-01-21 02:57:20 +0800
commitc2beffd03405e6db4295afd6c2982388b808cb2e (patch)
tree819e50881626c5109ccdba5abb158585a3ca148b /src/ephy-favorites-menu.c
parent822ca51797e05edbe42b80f1a33a70a7327d732e (diff)
downloadgsoc2013-epiphany-c2beffd03405e6db4295afd6c2982388b808cb2e.tar
gsoc2013-epiphany-c2beffd03405e6db4295afd6c2982388b808cb2e.tar.gz
gsoc2013-epiphany-c2beffd03405e6db4295afd6c2982388b808cb2e.tar.bz2
gsoc2013-epiphany-c2beffd03405e6db4295afd6c2982388b808cb2e.tar.lz
gsoc2013-epiphany-c2beffd03405e6db4295afd6c2982388b808cb2e.tar.xz
gsoc2013-epiphany-c2beffd03405e6db4295afd6c2982388b808cb2e.tar.zst
gsoc2013-epiphany-c2beffd03405e6db4295afd6c2982388b808cb2e.zip
Merge eog-menu-api branch
2003-01-20 Marco Pesenti Gritti <marco@it.gnome.org> * Merge eog-menu-api branch
Diffstat (limited to 'src/ephy-favorites-menu.c')
-rw-r--r--src/ephy-favorites-menu.c104
1 files changed, 59 insertions, 45 deletions
diff --git a/src/ephy-favorites-menu.c b/src/ephy-favorites-menu.c
index b463663c2..8a557a7ad 100644
--- a/src/ephy-favorites-menu.c
+++ b/src/ephy-favorites-menu.c
@@ -23,7 +23,7 @@
#include "ephy-favorites-menu.h"
#include "ephy-gobject-misc.h"
#include "ephy-string.h"
-#include "ephy-bonobo-extensions.h"
+#include "egg-menu-merge.h"
#include "ephy-marshal.h"
#include "ephy-shell.h"
#include "ephy-debug.h"
@@ -39,9 +39,10 @@
*/
struct _EphyFavoritesMenuPrivate
{
- gchar *path;
EphyWindow *window;
EphyBookmarks *bookmarks;
+ EggActionGroup *action_group;
+ guint ui_id;
};
typedef struct
@@ -109,18 +110,35 @@ ephy_favorites_menu_init (EphyFavoritesMenu *wrhm)
wrhm->priv = p;
wrhm->priv->bookmarks = ephy_shell_get_bookmarks (ephy_shell);
+ wrhm->priv->ui_id = -1;
+ wrhm->priv->action_group = NULL;
}
static void
-ephy_favorites_menu_finalize_impl (GObject *o)
+ephy_favorites_menu_clean (EphyFavoritesMenu *wrhm)
{
- EphyFavoritesMenu *wrhm = EPHY_FAVORITES_MENU (o);
EphyFavoritesMenuPrivate *p = wrhm->priv;
+ EggMenuMerge *merge = EGG_MENU_MERGE (p->window->ui_merge);
+
+ if (p->ui_id >= 0)
+ {
+ egg_menu_merge_remove_ui (merge, p->ui_id);
+ }
- if (p->path)
+ if (p->action_group != NULL)
{
- g_free (p->path);
+ egg_menu_merge_remove_action_group (merge, p->action_group);
+ g_object_unref (p->action_group);
}
+}
+
+static void
+ephy_favorites_menu_finalize_impl (GObject *o)
+{
+ EphyFavoritesMenu *wrhm = EPHY_FAVORITES_MENU (o);
+ EphyFavoritesMenuPrivate *p = wrhm->priv;
+
+ ephy_favorites_menu_clean (wrhm);
g_free (p);
@@ -139,6 +157,7 @@ ephy_favorites_menu_set_property (GObject *object,
{
case PROP_EPHY_WINDOW:
m->priv->window = g_value_get_object (value);
+ ephy_favorites_menu_rebuild (m);
break;
}
}
@@ -168,26 +187,6 @@ ephy_favorites_menu_new (EphyWindow *window)
return ret;
}
-void
-ephy_favorites_menu_set_path (EphyFavoritesMenu *wrhm,
- const gchar *path)
-{
- EphyFavoritesMenuPrivate *p;
-
- g_return_if_fail (EPHY_IS_FAVORITES_MENU (wrhm));
- g_return_if_fail (path != NULL);
-
- p = wrhm->priv;
-
- if (p->path)
- {
- g_free (p->path);
- }
- p->path = g_strdup (path);
-
- ephy_favorites_menu_update (wrhm);
-}
-
static void
ephy_favorites_menu_verb_cb (BonoboUIComponent *uic,
FavoriteData *data,
@@ -204,11 +203,7 @@ ephy_favorites_menu_rebuild (EphyFavoritesMenu *wrhm)
gint i;
EphyNode *fav;
GPtrArray *children;
- BonoboUIComponent *uic = BONOBO_UI_COMPONENT (p->window->ui_component);
-
- if (!p->path) return;
-
- ephy_bonobo_clear_path (uic, p->path);
+ EggMenuMerge *merge = EGG_MENU_MERGE (p->window->ui_merge);
LOG ("Rebuilding recent history menu")
@@ -216,17 +211,22 @@ ephy_favorites_menu_rebuild (EphyFavoritesMenu *wrhm)
children = ephy_node_get_children (fav);
xml = g_string_new (NULL);
- g_string_append_printf (xml, "<placeholder name=\"wrhm%x\">\n", (guint) wrhm);
+ g_string_append (xml, "<Root><menu><submenu name=\"GoMenu\">"
+ "<placeholder name=\"GoFavorites\">");
+
+ p->action_group = egg_action_group_new ("FavoritesActions");
+ egg_menu_merge_insert_action_group (merge, p->action_group, 0);
for (i = 0; i < children->len; i++)
{
- char *verb = g_strdup_printf ("Wrhm%xn%d", (guint) wrhm, i);
+ char *verb = g_strdup_printf ("GoFav%d", i);
char *title_s;
const char *title;
const char *url;
xmlChar *label_x;
EphyNode *child;
FavoriteData *data;
+ EggAction *action;
child = g_ptr_array_index (children, i);
title = ephy_node_get_property_string (child, EPHY_NODE_BMK_PROP_TITLE);
@@ -234,21 +234,32 @@ ephy_favorites_menu_rebuild (EphyFavoritesMenu *wrhm)
title_s = ephy_string_shorten (title, MAX_LABEL_LENGTH);
label_x = xmlEncodeSpecialChars (NULL, title_s);
+ data = g_new0 (FavoriteData, 1);
+ data->window = wrhm->priv->window;
+ data->url = url;
+
+ action = g_object_new (EGG_TYPE_ACTION,
+ "name", verb,
+ "label", label_x,
+ "tooltip", "Hello",
+ "stock_id", NULL,
+ NULL);
+ g_signal_connect_closure
+ (action, "activate",
+ g_cclosure_new (G_CALLBACK (ephy_favorites_menu_verb_cb),
+ data,
+ (GClosureNotify)g_free),
+ FALSE);
+ egg_action_group_add_action (p->action_group, action);
+ g_object_unref (action);
+
g_string_append (xml, "<menuitem name=\"");
g_string_append (xml, verb);
- g_string_append (xml, "\" label=\"");
- g_string_append (xml, label_x);
+ g_string_append (xml, "Menu");
g_string_append (xml, "\" verb=\"");
g_string_append (xml, verb);
g_string_append (xml, "\"/>\n");
- data = g_new0 (FavoriteData, 1);
- data->window = wrhm->priv->window;
- data->url = url;
- bonobo_ui_component_add_verb_full (uic, verb, g_cclosure_new
- (G_CALLBACK (ephy_favorites_menu_verb_cb), data,
- (GClosureNotify)g_free));
-
xmlFree (label_x);
g_free (title_s);
g_free (verb);
@@ -256,13 +267,16 @@ ephy_favorites_menu_rebuild (EphyFavoritesMenu *wrhm)
ephy_node_thaw (fav);
- g_string_append (xml, "</placeholder>\n");
+ g_string_append (xml, "</placeholder></submenu></menu></Root>");
if (children->len > 0)
{
- bonobo_ui_component_set (uic, p->path,
- xml->str, NULL);
+ GError *error = NULL;
+
+ p->ui_id = egg_menu_merge_add_ui_from_string
+ (merge, xml->str, -1, &error);
}
+
g_string_free (xml, TRUE);
}