diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 42f48ab7a7..501d283923 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -653,6 +653,30 @@
* font: Sans 15;
*
*
+ * margin-top
+ * integer
+ * #gint
+ * margin-top: 0;
+ *
+ *
+ * margin-left
+ * integer
+ * #gint
+ * margin-left: 1;
+ *
+ *
+ * margin-bottom
+ * integer
+ * #gint
+ * margin-bottom: 2;
+ *
+ *
+ * margin-right
+ * integer
+ * #gint
+ * margin-right: 4;
+ *
+ *
* margin
* @width
* @vertical_width @horizontal_width
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 7f6ebff8ed..b93dc367ca 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -506,7 +506,6 @@ static guint signals[LAST_SIGNAL] = { 0 };
static GQuark provider_list_quark = 0;
static GdkRGBA fallback_color = { 1.0, 0.75, 0.75, 1.0 };
-static GtkBorder fallback_border = { 0 };
static void gtk_style_context_finalize (GObject *object);
@@ -3556,28 +3555,27 @@ gtk_style_context_get_margin (GtkStyleContext *context,
{
GtkStyleContextPrivate *priv;
StyleData *data;
- const GValue *value;
- GtkBorder *b;
+ int top, left, bottom, right;
g_return_if_fail (margin != NULL);
- *margin = fallback_border;
-
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
priv = context->priv;
g_return_if_fail (priv->widget_path != NULL);
data = style_data_lookup (context);
- value = _gtk_style_properties_peek_property (data->store,
- "margin",
- state,
- NULL);
+ gtk_style_properties_get (data->store,
+ state,
+ "margin-top", &top,
+ "margin-left", &left,
+ "margin-bottom", &bottom,
+ "margin-right", &right,
+ NULL);
- if (value)
- {
- b = g_value_get_boxed (value);
- *margin = *b;
- }
+ margin->top = top;
+ margin->left = left;
+ margin->bottom = bottom;
+ margin->right = right;
}
/**
diff --git a/gtk/gtkstyleproperty.c b/gtk/gtkstyleproperty.c
index 9f58bd5cb0..abed616fbb 100644
--- a/gtk/gtkstyleproperty.c
+++ b/gtk/gtkstyleproperty.c
@@ -1256,6 +1256,25 @@ pack_padding (GValue *value,
"padding-bottom", "padding-right");
}
+static GParameter *
+unpack_margin (const GValue *value,
+ guint *n_params)
+{
+ return unpack_border (value, n_params,
+ "margin-top", "margin-left",
+ "margin-bottom", "margin-right");
+}
+
+static void
+pack_margin (GValue *value,
+ GtkStyleProperties *props,
+ GtkStateFlags state)
+{
+ pack_border (value, props, state,
+ "margin-top", "margin-left",
+ "margin-bottom", "margin-right");
+}
+
/*** API ***/
static void
@@ -1454,10 +1473,32 @@ gtk_style_property_init (void)
gtk_style_properties_register_property (NULL, pspec);
gtk_style_properties_register_property (NULL,
- g_param_spec_boxed ("margin",
+ g_param_spec_int ("margin-top",
+ "margin top",
+ "Margin at top",
+ 0, G_MAXINT, 0, 0));
+ gtk_style_properties_register_property (NULL,
+ g_param_spec_int ("margin-left",
+ "margin left",
+ "Margin at left",
+ 0, G_MAXINT, 0, 0));
+ gtk_style_properties_register_property (NULL,
+ g_param_spec_int ("margin-bottom",
+ "margin bottom",
+ "Margin at bottom",
+ 0, G_MAXINT, 0, 0));
+ gtk_style_properties_register_property (NULL,
+ g_param_spec_int ("margin-right",
+ "margin right",
+ "Margin at right",
+ 0, G_MAXINT, 0, 0));
+ _gtk_style_property_register (g_param_spec_boxed ("margin",
"Margin",
"Margin",
- GTK_TYPE_BORDER, 0));
+ GTK_TYPE_BORDER, 0),
+ NULL,
+ unpack_margin,
+ pack_margin);
gtk_style_properties_register_property (NULL,
g_param_spec_int ("padding-top",
"padding top",