[gtk+/wip/css: 48/153] styleproperty: Add GtkStyleProperty::value-type



commit f020777e589e5bd080e3f75dee2792cf5a09994a
Author: Benjamin Otte <otte redhat com>
Date:   Sat Dec 31 17:36:22 2011 +0100

    styleproperty: Add GtkStyleProperty::value-type

 gtk/gtkcssshorthandpropertyimpl.c |    1 +
 gtk/gtkstyleproperty.c            |   37 ++++++++++++++++++++++++++++++++++++-
 gtk/gtkstylepropertyprivate.h     |    2 ++
 3 files changed, 39 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkcssshorthandpropertyimpl.c b/gtk/gtkcssshorthandpropertyimpl.c
index 4f2a5cc..ad47d17 100644
--- a/gtk/gtkcssshorthandpropertyimpl.c
+++ b/gtk/gtkcssshorthandpropertyimpl.c
@@ -784,6 +784,7 @@ _gtk_css_shorthand_property_register (GParamSpec               *pspec,
 
   node = g_object_new (GTK_TYPE_CSS_SHORTHAND_PROPERTY,
                        "name", pspec->name,
+                       "value-type", pspec->value_type,
                        "subproperties", subproperties,
                        NULL);
 
diff --git a/gtk/gtkstyleproperty.c b/gtk/gtkstyleproperty.c
index f7f2efe..646e5c8 100644
--- a/gtk/gtkstyleproperty.c
+++ b/gtk/gtkstyleproperty.c
@@ -54,7 +54,8 @@
 
 enum {
   PROP_0,
-  PROP_NAME
+  PROP_NAME,
+  PROP_VALUE_TYPE
 };
 
 static GHashTable *parse_funcs = NULL;
@@ -90,6 +91,9 @@ gtk_style_property_set_property (GObject      *object,
       g_assert (g_hash_table_lookup (klass->properties, property->name) == NULL);
       g_hash_table_insert (klass->properties, property->name, property);
       break;
+    case PROP_VALUE_TYPE:
+      property->value_type = g_value_get_gtype (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -109,6 +113,9 @@ gtk_style_property_get_property (GObject    *object,
     case PROP_NAME:
       g_value_set_string (value, property->name);
       break;
+    case PROP_VALUE_TYPE:
+      g_value_set_gtype (value, property->value_type);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -131,6 +138,13 @@ _gtk_style_property_class_init (GtkStylePropertyClass *klass)
                                                         P_("The name of the property"),
                                                         NULL,
                                                         G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+  g_object_class_install_property (object_class,
+                                   PROP_VALUE_TYPE,
+                                   g_param_spec_gtype ("value-type",
+                                                       P_("Value type"),
+                                                       P_("The value type returned by GtkStyleContext"),
+                                                       G_TYPE_NONE,
+                                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 
   klass->properties = g_hash_table_new (g_str_hash, g_str_equal);
 }
@@ -138,6 +152,7 @@ _gtk_style_property_class_init (GtkStylePropertyClass *klass)
 static void
 _gtk_style_property_init (GtkStyleProperty *property)
 {
+  property->value_type = G_TYPE_NONE;
 }
 
 static void
@@ -2449,6 +2464,25 @@ _gtk_style_property_get_name (GtkStyleProperty *property)
   return property->name;
 }
 
+/**
+ * _gtk_style_property_get_value_type:
+ * @property: the property to query
+ *
+ * Gets the value type of the @property, if the property is usable
+ * in public API via _gtk_style_property_assign() and
+ * _gtk_style_property_query(). If the @property is not usable in that
+ * way, %G_TYPE_NONE is returned.
+ *
+ * Returns: the value type in use or %G_TYPE_NONE if none.
+ **/
+GType
+_gtk_style_property_get_value_type (GtkStyleProperty *property)
+{
+  g_return_val_if_fail (GTK_IS_STYLE_PROPERTY (property), G_TYPE_NONE);
+
+  return property->value_type;
+}
+
 
 void
 _gtk_style_property_register (GParamSpec               *pspec,
@@ -2462,6 +2496,7 @@ _gtk_style_property_register (GParamSpec               *pspec,
 
   node = g_object_new (GTK_TYPE_CSS_STYLE_PROPERTY,
                        "name", pspec->name,
+                       "value-type", pspec->value_type,
                        NULL);
   node->flags = flags;
   node->pspec = pspec;
diff --git a/gtk/gtkstylepropertyprivate.h b/gtk/gtkstylepropertyprivate.h
index 946d2cb..a7ca9da 100644
--- a/gtk/gtkstylepropertyprivate.h
+++ b/gtk/gtkstylepropertyprivate.h
@@ -58,6 +58,7 @@ struct _GtkStyleProperty
   GObject parent;
 
   char *name;
+  GType value_type;
 
   GParamSpec               *pspec;
   GtkStylePropertyFlags     flags;
@@ -113,6 +114,7 @@ void                     _gtk_style_property_print_value   (GtkStyleProperty *
                                                             const GValue           *value,
                                                             GString                *string);
 
+GType                    _gtk_style_property_get_value_type(GtkStyleProperty *      property);
 void                     _gtk_style_property_query         (GtkStyleProperty *      property,
                                                             GtkStyleProperties     *props,
                                                             GtkStateFlags           state,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]