static GtkCssValue * gtk_css_shorthand_property_parse_value (GtkStyleProperty *property, GtkCssParser *parser, GFile *base) { GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property); GtkCssValue **data; GtkCssValue *result; guint i; data = g_new0 (GtkCssValue *, shorthand->subproperties->len); if (_gtk_css_parser_try (parser, "initial", TRUE)) { /* the initial value can be explicitly specified with the * ‘initial’ keyword which all properties accept. */ for (i = 0; i < shorthand->subproperties->len; i++) { data[i] = _gtk_css_initial_value_new (); } } else if (_gtk_css_parser_try (parser, "inherit", TRUE)) { /* All properties accept the ‘inherit’ value which * explicitly specifies that the value will be determined * by inheritance. The ‘inherit’ value can be used to * strengthen inherited values in the cascade, and it can * also be used on properties that are not normally inherited. */ for (i = 0; i < shorthand->subproperties->len; i++) { data[i] = _gtk_css_inherit_value_new (); } } else if (!shorthand->parse (shorthand, data, parser, base)) { for (i = 0; i < shorthand->subproperties->len; i++) { if (data[i] != NULL) _gtk_css_value_unref (data[i]); } g_free (data); return NULL; } /* All values that aren't set by the parse func are set to their * default values here. * XXX: Is the default always initial or can it be inherit? */ for (i = 0; i < shorthand->subproperties->len; i++) { if (data[i] == NULL) data[i] = _gtk_css_initial_value_new (); } result = _gtk_css_array_value_new_from_array (data, shorthand->subproperties->len); g_free (data); return result; }
static void gtk_css_shorthand_property_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { GtkCssShorthandProperty *property = GTK_CSS_SHORTHAND_PROPERTY (object); const char **subproperties; guint i; switch (prop_id) { case PROP_SUBPROPERTIES: subproperties = g_value_get_boxed (value); g_assert (subproperties); for (i = 0; subproperties[i] != NULL; i++) { GtkStyleProperty *subproperty = _gtk_style_property_lookup (subproperties[i]); g_assert (GTK_IS_CSS_STYLE_PROPERTY (subproperty)); g_ptr_array_add (property->subproperties, subproperty); } break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void _gtk_css_shorthand_property_query (GtkStyleProperty *property, GValue *value, GtkStyleQueryFunc query_func, gpointer query_data) { GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property); return shorthand->query (shorthand, value, query_func, query_data); }
static void _gtk_css_shorthand_property_assign (GtkStyleProperty *property, GtkStyleProperties *props, GtkStateFlags state, const GValue *value) { GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property); shorthand->assign (shorthand, props, state, value); }
static void transition_info_add (TransitionInfo infos[GTK_CSS_PROPERTY_N_PROPERTIES], GtkStyleProperty *property, guint index) { if (property == NULL) { guint i; for (i = 0; i < _gtk_css_style_property_get_n_properties (); i++) { GtkCssStyleProperty *prop = _gtk_css_style_property_lookup_by_id (i); transition_info_add (infos, GTK_STYLE_PROPERTY (prop), index); } } else if (GTK_IS_CSS_SHORTHAND_PROPERTY (property)) { GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property); guint i; for (i = 0; i < _gtk_css_shorthand_property_get_n_subproperties (shorthand); i++) { GtkCssStyleProperty *prop = _gtk_css_shorthand_property_get_subproperty (shorthand, i); transition_info_add (infos, GTK_STYLE_PROPERTY (prop), index); } } else if (GTK_IS_CSS_STYLE_PROPERTY (property)) { guint id; if (!_gtk_css_style_property_is_animated (GTK_CSS_STYLE_PROPERTY (property))) return; id = _gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (property)); g_assert (id < GTK_CSS_PROPERTY_N_PROPERTIES); infos[id].index = index; infos[id].pending = TRUE; } else { g_assert_not_reached (); } }