diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2010-08-02 13:58:16 +0200 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2010-12-04 15:37:23 +0100 |
commit | c71248091218455c17939cfe0d82a6fe20d4158e (patch) | |
tree | ff90ab0f91b411a7c43d5bb1f479e083bbae8c78 /gtk/gtkstylecontext.c | |
parent | 5f2e8bc0d10bd89bc4b0a7f49e1557d68313c805 (diff) | |
download | gtk+-c71248091218455c17939cfe0d82a6fe20d4158e.tar.gz |
GtkStyleContext: Add varargs functions for getting widget style properties.
Diffstat (limited to 'gtk/gtkstylecontext.c')
-rw-r--r-- | gtk/gtkstylecontext.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 63c28cae7a..f7297f71cb 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -21,6 +21,7 @@ #include <gdk/gdk.h> #include <stdlib.h> +#include <gobject/gvaluecollector.h> #include "gtkstylecontext.h" #include "gtktypebuiltins.h" @@ -1086,6 +1087,77 @@ gtk_style_context_get_style_property (GtkStyleContext *context, G_VALUE_TYPE_NAME (value)); } +void +gtk_style_context_get_style_valist (GtkStyleContext *context, + va_list args) +{ + GtkStyleContextPrivate *priv; + const gchar *prop_name; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + + prop_name = va_arg (args, const gchar *); + priv = context->priv; + + if (!priv->widget_path) + return; + + while (prop_name) + { + GtkWidgetClass *widget_class; + GParamSpec *pspec; + const GValue *peek_value; + GType widget_type; + gchar *error; + + widget_type = gtk_widget_path_get_widget_type (priv->widget_path); + + widget_class = g_type_class_ref (widget_type); + pspec = gtk_widget_class_find_style_property (widget_class, prop_name); + g_type_class_unref (widget_class); + + if (!pspec) + { + g_warning ("%s: widget class `%s' has no style property named `%s'", + G_STRLOC, + g_type_name (widget_type), + prop_name); + continue; + } + + peek_value = _gtk_style_context_peek_style_property (context, + widget_type, + pspec); + + G_VALUE_LCOPY (peek_value, args, 0, &error); + + if (error) + { + g_warning ("can't retrieve style property `%s' of type `%s': %s", + pspec->name, + G_VALUE_TYPE_NAME (peek_value), + error); + g_free (error); + } + + prop_name = va_arg (args, const gchar *); + } +} + +void +gtk_style_context_get_style (GtkStyleContext *context, + ...) +{ + va_list args; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + + va_start (args, context); + gtk_style_context_get_style_valist (context, args); + va_end (args); +} + + GtkIconSet * gtk_style_context_lookup_icon_set (GtkStyleContext *context, const gchar *stock_id) |