summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-06-29 23:08:57 +0200
committerraveit65 <[email protected]>2020-07-10 11:59:14 +0200
commit8863ed43f2d200bfedbe25fb0dc446897c06ce5c (patch)
tree6c1968474bd65b9d0df045487f37cd407cb7c302 /shell
parent9b8d222850643c1977333b7aa558bd020418680f (diff)
downloadatril-8863ed43f2d200bfedbe25fb0dc446897c06ce5c.tar.bz2
atril-8863ed43f2d200bfedbe25fb0dc446897c06ce5c.tar.xz
ev-properties-dialog: Add on_notebook_scroll_event
Diffstat (limited to 'shell')
-rw-r--r--shell/ev-properties-dialog.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/shell/ev-properties-dialog.c b/shell/ev-properties-dialog.c
index cbb7b0f7..91d08762 100644
--- a/shell/ev-properties-dialog.c
+++ b/shell/ev-properties-dialog.c
@@ -52,6 +52,64 @@ ev_properties_dialog_class_init (EvPropertiesDialogClass *properties_class)
{
}
+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
ev_properties_dialog_init (EvPropertiesDialog *properties)
{
@@ -70,6 +128,12 @@ ev_properties_dialog_init (EvPropertiesDialog *properties)
GTK_RESPONSE_CANCEL);
properties->notebook = gtk_notebook_new ();
+ gtk_widget_add_events (properties->notebook, GDK_SCROLL_MASK);
+ g_signal_connect (properties->notebook,
+ "scroll-event",
+ G_CALLBACK (on_notebook_scroll_event),
+ NULL);
+
gtk_container_set_border_width (GTK_CONTAINER (properties->notebook), 5);
gtk_box_pack_start (content_area, properties->notebook, TRUE, TRUE, 0);
gtk_widget_show (properties->notebook);