forked from AuroraMiddleware/gtk
GtkStyleContext: Add gtk_style_context_lookup_icon_set().
This commit is contained in:
parent
318e0f28ee
commit
a256171d34
@ -59,6 +59,8 @@ struct GtkStyleContextPrivate
|
||||
GList *providers;
|
||||
GList *providers_last;
|
||||
|
||||
GSList *icon_factories;
|
||||
|
||||
GtkStyleSet *store;
|
||||
GtkWidgetPath *widget_path;
|
||||
|
||||
@ -154,6 +156,9 @@ gtk_style_context_finalize (GObject *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);
|
||||
}
|
||||
|
||||
@ -191,6 +196,32 @@ rebuild_properties (GtkStyleContext *context)
|
||||
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
|
||||
gtk_style_context_add_provider (GtkStyleContext *context,
|
||||
GtkStyleProvider *provider,
|
||||
@ -251,6 +282,7 @@ gtk_style_context_add_provider (GtkStyleContext *context,
|
||||
{
|
||||
rebuild_properties (context);
|
||||
clear_property_cache (context);
|
||||
rebuild_icon_factories (context);
|
||||
}
|
||||
}
|
||||
|
||||
@ -296,6 +328,7 @@ gtk_style_context_remove_provider (GtkStyleContext *context,
|
||||
{
|
||||
rebuild_properties (context);
|
||||
clear_property_cache (context);
|
||||
rebuild_icon_factories (context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -425,6 +458,7 @@ gtk_style_context_set_path (GtkStyleContext *context,
|
||||
priv->widget_path = gtk_widget_path_copy (path);
|
||||
rebuild_properties (context);
|
||||
clear_property_cache (context);
|
||||
rebuild_icon_factories (context);
|
||||
}
|
||||
}
|
||||
|
||||
@ -799,6 +833,33 @@ gtk_style_context_get_style_property (GtkStyleContext *context,
|
||||
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 */
|
||||
void
|
||||
gtk_render_check (GtkStyleContext *context,
|
||||
|
@ -99,6 +99,10 @@ void gtk_style_context_get_style_property (GtkStyleContext *context,
|
||||
const gchar *property_name,
|
||||
GValue *value);
|
||||
|
||||
GtkIconSet * gtk_style_context_lookup_icon_set (GtkStyleContext *context,
|
||||
const gchar *stock_id);
|
||||
|
||||
|
||||
/* Semi-private API */
|
||||
const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context,
|
||||
GType widget_type,
|
||||
|
Loading…
Reference in New Issue
Block a user