summaryrefslogtreecommitdiff
path: root/src/gpm-common.c
diff options
context:
space:
mode:
authorLaurent Napias <[email protected]>2019-06-29 22:28:21 +0200
committerraveit65 <[email protected]>2019-07-10 21:09:34 +0200
commit67b0883a92607d52ece6ab7e8f8869e7f55bab29 (patch)
treebcccbc8319590fa23563c2d2f5156b0c99b03b92 /src/gpm-common.c
parentef6434d21bd88d18d48f01113bc44e1611acc918 (diff)
downloadmate-power-manager-67b0883a92607d52ece6ab7e8f8869e7f55bab29.tar.bz2
mate-power-manager-67b0883a92607d52ece6ab7e8f8869e7f55bab29.tar.xz
Add scroll interface tabs with mouse wheel
in preferences and gpm-statistics (mouse-battery)
Diffstat (limited to 'src/gpm-common.c')
-rw-r--r--src/gpm-common.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/gpm-common.c b/src/gpm-common.c
index 6556d85..754ac9e 100644
--- a/src/gpm-common.c
+++ b/src/gpm-common.c
@@ -158,6 +158,65 @@ gpm_help_display (const gchar *link_id)
g_free (uri);
}
+/**
+ * gpm_dialog_page_scroll_event_cb:
+ **/
+gboolean
+gpm_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;
+}
+
/***************************************************************************
*** MAKE CHECK TESTS ***
***************************************************************************/