[gtk+/parser] API: Add API to set style properties to be inherit



commit e6ef8e5257be496f61da295d8f931be55ff00772
Author: Benjamin Otte <otte redhat com>
Date:   Mon May 16 19:31:47 2011 +0200

    API: Add API to set style properties to be inherit
    
    The API is not used anywhere yet.

 docs/reference/gtk/gtk3-sections.txt |    2 +
 gtk/gtk.symbols                      |    2 +
 gtk/gtkstyleproperties.c             |   48 ++++++++++++++++++++++++++++++++++
 gtk/gtkstyleproperties.h             |    4 +++
 4 files changed, 56 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index 242e582..291b219 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -5487,6 +5487,8 @@ gtk_style_properties_map_color
 gtk_style_properties_merge
 gtk_style_properties_new
 GtkStylePropertyParser
+gtk_style_param_set_inherit
+gtk_style_param_get_inherit
 gtk_style_properties_register_property
 gtk_style_properties_set
 gtk_style_properties_set_property
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index ee492ff..88e2e7a 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -2520,6 +2520,8 @@ gtk_style_has_context
 gtk_style_lookup_color
 gtk_style_lookup_icon_set
 gtk_style_new
+gtk_style_param_get_inherit
+gtk_style_param_set_inherit
 gtk_style_properties_clear
 gtk_style_properties_get
 gtk_style_properties_get_property
diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c
index 38ededc..28c2d9a 100644
--- a/gtk/gtkstyleproperties.c
+++ b/gtk/gtkstyleproperties.c
@@ -523,6 +523,54 @@ gtk_style_properties_lookup_property (const gchar             *property_name,
   return found;
 }
 
+/* GParamSpec functionality */
+
+enum {
+  GTK_STYLE_PROPERTY_INHERIT = 1 << G_PARAM_USER_SHIFT
+};
+
+/**
+ * gtk_style_param_set_inherit:
+ * @pspec: A style param
+ * @inherit: whether the @pspec value should be inherited
+ *
+ * Sets whether a param spec installed with function such as
+ * gtk_style_properties_register_property() or
+ * gtk_widget_class_install_style_property() should inherit their
+ * value from the parent widget if it is not set instead of using
+ * the default value of @pspec. See the
+ * <ulink url="http://www.w3.org/TR/CSS21/cascade.html#inheritance";>
+ * CSS specification's description of inheritance</ulink> for a
+ * longer description of this concept.
+ *
+ * By default, param specs do not inherit their value.
+ **/
+void
+gtk_style_param_set_inherit (GParamSpec *pspec,
+                             gboolean    inherit)
+{
+  if (inherit)
+    pspec->flags |= GTK_STYLE_PROPERTY_INHERIT;
+  else
+    pspec->flags &= ~GTK_STYLE_PROPERTY_INHERIT;
+}
+
+/**
+ * gtk_style_param_get_inherit:
+ * @pspec: a style param
+ *
+ * Checks if the value of this param should be inherited from the parent
+ * #GtkWidget instead of using the default value when it has not been
+ * specified. See gtk_style_param_set_inherit() for more details.
+ *
+ * Returns: %TRUE if the param should inherit its value
+ **/
+gboolean
+gtk_style_param_get_inherit (GParamSpec *pspec)
+{
+  return (pspec->flags & GTK_STYLE_PROPERTY_INHERIT) ? TRUE : FALSE;
+}
+
 /* GtkStyleProperties methods */
 
 /**
diff --git a/gtk/gtkstyleproperties.h b/gtk/gtkstyleproperties.h
index 0cc4788..a38905e 100644
--- a/gtk/gtkstyleproperties.h
+++ b/gtk/gtkstyleproperties.h
@@ -66,6 +66,10 @@ typedef gboolean (* GtkStylePropertyParser) (const gchar  *string,
 
 GType gtk_style_properties_get_type (void) G_GNUC_CONST;
 
+void     gtk_style_param_set_inherit            (GParamSpec             *pspec,
+                                                 gboolean                inherit);
+gboolean gtk_style_param_get_inherit            (GParamSpec             *pspec);
+
 /* Functions to register style properties */
 void     gtk_style_properties_register_property (GtkStylePropertyParser  parse_func,
                                                  GParamSpec             *pspec);



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