[glib/g-property: 11/22] gparam: Introduce nick and blurb setters



commit 3061b65fc3cf577b274e0a30c7ef64a27021b9c0
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Mon Jun 6 16:21:15 2011 +0100

    gparam: Introduce nick and blurb setters
    
    Instead of having them on GProperty, let's add the static nick and blurb
    setters where they belong, i.e. GParamSpec.

 gobject/gobject.symbols |    2 +
 gobject/gparam.c        |   64 +++++++++++++++++++++++++++++++++++++++++++++++
 gobject/gparam.h        |    9 +++++-
 3 files changed, 73 insertions(+), 2 deletions(-)
---
diff --git a/gobject/gobject.symbols b/gobject/gobject.symbols
index 6098c8a..5b516c4 100644
--- a/gobject/gobject.symbols
+++ b/gobject/gobject.symbols
@@ -188,6 +188,8 @@ g_param_spec_steal_qdata
 g_param_spec_set_qdata
 g_param_spec_set_qdata_full
 g_param_spec_get_qdata
+g_param_spec_set_static_nick
+g_param_spec_set_static_blurb
 g_param_value_convert
 g_param_value_defaults
 g_param_values_cmp
diff --git a/gobject/gparam.c b/gobject/gparam.c
index cc84581..5ad8b18 100644
--- a/gobject/gparam.c
+++ b/gobject/gparam.c
@@ -339,6 +339,70 @@ g_param_spec_get_blurb (GParamSpec *pspec)
   return NULL;
 }
 
+/**
+ * g_param_spec_set_static_nick:
+ * @pspec: a #GParamSpec
+ * @nick: the user-readable, and possibly translatable, name of the
+ *   #GParamSpec
+ *
+ * Sets a static string as the name of the #GParamSpec, for introspection
+ * purposes. The @nick string should be static and exist for the duration
+ * of the process.
+ *
+ * This function can only be called once, or if no nick was passed to
+ * g_param_spec_internal().
+ *
+ * Since: 2.30
+ */
+void
+g_param_spec_set_static_nick (GParamSpec *pspec,
+                              const char *nick)
+{
+  g_return_if_fail (G_IS_PARAM_SPEC (pspec));
+  g_return_if_fail (nick != NULL);
+
+  if (pspec->_nick != NULL)
+    {
+      g_critical (G_STRLOC ": Redefining the nick of a property is not allowed");
+      return;
+    }
+
+  pspec->_nick = (gchar *) nick;
+  pspec->flags |= G_PARAM_STATIC_NICK;
+}
+
+/**
+ * g_param_spec_set_static_blurb:
+ * @pspec: a #GParamSpec
+ * @blurb: the user-readable, and possibly translatable, description of the
+ *   #GParamSpec
+ *
+ * Sets a static string as the description of the #GParamSpec, for
+ * introspection purposes. The @blurb string should be static and exist for
+ * the duration of the process.
+ *
+ * This function can only be called once, or if no blurb was passed to
+ * g_param_spec_internal().
+ *
+ * Since: 2.30
+ */
+void
+g_param_spec_set_static_blurb (GParamSpec *pspec,
+                               const char *blurb)
+{
+  g_return_if_fail (G_IS_PARAM_SPEC (pspec));
+  g_return_if_fail (blurb != NULL);
+
+  if (pspec->_blurb != NULL)
+    {
+      g_critical (G_STRLOC ": Redefining the blurb of a property is not allowed");
+      return;
+    }
+
+  pspec->_blurb = (gchar *) blurb;
+  pspec->flags |= G_PARAM_STATIC_BLURB;
+}
+
 static void
 canonicalize_key (gchar *key)
 {
diff --git a/gobject/gparam.h b/gobject/gparam.h
index 5ee41ab..0bfe4ac 100644
--- a/gobject/gparam.h
+++ b/gobject/gparam.h
@@ -25,7 +25,7 @@
 #ifndef __G_PARAM_H__
 #define __G_PARAM_H__
 
-#include	<gobject/gvalue.h>
+#include <gobject/gvalue.h>
 
 G_BEGIN_DECLS
 
@@ -304,12 +304,17 @@ gint		g_param_values_cmp		(GParamSpec    *pspec,
 const gchar *   g_param_spec_get_name           (GParamSpec    *pspec);
 const gchar *   g_param_spec_get_nick           (GParamSpec    *pspec);
 const gchar *   g_param_spec_get_blurb          (GParamSpec    *pspec);
+
+void            g_param_spec_set_static_nick    (GParamSpec    *pspec,
+                                                 const char    *nick);
+void            g_param_spec_set_static_blurb   (GParamSpec    *pspec,
+                                                 const char    *blurb);
+
 void            g_value_set_param               (GValue	       *value,
 						 GParamSpec    *param);
 GParamSpec*     g_value_get_param               (const GValue  *value);
 GParamSpec*     g_value_dup_param               (const GValue  *value);
 
-
 void           g_value_take_param               (GValue        *value,
 					         GParamSpec    *param);
 #ifndef G_DISABLE_DEPRECATED



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