diff options
author | Laurent Napias <[email protected]> | 2019-06-26 22:51:52 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2019-07-02 11:07:04 +0200 |
commit | b931a8f99fc07cf860819507e18546bb9583a2f1 (patch) | |
tree | 3e0dfaa5be7b0e9f63f34bc147df4a688493f3c6 /capplets/common/capplet-util.c | |
parent | 566addef611bfab08379e29a16379e6a12642db7 (diff) | |
download | mate-control-center-b931a8f99fc07cf860819507e18546bb9583a2f1.tar.bz2 mate-control-center-b931a8f99fc07cf860819507e18546bb9583a2f1.tar.xz |
Add scroll tabs with mouse wheel in severals capplets
Diffstat (limited to 'capplets/common/capplet-util.c')
-rw-r--r-- | capplets/common/capplet-util.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/capplets/common/capplet-util.c b/capplets/common/capplet-util.c index d2458d9b..b9fde6bb 100644 --- a/capplets/common/capplet-util.c +++ b/capplets/common/capplet-util.c @@ -170,6 +170,66 @@ capplet_file_delete_recursive (GFile *file, GError **error) return g_file_delete (file, NULL, error); } +gboolean +capplet_dialog_page_scroll_event_cb (GtkWidget *widget, GdkEventScroll *event, GtkWindow *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; + case GDK_SCROLL_SMOOTH: + switch (gtk_notebook_get_tab_pos (notebook)) { + case GTK_POS_LEFT: + case GTK_POS_RIGHT: + if (event->delta_y > 0) + gtk_notebook_next_page (notebook); + else if (event->delta_y < 0) + gtk_notebook_prev_page (notebook); + break; + case GTK_POS_TOP: + case GTK_POS_BOTTOM: + if (event->delta_x > 0) + gtk_notebook_next_page (notebook); + else if (event->delta_x < 0) + gtk_notebook_prev_page (notebook); + break; + } + break; + } + + return TRUE; +} + void capplet_init (GOptionContext *context, int *argc, |