]> Pileus Git - ~andy/gtk/commitdiff
stylecontext: Add _gtk_style_context_peek_property()
authorBenjamin Otte <otte@redhat.com>
Tue, 3 Jan 2012 01:35:05 +0000 (02:35 +0100)
committerBenjamin Otte <otte@redhat.com>
Mon, 9 Jan 2012 17:37:56 +0000 (18:37 +0100)
This allows peeking at the computed value for a property. This is useful
for looking at GtkCssImage.

gtk/gtkstylecontext.c
gtk/gtkstylecontextprivate.h

index 6588207d92cfdbe1896860ce270ace042e65022a..be0fb8a666d9e7928774e2b4f43ac7d3db0511bb 100644 (file)
@@ -2297,6 +2297,27 @@ style_property_values_cmp (gconstpointer bsearch_node1,
   return 0;
 }
 
+const GValue *
+_gtk_style_context_peek_property (GtkStyleContext *context,
+                                  const char      *property_name)
+{
+  GtkStyleProperty *property;
+  StyleData *data;
+
+  property = _gtk_style_property_lookup (property_name);
+  if (!GTK_IS_CSS_STYLE_PROPERTY (property))
+    {
+      g_warning ("Style property \"%s\" does not exist", property_name);
+      return NULL;
+    }
+
+  data = style_data_lookup (context, gtk_style_context_get_state (context));
+
+  return _gtk_style_properties_peek_property (data->store,
+                                              GTK_CSS_STYLE_PROPERTY (property),
+                                              0);
+}
+
 const GValue *
 _gtk_style_context_peek_style_property (GtkStyleContext *context,
                                         GType            widget_type,
index 981eda76e2b23de25de33f87bd1baebba4a5b43c..ffde8db52e6225df53bbb6ebc4624f23c182e5e1 100644 (file)
@@ -25,6 +25,8 @@
 
 G_BEGIN_DECLS
 
+const GValue * _gtk_style_context_peek_property              (GtkStyleContext *context,
+                                                              const char      *property_name);
 const GValue * _gtk_style_context_peek_style_property        (GtkStyleContext *context,
                                                               GType            widget_type,
                                                               GtkStateFlags    state,