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 )
master-1.22
noone3 2016-08-15 17:16:51 +02:00 committed by monsta
parent f30b1cd380
commit 8d2eb08981
1 changed files with 52 additions and 1 deletions

View File

@ -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)
{