Commit a256171d authored by Carlos Garnacho's avatar Carlos Garnacho

GtkStyleContext: Add gtk_style_context_lookup_icon_set().

parent 318e0f28
...@@ -59,6 +59,8 @@ struct GtkStyleContextPrivate ...@@ -59,6 +59,8 @@ struct GtkStyleContextPrivate
GList *providers; GList *providers;
GList *providers_last; GList *providers_last;
GSList *icon_factories;
GtkStyleSet *store; GtkStyleSet *store;
GtkWidgetPath *widget_path; GtkWidgetPath *widget_path;
...@@ -154,6 +156,9 @@ gtk_style_context_finalize (GObject *object) ...@@ -154,6 +156,9 @@ gtk_style_context_finalize (GObject *object)
clear_property_cache (GTK_STYLE_CONTEXT (object)); clear_property_cache (GTK_STYLE_CONTEXT (object));
g_slist_foreach (priv->icon_factories, (GFunc) g_object_unref, NULL);
g_slist_free (priv->icon_factories);
G_OBJECT_CLASS (gtk_style_context_parent_class)->finalize (object); G_OBJECT_CLASS (gtk_style_context_parent_class)->finalize (object);
} }
...@@ -191,6 +196,32 @@ rebuild_properties (GtkStyleContext *context) ...@@ -191,6 +196,32 @@ rebuild_properties (GtkStyleContext *context)
NULL); NULL);
} }
static void
rebuild_icon_factories (GtkStyleContext *context)
{
GtkStyleContextPrivate *priv;
GList *providers;
priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context);
g_slist_foreach (priv->icon_factories, (GFunc) g_object_unref, NULL);
g_slist_free (priv->icon_factories);
priv->icon_factories = NULL;
for (providers = priv->providers_last; providers; providers = providers->prev)
{
GtkIconFactory *factory;
GtkStyleProviderData *data;
data = providers->data;
factory = gtk_style_provider_get_icon_factory (data->provider,
priv->widget_path);
if (factory)
priv->icon_factories = g_slist_prepend (priv->icon_factories, factory);
}
}
void void
gtk_style_context_add_provider (GtkStyleContext *context, gtk_style_context_add_provider (GtkStyleContext *context,
GtkStyleProvider *provider, GtkStyleProvider *provider,
...@@ -251,6 +282,7 @@ gtk_style_context_add_provider (GtkStyleContext *context, ...@@ -251,6 +282,7 @@ gtk_style_context_add_provider (GtkStyleContext *context,
{ {
rebuild_properties (context); rebuild_properties (context);
clear_property_cache (context); clear_property_cache (context);
rebuild_icon_factories (context);
} }
} }
...@@ -296,6 +328,7 @@ gtk_style_context_remove_provider (GtkStyleContext *context, ...@@ -296,6 +328,7 @@ gtk_style_context_remove_provider (GtkStyleContext *context,
{ {
rebuild_properties (context); rebuild_properties (context);
clear_property_cache (context); clear_property_cache (context);
rebuild_icon_factories (context);
} }
} }
} }
...@@ -425,6 +458,7 @@ gtk_style_context_set_path (GtkStyleContext *context, ...@@ -425,6 +458,7 @@ gtk_style_context_set_path (GtkStyleContext *context,
priv->widget_path = gtk_widget_path_copy (path); priv->widget_path = gtk_widget_path_copy (path);
rebuild_properties (context); rebuild_properties (context);
clear_property_cache (context); clear_property_cache (context);
rebuild_icon_factories (context);
} }
} }
...@@ -799,6 +833,33 @@ gtk_style_context_get_style_property (GtkStyleContext *context, ...@@ -799,6 +833,33 @@ gtk_style_context_get_style_property (GtkStyleContext *context,
G_VALUE_TYPE_NAME (value)); G_VALUE_TYPE_NAME (value));
} }
GtkIconSet *
gtk_style_context_lookup_icon_set (GtkStyleContext *context,
const gchar *stock_id)
{
GtkStyleContextPrivate *priv;
GSList *list;
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
g_return_val_if_fail (stock_id != NULL, NULL);
priv = GTK_STYLE_CONTEXT_GET_PRIVATE (context);
for (list = priv->icon_factories; list; list = list->next)
{
GtkIconFactory *factory;
GtkIconSet *icon_set;
factory = list->data;
icon_set = gtk_icon_factory_lookup (factory, stock_id);
if (icon_set)
return icon_set;
}
return gtk_icon_factory_lookup_default (stock_id);
}
/* Paint methods */ /* Paint methods */
void void
gtk_render_check (GtkStyleContext *context, gtk_render_check (GtkStyleContext *context,
......
...@@ -99,6 +99,10 @@ void gtk_style_context_get_style_property (GtkStyleContext *context, ...@@ -99,6 +99,10 @@ void gtk_style_context_get_style_property (GtkStyleContext *context,
const gchar *property_name, const gchar *property_name,
GValue *value); GValue *value);
GtkIconSet * gtk_style_context_lookup_icon_set (GtkStyleContext *context,
const gchar *stock_id);
/* Semi-private API */ /* Semi-private API */
const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context, const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context,
GType widget_type, GType widget_type,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment