[Xfce4-commits] <midori:master> Introduce MIDORI_EVENT_NEW_TAB and use it

Christian Dywan noreply at xfce.org
Wed Sep 28 17:50:01 CEST 2011


Updating branch refs/heads/master
         to ae56fbf818c1765e1629de9ebc313e3d521f243b (commit)
       from daa6fa0ee71fa901fd903a52b8e6d2c0741ac6ce (commit)

commit ae56fbf818c1765e1629de9ebc313e3d521f243b
Author: Christian Dywan <christian at twotoasts.de>
Date:   Wed Sep 28 17:45:37 2011 +0200

    Introduce MIDORI_EVENT_NEW_TAB and use it
    
    Fixes: https://bugs.launchpad.net/midori/+bug/797224
    Fixes: https://bugs.launchpad.net/midori/+bug/797229

 midori/midori-browser.c  |   30 +++++++++++++++---------------
 midori/midori-platform.h |    5 +++++
 2 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index bd598b3..e2bdcbd 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 e3d91c0..194bf57 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__ */


More information about the Xfce4-commits mailing list