From 6c7e40c3ba072da5e5809f84b0c3759fb751c032 Mon Sep 17 00:00:00 2001 From: JosephMcc Date: Tue, 12 Dec 2017 18:42:51 -0800 Subject: [PATCH] xed-notebook: Allow changing tabs with mouse back/forward buttons While at it, fix the direction for switching tabs when scrolling with the mouse wheel. Closes https://github.com/linuxmint/xed/issues/115 --- xed/xed-notebook.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/xed/xed-notebook.c b/xed/xed-notebook.c index 6e13d4b..8dceee0 100644 --- a/xed/xed-notebook.c +++ b/xed/xed-notebook.c @@ -543,6 +543,8 @@ button_release_cb (XedNotebook *notebook, GdkEventButton *event, gpointer data) { + gboolean ret_val = FALSE; + if (notebook->priv->drag_in_progress) { gint cur_page_num; @@ -566,11 +568,23 @@ button_release_cb (XedNotebook *notebook, } gtk_grab_remove (GTK_WIDGET (notebook)); } + else if ((event->type == GDK_BUTTON_RELEASE) && (event->button == 8)) + { + gtk_notebook_prev_page (GTK_NOTEBOOK (notebook)); + + ret_val = TRUE; + } + else if ((event->type == GDK_BUTTON_RELEASE) && (event->button == 9)) + { + gtk_notebook_next_page (GTK_NOTEBOOK (notebook)); + + ret_val = TRUE; + } /* This must be called even if a drag isn't happening */ drag_stop (notebook); - return FALSE; + return ret_val; } static gboolean @@ -638,13 +652,13 @@ notebook_scroll_event_cb (XedNotebook *notebook, switch (event->direction) { case GDK_SCROLL_DOWN: - case GDK_SCROLL_RIGHT: - gtk_notebook_next_page (GTK_NOTEBOOK (notebook)); - break; - case GDK_SCROLL_UP: case GDK_SCROLL_LEFT: gtk_notebook_prev_page (GTK_NOTEBOOK (notebook)); break; + case GDK_SCROLL_UP: + case GDK_SCROLL_RIGHT: + gtk_notebook_next_page (GTK_NOTEBOOK (notebook)); + break; default: break; }