styleproperty: Don't use gtk_style_properties_register_property()

This would make the internal properties custom properties. And they are
not.

Also get rid of default initial values, we now specify the correct one
at all times.
This commit is contained in:
Benjamin Otte
2012-01-02 11:27:54 +01:00
parent 4b4792f65d
commit 65f6925dd1

View File

@ -52,30 +52,6 @@ _gtk_style_property_register (GParamSpec *pspec,
const GValue * initial_value) const GValue * initial_value)
{ {
GtkStyleProperty *node; GtkStyleProperty *node;
GValue initial_fallback = { 0, };
if (initial_value == NULL)
{
g_value_init (&initial_fallback, pspec->value_type);
if (pspec->value_type == GTK_TYPE_THEMING_ENGINE)
g_value_set_object (&initial_fallback, gtk_theming_engine_load (NULL));
else if (pspec->value_type == PANGO_TYPE_FONT_DESCRIPTION)
g_value_take_boxed (&initial_fallback, pango_font_description_from_string ("Sans 10"));
else if (pspec->value_type == GDK_TYPE_RGBA)
{
GdkRGBA color;
gdk_rgba_parse (&color, "pink");
g_value_set_boxed (&initial_fallback, &color);
}
else if (pspec->value_type == GTK_TYPE_BORDER)
{
g_value_take_boxed (&initial_fallback, gtk_border_new ());
}
else
g_param_value_set_default (pspec, &initial_fallback);
initial_value = &initial_fallback;
}
node = g_object_new (GTK_TYPE_CSS_STYLE_PROPERTY, node = g_object_new (GTK_TYPE_CSS_STYLE_PROPERTY,
"inherit", (flags & GTK_STYLE_PROPERTY_INHERIT) ? TRUE : FALSE, "inherit", (flags & GTK_STYLE_PROPERTY_INHERIT) ? TRUE : FALSE,
@ -87,9 +63,6 @@ _gtk_style_property_register (GParamSpec *pspec,
GTK_CSS_STYLE_PROPERTY (node)->pspec = pspec; GTK_CSS_STYLE_PROPERTY (node)->pspec = pspec;
node->parse_func = parse_func; node->parse_func = parse_func;
node->print_func = print_func; node->print_func = print_func;
if (G_IS_VALUE (&initial_fallback))
g_value_unset (&initial_fallback);
} }
static void static void
@ -362,6 +335,9 @@ _gtk_css_style_property_init_properties (void)
char *default_font_family[] = { "Sans", NULL }; char *default_font_family[] = { "Sans", NULL };
GdkRGBA rgba; GdkRGBA rgba;
GtkCssBorderCornerRadius no_corner_radius = { 0, }; GtkCssBorderCornerRadius no_corner_radius = { 0, };
GtkBorder border_of_ones = { 1, 1, 1, 1 };
GtkCssBackgroundRepeat background_repeat = { GTK_CSS_BACKGROUND_REPEAT_STYLE_REPEAT };
GtkCssBorderImageRepeat border_image_repeat = { GTK_CSS_REPEAT_STYLE_STRETCH, GTK_CSS_REPEAT_STYLE_STRETCH };
/* note that gtk_style_properties_register_property() calls this function, /* note that gtk_style_properties_register_property() calls this function,
* so make sure we're sanely inited to avoid infloops */ * so make sure we're sanely inited to avoid infloops */
@ -448,71 +424,111 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL); NULL);
gtk_style_properties_register_property (NULL, gtk_style_property_register (g_param_spec_boxed ("box-shadow",
g_param_spec_boxed ("box-shadow",
"Box shadow", "Box shadow",
"Box shadow", "Box shadow",
GTK_TYPE_SHADOW, 0)); GTK_TYPE_SHADOW, 0),
gtk_style_properties_register_property (NULL, 0,
g_param_spec_int ("margin-top", NULL,
NULL,
NULL);
gtk_style_property_register (g_param_spec_int ("margin-top",
"margin top", "margin top",
"Margin at top", "Margin at top",
0, G_MAXINT, 0, 0)); 0, G_MAXINT, 0, 0),
gtk_style_properties_register_property (NULL, 0,
g_param_spec_int ("margin-left", NULL,
NULL,
0);
gtk_style_property_register (g_param_spec_int ("margin-left",
"margin left", "margin left",
"Margin at left", "Margin at left",
0, G_MAXINT, 0, 0)); 0, G_MAXINT, 0, 0),
gtk_style_properties_register_property (NULL, 0,
g_param_spec_int ("margin-bottom", NULL,
NULL,
0);
gtk_style_property_register (g_param_spec_int ("margin-bottom",
"margin bottom", "margin bottom",
"Margin at bottom", "Margin at bottom",
0, G_MAXINT, 0, 0)); 0, G_MAXINT, 0, 0),
gtk_style_properties_register_property (NULL, 0,
g_param_spec_int ("margin-right", NULL,
NULL,
0);
gtk_style_property_register (g_param_spec_int ("margin-right",
"margin right", "margin right",
"Margin at right", "Margin at right",
0, G_MAXINT, 0, 0)); 0, G_MAXINT, 0, 0),
gtk_style_properties_register_property (NULL, 0,
g_param_spec_int ("padding-top", NULL,
NULL,
0);
gtk_style_property_register (g_param_spec_int ("padding-top",
"padding top", "padding top",
"Padding at top", "Padding at top",
0, G_MAXINT, 0, 0)); 0, G_MAXINT, 0, 0),
gtk_style_properties_register_property (NULL, 0,
g_param_spec_int ("padding-left", NULL,
NULL,
0);
gtk_style_property_register (g_param_spec_int ("padding-left",
"padding left", "padding left",
"Padding at left", "Padding at left",
0, G_MAXINT, 0, 0)); 0, G_MAXINT, 0, 0),
gtk_style_properties_register_property (NULL, 0,
g_param_spec_int ("padding-bottom", NULL,
NULL,
0);
gtk_style_property_register (g_param_spec_int ("padding-bottom",
"padding bottom", "padding bottom",
"Padding at bottom", "Padding at bottom",
0, G_MAXINT, 0, 0)); 0, G_MAXINT, 0, 0),
gtk_style_properties_register_property (NULL, 0,
g_param_spec_int ("padding-right", NULL,
NULL,
0);
gtk_style_property_register (g_param_spec_int ("padding-right",
"padding right", "padding right",
"Padding at right", "Padding at right",
0, G_MAXINT, 0, 0)); 0, G_MAXINT, 0, 0),
gtk_style_properties_register_property (NULL, 0,
g_param_spec_int ("border-top-width", NULL,
NULL,
0);
gtk_style_property_register (g_param_spec_int ("border-top-width",
"border top width", "border top width",
"Border width at top", "Border width at top",
0, G_MAXINT, 0, 0)); 0, G_MAXINT, 0, 0),
gtk_style_properties_register_property (NULL, 0,
g_param_spec_int ("border-left-width", NULL,
NULL,
0);
gtk_style_property_register (g_param_spec_int ("border-left-width",
"border left width", "border left width",
"Border width at left", "Border width at left",
0, G_MAXINT, 0, 0)); 0, G_MAXINT, 0, 0),
gtk_style_properties_register_property (NULL, 0,
g_param_spec_int ("border-bottom-width", NULL,
NULL,
0);
gtk_style_property_register (g_param_spec_int ("border-bottom-width",
"border bottom width", "border bottom width",
"Border width at bottom", "Border width at bottom",
0, G_MAXINT, 0, 0)); 0, G_MAXINT, 0, 0),
gtk_style_properties_register_property (NULL, 0,
g_param_spec_int ("border-right-width", NULL,
NULL,
0);
gtk_style_property_register (g_param_spec_int ("border-right-width",
"border right width", "border right width",
"Border width at right", "Border width at right",
0, G_MAXINT, 0, 0)); 0, G_MAXINT, 0, 0),
0,
NULL,
NULL,
0);
gtk_style_property_register (g_param_spec_boxed ("border-top-left-radius", gtk_style_property_register (g_param_spec_boxed ("border-top-left-radius",
"Border top left radius", "Border top left radius",
@ -547,24 +563,35 @@ _gtk_css_style_property_init_properties (void)
border_corner_radius_value_print, border_corner_radius_value_print,
&no_corner_radius); &no_corner_radius);
gtk_style_properties_register_property (NULL, gtk_style_property_register (g_param_spec_enum ("border-style",
g_param_spec_enum ("border-style",
"Border style", "Border style",
"Border style", "Border style",
GTK_TYPE_BORDER_STYLE, GTK_TYPE_BORDER_STYLE,
GTK_BORDER_STYLE_NONE, 0)); GTK_BORDER_STYLE_NONE, 0),
gtk_style_properties_register_property (NULL, 0,
g_param_spec_enum ("background-clip", NULL,
NULL,
GTK_BORDER_STYLE_NONE);
gtk_style_property_register (g_param_spec_enum ("background-clip",
"Background clip", "Background clip",
"Background clip", "Background clip",
GTK_TYPE_CSS_AREA, GTK_TYPE_CSS_AREA,
GTK_CSS_AREA_BORDER_BOX, 0)); GTK_CSS_AREA_BORDER_BOX, 0),
gtk_style_properties_register_property (NULL, 0,
g_param_spec_enum ("background-origin", NULL,
NULL,
GTK_CSS_AREA_BORDER_BOX);
gtk_style_property_register (g_param_spec_enum ("background-origin",
"Background origin", "Background origin",
"Background origin", "Background origin",
GTK_TYPE_CSS_AREA, GTK_TYPE_CSS_AREA,
GTK_CSS_AREA_PADDING_BOX, 0)); GTK_CSS_AREA_PADDING_BOX, 0),
0,
NULL,
NULL,
GTK_CSS_AREA_PADDING_BOX);
g_value_init (&value, GTK_TYPE_CSS_SPECIAL_VALUE); g_value_init (&value, GTK_TYPE_CSS_SPECIAL_VALUE);
g_value_set_enum (&value, GTK_CSS_CURRENT_COLOR); g_value_set_enum (&value, GTK_CSS_CURRENT_COLOR);
_gtk_style_property_register (g_param_spec_boxed ("border-top-color", _gtk_style_property_register (g_param_spec_boxed ("border-top-color",
@ -601,32 +628,49 @@ _gtk_css_style_property_init_properties (void)
&value); &value);
g_value_unset (&value); g_value_unset (&value);
gtk_style_properties_register_property (NULL, gtk_style_property_register (g_param_spec_boxed ("background-image",
g_param_spec_boxed ("background-image",
"Background Image", "Background Image",
"Background Image", "Background Image",
CAIRO_GOBJECT_TYPE_PATTERN, 0)); CAIRO_GOBJECT_TYPE_PATTERN, 0),
gtk_style_properties_register_property (NULL, 0,
g_param_spec_boxed ("background-repeat", NULL,
NULL,
NULL);
gtk_style_property_register (g_param_spec_boxed ("background-repeat",
"Background repeat", "Background repeat",
"Background repeat", "Background repeat",
GTK_TYPE_CSS_BACKGROUND_REPEAT, 0)); GTK_TYPE_CSS_BACKGROUND_REPEAT, 0),
0,
NULL,
NULL,
&background_repeat);
gtk_style_properties_register_property (NULL, gtk_style_property_register (g_param_spec_boxed ("border-image-source",
g_param_spec_boxed ("border-image-source",
"Border image source", "Border image source",
"Border image source", "Border image source",
CAIRO_GOBJECT_TYPE_PATTERN, 0)); CAIRO_GOBJECT_TYPE_PATTERN, 0),
gtk_style_properties_register_property (NULL, 0,
g_param_spec_boxed ("border-image-repeat", NULL,
NULL,
NULL);
gtk_style_property_register (g_param_spec_boxed ("border-image-repeat",
"Border image repeat", "Border image repeat",
"Border image repeat", "Border image repeat",
GTK_TYPE_CSS_BORDER_IMAGE_REPEAT, 0)); GTK_TYPE_CSS_BORDER_IMAGE_REPEAT, 0),
gtk_style_properties_register_property (NULL, 0,
g_param_spec_boxed ("border-image-slice", NULL,
NULL,
&border_image_repeat);
/* XXX: The initial vaue is wrong, it should be 100% */
gtk_style_property_register (g_param_spec_boxed ("border-image-slice",
"Border image slice", "Border image slice",
"Border image slice", "Border image slice",
GTK_TYPE_BORDER, 0)); GTK_TYPE_BORDER, 0),
0,
NULL,
NULL,
&border_of_ones);
gtk_style_property_register (g_param_spec_boxed ("border-image-width", gtk_style_property_register (g_param_spec_boxed ("border-image-width",
"Border image width", "Border image width",
"Border image width", "Border image width",
@ -635,16 +679,22 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
NULL); NULL);
gtk_style_properties_register_property (NULL, gtk_style_property_register (g_param_spec_object ("engine",
g_param_spec_object ("engine",
"Theming Engine", "Theming Engine",
"Theming Engine", "Theming Engine",
GTK_TYPE_THEMING_ENGINE, 0)); GTK_TYPE_THEMING_ENGINE, 0),
gtk_style_properties_register_property (NULL, 0,
g_param_spec_boxed ("transition", NULL,
NULL,
gtk_theming_engine_load (NULL));
gtk_style_property_register (g_param_spec_boxed ("transition",
"Transition animation description", "Transition animation description",
"Transition animation description", "Transition animation description",
GTK_TYPE_ANIMATION_DESCRIPTION, 0)); GTK_TYPE_ANIMATION_DESCRIPTION, 0),
0,
NULL,
NULL,
NULL);
/* Private property holding the binding sets */ /* Private property holding the binding sets */
gtk_style_property_register (g_param_spec_boxed ("gtk-key-bindings", gtk_style_property_register (g_param_spec_boxed ("gtk-key-bindings",