2 * Copyright © 2011 Red Hat Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 * Authors: Benjamin Otte <otte@gnome.org>
23 #include "gtkcssshorthandpropertyprivate.h"
25 #include <cairo-gobject.h>
28 #include "gtkcssimageprivate.h"
29 #include "gtkcssstylefuncsprivate.h"
30 #include "gtkcsstypesprivate.h"
31 #include "gtkprivatetypebuiltins.h"
32 #include "gtkstylepropertiesprivate.h"
33 #include "gtksymboliccolorprivate.h"
34 #include "gtktypebuiltins.h"
36 /* this is in case round() is not provided by the compiler,
37 * such as in the case of C89 compilers, like MSVC
39 #include "fallback-c89.c"
44 value_is_done_parsing (GtkCssParser *parser)
46 return _gtk_css_parser_is_eof (parser) ||
47 _gtk_css_parser_begins_with (parser, ';') ||
48 _gtk_css_parser_begins_with (parser, '}');
52 parse_border_width (GtkCssShorthandProperty *shorthand,
57 GValue temp = G_VALUE_INIT;
60 g_value_init (&temp, GTK_TYPE_BORDER);
61 if (!_gtk_css_style_parse_value (&temp, parser, base))
63 g_value_unset (&temp);
67 border = g_value_get_boxed (&temp);
69 g_value_init (&values[0], G_TYPE_INT);
70 g_value_init (&values[1], G_TYPE_INT);
71 g_value_init (&values[2], G_TYPE_INT);
72 g_value_init (&values[3], G_TYPE_INT);
73 g_value_set_int (&values[0], border->top);
74 g_value_set_int (&values[1], border->right);
75 g_value_set_int (&values[2], border->bottom);
76 g_value_set_int (&values[3], border->left);
78 g_value_unset (&temp);
84 parse_four_numbers (GtkCssShorthandProperty *shorthand,
87 GtkCssNumberParseFlags flags)
89 GtkCssNumber numbers[4];
92 for (i = 0; i < 4; i++)
94 if (!_gtk_css_parser_has_number (parser))
97 if (!_gtk_css_parser_read_number (parser,
105 _gtk_css_parser_error (parser, "Expected a length");
111 numbers[i] = numbers[(i - 1) >> 1];
114 for (i = 0; i < 4; i++)
116 g_value_init (&values[i], GTK_TYPE_CSS_NUMBER);
117 g_value_set_boxed (&values[i], &numbers[i]);
124 parse_margin (GtkCssShorthandProperty *shorthand,
126 GtkCssParser *parser,
129 return parse_four_numbers (shorthand,
132 GTK_CSS_NUMBER_AS_PIXELS
133 | GTK_CSS_PARSE_LENGTH);
137 parse_border_width_really (GtkCssShorthandProperty *shorthand,
139 GtkCssParser *parser,
142 return parse_four_numbers (shorthand,
145 GTK_CSS_POSITIVE_ONLY
146 | GTK_CSS_NUMBER_AS_PIXELS
147 | GTK_CSS_PARSE_LENGTH);
151 parse_border_radius (GtkCssShorthandProperty *shorthand,
153 GtkCssParser *parser,
156 GtkCssBorderCornerRadius borders[4];
159 for (i = 0; i < G_N_ELEMENTS (borders); i++)
161 if (!_gtk_css_parser_has_number (parser))
163 if (!_gtk_css_parser_read_number (parser,
164 &borders[i].horizontal,
165 GTK_CSS_POSITIVE_ONLY
166 | GTK_CSS_PARSE_PERCENT
167 | GTK_CSS_NUMBER_AS_PIXELS
168 | GTK_CSS_PARSE_LENGTH))
174 _gtk_css_parser_error (parser, "Expected a number");
178 /* The magic (i - 1) >> 1 below makes it take the correct value
179 * according to spec. Feel free to check the 4 cases */
180 for (; i < G_N_ELEMENTS (borders); i++)
181 borders[i].horizontal = borders[(i - 1) >> 1].horizontal;
183 if (_gtk_css_parser_try (parser, "/", TRUE))
185 for (i = 0; i < G_N_ELEMENTS (borders); i++)
187 if (!_gtk_css_parser_has_number (parser))
189 if (!_gtk_css_parser_read_number (parser,
190 &borders[i].vertical,
191 GTK_CSS_POSITIVE_ONLY
192 | GTK_CSS_PARSE_PERCENT
193 | GTK_CSS_NUMBER_AS_PIXELS
194 | GTK_CSS_PARSE_LENGTH))
200 _gtk_css_parser_error (parser, "Expected a number");
204 for (; i < G_N_ELEMENTS (borders); i++)
205 borders[i].vertical = borders[(i - 1) >> 1].vertical;
210 for (i = 0; i < G_N_ELEMENTS (borders); i++)
211 borders[i].vertical = borders[i].horizontal;
214 for (i = 0; i < G_N_ELEMENTS (borders); i++)
216 g_value_init (&values[i], GTK_TYPE_CSS_BORDER_CORNER_RADIUS);
217 g_value_set_boxed (&values[i], &borders[i]);
224 parse_border_color (GtkCssShorthandProperty *shorthand,
226 GtkCssParser *parser,
229 GtkSymbolicColor *symbolic;
232 for (i = 0; i < 4; i++)
234 if (_gtk_css_parser_try (parser, "currentcolor", TRUE))
236 symbolic = gtk_symbolic_color_ref (_gtk_symbolic_color_get_current_color ());
240 symbolic = _gtk_css_parser_read_symbolic_color (parser);
241 if (symbolic == NULL)
245 g_value_init (&values[i], GTK_TYPE_SYMBOLIC_COLOR);
246 g_value_set_boxed (&values[i], symbolic);
248 if (value_is_done_parsing (parser))
252 for (i++; i < 4; i++)
254 g_value_init (&values[i], G_VALUE_TYPE (&values[(i - 1) >> 1]));
255 g_value_copy (&values[(i - 1) >> 1], &values[i]);
262 parse_border_style (GtkCssShorthandProperty *shorthand,
264 GtkCssParser *parser,
267 GtkBorderStyle styles[4];
270 for (i = 0; i < 4; i++)
272 if (!_gtk_css_parser_try_enum (parser, GTK_TYPE_BORDER_STYLE, (int *)&styles[i]))
278 _gtk_css_parser_error (parser, "Expected a border style");
282 for (; i < G_N_ELEMENTS (styles); i++)
283 styles[i] = styles[(i - 1) >> 1];
285 for (i = 0; i < G_N_ELEMENTS (styles); i++)
287 g_value_init (&values[i], GTK_TYPE_BORDER_STYLE);
288 g_value_set_enum (&values[i], styles[i]);
295 parse_border_image (GtkCssShorthandProperty *shorthand,
297 GtkCssParser *parser,
302 if (_gtk_css_parser_try (parser, "none", TRUE))
306 image = _gtk_css_image_new_parse (parser, base);
310 g_value_init (&values[0], GTK_TYPE_CSS_IMAGE);
311 g_value_set_object (&values[0], image);
313 if (value_is_done_parsing (parser))
316 g_value_init (&values[1], GTK_TYPE_BORDER);
317 if (!_gtk_css_style_parse_value (&values[1], parser, base))
320 if (_gtk_css_parser_try (parser, "/", TRUE))
322 g_value_init (&values[2], GTK_TYPE_BORDER);
323 if (!_gtk_css_style_parse_value (&values[2], parser, base))
327 if (value_is_done_parsing (parser))
330 g_value_init (&values[3], GTK_TYPE_CSS_BORDER_IMAGE_REPEAT);
331 if (!_gtk_css_style_parse_value (&values[3], parser, base))
338 parse_border_side (GtkCssShorthandProperty *shorthand,
340 GtkCssParser *parser,
347 if (!G_IS_VALUE (&values[0]) &&
348 _gtk_css_parser_has_number (parser))
351 if (!_gtk_css_parser_read_number (parser,
353 GTK_CSS_POSITIVE_ONLY
354 | GTK_CSS_NUMBER_AS_PIXELS
355 | GTK_CSS_PARSE_LENGTH))
358 g_value_init (&values[0], GTK_TYPE_CSS_NUMBER);
359 g_value_set_boxed (&values[0], &number);
361 else if (!G_IS_VALUE (&values[1]) &&
362 _gtk_css_parser_try_enum (parser, GTK_TYPE_BORDER_STYLE, &style))
364 g_value_init (&values[1], GTK_TYPE_BORDER_STYLE);
365 g_value_set_enum (&values[1], style);
367 else if (!G_IS_VALUE (&values[2]))
369 GtkSymbolicColor *symbolic;
371 symbolic = _gtk_css_parser_read_symbolic_color (parser);
372 if (symbolic == NULL)
375 g_value_init (&values[2], GTK_TYPE_SYMBOLIC_COLOR);
376 g_value_take_boxed (&values[2], symbolic);
380 /* We parsed everything and there's still stuff left?
381 * Pretend we didn't notice and let the normal code produce
382 * a 'junk at end of value' error */
386 while (!value_is_done_parsing (parser));
392 parse_border (GtkCssShorthandProperty *shorthand,
394 GtkCssParser *parser,
401 if (!G_IS_VALUE (&values[0]) &&
402 _gtk_css_parser_has_number (parser))
405 if (!_gtk_css_parser_read_number (parser,
407 GTK_CSS_POSITIVE_ONLY
408 | GTK_CSS_NUMBER_AS_PIXELS
409 | GTK_CSS_PARSE_LENGTH))
412 g_value_init (&values[0], GTK_TYPE_CSS_NUMBER);
413 g_value_init (&values[1], GTK_TYPE_CSS_NUMBER);
414 g_value_init (&values[2], GTK_TYPE_CSS_NUMBER);
415 g_value_init (&values[3], GTK_TYPE_CSS_NUMBER);
416 g_value_set_boxed (&values[0], &number);
417 g_value_set_boxed (&values[1], &number);
418 g_value_set_boxed (&values[2], &number);
419 g_value_set_boxed (&values[3], &number);
421 else if (!G_IS_VALUE (&values[4]) &&
422 _gtk_css_parser_try_enum (parser, GTK_TYPE_BORDER_STYLE, &style))
424 g_value_init (&values[4], GTK_TYPE_BORDER_STYLE);
425 g_value_init (&values[5], GTK_TYPE_BORDER_STYLE);
426 g_value_init (&values[6], GTK_TYPE_BORDER_STYLE);
427 g_value_init (&values[7], GTK_TYPE_BORDER_STYLE);
428 g_value_set_enum (&values[4], style);
429 g_value_set_enum (&values[5], style);
430 g_value_set_enum (&values[6], style);
431 g_value_set_enum (&values[7], style);
433 else if (!G_IS_VALUE (&values[8]))
435 GtkSymbolicColor *symbolic;
437 symbolic = _gtk_css_parser_read_symbolic_color (parser);
438 if (symbolic == NULL)
441 g_value_init (&values[8], GTK_TYPE_SYMBOLIC_COLOR);
442 g_value_init (&values[9], GTK_TYPE_SYMBOLIC_COLOR);
443 g_value_init (&values[10], GTK_TYPE_SYMBOLIC_COLOR);
444 g_value_init (&values[11], GTK_TYPE_SYMBOLIC_COLOR);
445 g_value_set_boxed (&values[8], symbolic);
446 g_value_set_boxed (&values[9], symbolic);
447 g_value_set_boxed (&values[10], symbolic);
448 g_value_take_boxed (&values[11], symbolic);
452 /* We parsed everything and there's still stuff left?
453 * Pretend we didn't notice and let the normal code produce
454 * a 'junk at end of value' error */
458 while (!value_is_done_parsing (parser));
460 /* Note that border-image values are not set: according to the spec
461 they just need to be reset when using the border shorthand */
467 parse_font (GtkCssShorthandProperty *shorthand,
469 GtkCssParser *parser,
472 PangoFontDescription *desc;
476 str = _gtk_css_parser_read_value (parser);
480 desc = pango_font_description_from_string (str);
483 mask = pango_font_description_get_set_fields (desc);
485 if (mask & PANGO_FONT_MASK_FAMILY)
487 GPtrArray *strv = g_ptr_array_new ();
489 g_ptr_array_add (strv, g_strdup (pango_font_description_get_family (desc)));
490 g_ptr_array_add (strv, NULL);
491 g_value_init (&values[0], G_TYPE_STRV);
492 g_value_take_boxed (&values[0], g_ptr_array_free (strv, FALSE));
494 if (mask & PANGO_FONT_MASK_STYLE)
496 g_value_init (&values[1], PANGO_TYPE_STYLE);
497 g_value_set_enum (&values[1], pango_font_description_get_style (desc));
499 if (mask & PANGO_FONT_MASK_VARIANT)
501 g_value_init (&values[2], PANGO_TYPE_VARIANT);
502 g_value_set_enum (&values[2], pango_font_description_get_variant (desc));
504 if (mask & PANGO_FONT_MASK_WEIGHT)
506 g_value_init (&values[3], PANGO_TYPE_WEIGHT);
507 g_value_set_enum (&values[3], pango_font_description_get_weight (desc));
509 if (mask & PANGO_FONT_MASK_SIZE)
511 g_value_init (&values[4], G_TYPE_DOUBLE);
512 g_value_set_double (&values[4],
513 (double) pango_font_description_get_size (desc) / PANGO_SCALE);
516 pango_font_description_free (desc);
522 parse_background (GtkCssShorthandProperty *shorthand,
524 GtkCssParser *parser,
532 if (!G_IS_VALUE (&values[0]) &&
533 (_gtk_css_parser_has_prefix (parser, "none") ||
534 _gtk_css_image_can_parse (parser)))
538 if (_gtk_css_parser_try (parser, "none", TRUE))
542 image = _gtk_css_image_new_parse (parser, base);
547 g_value_init (&values[0], GTK_TYPE_CSS_IMAGE);
548 g_value_take_object (&values[0], image);
550 else if (!G_IS_VALUE (&values[1]) &&
551 _gtk_css_parser_try_enum (parser, GTK_TYPE_CSS_BACKGROUND_REPEAT, &enum_value))
553 if (enum_value <= GTK_CSS_BACKGROUND_REPEAT_MASK)
557 if (_gtk_css_parser_try_enum (parser, GTK_TYPE_CSS_BACKGROUND_REPEAT, &vertical))
559 if (vertical >= GTK_CSS_BACKGROUND_REPEAT_MASK)
561 _gtk_css_parser_error (parser, "Not a valid 2nd value for border-repeat");
565 enum_value |= vertical << GTK_CSS_BACKGROUND_REPEAT_SHIFT;
568 enum_value |= enum_value << GTK_CSS_BACKGROUND_REPEAT_SHIFT;
571 g_value_init (&values[1], GTK_TYPE_CSS_BACKGROUND_REPEAT);
572 g_value_set_enum (&values[1], enum_value);
574 else if ((!G_IS_VALUE (&values[2]) || !G_IS_VALUE (&values[3])) &&
575 _gtk_css_parser_try_enum (parser, GTK_TYPE_CSS_AREA, &enum_value))
577 guint idx = !G_IS_VALUE (&values[2]) ? 2 : 3;
578 g_value_init (&values[idx], GTK_TYPE_CSS_AREA);
579 g_value_set_enum (&values[idx], enum_value);
581 else if (!G_IS_VALUE (&values[4]))
583 GtkSymbolicColor *symbolic;
585 symbolic = _gtk_css_parser_read_symbolic_color (parser);
586 if (symbolic == NULL)
589 g_value_init (&values[4], GTK_TYPE_SYMBOLIC_COLOR);
590 g_value_take_boxed (&values[4], symbolic);
594 /* We parsed everything and there's still stuff left?
595 * Pretend we didn't notice and let the normal code produce
596 * a 'junk at end of value' error */
600 while (!value_is_done_parsing (parser));
608 unpack_border (GtkCssShorthandProperty *shorthand,
609 GtkStyleProperties *props,
613 GValue v = G_VALUE_INIT;
614 GtkBorder *border = g_value_get_boxed (value);
616 g_value_init (&v, G_TYPE_INT);
618 g_value_set_int (&v, border->top);
619 _gtk_style_property_assign (GTK_STYLE_PROPERTY (_gtk_css_shorthand_property_get_subproperty (shorthand, 0)), props, state, &v);
620 g_value_set_int (&v, border->right);
621 _gtk_style_property_assign (GTK_STYLE_PROPERTY (_gtk_css_shorthand_property_get_subproperty (shorthand, 1)), props, state, &v);
622 g_value_set_int (&v, border->bottom);
623 _gtk_style_property_assign (GTK_STYLE_PROPERTY (_gtk_css_shorthand_property_get_subproperty (shorthand, 2)), props, state, &v);
624 g_value_set_int (&v, border->left);
625 _gtk_style_property_assign (GTK_STYLE_PROPERTY (_gtk_css_shorthand_property_get_subproperty (shorthand, 3)), props, state, &v);
631 pack_border (GtkCssShorthandProperty *shorthand,
633 GtkStyleQueryFunc query_func,
636 GtkCssStyleProperty *prop;
640 prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 0);
641 v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
643 border.top = g_value_get_int (v);
644 prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 1);
645 v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
647 border.right = g_value_get_int (v);
648 prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 2);
649 v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
651 border.bottom = g_value_get_int (v);
652 prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 3);
653 v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
655 border.left = g_value_get_int (v);
657 g_value_set_boxed (value, &border);
661 unpack_border_radius (GtkCssShorthandProperty *shorthand,
662 GtkStyleProperties *props,
666 GtkCssBorderCornerRadius border;
667 GValue v = G_VALUE_INIT;
670 _gtk_css_number_init (&border.horizontal, g_value_get_int (value), GTK_CSS_PX);
671 border.vertical = border.horizontal;
672 g_value_init (&v, GTK_TYPE_CSS_BORDER_CORNER_RADIUS);
673 g_value_set_boxed (&v, &border);
675 for (i = 0; i < 4; i++)
676 _gtk_style_property_assign (GTK_STYLE_PROPERTY (_gtk_css_shorthand_property_get_subproperty (shorthand, i)), props, state, &v);
682 pack_border_radius (GtkCssShorthandProperty *shorthand,
684 GtkStyleQueryFunc query_func,
687 GtkCssBorderCornerRadius *top_left;
688 GtkCssStyleProperty *prop;
691 prop = GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("border-top-left-radius"));
692 v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
695 top_left = g_value_get_boxed (v);
697 g_value_set_int (value, top_left->horizontal.value);
702 unpack_font_description (GtkCssShorthandProperty *shorthand,
703 GtkStyleProperties *props,
707 GtkStyleProperty *prop;
708 PangoFontDescription *description;
710 GValue v = G_VALUE_INIT;
712 /* For backwards compat, we only unpack values that are indeed set.
713 * For strict CSS conformance we need to unpack all of them.
714 * Note that we do set all of them in the parse function, so it
715 * will not have effects when parsing CSS files. It will though
716 * for custom style providers.
719 description = g_value_get_boxed (value);
722 mask = pango_font_description_get_set_fields (description);
726 if (mask & PANGO_FONT_MASK_FAMILY)
728 GPtrArray *strv = g_ptr_array_new ();
730 g_ptr_array_add (strv, g_strdup (pango_font_description_get_family (description)));
731 g_ptr_array_add (strv, NULL);
732 g_value_init (&v, G_TYPE_STRV);
733 g_value_take_boxed (&v, g_ptr_array_free (strv, FALSE));
735 prop = _gtk_style_property_lookup ("font-family");
736 _gtk_style_property_assign (prop, props, state, &v);
740 if (mask & PANGO_FONT_MASK_STYLE)
742 g_value_init (&v, PANGO_TYPE_STYLE);
743 g_value_set_enum (&v, pango_font_description_get_style (description));
745 prop = _gtk_style_property_lookup ("font-style");
746 _gtk_style_property_assign (prop, props, state, &v);
750 if (mask & PANGO_FONT_MASK_VARIANT)
752 g_value_init (&v, PANGO_TYPE_VARIANT);
753 g_value_set_enum (&v, pango_font_description_get_variant (description));
755 prop = _gtk_style_property_lookup ("font-variant");
756 _gtk_style_property_assign (prop, props, state, &v);
760 if (mask & PANGO_FONT_MASK_WEIGHT)
762 g_value_init (&v, PANGO_TYPE_WEIGHT);
763 g_value_set_enum (&v, pango_font_description_get_weight (description));
765 prop = _gtk_style_property_lookup ("font-weight");
766 _gtk_style_property_assign (prop, props, state, &v);
770 if (mask & PANGO_FONT_MASK_SIZE)
772 g_value_init (&v, G_TYPE_DOUBLE);
773 g_value_set_double (&v, (double) pango_font_description_get_size (description) / PANGO_SCALE);
775 prop = _gtk_style_property_lookup ("font-size");
776 _gtk_style_property_assign (prop, props, state, &v);
782 pack_font_description (GtkCssShorthandProperty *shorthand,
784 GtkStyleQueryFunc query_func,
787 PangoFontDescription *description;
790 description = pango_font_description_new ();
792 v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-family"))), query_data);
795 const char **families = g_value_get_boxed (v);
796 /* xxx: Can we set all the families here somehow? */
798 pango_font_description_set_family (description, families[0]);
801 v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-size"))), query_data);
803 pango_font_description_set_size (description, round (g_value_get_double (v) * PANGO_SCALE));
805 v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-style"))), query_data);
807 pango_font_description_set_style (description, g_value_get_enum (v));
809 v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-variant"))), query_data);
811 pango_font_description_set_variant (description, g_value_get_enum (v));
813 v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-weight"))), query_data);
815 pango_font_description_set_weight (description, g_value_get_enum (v));
817 g_value_take_boxed (value, description);
821 unpack_to_everything (GtkCssShorthandProperty *shorthand,
822 GtkStyleProperties *props,
826 GtkCssStyleProperty *prop;
829 n = _gtk_css_shorthand_property_get_n_subproperties (shorthand);
831 for (i = 0; i < n; i++)
833 prop = _gtk_css_shorthand_property_get_subproperty (shorthand, i);
834 _gtk_style_property_assign (GTK_STYLE_PROPERTY (prop), props, state, value);
839 pack_first_element (GtkCssShorthandProperty *shorthand,
841 GtkStyleQueryFunc query_func,
844 GtkCssStyleProperty *prop;
848 /* NB: This is a fallback for properties that originally were
849 * not used as shorthand. We just pick the first subproperty
850 * as a representative.
851 * Lesson learned: Don't query the shorthand, query the
852 * real properties instead. */
853 for (i = 0; i < _gtk_css_shorthand_property_get_n_subproperties (shorthand); i++)
855 prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 0);
856 v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
859 g_value_copy (v, value);
866 _gtk_css_shorthand_property_register (const char *name,
868 const char **subproperties,
869 GtkCssShorthandPropertyParseFunc parse_func,
870 GtkCssShorthandPropertyAssignFunc assign_func,
871 GtkCssShorthandPropertyQueryFunc query_func)
873 GtkCssShorthandProperty *node;
875 node = g_object_new (GTK_TYPE_CSS_SHORTHAND_PROPERTY,
877 "value-type", value_type,
878 "subproperties", subproperties,
881 node->parse = parse_func;
882 node->assign = assign_func;
883 node->query = query_func;
887 _gtk_css_shorthand_property_init_properties (void)
889 /* The order is important here, be careful when changing it */
890 const char *font_subproperties[] = { "font-family", "font-style", "font-variant", "font-weight", "font-size", NULL };
891 const char *margin_subproperties[] = { "margin-top", "margin-right", "margin-bottom", "margin-left", NULL };
892 const char *padding_subproperties[] = { "padding-top", "padding-right", "padding-bottom", "padding-left", NULL };
893 const char *border_width_subproperties[] = { "border-top-width", "border-right-width", "border-bottom-width", "border-left-width", NULL };
894 const char *border_radius_subproperties[] = { "border-top-left-radius", "border-top-right-radius",
895 "border-bottom-right-radius", "border-bottom-left-radius", NULL };
896 const char *border_color_subproperties[] = { "border-top-color", "border-right-color", "border-bottom-color", "border-left-color", NULL };
897 const char *border_style_subproperties[] = { "border-top-style", "border-right-style", "border-bottom-style", "border-left-style", NULL };
898 const char *border_image_subproperties[] = { "border-image-source", "border-image-slice", "border-image-width", "border-image-repeat", NULL };
899 const char *border_top_subproperties[] = { "border-top-width", "border-top-style", "border-top-color", NULL };
900 const char *border_right_subproperties[] = { "border-right-width", "border-right-style", "border-right-color", NULL };
901 const char *border_bottom_subproperties[] = { "border-bottom-width", "border-bottom-style", "border-bottom-color", NULL };
902 const char *border_left_subproperties[] = { "border-left-width", "border-left-style", "border-left-color", NULL };
903 const char *border_subproperties[] = { "border-top-width", "border-right-width", "border-bottom-width", "border-left-width",
904 "border-top-style", "border-right-style", "border-bottom-style", "border-left-style",
905 "border-top-color", "border-right-color", "border-bottom-color", "border-left-color",
906 "border-image-source", "border-image-slice", "border-image-width", "border-image-repeat", NULL };
907 const char *outline_subproperties[] = { "outline-width", "outline-style", "outline-color", NULL };
908 const char *background_subproperties[] = { "background-image", "background-repeat", "background-clip", "background-origin",
909 "background-color", NULL };
911 _gtk_css_shorthand_property_register ("font",
912 PANGO_TYPE_FONT_DESCRIPTION,
915 unpack_font_description,
916 pack_font_description);
917 _gtk_css_shorthand_property_register ("margin",
919 margin_subproperties,
923 _gtk_css_shorthand_property_register ("padding",
925 padding_subproperties,
929 _gtk_css_shorthand_property_register ("border-width",
931 border_width_subproperties,
932 parse_border_width_really,
935 _gtk_css_shorthand_property_register ("border-radius",
937 border_radius_subproperties,
939 unpack_border_radius,
941 _gtk_css_shorthand_property_register ("border-color",
943 border_color_subproperties,
945 unpack_to_everything,
947 _gtk_css_shorthand_property_register ("border-style",
948 GTK_TYPE_BORDER_STYLE,
949 border_style_subproperties,
951 unpack_to_everything,
953 _gtk_css_shorthand_property_register ("border-image",
955 border_image_subproperties,
959 _gtk_css_shorthand_property_register ("border-top",
961 border_top_subproperties,
965 _gtk_css_shorthand_property_register ("border-right",
967 border_right_subproperties,
971 _gtk_css_shorthand_property_register ("border-bottom",
973 border_bottom_subproperties,
977 _gtk_css_shorthand_property_register ("border-left",
979 border_left_subproperties,
983 _gtk_css_shorthand_property_register ("border",
985 border_subproperties,
989 _gtk_css_shorthand_property_register ("outline",
991 outline_subproperties,
995 _gtk_css_shorthand_property_register ("background",
997 background_subproperties,