summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Napias <[email protected]>2019-06-18 18:52:09 +0200
committermonsta <[email protected]box.ru>2019-08-12 14:13:50 +0300
commita9dff714226274dd98a23505a59afb479ca9ef1c (patch)
treeb0d212a45af82f33432da33dfcc3db6d3d346938
parentdb1ef0a5885ea4464f110abaf06efb1a75f15151 (diff)
downloadmate-media-1.20.tar.bz2
mate-media-1.20.tar.xz
Add scroll interface tabs with mouse wheel1.20
-rw-r--r--mate-volume-control/gvc-mixer-dialog.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/mate-volume-control/gvc-mixer-dialog.c b/mate-volume-control/gvc-mixer-dialog.c
index b36232c..f6cda1e 100644
--- a/mate-volume-control/gvc-mixer-dialog.c
+++ b/mate-volume-control/gvc-mixer-dialog.c
@@ -131,6 +131,10 @@ static void bar_set_stream_control (GvcMixerDialog *dialog,
GtkWidget *bar,
MateMixerStreamControl *control);
+static gboolean dialog_page_scroll_event_cb (GtkWidget *widget,
+ GdkEventScroll *event,
+ GtkWindow *window);
+
G_DEFINE_TYPE (GvcMixerDialog, gvc_mixer_dialog, GTK_TYPE_DIALOG)
static MateMixerSwitch *
@@ -1919,6 +1923,13 @@ gvc_mixer_dialog_constructor (GType type,
self->priv->output_bar, TRUE, TRUE, 12);
self->priv->notebook = gtk_notebook_new ();
+
+ gtk_widget_add_events (self->priv->notebook, GDK_SCROLL_MASK);
+ g_signal_connect (self->priv->notebook,
+ "scroll-event",
+ G_CALLBACK (dialog_page_scroll_event_cb),
+ self);
+
gtk_box_pack_start (GTK_BOX (main_vbox),
self->priv->notebook,
TRUE, TRUE, 0);
@@ -2361,3 +2372,67 @@ gvc_mixer_dialog_set_page (GvcMixerDialog *self, const gchar *page)
return TRUE;
}
+
+static gboolean
+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;
+}