From 5ab58b60c1cdd1cdfb8264640bb01f0286fd850c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Geulfucci?= Date: Tue, 5 May 2009 23:22:39 +0200 Subject: [PATCH] Extend menu item middle click to support trash and history --- midori/midori-browser.c | 45 ++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/midori/midori-browser.c b/midori/midori-browser.c index d7215acb..9701fa5c 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -2172,12 +2172,39 @@ _action_trash_activate_item (GtkAction* action, KatzeItem* item, MidoriBrowser* browser) { - gint n = midori_browser_add_item (browser, item); - midori_browser_set_current_page (browser, n); + midori_browser_set_current_uri (browser, katze_item_get_uri (item)); katze_array_remove_item (browser->trash, item); _midori_browser_update_actions (browser); } +static gboolean +_action_trash_activate_item_alt (GtkAction* action, + KatzeItem* item, + guint button, + MidoriBrowser* browser) +{ + if (button == 2) + { + gint n; + gboolean open_in_background; + + g_object_get (browser->settings, "open-tabs-in-the-background", + &open_in_background, NULL); + + n = midori_browser_add_uri (browser, katze_item_get_uri (item)); + + if (!open_in_background) + midori_browser_set_current_page (browser, n); + + katze_array_remove_item (browser->trash, item); + _midori_browser_update_actions (browser); + + return TRUE; + } + + return FALSE; +} + static void _action_history_populate_popup (GtkAction* action, GtkMenu* menu, @@ -2227,10 +2254,10 @@ _action_bookmarks_activate_item (GtkAction* action, } static gboolean -_action_bookmarks_activate_item_alt (GtkAction* action, - KatzeItem* item, - guint button, - MidoriBrowser* browser) +_action_menus_activate_item_alt (GtkAction* action, + KatzeItem* item, + guint button, + MidoriBrowser* browser) { if (button == 2) { @@ -4146,6 +4173,8 @@ midori_browser_init (MidoriBrowser* browser) _action_trash_populate_popup, browser, "signal::activate-item", _action_trash_activate_item, browser, + "signal::activate-item-alt", + _action_trash_activate_item_alt, browser, NULL); gtk_action_group_add_action_with_accel (browser->action_group, action, ""); g_object_unref (action); @@ -4161,6 +4190,8 @@ midori_browser_init (MidoriBrowser* browser) _action_history_populate_popup, browser, "signal::activate-item", _action_history_activate_item, browser, + "signal::activate-item-alt", + _action_menus_activate_item_alt, browser, NULL); gtk_action_group_add_action_with_accel (browser->action_group, action, ""); g_object_unref (action); @@ -4177,7 +4208,7 @@ midori_browser_init (MidoriBrowser* browser) "signal::activate-item", _action_bookmarks_activate_item, browser, "signal::activate-item-alt", - _action_bookmarks_activate_item_alt, browser, + _action_menus_activate_item_alt, browser, NULL); gtk_action_group_add_action_with_accel (browser->action_group, action, ""); g_object_unref (action);