aboutsummaryrefslogtreecommitdiffstats
path: root/lib/widgets/ephy-middle-clickable-button.c
diff options
context:
space:
mode:
authorXan Lopez <xan@igalia.com>2012-01-01 07:09:35 +0800
committerXan Lopez <xan@igalia.com>2012-01-02 00:30:53 +0800
commitd5b4f4ba1d31e368e23ddd77774e285a13908622 (patch)
tree4940ca63c17dc4b5d3d8707c0294e2ee0023a72e /lib/widgets/ephy-middle-clickable-button.c
parent10c1b6a7194f8dfc7c7cca278cfb6444255caed2 (diff)
downloadgsoc2013-epiphany-d5b4f4ba1d31e368e23ddd77774e285a13908622.tar
gsoc2013-epiphany-d5b4f4ba1d31e368e23ddd77774e285a13908622.tar.gz
gsoc2013-epiphany-d5b4f4ba1d31e368e23ddd77774e285a13908622.tar.bz2
gsoc2013-epiphany-d5b4f4ba1d31e368e23ddd77774e285a13908622.tar.lz
gsoc2013-epiphany-d5b4f4ba1d31e368e23ddd77774e285a13908622.tar.xz
gsoc2013-epiphany-d5b4f4ba1d31e368e23ddd77774e285a13908622.tar.zst
gsoc2013-epiphany-d5b4f4ba1d31e368e23ddd77774e285a13908622.zip
Fake middle clicks without gtk_button_{press,release}, which are deprecated
Factor the logic that fakes clicks from a middle click in EphyMiddleClick(Tool)Button by forwarding a left click to GTK+ when we receive a middle click. Since ephy_gui_is_middle_click stops working in this case, add the minimal logic in EphyLinkAction to make it work again (basically, cache the button that activated the action inside the action itself). The EphyMiddleClickable(Tool)Button classes were written by Alexandre Mazari. https://bugzilla.gnome.org/show_bug.cgi?id=628364
Diffstat (limited to 'lib/widgets/ephy-middle-clickable-button.c')
-rw-r--r--lib/widgets/ephy-middle-clickable-button.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/lib/widgets/ephy-middle-clickable-button.c b/lib/widgets/ephy-middle-clickable-button.c
new file mode 100644
index 000000000..1e6f53e98
--- /dev/null
+++ b/lib/widgets/ephy-middle-clickable-button.c
@@ -0,0 +1,68 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * Copyright © 2011 Alexandre Mazari
+ * Copyright © 2011 Igalia S.L.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "ephy-middle-clickable-button.h"
+
+G_DEFINE_TYPE (EphyMiddleClickableButton, ephy_middle_clickable_button, GTK_TYPE_BUTTON)
+
+static gboolean
+ephy_middle_clickable_button_handle_event (GtkWidget * widget,
+ GdkEventButton * event)
+{
+ gboolean ret;
+ int actual_button;
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (ephy_middle_clickable_button_parent_class);
+
+ actual_button = event->button;
+
+ if (actual_button == 2)
+ event->button = 1;
+
+ if (event->type == GDK_BUTTON_PRESS)
+ ret = widget_class->button_press_event (widget, event);
+ else
+ ret = widget_class->button_release_event (widget, event);
+
+ event->button = actual_button;
+
+ return ret;
+}
+
+static void
+ephy_middle_clickable_button_class_init (EphyMiddleClickableButtonClass *class)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
+
+ widget_class->button_press_event = ephy_middle_clickable_button_handle_event;
+ widget_class->button_release_event = ephy_middle_clickable_button_handle_event;
+}
+
+static void
+ephy_middle_clickable_button_init (EphyMiddleClickableButton *class)
+{
+}
+
+GtkWidget *
+ephy_middle_clickable_button_new ()
+{
+ return gtk_widget_new (EPHY_TYPE_MIDDLE_CLICKABLE_BUTTON, NULL);
+}