summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortamplan <[email protected]>2020-05-18 18:59:12 +0200
committerRobert Antoni Buj Gelonch <[email protected]>2020-05-26 17:26:51 +0200
commit454dccb8138d611da9798bde106363fa9cf83e01 (patch)
tree396e54db6d8f74d6c12274a2dc6f23639e53b477
parent4a62ca15be595c521f3313c20dd9d4c415970d6e (diff)
downloadmate-session-manager-454dccb8138d611da9798bde106363fa9cf83e01.tar.bz2
mate-session-manager-454dccb8138d611da9798bde106363fa9cf83e01.tar.xz
Add tab scrolling support for GTK3
-rw-r--r--capplet/gsm-properties-dialog.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/capplet/gsm-properties-dialog.c b/capplet/gsm-properties-dialog.c
index 69fe3fe..7c5df0e 100644
--- a/capplet/gsm-properties-dialog.c
+++ b/capplet/gsm-properties-dialog.c
@@ -79,6 +79,8 @@ enum {
};
static void gsm_properties_dialog_finalize (GObject *object);
+static gboolean gsm_properties_dialog_page_scroll_event_cb (GtkWidget *notebook,
+ GdkEventScroll *event);
G_DEFINE_TYPE (GsmPropertiesDialog, gsm_properties_dialog, GTK_TYPE_DIALOG)
@@ -780,6 +782,13 @@ gsm_properties_dialog_init (GsmPropertiesDialog *dialog)
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
widget = GTK_WIDGET (gtk_builder_get_object (dialog->xml,
"main-notebook"));
+
+ gtk_widget_add_events (widget, GDK_SCROLL_MASK);
+ g_signal_connect (widget,
+ "scroll-event",
+ G_CALLBACK (gsm_properties_dialog_page_scroll_event_cb),
+ NULL);
+
gtk_box_pack_start (GTK_BOX (content_area), widget, TRUE, TRUE, 0);
gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
@@ -808,3 +817,46 @@ gsm_properties_dialog_new (void)
return GTK_WIDGET (object);
}
+
+static gboolean
+gsm_properties_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;
+}