summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornoone3 <[email protected]>2016-08-15 17:16:51 +0200
committermonsta <[email protected]>2016-09-14 14:14:52 +0300
commit8d2eb0898154f2624e2ae34039169f307a3411a5 (patch)
tree8d9d195da6f8947e66a99764405e91123693700f
parentf30b1cd380be638948a1b82c59639b6b39a3587d (diff)
downloadmate-terminal-8d2eb0898154f2624e2ae34039169f307a3411a5.tar.bz2
mate-terminal-8d2eb0898154f2624e2ae34039169f307a3411a5.tar.xz
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 )
-rw-r--r--src/terminal-window.c53
1 files changed, 52 insertions, 1 deletions
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)
{