From: Christian Dywan Date: Wed, 28 Sep 2011 15:45:37 +0000 (+0200) Subject: Introduce MIDORI_EVENT_NEW_TAB and use it X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae56fbf818c1765e1629de9ebc313e3d521f243b;p=midori Introduce MIDORI_EVENT_NEW_TAB and use it Fixes: https://bugs.launchpad.net/midori/+bug/797224 Fixes: https://bugs.launchpad.net/midori/+bug/797229 --- diff --git a/midori/midori-browser.c b/midori/midori-browser.c index bd598b3b..e2bdcbdb 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -2799,15 +2799,15 @@ midori_bookmarkbar_activate_item_alt (GtkAction* action, guint button, MidoriBrowser* browser) { - if (button == 1) - { - midori_browser_open_bookmark (browser, item); - } - else if (button == 2) + if (MIDORI_EVENT_NEW_TAB (gtk_get_current_event ())) { gint n = midori_browser_add_uri (browser, katze_item_get_uri (item)); midori_browser_set_current_page_smartly (browser, n); } + else if (button == 1) + { + midori_browser_open_bookmark (browser, item); + } return TRUE; } @@ -2845,17 +2845,17 @@ _action_trash_activate_item_alt (GtkAction* action, guint button, MidoriBrowser* browser) { - if (button == 1) + if (MIDORI_EVENT_NEW_TAB (gtk_get_current_event ())) { - guint n = midori_browser_add_item (browser, item); - midori_browser_set_current_page (browser, n); + gint n = midori_browser_add_item (browser, item); + midori_browser_set_current_page_smartly (browser, n); katze_array_remove_item (browser->trash, item); _midori_browser_update_actions (browser); } - else if (button == 2) + else if (button == 1) { - gint n = midori_browser_add_item (browser, item); - midori_browser_set_current_page_smartly (browser, n); + guint n = midori_browser_add_item (browser, item); + midori_browser_set_current_page (browser, n); katze_array_remove_item (browser->trash, item); _midori_browser_update_actions (browser); } @@ -4151,7 +4151,7 @@ midori_browser_menu_item_middle_click_event_cb (GtkWidget* toolitem, GdkEventButton* event, MidoriBrowser* browser) { - if (event->button == 2) + if (MIDORI_EVENT_NEW_TAB (event)) { GtkAction* action; @@ -5056,7 +5056,7 @@ midori_browser_notebook_button_press_event_after_cb (GtkNotebook* notebook, /* Open a new tab on double click or middle mouse click */ if (/*(event->type == GDK_2BUTTON_PRESS && event->button == 1) - || */(event->type == GDK_BUTTON_PRESS && event->button == 2)) + || */(event->type == GDK_BUTTON_PRESS && MIDORI_EVENT_NEW_TAB (event))) { gint n = midori_browser_add_uri (browser, ""); midori_browser_set_current_page (browser, n); @@ -6368,7 +6368,7 @@ midori_browser_toolbar_item_button_press_event_cb (GtkWidget* toolitem, GdkEventButton* event, MidoriBrowser* browser) { - if (event->button == 2) + if (MIDORI_EVENT_NEW_TAB (event)) { GtkWidget* parent = gtk_widget_get_parent (toolitem); GtkAction* action = gtk_activatable_get_related_action ( @@ -6613,7 +6613,7 @@ midori_bookmarkbar_item_button_press_event_cb (GtkWidget* toolitem, gint n; item = (KatzeItem*)g_object_get_data (G_OBJECT (toolitem), "KatzeItem"); - if (event->button == 2) + if (MIDORI_EVENT_NEW_TAB (event)) { if (KATZE_ITEM_IS_BOOKMARK (item)) { diff --git a/midori/midori-platform.h b/midori/midori-platform.h index e3d91c0e..194bf57b 100644 --- a/midori/midori-platform.h +++ b/midori/midori-platform.h @@ -29,4 +29,9 @@ (evt->button == 3) #endif +#define MIDORI_EVENT_NEW_TAB(evt) \ + ((((GdkEventButton*)evt)->button == 1 \ + && MIDORI_MOD_NEW_TAB(((GdkEventButton*)evt)->state)) \ + || (((GdkEventButton*)evt)->button == 2)) + #endif /* !__MIDORI_PLATFORM_H__ */