aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@gnome.org>2004-07-02 17:40:09 +0800
committerMarco Pesenti Gritti <marco@src.gnome.org>2004-07-02 17:40:09 +0800
commite4d85cc76bedf4d4a39453095f2ed9a97ce398ff (patch)
treea001275f0b1e9c3631fd1e955f0ec74a37674291
parent6dadef323fb59daefac69200014b1d5f238a911a (diff)
downloadgsoc2013-epiphany-e4d85cc76bedf4d4a39453095f2ed9a97ce398ff.tar
gsoc2013-epiphany-e4d85cc76bedf4d4a39453095f2ed9a97ce398ff.tar.gz
gsoc2013-epiphany-e4d85cc76bedf4d4a39453095f2ed9a97ce398ff.tar.bz2
gsoc2013-epiphany-e4d85cc76bedf4d4a39453095f2ed9a97ce398ff.tar.lz
gsoc2013-epiphany-e4d85cc76bedf4d4a39453095f2ed9a97ce398ff.tar.xz
gsoc2013-epiphany-e4d85cc76bedf4d4a39453095f2ed9a97ce398ff.tar.zst
gsoc2013-epiphany-e4d85cc76bedf4d4a39453095f2ed9a97ce398ff.zip
Implement topic context menu.
2004-07-02 Marco Pesenti Gritti <marco@gnome.org> * src/bookmarks/ephy-topic-action.c: (remove_activate_cb), (add_open_in_tabs_menu), (build_bookmarks_menu), (show_context_menu), (button_press_cb), (connect_proxy): Implement topic context menu.
-rw-r--r--ChangeLog8
-rw-r--r--src/bookmarks/ephy-topic-action.c84
2 files changed, 86 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 1af2bda98..566e6af1b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2004-07-02 Marco Pesenti Gritti <marco@gnome.org>
+ * src/bookmarks/ephy-topic-action.c: (remove_activate_cb),
+ (add_open_in_tabs_menu), (build_bookmarks_menu),
+ (show_context_menu), (button_press_cb), (connect_proxy):
+
+ Implement topic context menu.
+
+2004-07-02 Marco Pesenti Gritti <marco@gnome.org>
+
* src/bookmarks/ephy-favorites-menu.c:
* src/bookmarks/ephy-favorites-menu.h:
diff --git a/src/bookmarks/ephy-topic-action.c b/src/bookmarks/ephy-topic-action.c
index 76503124a..436b1f5ca 100644
--- a/src/bookmarks/ephy-topic-action.c
+++ b/src/bookmarks/ephy-topic-action.c
@@ -29,6 +29,7 @@
#include "ephy-topic-action.h"
#include "ephy-node-common.h"
#include "ephy-bookmarks.h"
+#include "ephy-bookmarksbar.h"
#include "ephy-favicon-cache.h"
#include "ephy-shell.h"
#include "ephy-debug.h"
@@ -338,6 +339,41 @@ open_in_tabs_activate_cb (GtkWidget *menu, EphyTopicAction *action)
g_list_free (uri_list);
}
+static void
+remove_activate_cb (GtkWidget *menu, GtkWidget *proxy)
+{
+ EphyBookmarks *bookmarks;
+ EggToolbarsModel *model;
+ GtkWidget *item, *toolbar;
+ int pos;
+
+ item = gtk_widget_get_ancestor (proxy, GTK_TYPE_TOOL_ITEM);
+ g_return_if_fail (item != NULL);
+
+ toolbar = gtk_widget_get_ancestor (proxy, GTK_TYPE_TOOLBAR);
+ g_return_if_fail (toolbar != NULL);
+
+ pos = gtk_toolbar_get_item_index (GTK_TOOLBAR (toolbar),
+ GTK_TOOL_ITEM (item));
+
+ bookmarks = ephy_shell_get_bookmarks (ephy_shell);
+ model = ephy_bookmarks_get_toolbars_model (bookmarks);
+ egg_toolbars_model_remove_item (model, 0, pos);
+}
+
+static void
+add_open_in_tabs_menu (EphyTopicAction *action, GtkWidget *menu)
+{
+ GtkWidget *item;
+
+ item = gtk_menu_item_new_with_mnemonic (_("_Open in Tabs"));
+ gtk_widget_show (item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+ g_signal_connect (item, "activate",
+ G_CALLBACK (open_in_tabs_activate_cb), action);
+}
+
static GtkWidget *
build_bookmarks_menu (EphyTopicAction *action, EphyNode *node)
{
@@ -356,12 +392,7 @@ build_bookmarks_menu (EphyTopicAction *action, EphyNode *node)
gtk_widget_show (item);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- item = gtk_menu_item_new_with_mnemonic (_("_Open in Tabs"));
- gtk_widget_show (item);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
- g_signal_connect (item, "activate",
- G_CALLBACK (open_in_tabs_activate_cb), action);
+ add_open_in_tabs_menu (action, menu);
}
return menu;
@@ -531,6 +562,44 @@ create_menu_item (GtkAction *action)
}
static void
+show_context_menu (EphyTopicAction *action, GtkWidget *proxy)
+{
+ GtkWidget *menu, *item;
+
+ menu = gtk_menu_new ();
+
+ add_open_in_tabs_menu (action, menu);
+
+ item = gtk_separator_menu_item_new ();
+ gtk_widget_show (item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+ item = gtk_image_menu_item_new_from_stock (GTK_STOCK_REMOVE, NULL);
+ gtk_widget_show (item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ g_signal_connect (item, "activate",
+ G_CALLBACK (remove_activate_cb), proxy);
+
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 3,
+ gtk_get_current_event_time ());
+}
+
+static gboolean
+button_press_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ EphyTopicAction *action)
+{
+ if (event->button == 3 &&
+ gtk_widget_get_ancestor (widget, EPHY_TYPE_BOOKMARKSBAR))
+ {
+ show_context_menu (action, widget);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
connect_proxy (GtkAction *action, GtkWidget *proxy)
{
GtkWidget *button;
@@ -549,6 +618,9 @@ connect_proxy (GtkAction *action, GtkWidget *proxy)
g_signal_connect (button, "toggled",
G_CALLBACK (button_toggled_cb), action);
+ g_signal_connect (button, "button-press-event",
+ G_CALLBACK (button_press_cb), action);
+
/* We want the menu to popup up on mouse down */
g_signal_connect (button, "pressed",
G_CALLBACK (button_pressed_cb), action);