From bac3dc1842d98c5f42f1b8b576531c55f8b7cb41 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Wed, 21 Sep 2011 23:03:00 +0200 Subject: [PATCH] Introduce MIDORI_EVENT_CONTEXT_MENU in midori-platform.h The new header contains all state and event handling. --- .../cookie-manager/cookie-manager-page.c | 2 +- extensions/feed-panel/feed-panel.c | 2 +- extensions/mouse-gestures.c | 2 +- extensions/tab-panel.c | 2 +- midori/midori-browser.c | 7 ++-- midori/midori-locationaction.c | 1 + midori/midori-platform.h | 32 +++++++++++++++++++ midori/midori-searchaction.c | 1 + midori/midori-view.c | 3 +- midori/midori.h | 1 + midori/sokoke.h | 6 ---- 11 files changed, 45 insertions(+), 14 deletions(-) create mode 100644 midori/midori-platform.h diff --git a/extensions/cookie-manager/cookie-manager-page.c b/extensions/cookie-manager/cookie-manager-page.c index b6ab1c5a..1db5d50e 100644 --- a/extensions/cookie-manager/cookie-manager-page.c +++ b/extensions/cookie-manager/cookie-manager-page.c @@ -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; diff --git a/extensions/feed-panel/feed-panel.c b/extensions/feed-panel/feed-panel.c index 760dab69..052ca853 100644 --- a/extensions/feed-panel/feed-panel.c +++ b/extensions/feed-panel/feed-panel.c @@ -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 diff --git a/extensions/mouse-gestures.c b/extensions/mouse-gestures.c index 6a3bf47b..bbe38b49 100644 --- a/extensions/mouse-gestures.c +++ b/extensions/mouse-gestures.c @@ -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); diff --git a/extensions/tab-panel.c b/extensions/tab-panel.c index 4d58447e..0c2291a2 100644 --- a/extensions/tab-panel.c +++ b/extensions/tab-panel.c @@ -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; diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 5f111272..bd598b3b 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -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; diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c index e7225cef..3a1d2e2c 100644 --- a/midori/midori-locationaction.c +++ b/midori/midori-locationaction.c @@ -17,6 +17,7 @@ #include "sokoke.h" #include "midori-browser.h" #include "midori-searchaction.h" +#include "midori-platform.h" #include #include diff --git a/midori/midori-platform.h b/midori/midori-platform.h new file mode 100644 index 00000000..e3d91c0e --- /dev/null +++ b/midori/midori-platform.h @@ -0,0 +1,32 @@ +/* + Copyright (C) 2010-2011 Christian Dywan + + 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 + +/* 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__ */ diff --git a/midori/midori-searchaction.c b/midori/midori-searchaction.c index 1641afdc..3be44c3a 100644 --- a/midori/midori-searchaction.c +++ b/midori/midori-searchaction.c @@ -14,6 +14,7 @@ #include "gtkiconentry.h" #include "marshal.h" #include "sokoke.h" +#include "midori-platform.h" #include #include diff --git a/midori/midori-view.c b/midori/midori-view.c index ca8f2fa5..0d7a96e6 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -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)); diff --git a/midori/midori.h b/midori/midori.h index 84a13d5c..775eee08 100644 --- a/midori/midori.h +++ b/midori/midori.h @@ -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 diff --git a/midori/sokoke.h b/midori/sokoke.h index 350667c8..b446982c 100644 --- a/midori/sokoke.h +++ b/midori/sokoke.h @@ -13,12 +13,6 @@ #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 #include