summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-06-29 18:32:11 +0200
committerraveit65 <[email protected]>2020-07-02 17:31:57 +0200
commit8918231e7974209d058278e14ece22ce69184c1d (patch)
tree0534415e8327a8f26bbf4b5239e9754b3c3f7a86
parent305119909b6f859ab3ff832fec5559a129c98db2 (diff)
downloadpluma-8918231e7974209d058278e14ece22ce69184c1d.tar.bz2
pluma-8918231e7974209d058278e14ece22ce69184c1d.tar.xz
pluma-preferences-dialog: Refactor on_notebook_scroll_event
-rw-r--r--pluma/dialogs/pluma-preferences-dialog.c108
1 files changed, 60 insertions, 48 deletions
diff --git a/pluma/dialogs/pluma-preferences-dialog.c b/pluma/dialogs/pluma-preferences-dialog.c
index 7d4da4aa..336ccb7d 100644
--- a/pluma/dialogs/pluma-preferences-dialog.c
+++ b/pluma/dialogs/pluma-preferences-dialog.c
@@ -141,9 +141,6 @@ struct _PlumaPreferencesDialogPrivate
G_DEFINE_TYPE_WITH_PRIVATE (PlumaPreferencesDialog, pluma_preferences_dialog, GTK_TYPE_DIALOG)
-static gboolean pluma_preferences_dialog_page_scroll_event_cb (GtkWidget *notebook,
- GdkEventScroll *event);
-
static void
pluma_preferences_dialog_class_init (PlumaPreferencesDialogClass *klass)
{
@@ -1271,6 +1268,65 @@ setup_plugins_page (PlumaPreferencesDialog *dlg)
gtk_widget_show_all (page_content);
}
+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 void
pluma_preferences_dialog_init (PlumaPreferencesDialog *dlg)
{
@@ -1372,7 +1428,7 @@ pluma_preferences_dialog_init (PlumaPreferencesDialog *dlg)
gtk_widget_add_events (dlg->priv->notebook, GDK_SCROLL_MASK);
g_signal_connect (dlg->priv->notebook,
"scroll-event",
- G_CALLBACK (pluma_preferences_dialog_page_scroll_event_cb),
+ G_CALLBACK (on_notebook_scroll_event),
NULL);
setup_editor_page (dlg);
@@ -1405,47 +1461,3 @@ pluma_show_preferences_dialog (PlumaWindow *parent)
gtk_window_present (GTK_WINDOW (preferences_dialog));
}
-
-static gboolean
-pluma_preferences_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;
-}