summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Barciela <[email protected]>2018-08-16 03:49:36 +0200
committerZenWalker <[email protected]>2018-08-22 00:43:06 +0200
commitb52da1aed1c634fc69f1cfa8df1725ed12603424 (patch)
tree4654bf25e5363815eb63bb834317cbdbd56f5728
parent320a44d23c9c8209042d7df2161e9fadd4a478cc (diff)
downloadpluma-b52da1aed1c634fc69f1cfa8df1725ed12603424.tar.bz2
pluma-b52da1aed1c634fc69f1cfa8df1725ed12603424.tar.xz
pluma-view: Fix: unexpectedly switch between tabs
Fixes https://github.com/mate-desktop/pluma/issues/349#issuecomment-413572946
-rw-r--r--pluma/pluma-view.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/pluma/pluma-view.c b/pluma/pluma-view.c
index c822ebd3..17dc8f20 100644
--- a/pluma/pluma-view.c
+++ b/pluma/pluma-view.c
@@ -107,6 +107,8 @@ static void pluma_view_dispose (GObject *object);
static void pluma_view_finalize (GObject *object);
static gint pluma_view_focus_out (GtkWidget *widget,
GdkEventFocus *event);
+static gboolean pluma_view_scroll_event (GtkWidget *widget,
+ GdkEventScroll *event);
static gboolean pluma_view_drag_motion (GtkWidget *widget,
GdkDragContext *context,
gint x,
@@ -181,6 +183,36 @@ document_read_only_notify_handler (PlumaDocument *document,
!pluma_document_get_readonly (document));
}
+static gboolean
+pluma_view_scroll_event (GtkWidget *widget,
+ GdkEventScroll *event)
+{
+ if (event->direction == GDK_SCROLL_UP)
+ {
+ event->delta_x = 0;
+ event->delta_y = -1;
+ }
+ else if (event->direction == GDK_SCROLL_DOWN)
+ {
+ event->delta_x = 0;
+ event->delta_y = 1;
+ }
+ else if (event->direction == GDK_SCROLL_LEFT)
+ {
+ event->delta_x = -1;
+ event->delta_y = 0;
+ }
+ else if (event->direction == GDK_SCROLL_RIGHT)
+ {
+ event->delta_x = 1;
+ event->delta_y = 0;
+ }
+
+ event->direction = GDK_SCROLL_SMOOTH;
+
+ return FALSE;
+}
+
static void
pluma_view_class_init (PlumaViewClass *klass)
{
@@ -195,6 +227,7 @@ pluma_view_class_init (PlumaViewClass *klass)
widget_class->focus_out_event = pluma_view_focus_out;
widget_class->draw = pluma_view_draw;
+ widget_class->scroll_event = pluma_view_scroll_event;
/*
* Override the gtk_text_view_drag_motion and drag_drop