summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortamplan <[email protected]>2020-06-28 12:10:46 +0200
committerGitHub <[email protected]>2020-06-28 12:10:46 +0200
commit5d594e559d532b0ddc7b6fd9f92bdd34f67fe9af (patch)
tree07c6ee86895572a8209df88fe6235783e194de0d
parent6434ac44d98c97e04f32defd61cab55e2ba92e77 (diff)
downloadmate-terminal-5d594e559d532b0ddc7b6fd9f92bdd34f67fe9af.tar.bz2
mate-terminal-5d594e559d532b0ddc7b6fd9f92bdd34f67fe9af.tar.xz
Add tab scrolling support for GTK3
-rw-r--r--src/profile-editor.c51
-rw-r--r--src/profile-editor.h3
2 files changed, 54 insertions, 0 deletions
diff --git a/src/profile-editor.c b/src/profile-editor.c
index 97de02e..27cc61b 100644
--- a/src/profile-editor.c
+++ b/src/profile-editor.c
@@ -849,7 +849,58 @@ terminal_profile_edit (TerminalProfile *profile,
terminal_profile_editor_focus_widget (editor, widget_name);
+ w = GTK_WIDGET (gtk_builder_get_object (builder, "profile-editor-notebook"));
+ gtk_widget_add_events (w, GDK_SCROLL_MASK);
+ g_signal_connect (w,
+ "scroll-event",
+ G_CALLBACK (terminal_profile_edit_dialog_page_scroll_event_cb),
+ NULL);
+
gtk_window_set_transient_for (GTK_WINDOW (editor),
GTK_WINDOW (transient_parent));
gtk_window_present (GTK_WINDOW (editor));
}
+
+static gboolean
+terminal_profile_edit_dialog_page_scroll_event_cb (GtkWidget *widget,
+ GdkEventScroll *event)
+
+{
+ 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;
+ case GDK_SCROLL_SMOOTH:
+ break;
+ }
+
+ return TRUE;
+}
diff --git a/src/profile-editor.h b/src/profile-editor.h
index 8fd6e7f..caf9503 100644
--- a/src/profile-editor.h
+++ b/src/profile-editor.h
@@ -29,6 +29,9 @@ void terminal_profile_edit (TerminalProfile *profile,
GtkWindow *transient_parent,
const char *widget_name);
+static gboolean terminal_profile_edit_dialog_page_scroll_event_cb (GtkWidget *notebook,
+ GdkEventScroll *event);
+
G_END_DECLS
#endif /* TERMINAL_PROFILE_EDITOR_H */