From b52da1aed1c634fc69f1cfa8df1725ed12603424 Mon Sep 17 00:00:00 2001 From: Pablo Barciela Date: Thu, 16 Aug 2018 03:49:36 +0200 Subject: pluma-view: Fix: unexpectedly switch between tabs Fixes https://github.com/mate-desktop/pluma/issues/349#issuecomment-413572946 --- pluma/pluma-view.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) 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 -- cgit v1.2.1