From 51db2249d13b29b92ea996aab56ada70af3b61b2 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 6 Jun 2011 16:21:15 +0100 Subject: [PATCH] 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 1a052fd2d..e5c53cc2e 100644 --- a/gobject/gobject.symbols +++ b/gobject/gobject.symbols @@ -222,6 +222,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 b5c3024d7..53b7143d2 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 84b3c445f..00b4ad707 100644 --- a/gobject/gparam.h +++ b/gobject/gparam.h @@ -25,7 +25,7 @@ #ifndef __G_PARAM_H__ #define __G_PARAM_H__ -#include +#include 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)