summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Barciela <[email protected]>2017-09-25 09:57:26 +0200
committerraveit65 <[email protected]>2017-10-11 10:16:16 +0200
commit4df44887f4b7547fc9b31d1cb3f61688579fe39b (patch)
tree6d60a6da6b5c6e6244c63388285ac9d23b77695b
parentf0b6b6693720aef9281c840b84deff9a1a6e1aa2 (diff)
downloadpluma-4df44887f4b7547fc9b31d1cb3f61688579fe39b.tar.bz2
pluma-4df44887f4b7547fc9b31d1cb3f61688579fe39b.tar.xz
Fix: wrong behavior holding down [middle + right] click
Fixes https://github.com/mate-desktop/pluma/issues/250
-rw-r--r--pluma/pluma-view.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/pluma/pluma-view.c b/pluma/pluma-view.c
index 38535065..437d7017 100644
--- a/pluma/pluma-view.c
+++ b/pluma/pluma-view.c
@@ -56,6 +56,8 @@
#define PLUMA_VIEW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), PLUMA_TYPE_VIEW, PlumaViewPrivate))
+static gboolean middledown = FALSE;
+
typedef enum
{
GOTO_LINE,
@@ -121,8 +123,11 @@ static gboolean pluma_view_drag_drop (GtkWidget *widget,
gint x,
gint y,
guint timestamp);
+
static gboolean pluma_view_button_press_event (GtkWidget *widget,
GdkEventButton *event);
+static gboolean pluma_view_button_release_event (GtkWidget *widget,
+ GdkEventButton *event);
static gboolean start_interactive_search (PlumaView *view);
static gboolean start_interactive_goto_line (PlumaView *view);
@@ -206,6 +211,7 @@ pluma_view_class_init (PlumaViewClass *klass)
widget_class->drag_data_received = pluma_view_drag_data_received;
widget_class->drag_drop = pluma_view_drag_drop;
widget_class->button_press_event = pluma_view_button_press_event;
+ widget_class->button_release_event = pluma_view_button_release_event;
klass->start_interactive_search = start_interactive_search;
klass->start_interactive_goto_line = start_interactive_goto_line;
klass->reset_searched_text = reset_searched_text;
@@ -1987,6 +1993,16 @@ show_line_numbers_menu (GtkWidget *view,
static gboolean
pluma_view_button_press_event (GtkWidget *widget, GdkEventButton *event)
{
+ if ((event->button == 3) && (middledown))
+ {
+ middledown = FALSE;
+ return TRUE;
+ }
+ else if (event->button == 2)
+ {
+ middledown = TRUE;
+ }
+
if ((event->type == GDK_BUTTON_PRESS) &&
(event->window == gtk_text_view_get_window (GTK_TEXT_VIEW (widget),
GTK_TEXT_WINDOW_LEFT)))
@@ -2007,6 +2023,17 @@ pluma_view_button_press_event (GtkWidget *widget, GdkEventButton *event)
return GTK_WIDGET_CLASS (pluma_view_parent_class)->button_press_event (widget, event);
}
+static gboolean
+pluma_view_button_release_event (GtkWidget *widget, GdkEventButton *event)
+{
+ if (event->button == 2)
+ {
+ middledown = FALSE;
+ }
+
+ return GTK_WIDGET_CLASS (pluma_view_parent_class)->button_release_event (widget, event);
+}
+
static void
search_highlight_updated_cb (PlumaDocument *doc,
GtkTextIter *start,