Introduce MIDORI_EVENT_CONTEXT_MENU in midori-platform.h

The new header contains all state and event handling.
This commit is contained in:
Christian Dywan 2011-09-21 23:03:00 +02:00
parent fc21488881
commit bac3dc1842
11 changed files with 45 additions and 14 deletions

View 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;

View 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

View 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);

View 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;

View 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;

View 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>

32
midori/midori-platform.h Normal file
View file

@ -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__ */

View 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>

View 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));

View 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>

View file

@ -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 <JavaScriptCore/JavaScript.h>
#include <midori/midori-websettings.h>