summaryrefslogtreecommitdiff
path: root/mate-volume-control/gvc-mixer-dialog.c
diff options
context:
space:
mode:
Diffstat (limited to 'mate-volume-control/gvc-mixer-dialog.c')
-rw-r--r--mate-volume-control/gvc-mixer-dialog.c130
1 files changed, 60 insertions, 70 deletions
diff --git a/mate-volume-control/gvc-mixer-dialog.c b/mate-volume-control/gvc-mixer-dialog.c
index c3f3996..2138f2c 100644
--- a/mate-volume-control/gvc-mixer-dialog.c
+++ b/mate-volume-control/gvc-mixer-dialog.c
@@ -127,10 +127,6 @@ 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_WITH_PRIVATE (GvcMixerDialog, gvc_mixer_dialog, GTK_TYPE_DIALOG)
static MateMixerSwitch *
@@ -1873,6 +1869,64 @@ create_page_effects (GvcMixerDialog *self)
TRUE, TRUE, 6);
}
+static gboolean
+on_notebook_scroll_event (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:
+ 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;
+}
+
static GObject *
gvc_mixer_dialog_constructor (GType type,
guint n_construct_properties,
@@ -1928,8 +1982,8 @@ gvc_mixer_dialog_constructor (GType type,
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);
+ G_CALLBACK (on_notebook_scroll_event),
+ NULL);
gtk_box_pack_start (GTK_BOX (main_vbox),
self->priv->notebook,
@@ -2371,67 +2425,3 @@ 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;
-}