[california/wip/725767-week] Fix transition and initialization problems



commit 3234287abae077376a10428b762ef3c64585fe0f
Author: Jim Nelson <jim yorba org>
Date:   Fri May 2 18:32:21 2014 -0700

    Fix transition and initialization problems

 src/host/host-main-window.vala       |   11 ++++-------
 src/toolkit/toolkit-stack-model.vala |   10 +++++++++-
 2 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/src/host/host-main-window.vala b/src/host/host-main-window.vala
index f5ffa29..fc7e1c1 100644
--- a/src/host/host-main-window.vala
+++ b/src/host/host-main-window.vala
@@ -65,15 +65,12 @@ public class MainWindow : Gtk.ApplicationWindow {
         view_stack.transition_duration = 300;
         view_stack.transition_type = Gtk.StackTransitionType.SLIDE_UP_DOWN;
         
-        // add views to view stack
-        add_controller(month_view);
-        add_controller(week_view);
-        
-        // subscribe after adding so next set_visible_child_name() is first initialization
+        // subscribe before adding so first add to initialize UI
         view_stack.notify["visible-child"].connect(on_view_changed);
         
-        // start in Month view
-        view_stack.set_visible_child_name(month_view.title);
+        // add views to view stack, first added is first shown
+        add_controller(month_view);
+        add_controller(week_view);
         
         // if not on Unity, use headerbar as the titlebar (removes window chrome) and provide close
         // button for users who might have trouble finding it otherwise
diff --git a/src/toolkit/toolkit-stack-model.vala b/src/toolkit/toolkit-stack-model.vala
index e3ab17a..c63f615 100644
--- a/src/toolkit/toolkit-stack-model.vala
+++ b/src/toolkit/toolkit-stack-model.vala
@@ -244,7 +244,15 @@ public class StackModel<G> : BaseObject {
             if (iter.get_value() == stack.visible_child) {
                 visible_item = iter.get_key();
                 
-                balance_cache("on_stack_child_visible");
+                // to avoid stutter, only balance the cache when the transition has completed,
+                // which (apparently) it has not when this change is made (probably made at start
+                // of transition, not the end) ... "transition-running" property would be useful
+                // here, but that's not available until GTK 3.12
+                Idle.add(() => {
+                    balance_cache("on_stack_child_visible");
+                    
+                    return false;
+                }, Priority.LOW);
                 
                 return;
             }


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