Skip to content

Commit

Permalink
gdict-pref-dialog: Simplify notebook scroll event
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuj authored and raveit65 committed Jul 6, 2020
1 parent 0028746 commit f455902
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions mate-dictionary/src/gdict-pref-dialog.c
Expand Up @@ -579,7 +579,8 @@ gdict_pref_dialog_get_property (GObject *object,
}

static gboolean
gdict_dialog_page_scroll_event_cb (GtkWidget *widget, GdkEventScroll *event, GtkWindow *window)
on_preferences_notebook_scroll_event (GtkWidget *widget,
GdkEventScroll *event)
{
GtkNotebook *notebook = GTK_NOTEBOOK (widget);
GtkWidget *child, *event_widget, *action_widget;
Expand All @@ -601,39 +602,40 @@ gdict_dialog_page_scroll_event_cb (GtkWidget *widget, GdkEventScroll *event, Gtk
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);
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 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);
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;
}
break;
}

return TRUE;
}
Expand Down Expand Up @@ -697,8 +699,10 @@ gdict_pref_dialog_init (GdictPrefDialog *dialog)
dialog->notebook = GET_WIDGET ("preferences_notebook");

gtk_widget_add_events (dialog->notebook, GDK_SCROLL_MASK);
g_signal_connect (dialog->notebook, "scroll-event",
G_CALLBACK (gdict_dialog_page_scroll_event_cb), GTK_WINDOW (dialog));
g_signal_connect (dialog->notebook,
"scroll-event",
G_CALLBACK (on_preferences_notebook_scroll_event),
NULL);

dialog->sources_view = GET_WIDGET ("sources_treeview");
build_sources_view (dialog);
Expand Down

0 comments on commit f455902

Please sign in to comment.