diff options
author | Philip Langdale <philipl@mail.utexas.edu> | 2005-10-25 23:09:18 +0800 |
---|---|---|
committer | Philip Langdale <philipl@src.gnome.org> | 2005-10-25 23:09:18 +0800 |
commit | 9455974ddf49a94f3842f3afda49f54eb31ce512 (patch) | |
tree | 359ecf6018074fefd0cf6ad6f41828bfd297f954 /src/ephy-link-action.c | |
parent | bb93812b19ce2402d0b2a3b5ea29e3d17aa1040a (diff) | |
download | gsoc2013-epiphany-9455974ddf49a94f3842f3afda49f54eb31ce512.tar gsoc2013-epiphany-9455974ddf49a94f3842f3afda49f54eb31ce512.tar.gz gsoc2013-epiphany-9455974ddf49a94f3842f3afda49f54eb31ce512.tar.bz2 gsoc2013-epiphany-9455974ddf49a94f3842f3afda49f54eb31ce512.tar.lz gsoc2013-epiphany-9455974ddf49a94f3842f3afda49f54eb31ce512.tar.xz gsoc2013-epiphany-9455974ddf49a94f3842f3afda49f54eb31ce512.tar.zst gsoc2013-epiphany-9455974ddf49a94f3842f3afda49f54eb31ce512.zip |
src/ephy-link-action.c
2005-10-25 Philip Langdale <philipl@mail.utexas.edu>
* src/ephy-link-action.c
* src/ephy-link-action.h:
(proxy_button_release_event_cb), (proxy_drag_begin_cb),
(ephy_link_action_connect_proxy),
(ephy_link_action_disconnect_proxy),
(ephy_link_action_class_init), (ephy_link_action_init):
Fix bug #319529. Don't activate the action on a middle mouse
button release event if the release is linked to a DnD.
This requires adding state to the action to allow us to link
the drag-begin event to the button-release event.
Diffstat (limited to 'src/ephy-link-action.c')
-rw-r--r-- | src/ephy-link-action.c | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/src/ephy-link-action.c b/src/ephy-link-action.c index d4667090f..da627f451 100644 --- a/src/ephy-link-action.c +++ b/src/ephy-link-action.c @@ -28,15 +28,23 @@ #include "ephy-gui.h" #include <gtk/gtkbutton.h> +#include <gtk/gtkmain.h> #include <gtk/gtkmenuitem.h> #include <gtk/gtkmenutoolbutton.h> +#define EPHY_LINK_ACTION_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_LINK_ACTION, EphyLinkActionPrivate)) + +struct _EphyLinkActionPrivate +{ + gboolean ignore_next_middle_click; +}; + static GObjectClass *parent_class = NULL; static gboolean proxy_button_release_event_cb (GtkWidget *widget, GdkEventButton *event, - GtkAction *action) + EphyLinkAction *action) { /** * We do not use ephy_gui_is_middle_click() here because @@ -45,12 +53,37 @@ proxy_button_release_event_cb (GtkWidget *widget, */ if (event->button == 2) { - gtk_action_activate(action); + if (!action->priv->ignore_next_middle_click) + { + gtk_action_activate (GTK_ACTION (action)); + } + action->priv->ignore_next_middle_click = FALSE; } return FALSE; } +static void +proxy_drag_begin_cb (GtkWidget *widget, + GdkDragContext *context, + EphyLinkAction *action) +{ + GdkEventMotion *event; + GdkEvent *base_event = gtk_get_current_event (); + + g_return_if_fail (base_event != NULL); + g_return_if_fail (base_event->type == GDK_MOTION_NOTIFY); + + event = (GdkEventMotion *) base_event; + + if (event->state & GDK_BUTTON2_MASK) + { + action->priv->ignore_next_middle_click = TRUE; + } + + gdk_event_free(base_event); +} + static GtkWidget * get_event_widget (GtkWidget *proxy) { @@ -107,6 +140,9 @@ ephy_link_action_connect_proxy (GtkAction *action, GtkWidget *proxy) g_signal_connect (widget, "button-release-event", G_CALLBACK (proxy_button_release_event_cb), action); + g_signal_connect (widget, "drag-begin", + G_CALLBACK (proxy_drag_begin_cb), + action); } GTK_ACTION_CLASS (parent_class)->connect_proxy (action, proxy); @@ -125,6 +161,9 @@ ephy_link_action_disconnect_proxy (GtkAction *action, GtkWidget *proxy) g_signal_handlers_disconnect_by_func (widget, G_CALLBACK (proxy_button_release_event_cb), action); + g_signal_handlers_disconnect_by_func (widget, + G_CALLBACK (proxy_drag_begin_cb), + action); } GTK_ACTION_CLASS (parent_class)->disconnect_proxy (action, proxy); @@ -133,14 +172,23 @@ ephy_link_action_disconnect_proxy (GtkAction *action, GtkWidget *proxy) static void ephy_link_action_class_init (EphyLinkActionClass *class) { + GObjectClass *object_class = G_OBJECT_CLASS (class); GtkActionClass *action_class = GTK_ACTION_CLASS (class); parent_class = g_type_class_peek_parent (class); action_class->connect_proxy = ephy_link_action_connect_proxy; action_class->disconnect_proxy = ephy_link_action_disconnect_proxy; + + g_type_class_add_private (object_class, sizeof (EphyLinkActionPrivate)); } +static void +ephy_link_action_init (EphyLinkAction *action) +{ + action->priv = EPHY_LINK_ACTION_GET_PRIVATE (action); + action->priv->ignore_next_middle_click = FALSE; +} GType ephy_link_action_get_type (void) @@ -159,7 +207,7 @@ ephy_link_action_get_type (void) NULL, /* class_data */ sizeof (EphyLinkAction), 0, /* n_preallocs */ - NULL /* instance_init */ + (GInstanceInitFunc) ephy_link_action_init }; static const GInterfaceInfo link_info = { |