From abda398ba465f54fdf890177146c22260edef64b Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Fri, 2 Jul 2004 09:59:11 +0000 Subject: Implement bookmark context menu. 2004-07-02 Marco Pesenti Gritti * 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. --- src/bookmarks/ephy-bookmark-action.c | 71 ++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 3 deletions(-) (limited to 'src') 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 @@ -299,6 +299,20 @@ ephy_bookmark_action_sync_label (GtkAction *action, GParamSpec *pspec, GtkWidget g_free (title); } +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) { @@ -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)); } -- cgit