diff options
author | Marco Pesenti Gritti <marco@gnome.org> | 2004-07-02 17:59:11 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <marco@src.gnome.org> | 2004-07-02 17:59:11 +0800 |
commit | abda398ba465f54fdf890177146c22260edef64b (patch) | |
tree | 74ba4689ca6662169f35b2fcd830f025ff4135de /src/bookmarks | |
parent | e4d85cc76bedf4d4a39453095f2ed9a97ce398ff (diff) | |
download | gsoc2013-epiphany-abda398ba465f54fdf890177146c22260edef64b.tar gsoc2013-epiphany-abda398ba465f54fdf890177146c22260edef64b.tar.gz gsoc2013-epiphany-abda398ba465f54fdf890177146c22260edef64b.tar.bz2 gsoc2013-epiphany-abda398ba465f54fdf890177146c22260edef64b.tar.lz gsoc2013-epiphany-abda398ba465f54fdf890177146c22260edef64b.tar.xz gsoc2013-epiphany-abda398ba465f54fdf890177146c22260edef64b.tar.zst gsoc2013-epiphany-abda398ba465f54fdf890177146c22260edef64b.zip |
Implement bookmark context menu.
2004-07-02 Marco Pesenti Gritti <marco@gnome.org>
* src/bookmarks/ephy-bookmark-action.c: (open_in_tab_activate_cb),
(open_in_window_activate_cb), (remove_from_model),
(drag_data_delete_cb), (remove_activate_cb), (show_context_menu),
(button_press_cb):
Implement bookmark context menu.
Diffstat (limited to 'src/bookmarks')
-rw-r--r-- | src/bookmarks/ephy-bookmark-action.c | 71 |
1 files changed, 68 insertions, 3 deletions
diff --git a/src/bookmarks/ephy-bookmark-action.c b/src/bookmarks/ephy-bookmark-action.c index 2b44f1a5a..26b592a84 100644 --- a/src/bookmarks/ephy-bookmark-action.c +++ b/src/bookmarks/ephy-bookmark-action.c @@ -300,6 +300,20 @@ ephy_bookmark_action_sync_label (GtkAction *action, GParamSpec *pspec, GtkWidget } static void +open_in_tab_activate_cb (GtkWidget *widget, EphyBookmarkAction *action) +{ + g_signal_emit (action, signals[OPEN_IN_TAB], 0, + action->priv->location, FALSE); +} + +static void +open_in_window_activate_cb (GtkWidget *widget, EphyBookmarkAction *action) +{ + g_signal_emit (action, signals[OPEN_IN_TAB], 0, + action->priv->location, TRUE); +} + +static void activate_cb (GtkWidget *widget, GtkAction *action) { char *location = NULL; @@ -382,8 +396,7 @@ drag_data_get_cb (GtkWidget *widget, GdkDragContext *context, } static void -drag_data_delete_cb (GtkWidget *widget, GdkDragContext *context, - EphyBookmarkAction *action) +remove_from_model (GtkWidget *widget) { EphyBookmarks *bookmarks; EggToolbarsModel *model; @@ -404,6 +417,13 @@ drag_data_delete_cb (GtkWidget *widget, GdkDragContext *context, egg_toolbars_model_remove_item (model, 0, pos); } +static void +drag_data_delete_cb (GtkWidget *widget, GdkDragContext *context, + EphyBookmarkAction *action) +{ + remove_from_model (widget); +} + static gboolean drag_motion_cb (GtkWidget *widget, GdkEventMotion *event, EphyBookmarkAction *action) { @@ -421,12 +441,57 @@ drag_motion_cb (GtkWidget *widget, GdkEventMotion *event, EphyBookmarkAction *ac return TRUE; } +static void +remove_activate_cb (GtkWidget *menu, GtkWidget *proxy) +{ + remove_from_model (proxy); +} + +static void +show_context_menu (EphyBookmarkAction *action, GtkWidget *proxy) +{ + GtkWidget *menu, *item; + + menu = gtk_menu_new (); + + item = gtk_menu_item_new_with_mnemonic (_("_Open in New Tab")); + gtk_widget_show (item); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + g_signal_connect (item, "activate", + G_CALLBACK (open_in_tab_activate_cb), action); + + item = gtk_menu_item_new_with_mnemonic (_("_Open in New Window")); + gtk_widget_show (item); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + g_signal_connect (item, "activate", + G_CALLBACK (open_in_window_activate_cb), action); + + 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, EphyBookmarkAction *action) { - if (event->button == 2) + if (event->button == 3 && + gtk_widget_get_ancestor (widget, EPHY_TYPE_BOOKMARKSBAR)) + { + show_context_menu (action, widget); + return TRUE; + } + else if (event->button == 2) { gtk_button_pressed (GTK_BUTTON (widget)); } |