diff --git a/midori/midori-browser.c b/midori/midori-browser.c index bd436b9e..ee43f01b 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -2863,6 +2863,12 @@ static void _action_back_activate (GtkAction* action, MidoriBrowser* browser) { + if (g_object_get_data (G_OBJECT (action), "midori-middle-click")) + { + g_object_set_data (G_OBJECT (action), "midori-middle-click", (void*)0); + return; + } + GtkWidget* view = midori_browser_get_current_tab (browser); if (view) midori_view_go_back (MIDORI_VIEW (view)); @@ -2872,6 +2878,12 @@ static void _action_forward_activate (GtkAction* action, MidoriBrowser* browser) { + if (g_object_get_data (G_OBJECT (action), "midori-middle-click")) + { + g_object_set_data (G_OBJECT (action), "midori-middle-click", (void*)0); + return; + } + GtkWidget* view = midori_browser_get_current_tab (browser); if (view) midori_view_go_forward (MIDORI_VIEW (view)); @@ -2881,6 +2893,12 @@ static void _action_homepage_activate (GtkAction* action, MidoriBrowser* browser) { + if (g_object_get_data (G_OBJECT (action), "midori-middle-click")) + { + g_object_set_data (G_OBJECT (action), "midori-middle-click", (void*)0); + return; + } + gchar* homepage; if (!browser->settings) @@ -3274,6 +3292,10 @@ midori_browser_menu_middle_click_on_navigation_action (MidoriBrowser* browser, name = gtk_action_get_name (action); + /* We use a trick here to implement middle click and prevent the default + "activate" callback from being invoked. We set "midori-middle-click" + as GObject data and check the value in the "activate" callback. */ + if (g_str_equal (name, "Homepage")) { gint n; @@ -3281,6 +3303,8 @@ midori_browser_menu_middle_click_on_navigation_action (MidoriBrowser* browser, n = midori_browser_add_uri (browser, homepage); _midori_browser_set_current_page_smartly (browser, n); + g_object_set_data (G_OBJECT (action), "midori-middle-click", (void*)1); + return TRUE; } else if (g_str_equal (name, "Back")) @@ -3302,6 +3326,8 @@ midori_browser_menu_middle_click_on_navigation_action (MidoriBrowser* browser, n = midori_browser_add_uri (browser, back_uri); _midori_browser_set_current_page_smartly (browser, n); + g_object_set_data (G_OBJECT (action), "midori-middle-click", (void*)1); + return TRUE; } else if (g_str_equal (name, "Forward")) @@ -3324,6 +3350,8 @@ midori_browser_menu_middle_click_on_navigation_action (MidoriBrowser* browser, n = midori_browser_add_uri (browser, forward_uri); _midori_browser_set_current_page_smartly (browser, n); + g_object_set_data (G_OBJECT (action), "midori-middle-click", (void*)1); + return TRUE; }