[glib/wip/gproperty: 11/28] gparam: Introduce nick and blurb setters
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/gproperty: 11/28] gparam: Introduce nick and blurb setters
- Date: Fri, 17 Feb 2012 15:15:45 +0000 (UTC)
commit 003094aebe325580a504d15e8f06421313590eb1
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 8331ec0..cba71f8 100644
--- a/gobject/gobject.symbols
+++ b/gobject/gobject.symbols
@@ -193,6 +193,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 b05e8c3..2c09b8a 100644
--- a/gobject/gparam.c
+++ b/gobject/gparam.c
@@ -336,6 +336,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 8357477..56547ac 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);
GLIB_DEPRECATED_FOR(g_value_take_param)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]