]> spindle.queued.net Git - midori/commitdiff
Introduce MIDORI_EVENT_CONTEXT_MENU in midori-platform.h
authorChristian Dywan <christian@twotoasts.de>
Wed, 21 Sep 2011 21:03:00 +0000 (23:03 +0200)
committerChristian Dywan <christian@twotoasts.de>
Wed, 21 Sep 2011 21:04:20 +0000 (23:04 +0200)
The new header contains all state and event handling.

extensions/cookie-manager/cookie-manager-page.c
extensions/feed-panel/feed-panel.c
extensions/mouse-gestures.c
extensions/tab-panel.c
midori/midori-browser.c
midori/midori-locationaction.c
midori/midori-platform.h [new file with mode: 0644]
midori/midori-searchaction.c
midori/midori-view.c
midori/midori.h
midori/sokoke.h

index b6ab1c5aade2eef0117790f13e2ab2cd4c1accaa..1db5d50e5895aa6bfcd2050104d350c359e79283 100644 (file)
@@ -933,7 +933,7 @@ static gboolean  cm_tree_popup_menu_cb(GtkWidget *widget, CookieManagerPage *cmp
 static gboolean cm_tree_button_release_event_cb(GtkWidget *widget, GdkEventButton *ev,
                                                                                                CookieManagerPage *cmp)
 {
-       if (ev->button == 3)
+       if (MIDORI_EVENT_CONTEXT_MENU(ev))
        {
                cm_tree_show_popup_menu(widget, ev, cmp);
                return TRUE;
index 760dab693172ce15dc70ed27d7418fa73fc80c19..052ca8538c452071425d202f439bda9e8ad090cd 100644 (file)
@@ -622,7 +622,7 @@ webview_button_press_event_cb (GtkWidget*      widget,
                                GdkEventButton* event)
 {
     /* Disable the popup menu */
-    return (event->button == 3);
+    return MIDORI_EVENT_CONTEXT_MENU (event);
 }
 
 static gboolean
index 6a3bf47b3ec1910f946950896171c655ccb4845e..bbe38b49d4e736b13e80af750ff7c5d5cf4e9964 100644 (file)
@@ -187,7 +187,7 @@ mouse_gestures_button_release_event_cb (GtkWidget*      web_view,
         mouse_gesture_clear (gesture);
     }
 
-    if (event->button == 3)
+    if (MIDORI_EVENT_CONTEXT_MENU (event))
     {
         GtkWidget* menu = gtk_menu_new ();
         midori_view_populate_popup (view, menu, TRUE);
index 4d58447e1572393886439b642740c50ce9ae274f..0c2291a251a5212d03d89b02f9a5a5bd15246140 100644 (file)
@@ -406,7 +406,7 @@ tab_panel_toolitem_button_press_event_cb (GtkToolItem*    toolitem,
                                           GdkEventButton* event,
                                           GtkWidget*      view)
 {
-    if (event->button == 3)
+    if (MIDORI_EVENT_CONTEXT_MENU (event))
     {
         tab_panel_popup (GTK_WIDGET (toolitem), event, view);
         return TRUE;
index 5f111272eafe8c3d489bbc89f0b8e3c4ff5fc017..bd598b3b402ced1a75a40f53f59b8cc7b862fcbf 100644 (file)
@@ -22,6 +22,7 @@
 #include "midori-stock.h"
 #include "midori-findbar.h"
 #include "midori-transferbar.h"
+#include "midori-platform.h"
 
 #include "gtkiconentry.h"
 #include "marshal.h"
@@ -5062,7 +5063,7 @@ midori_browser_notebook_button_press_event_after_cb (GtkNotebook*    notebook,
 
         return TRUE;
     }
-    else if (event->type == GDK_BUTTON_PRESS && event->button == 3)
+    else if (event->type == GDK_BUTTON_PRESS && MIDORI_EVENT_CONTEXT_MENU (event))
     {
         GtkWidget* menu = gtk_menu_new ();
         GList* tabs = gtk_container_get_children (GTK_CONTAINER (notebook));
@@ -6379,7 +6380,7 @@ midori_browser_toolbar_item_button_press_event_cb (GtkWidget*      toolitem,
 
         return _action_navigation_activate (action, browser);
     }
-    else if (event->button == 3)
+    else if (MIDORI_EVENT_CONTEXT_MENU (event))
     {
         midori_browser_toolbar_popup_context_menu_cb (
             GTK_IS_BIN (toolitem) && gtk_bin_get_child (GTK_BIN (toolitem)) ?
@@ -6621,7 +6622,7 @@ midori_bookmarkbar_item_button_press_event_cb (GtkWidget*      toolitem,
             return TRUE;
         }
     }
-    else if (event->button == 3)
+    else if (MIDORI_EVENT_CONTEXT_MENU (event))
     {
         midori_browser_bookmark_popup (toolitem, NULL, item, browser);
         return TRUE;
index e7225cef8ab58dbf9b7ef38ef34b57d6643fce83..3a1d2e2c9a61eea0080572a44a5b2cbf1105c4a9 100644 (file)
@@ -17,6 +17,7 @@
 #include "sokoke.h"
 #include "midori-browser.h"
 #include "midori-searchaction.h"
+#include "midori-platform.h"
 
 #include <string.h>
 #include <glib/gi18n.h>
diff --git a/midori/midori-platform.h b/midori/midori-platform.h
new file mode 100644 (file)
index 0000000..e3d91c0
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ Copyright (C) 2010-2011 Christian Dywan <christian@twotoasts.de>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ See the file COPYING for the full license text.
+*/
+
+#ifndef __MIDORI_PLATFORM_H__
+#define __MIDORI_PLATFORM_H__ 1
+
+#include <gtk/gtk.h>
+
+/* Common behavior modifiers */
+#define MIDORI_MOD_NEW_WINDOW(state) (state & GDK_SHIFT_MASK)
+#define MIDORI_MOD_NEW_TAB(state) (state & GDK_CONTROL_MASK)
+#define MIDORI_MOD_BACKGROUND(state) (state & GDK_SHIFT_MASK)
+#define MIDORI_MOD_SCROLL(state) (state & GDK_CONTROL_MASK)
+
+#ifdef GDK_WINDOWING_QUARTZ
+    #define MIDORI_EVENT_CONTEXT_MENU(evt) \
+        ((evt->button == 3) \
+        || (evt->button == 1 && (evt->state & GDK_CONTROL_MASK)))
+#else
+    #define MIDORI_EVENT_CONTEXT_MENU(evt) \
+        (evt->button == 3)
+#endif
+
+#endif /* !__MIDORI_PLATFORM_H__ */
index 1641afdcd964e71d64e9dac1d9d65c1df2366d5d..3be44c3a6dc6bd94c0812ec1bf83c25cd270a805 100644 (file)
@@ -14,6 +14,7 @@
 #include "gtkiconentry.h"
 #include "marshal.h"
 #include "sokoke.h"
+#include "midori-platform.h"
 
 #include <string.h>
 #include <glib/gi18n.h>
index ca8f2fa5349e2a0ffae425146fbfe9d580c937b2..0d7a96e65ec022b09296b9bb91e9ed87003941be 100644 (file)
@@ -18,6 +18,7 @@
 #include "midori-stock.h"
 #include "midori-browser.h"
 #include "midori-searchaction.h"
+#include "midori-platform.h"
 
 #include "marshal.h"
 #include "sokoke.h"
@@ -4405,7 +4406,7 @@ midori_view_tab_label_button_press_event (GtkWidget*      tab_label,
         gtk_widget_destroy (widget);
         return TRUE;
     }
-    else if (event->button == 3)
+    else if (MIDORI_EVENT_CONTEXT_MENU (event))
     {
         /* Show a context menu on right click */
         GtkWidget* menu = midori_view_get_tab_menu (MIDORI_VIEW (widget));
index 84a13d5caaef4494e89dbffae7140babadaadec1..775eee08fdefa9af7367064864d771aaadc8bfa2 100644 (file)
@@ -24,6 +24,7 @@
 #include "midori-view.h"
 #include "midori-viewable.h"
 #include "midori-websettings.h"
+#include "midori-platform.h"
 
 /* For convenience, include localization header */
 #include <glib/gi18n-lib.h>
index 350667c87d94bcd7db26c4da140eae67b11b4db1..b446982c6d252ce7f934db05a14cb961e387373a 100644 (file)
 #ifndef __SOKOKE_H__
 #define __SOKOKE_H__ 1
 
-/* Common behavior modifiers */
-#define MIDORI_MOD_NEW_WINDOW(state) (state & GDK_SHIFT_MASK)
-#define MIDORI_MOD_NEW_TAB(state) (state & GDK_CONTROL_MASK)
-#define MIDORI_MOD_BACKGROUND(state) (state & GDK_SHIFT_MASK)
-#define MIDORI_MOD_SCROLL(state) (state & GDK_CONTROL_MASK)
-
 #include <JavaScriptCore/JavaScript.h>
 #include <midori/midori-websettings.h>