[nautilus-actions] NADataBoxed and NADataType are deprecated in favor of NABoxed
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] NADataBoxed and NADataType are deprecated in favor of NABoxed
- Date: Wed, 19 Jan 2011 21:51:09 +0000 (UTC)
commit 1a74da13c7092a07d6a320d3e517ea1343965a0e
Author: Pierre <pierre vfedora13 virtuals pwi>
Date: Wed Jan 12 12:08:16 2011 +0100
NADataBoxed and NADataType are deprecated in favor of NABoxed
ChangeLog | 9 ++
src/api/na-boxed.h | 34 ++++++++-
src/api/na-data-boxed.h | 30 +------
src/api/na-data-types.h | 8 ++-
src/core/na-boxed.c | 185 +++++++++++++++++++++++-----------------------
src/core/na-data-boxed.c | 30 ++++++++
src/core/na-data-types.c | 44 ++---------
7 files changed, 180 insertions(+), 160 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c36f3ab..f1f10df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -35,6 +35,15 @@
* run-autogen.sh: Add sysconfdir argument to autogen.sh
+ * src/api/na-boxed.h:
+ * src/api/na-data-boxed.h:
+ * src/api/na-data-types.h:
+ * src/core/na-boxed.c:
+ * src/core/na-data-boxed.c:
+ * src/core/na-data-types.c:
+ Update reference documentation to deprecate NADataBoxed and NADataType
+ in favor of NABoxed.
+
* src/core/na-settings.c:
* src/core/na-settings.h: Configuration monitoring.
diff --git a/src/api/na-boxed.h b/src/api/na-boxed.h
index af39c68..17b9e01 100644
--- a/src/api/na-boxed.h
+++ b/src/api/na-boxed.h
@@ -47,6 +47,35 @@
G_BEGIN_DECLS
+/**
+ * NABoxedType:
+ * @NA_BOXED_TYPE_STRING: an ASCII string
+ * @NA_BOXED_TYPE_LOCALE_STRING: a localized UTF-8 string
+ * @NA_BOXED_TYPE_BOOLEAN: a boolean
+ * @NA_BOXED_TYPE_STRING_LIST: a list of ASCII strings
+ * @NA_BOXED_TYPE_POINTER: a ( void * ) pointer
+ * @NA_BOXED_TYPE_UINT: an unsigned integer
+ * @NA_BOXED_TYPE_UINT_LIST: a list of unsigned integers
+ *
+ * Each #NABoxed structure is typed at creation time with one of these
+ * elementary types. A #NABoxed structure as so at least a defined type,
+ * even if it does not yet have a value.
+ *
+ * <note>
+ * <para>
+ * Please note that this enumeration may be compiled in by the extensions.
+ * They must so remain fixed, unless you want see strange effects (e.g.
+ * an extension has been compiled with %NA_BOXED_TYPE_STRING = 2, while
+ * you have inserted another element, making it to 3 !) - or you know what
+ * you are doing...
+ * </para>
+ * <para>
+ * So, only add new items at the end of the enum. You have been warned!
+ * </para>
+ * </note>
+ *
+ * Since: 3.1.0
+ */
typedef enum {
NA_BOXED_TYPE_STRING = 1,
NA_BOXED_TYPE_LOCALE_STRING,
@@ -55,7 +84,8 @@ typedef enum {
NA_BOXED_TYPE_POINTER,
NA_BOXED_TYPE_UINT,
NA_BOXED_TYPE_UINT_LIST,
- /* count of defined NABoxed types */
+ /*< private >*/
+ /* the count of defined NABoxed types */
NA_BOXED_TYPE_N
}
NABoxedType;
@@ -72,8 +102,6 @@ gboolean na_boxed_get_boolean ( const NABoxed *boxed );
gconstpointer na_boxed_get_pointer ( const NABoxed *boxed );
GSList *na_boxed_get_string_list ( const NABoxed *boxed );
-const gchar *na_boxed_get_type_label ( guint type );
-
G_END_DECLS
#endif /* __NAUTILUS_ACTIONS_API_NA_BOXED_H__ */
diff --git a/src/api/na-data-boxed.h b/src/api/na-data-boxed.h
index d2067c8..f76681a 100644
--- a/src/api/na-data-boxed.h
+++ b/src/api/na-data-boxed.h
@@ -40,31 +40,11 @@
* The object which encapsulates an elementary data of #NAIFactoryObject.
* A #NADataBoxed object has a type and a value.
*
- * <refsect2>
- * <title>Versions historic</title>
- * <table>
- * <title>Historic of the versions of the #NADataBoxed interface</title>
- * <tgroup rowsep="1" colsep="1" align="center" cols="3">
- * <colspec colname="na-version" />
- * <colspec colname="api-version" />
- * <colspec colname="current" />
- * <thead>
- * <row>
- * <entry>&prodname; version</entry>
- * <entry>#NADataBoxed interface version</entry>
- * <entry></entry>
- * </row>
- * </thead>
- * <tbody>
- * <row>
- * <entry>since 2.30</entry>
- * <entry>1</entry>
- * <entry>current version</entry>
- * </row>
- * </tbody>
- * </tgroup>
- * </table>
- * </refsect2>
+ * Starting with version 3.1.0, #NAFactoryDataType is deprecated in favour
+ * of #NABoxed structure. New code should only use #NABoxed structure and
+ * accessors.
+ *
+ * Deprecated: 3.1.0
*/
#include <glib-object.h>
diff --git a/src/api/na-data-types.h b/src/api/na-data-types.h
index 16b40b0..4c82c1e 100644
--- a/src/api/na-data-types.h
+++ b/src/api/na-data-types.h
@@ -69,6 +69,12 @@ G_BEGIN_DECLS
* So, only add new items at the end of the enum. You have been warned!
* </para>
* </note>
+ *
+ * Starting with version 3.1.0, #NAFactoryDataType is deprecated in favour
+ * of #NABoxed structure. New code should only use #NABoxed structure and
+ * accessors.
+ *
+ * Deprecated: 3.1.0
*/
typedef enum {
NAFD_TYPE_STRING = 1,
@@ -82,8 +88,6 @@ typedef enum {
const gchar *na_data_types_get_gconf_dump_key( guint type );
-const gchar *na_data_types_get_label( guint type );
-
G_END_DECLS
#endif /* __NAUTILUS_ACTIONS_API_NA_FACTORY_DATA_TYPES_H__ */
diff --git a/src/core/na-boxed.c b/src/core/na-boxed.c
index cb78247..1aff985 100644
--- a/src/core/na-boxed.c
+++ b/src/core/na-boxed.c
@@ -66,9 +66,10 @@ typedef struct {
gpointer ( *get_pointer ) ( const NABoxed * );
GSList * ( *get_string_list )( const NABoxed * );
}
- BoxedFn;
+ BoxedDef;
-static BoxedFn *get_boxed_fn( guint type );
+static const BoxedDef *get_boxed_def( guint type );
+static const gchar *get_type_label( guint type );
static int string_compare( const NABoxed *a, const NABoxed *b );
static void string_copy( NABoxed *dest, const NABoxed *src );
@@ -104,7 +105,7 @@ static void uint_list_from_string( NABoxed *boxed, const gchar *string );
static void uint_list_from_array( NABoxed *boxed, const gchar **array );
static gpointer uint_list_get_pointer( const NABoxed *boxed );
-static BoxedFn st_boxed_fn[] = {
+static BoxedDef st_boxed_def[] = {
{ NA_BOXED_TYPE_STRING,
"string",
string_compare,
@@ -163,26 +164,51 @@ static BoxedFn st_boxed_fn[] = {
{ 0 }
};
-static BoxedFn *
-get_boxed_fn( guint type )
+static const BoxedDef *
+get_boxed_def( guint type )
{
- static const gchar *thisfn = "na_boxed_get_boxed_fn";
- int i;
- BoxedFn *fn;
+ static const gchar *thisfn = "na_boxed_get_boxed_def";
+ BoxedDef *def;
- fn = NULL;
-
- for( i = 0 ; st_boxed_fn[i].type && !fn ; ++i ){
- if( st_boxed_fn[i].type == type ){
- fn = st_boxed_fn+i;
+ def = st_boxed_def;
+ while( def->type ){
+ if( def->type == type ){
+ return( def );
}
+ def++;
}
- if( !fn ){
- g_warning( "%s: unmanaged type: %d", thisfn, type );
+ g_warning( "%s: unmanaged NABoxed type: %d", thisfn, type );
+ return( NULL );
+}
+
+/*
+ * get_type_label:
+ * @type: the #NABoxed type.
+ *
+ * Returns: the label of this type.
+ *
+ * The returned label is owned by the data factory management system, and
+ * should not be released by the caller.
+ *
+ * Since: 3.1.0
+ */
+static const gchar *
+get_type_label( guint type )
+{
+ static const gchar *thisfn = "na_boxed_get_type_label";
+ BoxedDef *def;
+
+ def = st_boxed_def;
+ while( def->type ){
+ if( def->type == type ){
+ return( def->label );
+ }
+ def++;
}
- return( fn );
+ g_warning( "%s: unmanaged NABoxed type: %d", thisfn, type );
+ return( NULL );
}
/**
@@ -199,14 +225,14 @@ int
na_boxed_compare( const NABoxed *a, const NABoxed *b )
{
static const gchar *thisfn = "na_boxed_compare";
- BoxedFn *fn;
+ const BoxedDef *def;
int result;
result = 0;
if( a->type != b->type ){
g_warning( "%s: unable to compare: a is of type '%s' while b is of type %s",
- thisfn, na_boxed_get_type_label( a->type ), na_boxed_get_type_label( b->type ));
+ thisfn, get_type_label( a->type ), get_type_label( b->type ));
} else if( a->is_set && !b->is_set ){
result = 1;
@@ -215,13 +241,13 @@ na_boxed_compare( const NABoxed *a, const NABoxed *b )
result = -1;
} else if( a->is_set && b->is_set ){
- fn = get_boxed_fn( a->type );
- if( fn ){
- if( fn->compare ){
- result = ( *fn->compare )( a, b );
+ def = get_boxed_def( a->type );
+ if( def ){
+ if( def->compare ){
+ result = ( *def->compare )( a, b );
} else {
g_warning( "%s: unable to compare: '%s' type does not provide 'compare' function",
- thisfn, fn->label );
+ thisfn, def->label );
}
}
}
@@ -243,21 +269,21 @@ na_boxed_copy( const NABoxed *boxed )
{
static const gchar *thisfn = "na_boxed_copy";
NABoxed *dest;
- BoxedFn *fn;
+ const BoxedDef *def;
dest = NULL;
- fn = get_boxed_fn( boxed->type );
- if( fn ){
- if( fn->copy ){
+ def = get_boxed_def( boxed->type );
+ if( def ){
+ if( def->copy ){
dest = g_new0( NABoxed, 1 );
dest->type = boxed->type;
dest->is_set = FALSE;
if( boxed->is_set ){
- ( *fn->copy )( dest, boxed );
+ ( *def->copy )( dest, boxed );
}
} else {
g_warning( "%s: unable to copy: '%s' type does not provide 'copy' function",
- thisfn, fn->label );
+ thisfn, def->label );
}
}
@@ -279,16 +305,16 @@ void
na_boxed_free( NABoxed *boxed )
{
static const gchar *thisfn = "na_boxed_free";
- BoxedFn *fn;
+ const BoxedDef *def;
- fn = get_boxed_fn( boxed->type );
- if( fn ){
- if( fn->free ){
- ( *fn->free )( boxed );
+ def = get_boxed_def( boxed->type );
+ if( def ){
+ if( def->free ){
+ ( *def->free )( boxed );
g_free( boxed );
} else {
g_warning( "%s: unable to free the content: '%s' type does not provide 'free' function",
- thisfn, fn->label );
+ thisfn, def->label );
}
}
}
@@ -310,19 +336,19 @@ NABoxed *
na_boxed_new_from_string( guint type, const gchar *string )
{
static const gchar *thisfn = "na_boxed_new_from_string";
- BoxedFn *fn;
+ const BoxedDef *def;
NABoxed *boxed;
boxed = NULL;
- fn = get_boxed_fn( type );
- if( fn ){
- if( fn->from_string ){
+ def = get_boxed_def( type );
+ if( def ){
+ if( def->from_string ){
boxed = g_new0( NABoxed, 1 );
boxed->type = type;
- ( *fn->from_string )( boxed, string );
+ ( *def->from_string )( boxed, string );
} else {
g_warning( "%s: unable to initialize the content: '%s' type does not provide 'from_string' function",
- thisfn, fn->label );
+ thisfn, def->label );
}
}
@@ -349,22 +375,22 @@ NABoxed *
na_boxed_new_from_string_with_sep( guint type, const gchar *string, const gchar *sep )
{
static const gchar *thisfn = "na_boxed_new_from_string_with_sep";
- BoxedFn *fn;
+ const BoxedDef *def;
NABoxed *boxed;
gchar **array;
boxed = NULL;
- fn = get_boxed_fn( type );
- if( fn ){
- if( fn->from_array ){
+ def = get_boxed_def( type );
+ if( def ){
+ if( def->from_array ){
boxed = g_new0( NABoxed, 1 );
boxed->type = type;
array = string ? g_strsplit( string, sep, -1 ) : NULL;
- ( *fn->from_array )( boxed, ( const gchar ** ) array );
+ ( *def->from_array )( boxed, ( const gchar ** ) array );
g_strfreev( array );
} else {
g_warning( "%s: unable to initialize the content: '%s' type does not provide 'from_array' function",
- thisfn, fn->label );
+ thisfn, def->label );
}
}
@@ -384,18 +410,18 @@ gboolean
na_boxed_get_boolean( const NABoxed *boxed )
{
static const gchar *thisfn = "na_boxed_get_boolean";
- BoxedFn *fn;
+ const BoxedDef *def;
gboolean value;
value = FALSE;
if( boxed->is_set ){
- fn = get_boxed_fn( boxed->type );
- if( fn ){
- if( fn->get_bool ){
- value = ( *fn->get_bool )( boxed );
+ def = get_boxed_def( boxed->type );
+ if( def ){
+ if( def->get_bool ){
+ value = ( *def->get_bool )( boxed );
} else {
g_warning( "%s: unable to get the value: '%s' type does not provide 'get_bool' function",
- thisfn, fn->label );
+ thisfn, def->label );
}
}
}
@@ -416,18 +442,18 @@ gconstpointer
na_boxed_get_pointer( const NABoxed *boxed )
{
static const gchar *thisfn = "na_boxed_get_pointer";
- BoxedFn *fn;
+ const BoxedDef *def;
gpointer value;
value = NULL;
if( boxed->is_set ){
- fn = get_boxed_fn( boxed->type );
- if( fn ){
- if( fn->get_pointer ){
- value = ( *fn->get_pointer )( boxed );
+ def = get_boxed_def( boxed->type );
+ if( def ){
+ if( def->get_pointer ){
+ value = ( *def->get_pointer )( boxed );
} else {
g_warning( "%s: unable to get the value: '%s' type does not provide 'get_pointer' function",
- thisfn, fn->label );
+ thisfn, def->label );
}
}
}
@@ -448,18 +474,18 @@ GSList *
na_boxed_get_string_list( const NABoxed *boxed )
{
static const gchar *thisfn = "na_boxed_get_string_list";
- BoxedFn *fn;
+ const BoxedDef *def;
GSList *value;
value = NULL;
if( boxed->is_set ){
- fn = get_boxed_fn( boxed->type );
- if( fn ){
- if( fn->get_string_list ){
- value = ( *fn->get_string_list )( boxed );
+ def = get_boxed_def( boxed->type );
+ if( def ){
+ if( def->get_string_list ){
+ value = ( *def->get_string_list )( boxed );
} else {
g_warning( "%s: unable to get the value: '%s' type does not provide 'get_string_list' function",
- thisfn, fn->label );
+ thisfn, def->label );
}
}
}
@@ -467,35 +493,6 @@ na_boxed_get_string_list( const NABoxed *boxed )
return( value );
}
-/**
- * na_boxed_get_type_label:
- * @type: the #NABoxed type.
- *
- * Returns: the label of this type.
- *
- * The returned label is owned by the dat factory management system, and
- * should not be released by the caller.
- *
- * Since: 3.1.0
- */
-const gchar *
-na_boxed_get_type_label( guint type )
-{
- static const gchar *thisfn = "na_boxed_get_type_label";
- BoxedFn *str;
-
- str = st_boxed_fn;
- while( str->type ){
- if( str->type == type ){
- return( str->label );
- }
- str++;
- }
-
- g_warning( "%s: unmanaged NABoxed type: %d", thisfn, type );
- return( NULL );
-}
-
static int
string_compare( const NABoxed *a, const NABoxed *b )
{
diff --git a/src/core/na-data-boxed.c b/src/core/na-data-boxed.c
index 7ad40d8..f7d58a4 100644
--- a/src/core/na-data-boxed.c
+++ b/src/core/na-data-boxed.c
@@ -407,6 +407,8 @@ get_data_boxed_fn( guint type )
* Returns: a #GParamSpec structure.
*
* Since: 2.30
+ *
+ * Deprecated: 3.1.0
*/
GParamSpec *
na_data_boxed_get_param_spec( const NADataDef *def )
@@ -435,6 +437,8 @@ na_data_boxed_get_param_spec( const NADataDef *def )
* Returns: a newly allocated #NADataBoxed.
*
* Since: 2.30
+ *
+ * Deprecated: 3.1.0
*/
NADataBoxed *
na_data_boxed_new( const NADataDef *def )
@@ -458,6 +462,8 @@ na_data_boxed_new( const NADataDef *def )
* Should never be %NULL.
*
* Since: 2.30
+ *
+ * Deprecated: 3.1.0
*/
NADataDef *
na_data_boxed_get_data_def( const NADataBoxed *boxed )
@@ -484,6 +490,8 @@ na_data_boxed_get_data_def( const NADataBoxed *boxed )
* Returns: %TRUE if the two boxeds are equal, %FALSE else.
*
* Since: 2.30
+ *
+ * Deprecated: 3.1.0
*/
gboolean
na_data_boxed_are_equal( const NADataBoxed *a, const NADataBoxed *b )
@@ -522,6 +530,8 @@ na_data_boxed_are_equal( const NADataBoxed *a, const NADataBoxed *b )
* %FALSE else.
*
* Since: 2.30
+ *
+ * Deprecated: 3.1.0
*/
gboolean
na_data_boxed_is_default( const NADataBoxed *boxed )
@@ -554,6 +564,8 @@ na_data_boxed_is_default( const NADataBoxed *boxed )
* Returns: %TRUE if the boxed is valid, %FALSE else.
*
* Since: 2.30
+ *
+ * Deprecated: 3.1.0
*/
gboolean
na_data_boxed_is_valid( const NADataBoxed *boxed )
@@ -586,6 +598,8 @@ na_data_boxed_is_valid( const NADataBoxed *boxed )
* Dump the content of @boxed.
*
* Since: 2.30
+ *
+ * Deprecated: 3.1.0
*/
void
na_data_boxed_dump( const NADataBoxed *boxed )
@@ -611,6 +625,8 @@ na_data_boxed_dump( const NADataBoxed *boxed )
* -> value is unchanged.
*
* Since: 2.30
+ *
+ * Deprecated: 3.1.0
*/
void
na_data_boxed_set_data_def( NADataBoxed *boxed, const NADataDef *new_def )
@@ -633,6 +649,8 @@ na_data_boxed_set_data_def( NADataBoxed *boxed, const NADataDef *new_def )
* should be g_free() by the caller.
*
* Since: 2.30
+ *
+ * Deprecated: 3.1.0
*/
gchar *
na_data_boxed_get_as_string( const NADataBoxed *boxed )
@@ -669,6 +687,8 @@ na_data_boxed_get_as_string( const NADataBoxed *boxed )
* allocated value, which should be released by the caller.
*
* Since: 2.30
+ *
+ * Deprecated: 3.1.0
*/
void *
na_data_boxed_get_as_void( const NADataBoxed *boxed )
@@ -702,6 +722,8 @@ na_data_boxed_get_as_void( const NADataBoxed *boxed )
* Setup @value with the content of the @boxed.
*
* Since: 2.30
+ *
+ * Deprecated: 3.1.0
*/
void
na_data_boxed_get_as_value( const NADataBoxed *boxed, GValue *value )
@@ -730,6 +752,8 @@ na_data_boxed_get_as_value( const NADataBoxed *boxed, GValue *value )
* Copy value from @value to @boxed.
*
* Since: 2.30
+ *
+ * Deprecated: 3.1.0
*/
void
na_data_boxed_set_from_boxed( NADataBoxed *boxed, const NADataBoxed *value )
@@ -763,6 +787,8 @@ na_data_boxed_set_from_boxed( NADataBoxed *boxed, const NADataBoxed *value )
* Evaluates the @value and set it to the @boxed.
*
* Since: 2.30
+ *
+ * Deprecated: 3.1.0
*/
void
na_data_boxed_set_from_string( NADataBoxed *boxed, const gchar *value )
@@ -794,6 +820,8 @@ na_data_boxed_set_from_string( NADataBoxed *boxed, const gchar *value )
* Evaluates the @value and set it to the @boxed.
*
* Since: 2.30
+ *
+ * Deprecated: 3.1.0
*/
void
na_data_boxed_set_from_value( NADataBoxed *boxed, const GValue *value )
@@ -825,6 +853,8 @@ na_data_boxed_set_from_value( NADataBoxed *boxed, const GValue *value )
* Evaluates the @value and set it to the @boxed.
*
* Since: 2.30
+ *
+ * Deprecated: 3.1.0
*/
void
na_data_boxed_set_from_void( NADataBoxed *boxed, const void *value )
diff --git a/src/core/na-data-types.c b/src/core/na-data-types.c
index 68e79b9..2647358 100644
--- a/src/core/na-data-types.c
+++ b/src/core/na-data-types.c
@@ -37,18 +37,17 @@
typedef struct {
guint type;
- gchar *label;
gchar *gconf_dump_key;
}
FactoryType;
static FactoryType st_factory_type[] = {
- { NAFD_TYPE_STRING, "string", "string" },
- { NAFD_TYPE_LOCALE_STRING, "locale string", "string" },
- { NAFD_TYPE_BOOLEAN, "bool", "bool" },
- { NAFD_TYPE_STRING_LIST, "string list", "list" },
- { NAFD_TYPE_POINTER, "pointer", NULL },
- { NAFD_TYPE_UINT, "uint", "int" },
+ { NAFD_TYPE_STRING, "string" },
+ { NAFD_TYPE_LOCALE_STRING, "string" },
+ { NAFD_TYPE_BOOLEAN, "bool" },
+ { NAFD_TYPE_STRING_LIST, "list" },
+ { NAFD_TYPE_POINTER, NULL },
+ { NAFD_TYPE_UINT, "int" },
{ 0 }
};
@@ -62,6 +61,8 @@ static FactoryType st_factory_type[] = {
* should not be released by the caller.
*
* Since: 2.30
+ *
+ * Deprecated: 3.1.0
*/
const gchar *
na_data_types_get_gconf_dump_key( guint type )
@@ -80,32 +81,3 @@ na_data_types_get_gconf_dump_key( guint type )
g_warning( "%s: unknown data type: %d", thisfn, type );
return( NULL );
}
-
-/**
- * na_data_types_get_label:
- * @type: the FactoryData type.
- *
- * Returns: the label of this type.
- *
- * The returned label is owned by the factory data management system, and
- * should not be released by the caller.
- *
- * Since: 3.1.0
- */
-const gchar *
-na_data_types_get_label( guint type )
-{
- static const gchar *thisfn = "na_data_types_get_label";
- FactoryType *str;
-
- str = st_factory_type;
- while( str->type ){
- if( str->type == type ){
- return( str->label );
- }
- str++;
- }
-
- g_warning( "%s: unknown data type: %d", thisfn, type );
- return( NULL );
-}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]