aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ephy-link-action.c63
-rw-r--r--src/ephy-link-action.h6
-rw-r--r--src/ephy-navigation-action.c3
-rw-r--r--src/ephy-navigation-history-action.c10
4 files changed, 49 insertions, 33 deletions
diff --git a/src/ephy-link-action.c b/src/ephy-link-action.c
index 160b253d3..804aae7c4 100644
--- a/src/ephy-link-action.c
+++ b/src/ephy-link-action.c
@@ -32,33 +32,19 @@ G_DEFINE_TYPE_WITH_CODE (EphyLinkAction, ephy_link_action, GTK_TYPE_ACTION,
G_IMPLEMENT_INTERFACE (EPHY_TYPE_LINK,
NULL))
+#define EPHY_LINK_ACTION_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_LINK_ACTION, EphyLinkActionPrivate))
+
+struct _EphyLinkActionPrivate
+{
+ guint button;
+};
+
static gboolean
proxy_button_press_event_cb (GtkButton *button,
GdkEventButton *event,
EphyLinkAction *action)
{
- if (event->button == 2)
- {
- gtk_button_pressed (button);
- }
-
- return FALSE;
-}
-
-static gboolean
-proxy_button_release_event_cb (GtkButton *button,
- GdkEventButton *event,
- EphyLinkAction *action)
-{
- /*
- * We do not use ephy_gui_is_middle_click() here because
- * that also catches ctrl + left_click which already
- * triggers an activate event for all proxies.
- */
- if (event->button == 2)
- {
- gtk_button_released (button);
- }
+ action->priv->button = event->button;
return FALSE;
}
@@ -109,9 +95,6 @@ ephy_link_action_connect_proxy (GtkAction *action, GtkWidget *proxy)
g_signal_connect (widget, "button-press-event",
G_CALLBACK (proxy_button_press_event_cb),
action);
- g_signal_connect (widget, "button-release-event",
- G_CALLBACK (proxy_button_release_event_cb),
- action);
}
GTK_ACTION_CLASS (ephy_link_action_parent_class)->connect_proxy (action, proxy);
@@ -130,9 +113,6 @@ ephy_link_action_disconnect_proxy (GtkAction *action, GtkWidget *proxy)
g_signal_handlers_disconnect_by_func (widget,
G_CALLBACK (proxy_button_press_event_cb),
action);
- g_signal_handlers_disconnect_by_func (widget,
- G_CALLBACK (proxy_button_release_event_cb),
- action);
}
GTK_ACTION_CLASS (ephy_link_action_parent_class)->disconnect_proxy (action, proxy);
@@ -141,7 +121,7 @@ ephy_link_action_disconnect_proxy (GtkAction *action, GtkWidget *proxy)
static void
ephy_link_action_init (EphyLinkAction *action)
{
- /* Empty, needed for G_DEFINE_TYPE macro */
+ action->priv = EPHY_LINK_ACTION_GET_PRIVATE (action);
}
static void
@@ -151,6 +131,31 @@ ephy_link_action_class_init (EphyLinkActionClass *class)
action_class->connect_proxy = ephy_link_action_connect_proxy;
action_class->disconnect_proxy = ephy_link_action_disconnect_proxy;
+
+ g_type_class_add_private (G_OBJECT_CLASS (class), sizeof (EphyLinkActionPrivate));
+}
+
+/**
+ * ephy_link_action_get_button:
+ * @action: an #EphyLinkAction
+ *
+ * This method stores the mouse button number that last activated, or
+ * is activating, the @action. This is useful because #GtkButton's
+ * cannot be clicked with a middle click by default, so inside
+ * Epiphany we fake this by forwarding a left click (button 1) event
+ * instead of a middle click (button 2) to the button. That makes the
+ * EphyGUI methods like ephy_gui_is_middle_click not work here, so we
+ * need to ask the @action directly about the button that activated
+ * it.
+ *
+ * Returns: the button number that last activated (or is activating) the @action
+ **/
+guint
+ephy_link_action_get_button (EphyLinkAction *action)
+{
+ g_return_val_if_fail (EPHY_IS_LINK_ACTION (action), 0);
+
+ return action->priv->button;
}
static void
diff --git a/src/ephy-link-action.h b/src/ephy-link-action.h
index 6dbf03728..a6b4419cc 100644
--- a/src/ephy-link-action.h
+++ b/src/ephy-link-action.h
@@ -44,6 +44,7 @@ G_BEGIN_DECLS
typedef struct _EphyLinkAction EphyLinkAction;
typedef struct _EphyLinkActionClass EphyLinkActionClass;
+typedef struct _EphyLinkActionPrivate EphyLinkActionPrivate;
typedef struct _EphyLinkActionGroup EphyLinkActionGroup;
typedef struct _EphyLinkActionGroupClass EphyLinkActionGroupClass;
@@ -51,6 +52,8 @@ typedef struct _EphyLinkActionGroupClass EphyLinkActionGroupClass;
struct _EphyLinkAction
{
GtkAction parent_instance;
+
+ EphyLinkActionPrivate *priv;
};
struct _EphyLinkActionClass
@@ -68,7 +71,8 @@ struct _EphyLinkActionGroupClass
GtkActionGroupClass parent_class;
};
-GType ephy_link_action_get_type (void);
+GType ephy_link_action_get_type (void);
+guint ephy_link_action_get_button (EphyLinkAction *action);
GType ephy_link_action_group_get_type (void);
diff --git a/src/ephy-navigation-action.c b/src/ephy-navigation-action.c
index ed544430b..438e6cf51 100644
--- a/src/ephy-navigation-action.c
+++ b/src/ephy-navigation-action.c
@@ -24,6 +24,7 @@
#include "config.h"
#include "ephy-navigation-action.h"
+#include "ephy-middle-clickable-tool-button.h"
#include "ephy-window.h"
#include <gtk/gtk.h>
@@ -93,7 +94,7 @@ ephy_navigation_action_class_init (EphyNavigationActionClass *class)
object_class->set_property = ephy_navigation_action_set_property;
object_class->get_property = ephy_navigation_action_get_property;
- action_class->toolbar_item_type = GTK_TYPE_TOOL_BUTTON;
+ action_class->toolbar_item_type = EPHY_TYPE_MIDDLE_CLICKABLE_TOOL_BUTTON;
g_object_class_install_property (object_class,
PROP_WINDOW,
diff --git a/src/ephy-navigation-history-action.c b/src/ephy-navigation-history-action.c
index daf98ad5e..7c8d9f3d7 100644
--- a/src/ephy-navigation-history-action.c
+++ b/src/ephy-navigation-history-action.c
@@ -87,8 +87,13 @@ action_activate (GtkAction *action)
web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
+ /* We use ephy_link_action_get_button on top of
+ * ephy_gui_is_middle_click because of the hacks we have to do to
+ * fake middle clicks on tool buttons. Read the documentation of
+ * ephy_link_action_get_button for more details. */
if (history_action->priv->direction == EPHY_NAVIGATION_HISTORY_DIRECTION_BACK) {
- if (ephy_gui_is_middle_click ()) {
+ if (ephy_gui_is_middle_click () ||
+ ephy_link_action_get_button (EPHY_LINK_ACTION (history_action)) == 2) {
embed = ephy_shell_new_tab (ephy_shell_get_default (),
EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed))),
embed,
@@ -98,7 +103,8 @@ action_activate (GtkAction *action)
}
webkit_web_view_go_back (web_view);
} else if (history_action->priv->direction == EPHY_NAVIGATION_HISTORY_DIRECTION_FORWARD) {
- if (ephy_gui_is_middle_click ()) {
+ if (ephy_gui_is_middle_click () ||
+ ephy_link_action_get_button (EPHY_LINK_ACTION (history_action)) == 2) {
const char *forward_uri;
WebKitWebHistoryItem *forward_item;
WebKitWebBackForwardList *history;