diff options
Diffstat (limited to 'capplet/gsm-properties-dialog.c')
-rw-r--r-- | capplet/gsm-properties-dialog.c | 105 |
1 files changed, 59 insertions, 46 deletions
diff --git a/capplet/gsm-properties-dialog.c b/capplet/gsm-properties-dialog.c index 7c5df0e..592b130 100644 --- a/capplet/gsm-properties-dialog.c +++ b/capplet/gsm-properties-dialog.c @@ -79,8 +79,6 @@ enum { }; static void gsm_properties_dialog_finalize (GObject *object); -static gboolean gsm_properties_dialog_page_scroll_event_cb (GtkWidget *notebook, - GdkEventScroll *event); G_DEFINE_TYPE (GsmPropertiesDialog, gsm_properties_dialog, GTK_TYPE_DIALOG) @@ -501,6 +499,64 @@ on_save_session_clicked (GtkWidget *widget, g_debug ("Session saving is not implemented yet!"); } +static gboolean +on_main_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 void setup_dialog (GsmPropertiesDialog *dialog) { @@ -786,7 +842,7 @@ gsm_properties_dialog_init (GsmPropertiesDialog *dialog) gtk_widget_add_events (widget, GDK_SCROLL_MASK); g_signal_connect (widget, "scroll-event", - G_CALLBACK (gsm_properties_dialog_page_scroll_event_cb), + G_CALLBACK (on_main_notebook_scroll_event), NULL); gtk_box_pack_start (GTK_BOX (content_area), widget, TRUE, TRUE, 0); @@ -817,46 +873,3 @@ gsm_properties_dialog_new (void) return GTK_WIDGET (object); } - -static gboolean -gsm_properties_dialog_page_scroll_event_cb (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: - break; - } - - return TRUE; -} |