[nautilus-actions] Fix incorrect and optimize handling of folder conditions
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Fix incorrect and optimize handling of folder conditions
- Date: Mon, 9 Aug 2010 21:16:16 +0000 (UTC)
commit a8205821a7b594f69e58b670611f912d3cd10248
Author: pierre <pierre vfedora10 virtuals pwi>
Date: Mon Aug 9 16:09:27 2010 +0200
Fix incorrect and optimize handling of folder conditions
ChangeLog | 3 ++
src/core/na-icontext.c | 64 +++++++++++++++++++----------------------------
2 files changed, 29 insertions(+), 38 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 570af08..84d7c32 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2010-08-09 Pierre Wieser <pwieser trychlos org>
+ * src/core/na-icontext.c (is_candidate_for_folders):
+ Fix incorrect and optimize handling of folder conditions.
+
* src/core/na-icontext.c (is_candidate_for_schemes):
Fix incorrect and optimize handling of scheme conditions.
diff --git a/src/core/na-icontext.c b/src/core/na-icontext.c
index e97f9e8..1058f28 100644
--- a/src/core/na-icontext.c
+++ b/src/core/na-icontext.c
@@ -901,62 +901,50 @@ is_compatible_scheme( const gchar *pattern, const gchar *scheme )
return( compatible );
}
+/*
+ * assumuing here the same sort of optimization than for schemes
+ * i.e. we assume that all selected items are located in the same dirname
+ * so we only check first dirname against folder conditions
+ */
static gboolean
is_candidate_for_folders( const NAIContext *object, guint target, GList *files )
{
static const gchar *thisfn = "na_icontext_is_candidate_for_folders";
gboolean ok = TRUE;
GSList *folders = na_object_get_folders( object );
- GSList *id;
- const gchar *pattern;
- GList *it;
- gchar *dirname, *dirname_utf8;
- gboolean positive, match;
- guint count_positive = 0;
- guint count_compatible = 0;
- GPatternSpec *pattern_spec;
if( folders ){
if( strcmp( folders->data, "/" ) != 0 || g_slist_length( folders ) > 1 ){
+ GSList *id;
+ gchar *dirname, *dirname_utf8;
+ const gchar *pattern;
+ gboolean match, positive;
+
+ dirname = na_selected_info_get_dirname( NA_SELECTED_INFO( files->data ));
+ dirname_utf8 = g_filename_to_utf8( dirname, -1, NULL, NULL, NULL );
+ match = FALSE;
+
for( id = folders ; id && ok ; id = id->next ){
pattern = ( const gchar * ) id->data;
positive = is_positive_assertion( pattern );
- if( positive ){
- count_positive += 1;
- } else {
- pattern += 1;
- }
-
- pattern_spec = NULL;
- if( g_strstr_len( pattern, -1, "*" ) != NULL ){
- pattern_spec = g_pattern_spec_new( pattern );
- }
-
- for( it = files ; it && ok ; it = it->next ){
- dirname = na_selected_info_get_dirname( NA_SELECTED_INFO( it->data ));
-
- if( pattern_spec ){
- dirname_utf8 = g_filename_to_utf8( dirname, -1, NULL, NULL, NULL );
- match = g_pattern_match_string( pattern_spec, dirname_utf8 );
- g_free( dirname_utf8 );
- } else {
- match = g_str_has_prefix( dirname, pattern );
+ if( !positive || !match ){
+ if( g_pattern_match_simple( positive ? pattern : pattern+1, dirname_utf8 )){
+ if( positive ){
+ match = TRUE;
+ } else {
+ ok = FALSE;
+ }
}
-
- g_free( dirname );
- g_debug( "%s: pattern=%s, positive=%s, match=%s", thisfn, pattern, positive ? "True":"False", match ? "True":"False" );
- count_compatible_patterns( positive, match, &count_compatible, &ok );
}
+ }
- if( pattern_spec ){
- g_pattern_spec_free( pattern_spec );
- }
+ if( ok ){
+ ok = match;
}
- }
- if( count_positive > 0 && count_compatible == 0 ){
- ok = FALSE;
+ g_free( dirname_utf8 );
+ g_free( dirname );
}
if( !ok ){
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]