forked from AuroraMiddleware/gtk
style: Make margin a shorthand
... and add the real properties: - margin-top - margin-left - margin-bottom - margin-right
This commit is contained in:
parent
a35aa96149
commit
21236cf270
@ -653,6 +653,30 @@
|
||||
* <entry>font: Sans 15;</entry>
|
||||
* </row>
|
||||
* <row>
|
||||
* <entry>margin-top</entry>
|
||||
* <entry>integer</entry>
|
||||
* <entry>#gint</entry>
|
||||
* <entry>margin-top: 0;</entry>
|
||||
* </row>
|
||||
* <row>
|
||||
* <entry>margin-left</entry>
|
||||
* <entry>integer</entry>
|
||||
* <entry>#gint</entry>
|
||||
* <entry>margin-left: 1;</entry>
|
||||
* </row>
|
||||
* <row>
|
||||
* <entry>margin-bottom</entry>
|
||||
* <entry>integer</entry>
|
||||
* <entry>#gint</entry>
|
||||
* <entry>margin-bottom: 2;</entry>
|
||||
* </row>
|
||||
* <row>
|
||||
* <entry>margin-right</entry>
|
||||
* <entry>integer</entry>
|
||||
* <entry>#gint</entry>
|
||||
* <entry>margin-right: 4;</entry>
|
||||
* </row>
|
||||
* <row>
|
||||
* <entry>margin</entry>
|
||||
* <entry morerows="1"><literallayout>@width
|
||||
* @vertical_width @horizontal_width
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user