[gtk+/gtk-style-context: 112/260] GtkStyleContext: Add gtk_style_context_lookup_icon_set().
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-style-context: 112/260] GtkStyleContext: Add gtk_style_context_lookup_icon_set().
- Date: Wed, 20 Oct 2010 10:30:51 +0000 (UTC)
commit f8ce57c2c8fe805e867cc88e733514fa9854375a
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Jun 27 19:37:34 2010 +0200
GtkStyleContext: Add gtk_style_context_lookup_icon_set().
gtk/gtkstylecontext.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++
gtk/gtkstylecontext.h | 4 +++
2 files changed, 65 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 91ff093..4dd2bfe 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -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,
diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h
index a968f00..a8fae59 100644
--- a/gtk/gtkstylecontext.h
+++ b/gtk/gtkstylecontext.h
@@ -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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]