diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2003-07-02 07:40:35 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2003-07-02 07:40:35 +0800 |
commit | 7c78319ee7d559c4cedb6f9d9845e5496ccb9520 (patch) | |
tree | 0500daf4c02f22b6a60ac84edb933a8688c8948e | |
parent | 3da50215b70179a91abab515bc2250184033eced (diff) | |
download | gsoc2013-epiphany-7c78319ee7d559c4cedb6f9d9845e5496ccb9520.tar gsoc2013-epiphany-7c78319ee7d559c4cedb6f9d9845e5496ccb9520.tar.gz gsoc2013-epiphany-7c78319ee7d559c4cedb6f9d9845e5496ccb9520.tar.bz2 gsoc2013-epiphany-7c78319ee7d559c4cedb6f9d9845e5496ccb9520.tar.lz gsoc2013-epiphany-7c78319ee7d559c4cedb6f9d9845e5496ccb9520.tar.xz gsoc2013-epiphany-7c78319ee7d559c4cedb6f9d9845e5496ccb9520.tar.zst gsoc2013-epiphany-7c78319ee7d559c4cedb6f9d9845e5496ccb9520.zip |
Implement toolbar overflow menu item for bookmark topics.
2003-07-02 Christian Persch <chpe@cvs.gnome.org>
* src/bookmarks/ephy-topic-action.c: (ephy_topic_action_sync_label),
(create_menu_item), (create_menu_proxy), (connect_proxy),
(ephy_topic_action_class_init):
Implement toolbar overflow menu item for bookmark topics.
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | src/bookmarks/ephy-topic-action.c | 81 |
2 files changed, 80 insertions, 9 deletions
@@ -1,3 +1,11 @@ +2003-07-02 Christian Persch <chpe@cvs.gnome.org> + + * src/bookmarks/ephy-topic-action.c: (ephy_topic_action_sync_label), + (create_menu_item), (create_menu_proxy), (connect_proxy), + (ephy_topic_action_class_init): + + Implement toolbar overflow menu item for bookmark topics. + 2003-07-02 Marco Pesenti Gritti <marco@it.gnome.org> * embed/mozilla/mozilla-embed-single.cpp: diff --git a/src/bookmarks/ephy-topic-action.c b/src/bookmarks/ephy-topic-action.c index 8a6abed4e..02a426a5c 100644 --- a/src/bookmarks/ephy-topic-action.c +++ b/src/bookmarks/ephy-topic-action.c @@ -141,14 +141,30 @@ menu_activate_cb (GtkWidget *item, EggAction *action) static void ephy_topic_action_sync_label (EggAction *action, GParamSpec *pspec, GtkWidget *proxy) { - GtkLabel *label; + GtkWidget *label = NULL; LOG ("Set bookmark action proxy label to %s", action->label) - label = GTK_LABEL (g_object_get_data (G_OBJECT (proxy), "label")); + if (EGG_IS_TOOL_ITEM (proxy)) + { + label = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "label")); + } + else if (GTK_IS_MENU_ITEM (proxy)) + { + label = GTK_BIN (proxy)->child; + } + else + { + g_warning ("Unknown widget"); + return; + } + g_return_if_fail (label != NULL); - gtk_label_set_label (label, action->label); + if (action->label) + { + gtk_label_set_label (GTK_LABEL (label), action->label); + } } static int @@ -403,24 +419,70 @@ button_pressed_cb (GtkWidget *button, gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); } +static GtkWidget * +create_menu_item (EggAction *action) +{ + GtkWidget *menu, *menu_item; + + LOG ("create_menu_item action %p", action) + + menu_item = gtk_menu_item_new_with_label (action->label); + + menu = build_menu (EPHY_TOPIC_ACTION (action)); + gtk_widget_show (menu); + + gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), menu); + + return menu_item; +} + +static gboolean +create_menu_proxy (EggToolItem *item, EggAction *action) +{ + GtkWidget *menu_item; + char *menu_id; + + LOG ("create_menu_proxy item %p, action %p", item, action) + + menu_item = create_menu_item (action); + + menu_id = g_strdup_printf ("ephy-topic-action-%d-menu-id", + EPHY_TOPIC_ACTION (action)->priv->topic_id); + + egg_tool_item_set_proxy_menu_item (item, menu_id, menu_item); + + g_free (menu_id); + + return TRUE; +} + static void connect_proxy (EggAction *action, GtkWidget *proxy) { GtkWidget *button; + LOG ("connect_proxy action %p, proxy %p", action, proxy) + (* EGG_ACTION_CLASS (parent_class)->connect_proxy) (action, proxy); ephy_topic_action_sync_label (action, NULL, proxy); g_signal_connect_object (action, "notify::label", G_CALLBACK (ephy_topic_action_sync_label), proxy, 0); - button = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "button")); - g_signal_connect (button, "toggled", - G_CALLBACK (button_toggled_cb), action); + if (EGG_IS_TOOL_ITEM (proxy)) + { + g_signal_connect_object (proxy, "create_menu_proxy", + G_CALLBACK (create_menu_proxy), + action, 0); + + button = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "button")); + g_signal_connect (button, "toggled", + G_CALLBACK (button_toggled_cb), action); - /* We want the menu to popup up on mouse down */ - g_signal_connect (button, "pressed", - G_CALLBACK (button_pressed_cb), action); + /* We want the menu to popup up on mouse down */ + g_signal_connect (button, "pressed", + G_CALLBACK (button_pressed_cb), action); + } } static void @@ -488,6 +550,7 @@ ephy_topic_action_class_init (EphyTopicActionClass *class) action_class->toolbar_item_type = EGG_TYPE_TOOL_ITEM; action_class->create_tool_item = create_tool_item; + action_class->create_menu_item = create_menu_item; action_class->connect_proxy = connect_proxy; object_class->finalize = ephy_topic_action_finalize; |