[gimp/gtk3-port: 411/440] app: use gimp_scroll_adjustment_values() in GimpNavigationEditor
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 411/440] app: use gimp_scroll_adjustment_values() in GimpNavigationEditor
- Date: Sun, 13 May 2018 12:53:07 +0000 (UTC)
commit e44656b45f35f83fe26b3971247785ff91924417
Author: Michael Natterer <mitch gimp org>
Date: Thu May 10 23:53:16 2018 +0200
app: use gimp_scroll_adjustment_values() in GimpNavigationEditor
and change signature of GimpNavigationView::scroll() to have
a GdkEventScroll instead of a GdkScrollDirection.
app/display/gimpnavigationeditor.c | 53 ++++++++---------------------------
app/widgets/gimpnavigationview.c | 17 ++---------
app/widgets/gimpnavigationview.h | 2 +-
3 files changed, 16 insertions(+), 56 deletions(-)
---
diff --git a/app/display/gimpnavigationeditor.c b/app/display/gimpnavigationeditor.c
index 7834e26..31e8b7d 100644
--- a/app/display/gimpnavigationeditor.c
+++ b/app/display/gimpnavigationeditor.c
@@ -82,7 +82,7 @@ static void gimp_navigation_editor_zoom (GimpNavigationView
GimpZoomType direction,
GimpNavigationEditor *editor);
static void gimp_navigation_editor_scroll (GimpNavigationView *view,
- GdkScrollDirection direction,
+ GdkEventScroll *sevent,
GimpNavigationEditor *editor);
static void gimp_navigation_editor_zoom_adj_changed (GtkAdjustment *adj,
@@ -569,50 +569,21 @@ gimp_navigation_editor_zoom (GimpNavigationView *view,
static void
gimp_navigation_editor_scroll (GimpNavigationView *view,
- GdkScrollDirection direction,
+ GdkEventScroll *sevent,
GimpNavigationEditor *editor)
{
if (editor->shell)
{
- GtkAdjustment *adj = NULL;
- gdouble value;
-
- switch (direction)
- {
- case GDK_SCROLL_LEFT:
- case GDK_SCROLL_RIGHT:
- adj = editor->shell->hsbdata;
- break;
-
- case GDK_SCROLL_UP:
- case GDK_SCROLL_DOWN:
- adj = editor->shell->vsbdata;
- break;
- }
-
- gimp_assert (adj != NULL);
-
- value = gtk_adjustment_get_value (adj);
-
- switch (direction)
- {
- case GDK_SCROLL_LEFT:
- case GDK_SCROLL_UP:
- value -= gtk_adjustment_get_page_increment (adj) / 2;
- break;
-
- case GDK_SCROLL_RIGHT:
- case GDK_SCROLL_DOWN:
- value += gtk_adjustment_get_page_increment (adj) / 2;
- break;
- }
-
- value = CLAMP (value,
- gtk_adjustment_get_lower (adj),
- gtk_adjustment_get_upper (adj) -
- gtk_adjustment_get_page_size (adj));
-
- gtk_adjustment_set_value (adj, value);
+ gdouble value_x;
+ gdouble value_y;
+
+ gimp_scroll_adjustment_values (sevent,
+ editor->shell->hsbdata,
+ editor->shell->vsbdata,
+ &value_x, &value_y);
+
+ gtk_adjustment_set_value (editor->shell->hsbdata, value_x);
+ gtk_adjustment_set_value (editor->shell->vsbdata, value_y);
}
}
diff --git a/app/widgets/gimpnavigationview.c b/app/widgets/gimpnavigationview.c
index 5033250..627f647 100644
--- a/app/widgets/gimpnavigationview.c
+++ b/app/widgets/gimpnavigationview.c
@@ -148,9 +148,9 @@ gimp_navigation_view_class_init (GimpNavigationViewClass *klass)
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpNavigationViewClass, scroll),
NULL, NULL,
- gimp_marshal_VOID__ENUM,
+ gimp_marshal_VOID__BOXED,
G_TYPE_NONE, 1,
- GDK_TYPE_SCROLL_DIRECTION);
+ GDK_TYPE_EVENT);
widget_class->size_allocate = gimp_navigation_view_size_allocate;
widget_class->draw = gimp_navigation_view_draw;
@@ -313,18 +313,7 @@ gimp_navigation_view_scroll (GtkWidget *widget,
}
else
{
- GdkScrollDirection direction = sevent->direction;
-
- if (sevent->state & GDK_SHIFT_MASK)
- switch (direction)
- {
- case GDK_SCROLL_UP: direction = GDK_SCROLL_LEFT; break;
- case GDK_SCROLL_DOWN: direction = GDK_SCROLL_RIGHT; break;
- case GDK_SCROLL_LEFT: direction = GDK_SCROLL_UP; break;
- case GDK_SCROLL_RIGHT: direction = GDK_SCROLL_DOWN; break;
- }
-
- g_signal_emit (widget, view_signals[SCROLL], 0, direction);
+ g_signal_emit (widget, view_signals[SCROLL], 0, sevent);
}
return TRUE;
diff --git a/app/widgets/gimpnavigationview.h b/app/widgets/gimpnavigationview.h
index 1a6dfc0..22d7113 100644
--- a/app/widgets/gimpnavigationview.h
+++ b/app/widgets/gimpnavigationview.h
@@ -49,7 +49,7 @@ struct _GimpNavigationViewClass
void (* zoom) (GimpNavigationView *view,
GimpZoomType direction);
void (* scroll) (GimpNavigationView *view,
- GdkScrollDirection direction);
+ GdkEventScroll *sevent);
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]