diff options
author | Benjamin Otte <otte@redhat.com> | 2011-12-28 22:59:55 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2012-01-09 18:37:50 +0100 |
commit | ba5e7012b1c4cec7f3cfcee662273d4b960e497d (patch) | |
tree | 1b7b5829f2b5711a7c1dd657fcc530c2122a8e6a /gtk/gtkstyleproperties.c | |
parent | 38a9b28a0edfdf8fd6749815bfc3c8edf457e3ec (diff) | |
download | gtk+-ba5e7012b1c4cec7f3cfcee662273d4b960e497d.tar.gz |
css: Redo StyleProvider interface
We now use the GtkStleProviderPrivate interface, which hopefully is
faster and more conformant to CSS. Long term, it definitely should be
both.
I would have liked to split this up into multiple commits, but couldn't
find a way.
Diffstat (limited to 'gtk/gtkstyleproperties.c')
-rw-r--r-- | gtk/gtkstyleproperties.c | 63 |
1 files changed, 60 insertions, 3 deletions
diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c index 5470bf5829..f2b6b7d23c 100644 --- a/gtk/gtkstyleproperties.c +++ b/gtk/gtkstyleproperties.c @@ -35,6 +35,7 @@ #include "gtkborderimageprivate.h" #include "gtkstylepropertyprivate.h" +#include "gtkstyleproviderprivate.h" #include "gtkintl.h" #include "gtkwin32themeprivate.h" @@ -76,15 +77,20 @@ struct _GtkStylePropertiesPrivate { GHashTable *color_map; GHashTable *properties; + GtkSymbolicColorLookupFunc color_lookup_func; + gpointer color_lookup_data; }; -static void gtk_style_properties_provider_init (GtkStyleProviderIface *iface); -static void gtk_style_properties_finalize (GObject *object); +static void gtk_style_properties_provider_init (GtkStyleProviderIface *iface); +static void gtk_style_properties_provider_private_init (GtkStyleProviderPrivateInterface *iface); +static void gtk_style_properties_finalize (GObject *object); G_DEFINE_TYPE_EXTENDED (GtkStyleProperties, gtk_style_properties, G_TYPE_OBJECT, 0, G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER, - gtk_style_properties_provider_init)); + gtk_style_properties_provider_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER_PRIVATE, + gtk_style_properties_provider_private_init)); static void gtk_style_properties_class_init (GtkStylePropertiesClass *klass) @@ -293,6 +299,57 @@ gtk_style_properties_provider_init (GtkStyleProviderIface *iface) iface->get_style = gtk_style_properties_get_style; } +static GtkSymbolicColor * +gtk_style_properties_provider_get_color (GtkStyleProviderPrivate *provider, + const char *name) +{ + return gtk_style_properties_lookup_color (GTK_STYLE_PROPERTIES (provider), name); +} + +static void +gtk_style_properties_provider_lookup (GtkStyleProviderPrivate *provider, + GtkWidgetPath *path, + GtkStateFlags state, + GtkCssLookup *lookup) +{ + GtkStyleProperties *props; + GtkStylePropertiesPrivate *priv; + GHashTableIter iter; + gpointer key, value; + + props = GTK_STYLE_PROPERTIES (provider); + priv = props->priv; + + /* Merge symbolic style properties */ + g_hash_table_iter_init (&iter, priv->properties); + + while (g_hash_table_iter_next (&iter, &key, &value)) + { + GtkStyleProperty *prop = key; + PropertyData *data = value; + const GValue *value; + guint id; + + id = _gtk_style_property_get_id (prop); + + if (!_gtk_css_lookup_is_missing (lookup, id)) + continue; + + value = property_data_match_state (data, state); + if (value == NULL) + continue; + + _gtk_css_lookup_set (lookup, id, value); + } +} + +static void +gtk_style_properties_provider_private_init (GtkStyleProviderPrivateInterface *iface) +{ + iface->get_color = gtk_style_properties_provider_get_color; + iface->lookup = gtk_style_properties_provider_lookup; +} + /* Property registration functions */ /** |