[gnome-builder/wip/path-bar: 10/11] stack-list: scroll to top when page flipping



commit 3d7d5d047c1aeafd729a51528988f1f452c3f8e5
Author: Christian Hergert <christian hergert me>
Date:   Fri Aug 14 16:16:31 2015 -0700

    stack-list: scroll to top when page flipping

 contrib/egg/egg-stack-list.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/contrib/egg/egg-stack-list.c b/contrib/egg/egg-stack-list.c
index 661efc9..bdc3968 100644
--- a/contrib/egg/egg-stack-list.c
+++ b/contrib/egg/egg-stack-list.c
@@ -147,6 +147,19 @@ egg_stack_list__overlay__get_child_position (EggStackList *self,
 }
 
 static void
+egg_stack_list_scroll_to_top (EggStackList *self)
+{
+  EggStackListPrivate *priv = egg_stack_list_get_instance_private (self);
+  GtkAdjustment *vadj;
+
+  g_assert (EGG_IS_STACK_LIST (self));
+
+  vadj = gtk_scrolled_window_get_vadjustment (priv->scroller);
+
+  gtk_adjustment_set_value (vadj, 0.0);
+}
+
+static void
 egg_stack_list_end_anim (EggStackList *self)
 {
   EggStackListPrivate *priv = egg_stack_list_get_instance_private (self);
@@ -183,6 +196,8 @@ egg_stack_list_end_anim (EggStackList *self)
                            info,
                            NULL);
 
+  egg_stack_list_scroll_to_top (self);
+
   gtk_stack_set_visible_child (GTK_STACK (priv->flip_stack), GTK_WIDGET (priv->scroller));
 
   g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_MODEL]);
@@ -465,6 +480,7 @@ egg_stack_list_push (EggStackList                 *self,
                                egg_stack_list_create_widget_func,
                                info,
                                NULL);
+      egg_stack_list_scroll_to_top (self);
       g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_MODEL]);
       return;
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]