From 8d2eb0898154f2624e2ae34039169f307a3411a5 Mon Sep 17 00:00:00 2001 From: noone3 Date: Mon, 15 Aug 2016 17:16:51 +0200 Subject: add (mouse wheel) tab scrolling Mouse wheel scrolling was removed in gtk3. Add functionality back via patch to mate-terminal, patch was originally against gnome-terminal (from https://git.gnome.org/browse/gnome-terminal/commit/?id=e2299ee2451167ad41b35705b4fbd577aebd0c39 ) --- src/terminal-window.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/src/terminal-window.c b/src/terminal-window.c index e7b53a2..132b98b 100644 --- a/src/terminal-window.c +++ b/src/terminal-window.c @@ -157,6 +157,9 @@ static void notebook_page_removed_callback (GtkWidget *notebook, GtkWidget *container, guint page_num, TerminalWindow *window); +static gboolean notebook_scroll_event_cb (GtkWidget *notebook, + GdkEventScroll *event, + TerminalWindow *window); /* Menu action callbacks */ static void file_new_window_callback (GtkAction *action, @@ -2022,7 +2025,11 @@ terminal_window_init (TerminalWindow *window) g_signal_connect_data (priv->notebook, "page-reordered", G_CALLBACK (terminal_window_update_tabs_menu_sensitivity), window, NULL, G_CONNECT_SWAPPED | G_CONNECT_AFTER); - + + gtk_widget_add_events (priv->notebook, GDK_SCROLL_MASK); + g_signal_connect (priv->notebook, "scroll-event", + G_CALLBACK (notebook_scroll_event_cb), window); + g_signal_connect (priv->notebook, "create-window", G_CALLBACK (handle_tab_droped_on_desktop), window); @@ -2885,6 +2892,50 @@ terminal_window_update_copy_selection (TerminalScreen *screen, TERMINAL_PROFILE_COPY_SELECTION); } +static gboolean +notebook_scroll_event_cb (GtkWidget *widget, + GdkEventScroll *event, + TerminalWindow *window) +{ + GtkNotebook *notebook = GTK_NOTEBOOK (widget); + GtkWidget *child, *event_widget, *action_widget; + + child = gtk_notebook_get_nth_page (notebook, gtk_notebook_get_current_page (notebook)); + if (child == NULL) + return FALSE; + + event_widget = gtk_get_event_widget ((GdkEvent *) event); + + /* Ignore scroll events from the content of the page */ + if (event_widget == NULL || + event_widget == child || + gtk_widget_is_ancestor (event_widget, child)) + return FALSE; + + /* And also from the action widgets */ + action_widget = gtk_notebook_get_action_widget (notebook, GTK_PACK_START); + if (event_widget == action_widget || + (action_widget != NULL && gtk_widget_is_ancestor (event_widget, action_widget))) + return FALSE; + action_widget = gtk_notebook_get_action_widget (notebook, GTK_PACK_END); + if (event_widget == action_widget || + (action_widget != NULL && gtk_widget_is_ancestor (event_widget, action_widget))) + return FALSE; + + switch (event->direction) { + case GDK_SCROLL_RIGHT: + case GDK_SCROLL_DOWN: + gtk_notebook_next_page (notebook); + break; + case GDK_SCROLL_LEFT: + case GDK_SCROLL_UP: + gtk_notebook_prev_page (notebook); + break; + } + + return TRUE; +} + void terminal_window_update_geometry (TerminalWindow *window) { -- cgit v1.2.1