summaryrefslogtreecommitdiff
path: root/mate-volume-control
diff options
context:
space:
mode:
authorLaurent Napias <[email protected]>2019-06-18 18:52:09 +0200
committerZenWalker <[email protected]>2019-06-21 15:10:49 +0200
commit5c1f718e74110bf08901bd76bc4106d0f044289f (patch)
tree5c78367e2b691562b7ae3cc0451374e3f18ade7a /mate-volume-control
parentfb5dd1edb999d54ca234794ec28d9e62308b15e0 (diff)
downloadmate-media-5c1f718e74110bf08901bd76bc4106d0f044289f.tar.bz2
mate-media-5c1f718e74110bf08901bd76bc4106d0f044289f.tar.xz
Add scroll interface tabs with mouse wheel
Diffstat (limited to 'mate-volume-control')
-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 e191bfc..f100e5a 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 *
@@ -1924,6 +1928,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);
@@ -2366,3 +2377,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;
+}