[nautilus-actions] Define new na_boxed_get_pointer() function
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Define new na_boxed_get_pointer() function
- Date: Wed, 19 Jan 2011 21:50:44 +0000 (UTC)
commit f518c1b65eab5b6437222ac4661c4eac94985513
Author: Pierre <pierre vfedora13 virtuals pwi>
Date: Wed Jan 12 11:33:20 2011 +0100
Define new na_boxed_get_pointer() function
ChangeLog | 5 +++
src/api/na-boxed.h | 15 +++++-----
src/core/na-boxed.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 86 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ace4629..1122efe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -35,6 +35,11 @@
* run-autogen.sh: Add sysconfdir argument to autogen.sh
+ * src/api/na-boxed.h:
+ * src/core/na-boxed.c (na_boxed_get_pointer): New function.
+
+ * run-autogen.sh: Add sysconfdir argument to autogen.sh.
+
* src/api/na-data-types.h:
* src/core/na-data-types.c
(na_data_types_copy, na_data_types_free): Removed functions.
diff --git a/src/api/na-boxed.h b/src/api/na-boxed.h
index 009c624..af39c68 100644
--- a/src/api/na-boxed.h
+++ b/src/api/na-boxed.h
@@ -62,14 +62,15 @@ typedef enum {
typedef struct _NABoxed NABoxed;
-int na_boxed_compare ( const NABoxed *a, const NABoxed *b );
-NABoxed *na_boxed_copy ( const NABoxed *value );
-void na_boxed_free ( NABoxed *value );
-NABoxed *na_boxed_new_from_string ( guint type, const gchar *string );
-NABoxed *na_boxed_new_from_string_with_sep( guint type, const gchar *string, const gchar *sep );
+int na_boxed_compare ( const NABoxed *a, const NABoxed *b );
+NABoxed *na_boxed_copy ( const NABoxed *value );
+void na_boxed_free ( NABoxed *value );
+NABoxed *na_boxed_new_from_string ( guint type, const gchar *string );
+NABoxed *na_boxed_new_from_string_with_sep( guint type, const gchar *string, const gchar *sep );
-gboolean na_boxed_get_boolean ( const NABoxed *boxed );
-GSList *na_boxed_get_string_list ( const NABoxed *boxed );
+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 );
diff --git a/src/core/na-boxed.c b/src/core/na-boxed.c
index 737b85b..cb78247 100644
--- a/src/core/na-boxed.c
+++ b/src/core/na-boxed.c
@@ -63,6 +63,7 @@ typedef struct {
void ( *from_string ) ( NABoxed *, const gchar * );
void ( *from_array ) ( NABoxed *, const gchar ** );
gboolean ( *get_bool ) ( const NABoxed * );
+ gpointer ( *get_pointer ) ( const NABoxed * );
GSList * ( *get_string_list )( const NABoxed * );
}
BoxedFn;
@@ -73,12 +74,14 @@ static int string_compare( const NABoxed *a, const NABoxed *b );
static void string_copy( NABoxed *dest, const NABoxed *src );
static void string_free( NABoxed *boxed );
static void string_from_string( NABoxed *boxed, const gchar *string );
+static gpointer string_get_pointer( const NABoxed *boxed );
static int string_list_compare( const NABoxed *a, const NABoxed *b );
static void string_list_copy( NABoxed *dest, const NABoxed *src );
static void string_list_free( NABoxed *boxed );
static void string_list_from_string( NABoxed *boxed, const gchar *string );
static void string_list_from_array( NABoxed *boxed, const gchar **array );
+static gpointer string_list_get_pointer( const NABoxed *boxed );
static GSList *string_list_get_string_list( const NABoxed *boxed );
static int bool_compare( const NABoxed *a, const NABoxed *b );
@@ -86,17 +89,20 @@ static void bool_copy( NABoxed *dest, const NABoxed *src );
static void bool_free( NABoxed *boxed );
static void bool_from_string( NABoxed *boxed, const gchar *string );
static gboolean bool_get_bool( const NABoxed *boxed );
+static gpointer bool_get_pointer( const NABoxed *boxed );
static int uint_compare( const NABoxed *a, const NABoxed *b );
static void uint_copy( NABoxed *dest, const NABoxed *src );
static void uint_free( NABoxed *boxed );
static void uint_from_string( NABoxed *boxed, const gchar *string );
+static gpointer uint_get_pointer( const NABoxed *boxed );
static int uint_list_compare( const NABoxed *a, const NABoxed *b );
static void uint_list_copy( NABoxed *dest, const NABoxed *src );
static void uint_list_free( NABoxed *boxed );
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[] = {
{ NA_BOXED_TYPE_STRING,
@@ -107,6 +113,7 @@ static BoxedFn st_boxed_fn[] = {
string_from_string,
NULL,
NULL,
+ string_get_pointer,
NULL
},
{ NA_BOXED_TYPE_STRING_LIST,
@@ -117,6 +124,7 @@ static BoxedFn st_boxed_fn[] = {
string_list_from_string,
string_list_from_array,
NULL,
+ string_list_get_pointer,
string_list_get_string_list
},
{ NA_BOXED_TYPE_BOOLEAN,
@@ -127,6 +135,7 @@ static BoxedFn st_boxed_fn[] = {
bool_from_string,
NULL,
bool_get_bool,
+ bool_get_pointer,
NULL
},
{ NA_BOXED_TYPE_UINT,
@@ -137,6 +146,7 @@ static BoxedFn st_boxed_fn[] = {
uint_from_string,
NULL,
NULL,
+ uint_get_pointer,
NULL
},
{ NA_BOXED_TYPE_UINT_LIST,
@@ -147,6 +157,7 @@ static BoxedFn st_boxed_fn[] = {
uint_list_from_string,
uint_list_from_array,
NULL,
+ uint_list_get_pointer,
NULL
},
{ 0 }
@@ -393,6 +404,38 @@ na_boxed_get_boolean( const NABoxed *boxed )
}
/**
+ * na_boxed_get_pointer:
+ * @boxed: the #NABoxed structure.
+ *
+ * Returns: a newly allocated string list if @boxed is of %NA_BOXED_TYPE_STRING_LIST
+ * type, which should be na_core_utils_slist_free() by the caller, %FALSE else.
+ *
+ * Since: 3.1.0
+ */
+gconstpointer
+na_boxed_get_pointer( const NABoxed *boxed )
+{
+ static const gchar *thisfn = "na_boxed_get_pointer";
+ BoxedFn *fn;
+ 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 );
+ } else {
+ g_warning( "%s: unable to get the value: '%s' type does not provide 'get_pointer' function",
+ thisfn, fn->label );
+ }
+ }
+ }
+
+ return(( gconstpointer ) value );
+}
+
+/**
* na_boxed_get_string_list:
* @boxed: the #NABoxed structure.
*
@@ -487,6 +530,12 @@ string_from_string( NABoxed *boxed, const gchar *string )
boxed->is_set = TRUE;
}
+static gpointer
+string_get_pointer( const NABoxed *boxed )
+{
+ return( boxed->u.string );
+}
+
/* the two string lists are equal if they have the same elements in the
* same order
* if not, we compare the length of the lists
@@ -564,6 +613,12 @@ string_list_from_array( NABoxed *boxed, const gchar **array )
boxed->is_set = TRUE;
}
+static gpointer
+string_list_get_pointer( const NABoxed *boxed )
+{
+ return( boxed->u.string_list );
+}
+
static GSList *
string_list_get_string_list( const NABoxed *boxed )
{
@@ -609,6 +664,12 @@ bool_get_bool( const NABoxed *boxed )
return( boxed->u.boolean );
}
+static gpointer
+bool_get_pointer( const NABoxed *boxed )
+{
+ return( GUINT_TO_POINTER( boxed->u.boolean ));
+}
+
static int
uint_compare( const NABoxed *a, const NABoxed *b )
{
@@ -641,6 +702,12 @@ uint_from_string( NABoxed *boxed, const gchar *string )
boxed->is_set = TRUE;
}
+static gpointer
+uint_get_pointer( const NABoxed *boxed )
+{
+ return( GUINT_TO_POINTER( boxed->u.uint ));
+}
+
/* compare uint list as string list:
* if the two list do not have the same count, then one is lesser than the other
* if they have same count and same elements in same order, they are equal
@@ -721,3 +788,9 @@ uint_list_from_array( NABoxed *boxed, const gchar **array )
}
boxed->is_set = TRUE;
}
+
+static gpointer
+uint_list_get_pointer( const NABoxed *boxed )
+{
+ return( boxed->u.uint_list );
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]