void _gtk_style_cascade_set_parent (GtkStyleCascade *cascade, GtkStyleCascade *parent) { gtk_internal_return_if_fail (GTK_IS_STYLE_CASCADE (cascade)); gtk_internal_return_if_fail (parent == NULL || GTK_IS_STYLE_CASCADE (parent)); if (cascade->parent == parent) return; if (parent) { g_object_ref (parent); g_signal_connect_swapped (parent, "-gtk-private-changed", G_CALLBACK (_gtk_style_provider_private_changed), cascade); } if (cascade->parent) { g_signal_handlers_disconnect_by_func (cascade->parent, _gtk_style_provider_private_changed, cascade); g_object_unref (cascade->parent); } cascade->parent = parent; }
void _gtk_style_cascade_add_provider (GtkStyleCascade *cascade, GtkStyleProvider *provider, guint priority) { GtkStyleProviderData data; guint i; gtk_internal_return_if_fail (GTK_IS_STYLE_CASCADE (cascade)); gtk_internal_return_if_fail (GTK_IS_STYLE_PROVIDER (provider)); gtk_internal_return_if_fail (GTK_STYLE_PROVIDER (cascade) != provider); data.provider = g_object_ref (provider); data.priority = priority; data.changed_signal_id = g_signal_connect_swapped (provider, "-gtk-private-changed", G_CALLBACK (_gtk_style_provider_private_changed), cascade); /* ensure it gets removed first */ _gtk_style_cascade_remove_provider (cascade, provider); for (i = 0; i < cascade->providers->len; i++) { if (g_array_index (cascade->providers, GtkStyleProviderData, i).priority > priority) break; } g_array_insert_val (cascade->providers, i, data); _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (cascade)); }
/** * _gtk_css_lookup_resolve: * @lookup: the lookup * @context: the context the values are resolved for * @values: a new #GtkCssStyle to be filled with the new properties * * Resolves the current lookup into a styleproperties object. This is done * by converting from the “winning declaration” to the “computed value”. * * XXX: This bypasses the notion of “specified value”. If this ever becomes * an issue, go fix it. **/ void _gtk_css_lookup_resolve (GtkCssLookup *lookup, GtkStyleProviderPrivate *provider, GtkCssStaticStyle *style, GtkCssStyle *parent_style) { guint i, n; gtk_internal_return_if_fail (lookup != NULL); gtk_internal_return_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider)); gtk_internal_return_if_fail (GTK_IS_CSS_STATIC_STYLE (style)); gtk_internal_return_if_fail (parent_style == NULL || GTK_IS_CSS_STYLE (parent_style)); n = _gtk_css_style_property_get_n_properties (); for (i = 0; i < n; i++) { if (lookup->values[i].value || _gtk_bitmask_get (lookup->missing, i)) gtk_css_static_style_compute_value (GTK_CSS_STATIC_STYLE (style), provider, parent_style, i, lookup->values[i].value, lookup->values[i].section); /* else not a relevant property */ } }
void _gtk_css_section_end (GtkCssSection *section) { gtk_internal_return_if_fail (section != NULL); gtk_internal_return_if_fail (section->parser != NULL); section->end_line = _gtk_css_parser_get_line (section->parser); section->end_position = _gtk_css_parser_get_position (section->parser); section->parser = NULL; }
void gtk_css_path_node_unset_context (GtkCssPathNode *node) { gtk_internal_return_if_fail (GTK_IS_CSS_PATH_NODE (node)); gtk_internal_return_if_fail (node->context != NULL); node->context = NULL; gtk_css_node_invalidate_style_provider (GTK_CSS_NODE (node)); }
void gtk_css_widget_node_widget_destroyed (GtkCssWidgetNode *node) { gtk_internal_return_if_fail (GTK_IS_CSS_WIDGET_NODE (node)); gtk_internal_return_if_fail (node->widget != NULL); node->widget = NULL; /* Contents of this node are now undefined. * So we don't clear the style or anything. */ }
/** * _gtk_css_lookup_set: * @lookup: the lookup * @id: id of the property to set, see _gtk_style_property_get_id() * @section: (allow-none): The @section the value was defined in or %NULL * @value: the “cascading value” to use * * Sets the @value for a given @id. No value may have been set for @id * before. See _gtk_css_lookup_is_missing(). This function is used to * set the “winning declaration” of a lookup. Note that for performance * reasons @value and @section are not copied. It is your responsibility * to ensure they are kept alive until _gtk_css_lookup_free() is called. **/ void _gtk_css_lookup_set (GtkCssLookup *lookup, guint id, GtkCssSection *section, GtkCssValue *value) { gtk_internal_return_if_fail (lookup != NULL); gtk_internal_return_if_fail (_gtk_bitmask_get (lookup->missing, id)); gtk_internal_return_if_fail (value != NULL); lookup->missing = _gtk_bitmask_set (lookup->missing, id, FALSE); lookup->values[id].value = value; lookup->values[id].section = section; }
/** * gtk_widget_path_free: * @path: a #GtkWidgetPath * * Decrements the reference count on @path, freeing the structure * if the reference count reaches 0. * * Since: 3.0 **/ void gtk_widget_path_free (GtkWidgetPath *path) { gtk_internal_return_if_fail (path != NULL); gtk_widget_path_unref (path); }
void _gtk_style_provider_private_changed (GtkStyleProviderPrivate *provider) { gtk_internal_return_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider)); g_signal_emit (provider, signals[CHANGED], 0); }
/** * gtk_widget_path_unref: * @path: a #GtkWidgetPath * * Decrements the reference count on @path, freeing the structure * if the reference count reaches 0. * * Since: 3.2 **/ void gtk_widget_path_unref (GtkWidgetPath *path) { guint i; gtk_internal_return_if_fail (path != NULL); path->ref_count -= 1; if (path->ref_count > 0) return; for (i = 0; i < path->elems->len; i++) { GtkPathElement *elem; elem = &g_array_index (path->elems, GtkPathElement, i); gtk_css_node_declaration_unref (elem->decl); if (elem->siblings) gtk_widget_path_unref (elem->siblings); } g_array_free (path->elems, TRUE); g_slice_free (GtkWidgetPath, path); }
void _gtk_css_lookup_free (GtkCssLookup *lookup) { gtk_internal_return_if_fail (lookup != NULL); _gtk_bitmask_free (lookup->missing); g_free (lookup); }
void gtk_css_animated_style_set_animated_value (GtkCssAnimatedStyle *style, guint id, GtkCssValue *value) { gtk_internal_return_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style)); gtk_internal_return_if_fail (value != NULL); if (style->animated_values == NULL) style->animated_values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref); if (id >= style->animated_values->len) g_ptr_array_set_size (style->animated_values, id + 1); if (g_ptr_array_index (style->animated_values, id)) _gtk_css_value_unref (g_ptr_array_index (style->animated_values, id)); g_ptr_array_index (style->animated_values, id) = _gtk_css_value_ref (value); }
void _gtk_css_computed_values_set_animated_value (GtkCssComputedValues *values, guint id, GtkCssValue *value) { gtk_internal_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values)); gtk_internal_return_if_fail (value != NULL); if (values->animated_values == NULL) values->animated_values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref); if (id >= values->animated_values->len) g_ptr_array_set_size (values->animated_values, id + 1); if (g_ptr_array_index (values->animated_values, id)) _gtk_css_value_unref (g_ptr_array_index (values->animated_values, id)); g_ptr_array_index (values->animated_values, id) = _gtk_css_value_ref (value); }
void _gtk_css_computed_values_compute_value (GtkCssComputedValues *values, GtkStyleProviderPrivate *provider, GtkCssComputedValues *parent_values, guint id, GtkCssValue *specified, GtkCssSection *section) { GtkCssDependencies dependencies; GtkCssValue *value; gtk_internal_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values)); gtk_internal_return_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider)); gtk_internal_return_if_fail (parent_values == NULL || GTK_IS_CSS_COMPUTED_VALUES (parent_values)); /* http://www.w3.org/TR/css3-cascade/#cascade * Then, for every element, the value for each property can be found * by following this pseudo-algorithm: * 1) Identify all declarations that apply to the element */ if (specified == NULL) { GtkCssStyleProperty *prop = _gtk_css_style_property_lookup_by_id (id); if (_gtk_css_style_property_is_inherit (prop)) specified = _gtk_css_inherit_value_new (); else specified = _gtk_css_initial_value_new (); } else _gtk_css_value_ref (specified); value = _gtk_css_value_compute (specified, id, provider, values, parent_values, &dependencies); _gtk_css_computed_values_set_value (values, id, value, dependencies, section); _gtk_css_value_unref (value); _gtk_css_value_unref (specified); }
void _gtk_style_provider_private_lookup (GtkStyleProviderPrivate *provider, const GtkCssMatcher *matcher, GtkCssLookup *lookup, GtkCssChange *out_change) { GtkStyleProviderPrivateInterface *iface; gtk_internal_return_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider)); gtk_internal_return_if_fail (matcher != NULL); gtk_internal_return_if_fail (lookup != NULL); if (out_change) *out_change = 0; iface = GTK_STYLE_PROVIDER_PRIVATE_GET_INTERFACE (provider); if (!iface->lookup) return; iface->lookup (provider, matcher, lookup, out_change); }
void _gtk_style_cascade_remove_provider (GtkStyleCascade *cascade, GtkStyleProvider *provider) { guint i; gtk_internal_return_if_fail (GTK_IS_STYLE_CASCADE (cascade)); gtk_internal_return_if_fail (GTK_IS_STYLE_PROVIDER (provider)); for (i = 0; i < cascade->providers->len; i++) { GtkStyleProviderData *data = &g_array_index (cascade->providers, GtkStyleProviderData, i); if (data->provider == provider) { g_array_remove_index (cascade->providers, i); _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (cascade)); break; } } }
void _gtk_style_cascade_set_scale (GtkStyleCascade *cascade, int scale) { gtk_internal_return_if_fail (GTK_IS_STYLE_CASCADE (cascade)); if (cascade->scale == scale) return; cascade->scale = scale; _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (cascade)); }
void _gtk_css_computed_values_cancel_animations (GtkCssComputedValues *values) { gtk_internal_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values)); if (values->animated_values) { g_ptr_array_unref (values->animated_values); values->animated_values = NULL; } g_slist_free_full (values->animations, g_object_unref); values->animations = NULL; }
/** * gtk_css_section_unref: * @section: a #GtkCssSection * * Decrements the reference count on @section, freeing the * structure if the reference count reaches 0. * * Since: 3.2 **/ void gtk_css_section_unref (GtkCssSection *section) { gtk_internal_return_if_fail (section != NULL); section->ref_count -= 1; if (section->ref_count > 0) return; if (section->parent) gtk_css_section_unref (section->parent); if (section->file) g_object_unref (section->file); g_slice_free (GtkCssSection, section); }
void _gtk_css_computed_values_set_value (GtkCssComputedValues *values, guint id, GtkCssValue *value, GtkCssDependencies dependencies, GtkCssSection *section) { gtk_internal_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values)); if (values->values == NULL) values->values = g_ptr_array_new_full (_gtk_css_style_property_get_n_properties (), (GDestroyNotify)_gtk_css_value_unref); if (id >= values->values->len) g_ptr_array_set_size (values->values, id + 1); if (g_ptr_array_index (values->values, id)) _gtk_css_value_unref (g_ptr_array_index (values->values, id)); g_ptr_array_index (values->values, id) = _gtk_css_value_ref (value); if (dependencies & (GTK_CSS_DEPENDS_ON_PARENT | GTK_CSS_EQUALS_PARENT)) values->depends_on_parent = _gtk_bitmask_set (values->depends_on_parent, id, TRUE); if (dependencies & (GTK_CSS_EQUALS_PARENT)) values->equals_parent = _gtk_bitmask_set (values->equals_parent, id, TRUE); if (dependencies & (GTK_CSS_DEPENDS_ON_COLOR)) values->depends_on_color = _gtk_bitmask_set (values->depends_on_color, id, TRUE); if (dependencies & (GTK_CSS_DEPENDS_ON_FONT_SIZE)) values->depends_on_font_size = _gtk_bitmask_set (values->depends_on_font_size, id, TRUE); if (values->sections && values->sections->len > id && g_ptr_array_index (values->sections, id)) { gtk_css_section_unref (g_ptr_array_index (values->sections, id)); g_ptr_array_index (values->sections, id) = NULL; } if (section) { if (values->sections == NULL) values->sections = g_ptr_array_new_with_free_func (maybe_unref_section); if (values->sections->len <= id) g_ptr_array_set_size (values->sections, id + 1); g_ptr_array_index (values->sections, id) = gtk_css_section_ref (section); } }
void gtk_css_path_node_set_widget_path (GtkCssPathNode *node, GtkWidgetPath *path) { gtk_internal_return_if_fail (GTK_IS_CSS_PATH_NODE (node)); if (node->path == path) return; if (node->path) gtk_widget_path_unref (node->path); if (path) gtk_widget_path_ref (path); node->path = path; gtk_css_node_invalidate (GTK_CSS_NODE (node), GTK_CSS_CHANGE_ANY); }
void _gtk_css_computed_values_compute_value (GtkCssComputedValues *values, GtkStyleProviderPrivate *provider, int scale, GtkCssComputedValues *parent_values, guint id, GtkCssValue *specified, GtkCssSection *section) { GtkCssDependencies dependencies; GtkCssValue *value; gtk_internal_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values)); gtk_internal_return_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider)); gtk_internal_return_if_fail (parent_values == NULL || GTK_IS_CSS_COMPUTED_VALUES (parent_values)); /* http://www.w3.org/TR/css3-cascade/#cascade * Then, for every element, the value for each property can be found * by following this pseudo-algorithm: * 1) Identify all declarations that apply to the element */ if (specified == NULL) { GtkCssStyleProperty *prop = _gtk_css_style_property_lookup_by_id (id); if (_gtk_css_style_property_is_inherit (prop)) specified = _gtk_css_inherit_value_new (); else specified = _gtk_css_initial_value_new (); } else _gtk_css_value_ref (specified); value = _gtk_css_value_compute (specified, id, provider, scale, values, parent_values, &dependencies); if (values->values == NULL) values->values = g_ptr_array_new_full (_gtk_css_style_property_get_n_properties (), (GDestroyNotify)_gtk_css_value_unref); if (id >= values->values->len) g_ptr_array_set_size (values->values, id + 1); if (g_ptr_array_index (values->values, id)) _gtk_css_value_unref (g_ptr_array_index (values->values, id)); g_ptr_array_index (values->values, id) = _gtk_css_value_ref (value); if (dependencies & (GTK_CSS_DEPENDS_ON_PARENT | GTK_CSS_EQUALS_PARENT)) values->depends_on_parent = _gtk_bitmask_set (values->depends_on_parent, id, TRUE); if (dependencies & (GTK_CSS_EQUALS_PARENT)) values->equals_parent = _gtk_bitmask_set (values->equals_parent, id, TRUE); if (dependencies & (GTK_CSS_DEPENDS_ON_COLOR)) values->depends_on_color = _gtk_bitmask_set (values->depends_on_color, id, TRUE); if (dependencies & (GTK_CSS_DEPENDS_ON_FONT_SIZE)) values->depends_on_font_size = _gtk_bitmask_set (values->depends_on_font_size, id, TRUE); if (values->sections && values->sections->len > id && g_ptr_array_index (values->sections, id)) { gtk_css_section_unref (g_ptr_array_index (values->sections, id)); g_ptr_array_index (values->sections, id) = NULL; } if (section) { if (values->sections == NULL) values->sections = g_ptr_array_new_with_free_func (maybe_unref_section); if (values->sections->len <= id) g_ptr_array_set_size (values->sections, id + 1); g_ptr_array_index (values->sections, id) = gtk_css_section_ref (section); } _gtk_css_value_unref (value); _gtk_css_value_unref (specified); }