[gnome-shell/nbtk-introduction] Don't use the default stage when setting up adjustments



commit faeda5dc8bd14a64c14fab727ae6a46a3a8121ea
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Mon Sep 21 17:20:34 2009 -0400

    Don't use the default stage when setting up adjustments
    
    If the actor isn't in a stage, then setting up the adjustment
    based on the actor's size (which we can't compute) and the
    size of the default stage (which isn't relevant), doesn't make
    sense. Just use arbitrary default values.
    
    The adjustments will be updated to reasonable values when first
    the box is first allocated.
    
    It's not entirely clear to me why we ever want to compute the
    adjustment settings this way; perhaps we should always use
    default values.
    
    http://bugzilla.moblin.org/show_bug.cgi?id=6307

 src/nbtk/nbtk-box-layout.c |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)
---
diff --git a/src/nbtk/nbtk-box-layout.c b/src/nbtk/nbtk-box-layout.c
index 8f9f246..5957e35 100644
--- a/src/nbtk/nbtk-box-layout.c
+++ b/src/nbtk/nbtk-box-layout.c
@@ -138,8 +138,6 @@ scrollable_get_adjustments (NbtkScrollable *scrollable,
 
   actor = CLUTTER_ACTOR (scrollable);
   stage = clutter_actor_get_stage (actor);
-  if (G_UNLIKELY (stage == NULL))
-    stage = clutter_stage_get_default ();
 
   if (hadjustment)
     {
@@ -150,9 +148,16 @@ scrollable_get_adjustments (NbtkScrollable *scrollable,
           NbtkAdjustment *adjustment;
           gdouble width, stage_width, increment;
 
-          width = clutter_actor_get_width (actor);
-          stage_width = clutter_actor_get_width (stage);
-          increment = MAX (1.0, MIN (stage_width, width));
+          if (stage)
+            {
+              width = clutter_actor_get_width (actor);
+              stage_width = clutter_actor_get_width (stage);
+              increment = MAX (1.0, MIN (stage_width, width));
+            }
+          else
+            {
+              width = increment = 1.0;
+            }
 
           adjustment = nbtk_adjustment_new (0,
                                             0,
@@ -178,9 +183,16 @@ scrollable_get_adjustments (NbtkScrollable *scrollable,
           NbtkAdjustment *adjustment;
           gdouble height, stage_height, increment;
 
-          height = clutter_actor_get_height (actor);
-          stage_height = clutter_actor_get_height (stage);
-          increment = MAX (1.0, MIN (stage_height, height));
+          if (stage)
+            {
+              height = clutter_actor_get_height (actor);
+              stage_height = clutter_actor_get_height (stage);
+              increment = MAX (1.0, MIN (stage_height, height));
+            }
+          else
+            {
+              height = increment = 1.0;
+            }
 
           adjustment = nbtk_adjustment_new (0,
                                             0,



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