[nautilus-actions] Check for duplicates when managing strings lists



commit 284e76a7dc3f0a3b7587b466a7bcf30d07661cf7
Author: Pierre Wieser <pwieser trychlos org>
Date:   Mon Feb 21 06:45:17 2011 +0100

    Check for duplicates when managing strings lists

 ChangeLog           |    3 +++
 src/core/na-boxed.c |   20 ++++++++++++--------
 2 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index feed274..0c58502 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2011-02-21 Pierre Wieser <pwieser trychlos org>
 
+	* src/core/na-boxed.c (string_list_from_string,
+	string_list_from_value, string_list_from_void): Check for duplicates.
+
 	* src/utils/nautilus-actions-new.c: Fix default mimetype.
 
 	* src/core/na-icontext.c (get_running_environment): New function.
diff --git a/src/core/na-boxed.c b/src/core/na-boxed.c
index 635570c..04f6771 100644
--- a/src/core/na-boxed.c
+++ b/src/core/na-boxed.c
@@ -1153,12 +1153,12 @@ string_list_from_string( NABoxed *boxed, const gchar *string )
 	if( array ){
 		i = ( gchar ** ) array;
 		while( *i ){
-			boxed->private->u.string_list = g_slist_prepend( boxed->private->u.string_list, g_strdup( *i ));
+			if( !na_core_utils_slist_count( boxed->private->u.string_list, ( const gchar * )( *i ))){
+				boxed->private->u.string_list = g_slist_prepend( boxed->private->u.string_list, g_strdup( *i ));
+			}
 			i++;
 		}
 		boxed->private->u.string_list = g_slist_reverse( boxed->private->u.string_list );
-	} else {
-		boxed->private->u.string_list = NULL;
 	}
 
 	g_strfreev( array );
@@ -1167,16 +1167,20 @@ string_list_from_string( NABoxed *boxed, const gchar *string )
 static void
 string_list_from_value( NABoxed *boxed, const GValue *value )
 {
-	if( g_value_get_pointer( value )){
-		boxed->private->u.string_list = na_core_utils_slist_duplicate( g_value_get_pointer( value ));
-	}
+	string_list_from_void( boxed, ( const void * ) g_value_get_pointer( value ));
 }
 
 static void
 string_list_from_void( NABoxed *boxed, const void *value )
 {
-	if( value ){
-		boxed->private->u.string_list = na_core_utils_slist_duplicate(( GSList * ) value );
+	GSList *value_slist;
+	GSList *it;
+
+	value_slist = ( GSList * ) value;
+	for( it = value_slist ; it ; it = it->next ){
+		if( !na_core_utils_slist_count( boxed->private->u.string_list, ( const gchar * ) it->data )){
+			boxed->private->u.string_list = g_slist_prepend( boxed->private->u.string_list, g_strdup(( const gchar * ) it->data ));
+		}
 	}
 }
 



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