[nautilus-actions] Rename na_core_utils_slist_find() as na_core_utils_slist_count()
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Rename na_core_utils_slist_find() as na_core_utils_slist_count()
- Date: Tue, 27 Jul 2010 21:47:33 +0000 (UTC)
commit 85dd5ea3b0c096c8a2e7562e4aacc599c0323e7a
Author: Pierre Wieser <pwieser trychlos org>
Date: Mon Jul 26 22:10:10 2010 +0200
Rename na_core_utils_slist_find() as na_core_utils_slist_count()
ChangeLog | 8 ++++++++
src/api/na-core-utils.h | 2 +-
src/core/na-core-utils.c | 27 +++++++++++++++------------
src/core/na-icontext.c | 4 ++--
src/io-desktop/nadp-writer.c | 2 +-
5 files changed, 27 insertions(+), 16 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a73ff5f..e968c63 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2010-07-26 Pierre Wieser <pwieser trychlos org>
+ * src/api/na-core-utils.h:
+ * src/core/na-core-utils.c (na_core_utils_slist_find):
+ Moved to na_core_utils_slist_count.
+
+ * src/core/na-icontext.c (is_candidate_for_show_in):
+ * src/io-desktop/nadp-writer.c
+ (nadp_writer_ifactory_provider_write_done): Updated accordingly.
+
* src/nact/nact-match-list.c (on_filter_edited):
Add g_return_if_fail checks on data and context.
diff --git a/src/api/na-core-utils.h b/src/api/na-core-utils.h
index e23c110..85ea1b5 100644
--- a/src/api/na-core-utils.h
+++ b/src/api/na-core-utils.h
@@ -65,7 +65,7 @@ GSList *na_core_utils_slist_remove_utf8( GSList *list, const gchar *string );
gchar **na_core_utils_slist_to_array( GSList *slist );
gchar *na_core_utils_slist_to_text( GSList *list );
GSList *na_core_utils_slist_setup_element( GSList *list, const gchar *element, gboolean set );
-gboolean na_core_utils_slist_find( GSList *list, const gchar *str );
+guint na_core_utils_slist_count( GSList *list, const gchar *str );
gboolean na_core_utils_slist_find_negated( GSList *list, const gchar *str );
gboolean na_core_utils_slist_are_equal( GSList *a, GSList *b );
void na_core_utils_slist_free( GSList *slist );
diff --git a/src/core/na-core-utils.c b/src/core/na-core-utils.c
index a0e92bb..de89a49 100644
--- a/src/core/na-core-utils.c
+++ b/src/core/na-core-utils.c
@@ -460,14 +460,14 @@ na_core_utils_slist_to_text( GSList *strlist )
GSList *
na_core_utils_slist_setup_element( GSList *list, const gchar *element, gboolean set )
{
- gboolean exist;
+ guint count;
- exist = na_core_utils_slist_find( list, element );
+ count = na_core_utils_slist_count( list, element );
- if( set && !exist ){
+ if( set && count == 0 ){
list = g_slist_prepend( list, g_strdup( element ));
}
- if( !set && exist ){
+ if( !set && count > 0 ){
list = na_core_utils_slist_remove_ascii( list, element );
}
@@ -475,27 +475,30 @@ na_core_utils_slist_setup_element( GSList *list, const gchar *element, gboolean
}
/**
- * na_core_utils_slist_find:
+ * na_core_utils_slist_count:
* @list: the GSList of strings to be searched.
* @str: the searched string.
*
* Search for a string in a string list.
*
- * Returns: %TRUE if the string has been found in list.
+ * Returns: the count of @Ã?tr in @list list.
*/
-gboolean
-na_core_utils_slist_find( GSList *list, const gchar *str )
+guint
+na_core_utils_slist_count( GSList *list, const gchar *str )
{
+ guint count;
GSList *il;
+ count = 0;
+
for( il = list ; il ; il = il->next ){
const gchar *istr = ( const gchar * ) il->data;
if( !na_core_utils_str_collate( str, istr )){
- return( TRUE );
+ count += 1;
}
}
- return( FALSE );
+ return( count );
}
/**
@@ -547,14 +550,14 @@ na_core_utils_slist_are_equal( GSList *first, GSList *second )
for( il = first ; il ; il = il->next ){
const gchar *str = ( const gchar * ) il->data;
- if( !na_core_utils_slist_find( second, str )){
+ if( na_core_utils_slist_count( second, str ) == 0 ){
return( FALSE );
}
}
for( il = second ; il ; il = il->next ){
const gchar *str = ( const gchar * ) il->data;
- if( !na_core_utils_slist_find( first, str )){
+ if( na_core_utils_slist_count( first, str ) == 0 ){
return( FALSE );
}
}
diff --git a/src/core/na-icontext.c b/src/core/na-icontext.c
index a3c6aa8..d5ed04b 100644
--- a/src/core/na-icontext.c
+++ b/src/core/na-icontext.c
@@ -448,9 +448,9 @@ is_candidate_for_show_in( const NAIContext *object, guint target, GList *files )
if( environment && strlen( environment )){
if( only_in && g_slist_length( only_in )){
- ok = na_core_utils_slist_find( only_in, environment );
+ ok = ( na_core_utils_slist_count( only_in, environment ) > 0 );
} else if( not_in && g_slist_length( not_in )){
- ok = !na_core_utils_slist_find( not_in, environment );
+ ok = ( na_core_utils_slist_count( not_in, environment ) == 0 );
}
}
diff --git a/src/io-desktop/nadp-writer.c b/src/io-desktop/nadp-writer.c
index d0fed77..33525ee 100644
--- a/src/io-desktop/nadp-writer.c
+++ b/src/io-desktop/nadp-writer.c
@@ -491,7 +491,7 @@ nadp_writer_ifactory_provider_write_done( const NAIFactoryProvider *provider, vo
na_core_utils_slist_dump( profile_groups );
for( ip = profile_groups ; ip ; ip = ip->next ){
- if( !na_core_utils_slist_find( subitems, ( const gchar * ) ip->data )){
+ if( na_core_utils_slist_count( subitems, ( const gchar * ) ip->data ) == 0 ){
g_debug( "nadp_writer_ifactory_provider_write_done: deleting (removed) profile %s", ( const gchar * ) ip->data );
nadp_desktop_file_remove_profile( NADP_DESKTOP_FILE( writer_data ), ( const gchar * ) ip->data );
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]