[gnome-shell] [StTable] fix x-align/y-align properties to be StAlign, not double



commit f52744cfbc8f83133f100dbd38907c078dd0f161
Author: Dan Winship <danw gnome org>
Date:   Mon Feb 15 12:08:45 2010 -0500

    [StTable] fix x-align/y-align properties to be StAlign, not double
    
    This puts it in sync with StBin and StBoxLayout
    
    https://bugzilla.gnome.org/show_bug.cgi?id=609848

 js/ui/calendar.js          |    4 +-
 js/ui/messageTray.js       |    2 +-
 src/st/st-table-child.c    |   80 ++++++++++++-------------------------------
 src/st/st-table-child.h    |    4 +-
 src/st/st-table.c          |    4 +-
 tests/interactive/table.js |    4 +-
 6 files changed, 32 insertions(+), 66 deletions(-)
---
diff --git a/js/ui/calendar.js b/js/ui/calendar.js
index 81673c7..68ec6a9 100644
--- a/js/ui/calendar.js
+++ b/js/ui/calendar.js
@@ -89,7 +89,7 @@ Calendar.prototype = {
             this.actor.add(new St.Label({ text: iter.toLocaleFormat("%a") }),
                            { row: 1,
                              col: (7 + iter.getDay() - this._weekStart) % 7,
-                             x_fill: false, x_align: 1.0 });
+                             x_fill: false, x_align: St.Align.END });
             iter.setTime(iter.getTime() + MSECS_IN_DAY);
         }
 
@@ -168,7 +168,7 @@ Calendar.prototype = {
                 label.style_class = "calendar-day";
             this.actor.add(label,
                            { row: row, col: (7 + iter.getDay() - this._weekStart) % 7,
-                             x_fill: false, x_align: 1.0 });
+                             x_fill: false, x_align: St.Align.END });
 
             iter.setTime(iter.getTime() + MSECS_IN_DAY);
             if (iter.getDay() == this._weekStart) {
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 94319ce..bab2089 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -220,7 +220,7 @@ Notification.prototype = {
             let box = new St.BoxLayout({ name: 'notification-actions' });
             this.addActor(box, { x_expand: false,
                                  x_fill: false,
-                                 x_align: 1.0 });
+                                 x_align: St.Align.END });
             this._actionBox = box;
         }
 
diff --git a/src/st/st-table-child.c b/src/st/st-table-child.c
index eafa83d..abfe55b 100644
--- a/src/st/st-table-child.c
+++ b/src/st/st-table-child.c
@@ -25,6 +25,7 @@
 #include "st-private.h"
 #include "st-table-child.h"
 #include "st-table-private.h"
+#include "st-enum-types.h"
 #include <st/st-widget.h>
 #include <st/st-table.h>
 
