diff options
author | Owen W. Taylor <otaylor@fishsoup.net> | 2009-09-29 23:03:41 -0400 |
---|---|---|
committer | Owen W. Taylor <otaylor@fishsoup.net> | 2009-09-29 23:06:18 -0400 |
commit | 1283f0b16069bba7cb732a0723acc8927d311820 (patch) | |
tree | c1224e23fb8efcbfbe8e956b47af98da94e36471 | |
parent | 3bbdc1e1e1cd76ee1343af1b07e9a625bb23ada3 (diff) | |
download | gnome-shell-1283f0b16069bba7cb732a0723acc8927d311820.tar.gz |
Turn StBoxLayout:spacing into a style property
Remove the StBoxLayout:spacing GObject property, and instead make
BoxLayout look up the spacing from the CSS style. This makes it
consistent with padding and will allow the use of units. (The
removal of the GObject property entirely instead of making it an
override is consistent with how we handle color, font, padding, etc.)
https://bugzilla.gnome.org/show_bug.cgi?id=596803
-rw-r--r-- | src/st/st-box-layout.c | 79 | ||||
-rw-r--r-- | src/st/st-box-layout.h | 4 | ||||
-rw-r--r-- | tests/interactive/borders.js | 5 | ||||
-rw-r--r-- | tests/interactive/box-layout.js | 4 | ||||
-rw-r--r-- | tests/interactive/inline-style.js | 2 |
5 files changed, 25 insertions, 69 deletions
diff --git a/src/st/st-box-layout.c b/src/st/st-box-layout.c index b3f347c1f..efac52248 100644 --- a/src/st/st-box-layout.c +++ b/src/st/st-box-layout.c @@ -61,7 +61,6 @@ enum { PROP_VERTICAL, PROP_PACK_START, - PROP_SPACING, PROP_HADJUST, PROP_VADJUST @@ -348,10 +347,6 @@ st_box_layout_get_property (GObject *object, g_value_set_boolean (value, priv->is_pack_start); break; - case PROP_SPACING: - g_value_set_uint (value, priv->spacing); - break; - case PROP_HADJUST: scrollable_get_adjustments (ST_SCROLLABLE (object), &adjustment, NULL); g_value_set_object (value, adjustment); @@ -385,10 +380,6 @@ st_box_layout_set_property (GObject *object, st_box_layout_set_pack_start (box, g_value_get_boolean (value)); break; - case PROP_SPACING: - st_box_layout_set_spacing (box, g_value_get_uint (value)); - break; - case PROP_HADJUST: scrollable_set_adjustments (ST_SCROLLABLE (object), g_value_get_object (value), @@ -1073,10 +1064,27 @@ st_box_layout_pick (ClutterActor *actor, } static void +st_box_layout_style_changed (StWidget *self) +{ + StBoxLayoutPrivate *priv = ST_BOX_LAYOUT (self)->priv; + StThemeNode *theme_node = st_widget_get_theme_node (self); + int old_spacing = priv->spacing; + double spacing = 0; + + st_theme_node_get_length (theme_node, "spacing", FALSE, &spacing); + priv->spacing = (int)(spacing + 0.5); + if (priv->spacing != old_spacing) + clutter_actor_queue_relayout (CLUTTER_ACTOR (self)); + + ST_WIDGET_CLASS (st_box_layout_parent_class)->style_changed (self); +} + +static void st_box_layout_class_init (StBoxLayoutClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); + StWidgetClass *widget_class = ST_WIDGET_CLASS (klass); GParamSpec *pspec; g_type_class_add_private (klass, sizeof (StBoxLayoutPrivate)); @@ -1093,6 +1101,8 @@ st_box_layout_class_init (StBoxLayoutClass *klass) actor_class->paint = st_box_layout_paint; actor_class->pick = st_box_layout_pick; + widget_class->style_changed = st_box_layout_style_changed; + pspec = g_param_spec_boolean ("vertical", "Vertical", "Whether the layout should be vertical, rather" @@ -1108,13 +1118,6 @@ st_box_layout_class_init (StBoxLayoutClass *klass) ST_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_PACK_START, pspec); - pspec = g_param_spec_uint ("spacing", - "Spacing", - "Spacing between children", - 0, G_MAXUINT, 0, - ST_PARAM_READWRITE); - g_object_class_install_property (object_class, PROP_SPACING, pspec); - /* StScrollable properties */ g_object_class_override_property (object_class, PROP_HADJUST, @@ -1222,47 +1225,3 @@ st_box_layout_get_pack_start (StBoxLayout *box) return box->priv->is_pack_start; } - -/** - * st_box_layout_set_spacing: - * @box: A #StBoxLayout - * @spacing: the spacing value - * - * Set the amount of spacing between children in pixels - * - */ -void -st_box_layout_set_spacing (StBoxLayout *box, - guint spacing) -{ - StBoxLayoutPrivate *priv; - - g_return_if_fail (ST_IS_BOX_LAYOUT (box)); - - priv = box->priv; - - if (priv->spacing != spacing) - { - priv->spacing = spacing; - - clutter_actor_queue_relayout (CLUTTER_ACTOR (box)); - - g_object_notify (G_OBJECT (box), "spacing"); - } -} - -/** - * st_box_layout_get_spacing: - * @box: A #StBoxLayout - * - * Get the spacing between children in pixels - * - * Returns: the spacing value - */ -guint -st_box_layout_get_spacing (StBoxLayout *box) -{ - g_return_val_if_fail (ST_IS_BOX_LAYOUT (box), 0); - - return box->priv->spacing; -} diff --git a/src/st/st-box-layout.h b/src/st/st-box-layout.h index f7ad946b3..30954a2ee 100644 --- a/src/st/st-box-layout.h +++ b/src/st/st-box-layout.h @@ -89,10 +89,6 @@ void st_box_layout_set_pack_start (StBoxLayout *box, gboolean pack_start); gboolean st_box_layout_get_pack_start (StBoxLayout *box); -void st_box_layout_set_spacing (StBoxLayout *box, - guint spacing); -guint st_box_layout_get_spacing (StBoxLayout *box); - G_END_DECLS #endif /* _ST_BOX_LAYOUT_H */ diff --git a/tests/interactive/borders.js b/tests/interactive/borders.js index d68534580..774e38094 100644 --- a/tests/interactive/borders.js +++ b/tests/interactive/borders.js @@ -13,8 +13,9 @@ stage.height = 700; let vbox = new St.BoxLayout({ vertical: true, width: stage.width, height: stage.height, - spacing: 20, - style: 'padding: 10px; background: #ffee88;' }); + style: 'padding: 10px;' + + 'spacing: 20px;' + + 'background: #ffee88;' }); stage.add_actor(vbox); vbox.add(new St.Label({ text: "Hello World", diff --git a/tests/interactive/box-layout.js b/tests/interactive/box-layout.js index 2b8dda856..4454cd0aa 100644 --- a/tests/interactive/box-layout.js +++ b/tests/interactive/box-layout.js @@ -11,8 +11,8 @@ let stage = Clutter.Stage.get_default(); let vbox = new St.BoxLayout({ vertical: true, width: stage.width, height: stage.height, - spacing: 10, - style: 'padding: 10px' }); + style: 'padding: 10px;' + + 'spacing: 10px;' }); stage.add_actor(vbox); //////////////////////////////////////////////////////////////////////////////// diff --git a/tests/interactive/inline-style.js b/tests/interactive/inline-style.js index 3cac25cea..fa23b1f70 100644 --- a/tests/interactive/inline-style.js +++ b/tests/interactive/inline-style.js @@ -13,7 +13,7 @@ let vbox = new St.BoxLayout({ vertical: true, height: stage.height }); stage.add_actor(vbox); -let hbox = new St.BoxLayout({ spacing: 12 }); +let hbox = new St.BoxLayout({ style: 'spacing: 12px;' }); vbox.add(hbox); let text = new St.Label({ text: "Styled Text" }); |