@@ -96,11 +97,11 @@ table_child_set_property (GObject      *gobject,
       clutter_actor_queue_relayout (CLUTTER_ACTOR (table));
       break;
     case CHILD_PROP_X_ALIGN:
-      child->x_align = g_value_get_double (value);
+      child->x_align = g_value_get_enum (value);
       clutter_actor_queue_relayout (CLUTTER_ACTOR (table));
       break;
     case CHILD_PROP_Y_ALIGN:
-      child->y_align = g_value_get_double (value);
+      child->y_align = g_value_get_enum (value);
       clutter_actor_queue_relayout (CLUTTER_ACTOR (table));
       break;
     case CHILD_PROP_X_FILL:
@@ -151,10 +152,10 @@ table_child_get_property (GObject    *gobject,
       g_value_set_boolean (value, child->y_expand);
       break;
     case CHILD_PROP_X_ALIGN:
-      g_value_set_double (value, child->x_align);
+      g_value_set_enum (value, child->x_align);
       break;
     case CHILD_PROP_Y_ALIGN:
-      g_value_set_double (value, child->y_align);
+      g_value_set_enum (value, child->y_align);
       break;
     case CHILD_PROP_X_FILL:
       g_value_set_boolean (value, child->x_fill);
@@ -237,21 +238,21 @@ st_table_child_class_init (StTableChildClass *klass)
 
   g_object_class_install_property (gobject_class, CHILD_PROP_Y_EXPAND, pspec);
 
-  pspec = g_param_spec_double ("x-align",
-                               "X Alignment",
-                               "X alignment of the widget within the cell",
-                               0, 1,
-                               0.5,
-                               ST_PARAM_READWRITE);
+  pspec = g_param_spec_enum ("x-align",
+                             "X Alignment",
+                             "X alignment of the widget within the cell",
+                             ST_TYPE_ALIGN,
+                             ST_ALIGN_MIDDLE,
+                             ST_PARAM_READWRITE);
 
   g_object_class_install_property (gobject_class, CHILD_PROP_X_ALIGN, pspec);
 
-  pspec = g_param_spec_double ("y-align",
-                               "Y Alignment",
-                               "Y alignment of the widget within the cell",
-                               0, 1,
-                               0.5,
-                               ST_PARAM_READWRITE);
+  pspec = g_param_spec_enum ("y-align",
+                             "Y Alignment",
+                             "Y alignment of the widget within the cell",
+                             ST_TYPE_ALIGN,
+                             ST_ALIGN_MIDDLE,
+                             ST_PARAM_READWRITE);
 
   g_object_class_install_property (gobject_class, CHILD_PROP_Y_ALIGN, pspec);
 
@@ -291,8 +292,8 @@ st_table_child_init (StTableChild *self)
   self->col_span = 1;
   self->row_span = 1;
 
-  self->x_align = 0.5;
-  self->y_align = 0.5;
+  self->x_align = ST_ALIGN_MIDDLE;
+  self->y_align = ST_ALIGN_MIDDLE;
 
   self->x_expand = TRUE;
   self->y_expand = TRUE;
@@ -637,12 +638,7 @@ st_table_child_get_x_align (StTable      *table,
 
   meta = get_child_meta (table, child);
 
-  if (meta->x_align == 0.0)
-    return ST_ALIGN_START;
-  else if (meta->x_align == 1.0)
-    return ST_ALIGN_END;
-  else
-    return ST_ALIGN_MIDDLE;
+  return meta->x_align;
 
 }
 
@@ -668,19 +664,7 @@ st_table_child_set_x_align (StTable      *table,
 
   meta = get_child_meta (table, child);
 
-  switch (align)
-    {
-    case ST_ALIGN_START:
-      meta->x_align = 0.0;
-      break;
-    case ST_ALIGN_MIDDLE:
-      meta->x_align = 0.5;
-      break;
-    case ST_ALIGN_END:
-      meta->x_align = 1.0;
-      break;
-    }
-
+  meta->x_align = align;
   clutter_actor_queue_relayout (child);
 }
 
@@ -704,13 +688,7 @@ st_table_child_get_y_align (StTable      *table,
 
   meta = get_child_meta (table, child);
 
-  if (meta->y_align == 0.0)
-    return ST_ALIGN_START;
-  else if (meta->y_align == 1.0)
-    return ST_ALIGN_END;
-  else
-    return ST_ALIGN_MIDDLE;
-
+  return meta->y_align;
 }
 
 /**
@@ -735,19 +713,7 @@ st_table_child_set_y_align (StTable      *table,
 
   meta = get_child_meta (table, child);
 
-  switch (align)
-    {
-    case ST_ALIGN_START:
-      meta->y_align = 0.0;
-      break;
-    case ST_ALIGN_MIDDLE:
-      meta->y_align = 0.5;
-      break;
-    case ST_ALIGN_END:
-      meta->y_align = 1.0;
-      break;
-    }
-
+  meta->y_align = align;
   clutter_actor_queue_relayout (child);
 }
 
diff --git a/src/st/st-table-child.h b/src/st/st-table-child.h
index cc3cafc..14df7ec 100644
--- a/src/st/st-table-child.h
+++ b/src/st/st-table-child.h
@@ -61,8 +61,8 @@ struct _StTableChild
   gint row;
   gint col_span;
   gint row_span;
-  gdouble x_align;
-  gdouble y_align;
+  StAlign x_align;
+  StAlign y_align;
   guint allocate_hidden : 1;
   guint x_expand : 1;
   guint y_expand : 1;
diff --git a/src/st/st-table.c b/src/st/st-table.c
index 42723a3..a2c16a4 100644
--- a/src/st/st-table.c
+++ b/src/st/st-table.c
@@ -419,7 +419,7 @@ st_table_homogeneous_allocate (ClutterActor          *self,
       StTableChild *meta;
       ClutterActor *child;
       ClutterActorBox childbox;
-      gdouble x_align, y_align;
+      StAlign x_align, y_align;
       gboolean x_fill, y_fill;
 
       child = CLUTTER_ACTOR (list->data);
@@ -779,7 +779,7 @@ st_table_preferred_allocate (ClutterActor          *self,
       ClutterActor *child;
       ClutterActorBox childbox;
       gint child_x, child_y;
-      gdouble x_align, y_align;
+      StAlign x_align, y_align;
       gboolean x_fill, y_fill;
 
       child = CLUTTER_ACTOR (list->data);
diff --git a/tests/interactive/table.js b/tests/interactive/table.js
index 32c7241..308ae91 100644
--- a/tests/interactive/table.js
+++ b/tests/interactive/table.js
@@ -47,8 +47,8 @@ table.add(L("5", "#ff00ff"),
           { row: 2, col: 1, x_expand: 0 });
 table.add(L("6", "#00ffff"),
           { row: 2, col: 2,
-            x_expand: 0, x_fill: 0, x_align: 1.0,
-            y_expand: 0, y_fill: 0, y_align: 1.0 });
+            x_expand: 0, x_fill: 0, x_align: St.Align.END,
+            y_expand: 0, y_fill: 0, y_align: St.Align.END });
 
 ////////////////////////////////////////////////////////////////////////////////
 



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