[nautilus-actions] Actually checks current folders vs. specified ones



commit 2d05d912786ed5da9a4e072c81cecbd32c4a8a41
Author: Pierre Wieser <pwieser trychlos org>
Date:   Sun Oct 25 18:09:49 2009 +0100

    Actually checks current folders vs. specified ones

 ChangeLog                       |    3 ++
 src/runtime/na-object-profile.c |   41 +++++++++++++++++++++++++++++++++++++-
 2 files changed, 42 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e2bbf23..0e8e901 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,9 @@
 	* src/runtime/na-iabout.c (na_iabout_display):
 	Do not mark authors names and emails for translating (#599520).
 
+	* src/runtime/na-object-profile.c (is_current_folder_inside):
+	Actually checks if current folder is inside one of specified folders.
+
 	* src/nact/nact-iactions-list.c
 	(nact_iactions_list_dispose): free list of modified items.
 	(nact_iactions_list_fill): reset level_zero_order_changed flag.
diff --git a/src/runtime/na-object-profile.c b/src/runtime/na-object-profile.c
index 43748b4..f570762 100644
--- a/src/runtime/na-object-profile.c
+++ b/src/runtime/na-object-profile.c
@@ -86,6 +86,7 @@ static void      instance_finalize( GObject *object );
 
 static gboolean  is_target_background_candidate( const NAObjectProfile *profile, NautilusFileInfo *current_folder );
 static gboolean  is_target_toolbar_candidate( const NAObjectProfile *profile, NautilusFileInfo *current_folder );
+static gboolean  is_current_folder_inside( const NAObjectProfile *profile, NautilusFileInfo *current_folder );
 static gboolean  is_target_selection_candidate( const NAObjectProfile *profile, GList *files );
 static int       validate_schemes( GSList *schemes2test, NautilusFileInfo *file );
 
@@ -1007,13 +1008,49 @@ na_object_profile_is_candidate( const NAObjectProfile *profile, gint target, GLi
 static gboolean
 is_target_background_candidate( const NAObjectProfile *profile, NautilusFileInfo *current_folder )
 {
-	return( TRUE );
+	gboolean is_candidate;
+
+	is_candidate = is_current_folder_inside( profile, current_folder );
+
+	return( is_candidate );
 }
 
 static gboolean
 is_target_toolbar_candidate( const NAObjectProfile *profile, NautilusFileInfo *current_folder )
 {
-	return( TRUE );
+	gboolean is_candidate;
+
+	is_candidate = is_current_folder_inside( profile, current_folder );
+
+	return( is_candidate );
+}
+
+static gboolean
+is_current_folder_inside( const NAObjectProfile *profile, NautilusFileInfo *current_folder )
+{
+	gboolean is_inside;
+	GSList *ifold;
+	const gchar *path;
+	gchar *current_folder_uri;
+
+	is_inside = FALSE;
+	current_folder_uri = nautilus_file_info_get_uri( current_folder );
+
+	for( ifold = profile->private->folders ; ifold && !is_inside ; ifold = ifold->next ){
+		path = ( const gchar * ) ifold->data;
+		if( path && g_utf8_strlen( path, -1 )){
+			if( !strcmp( path, "*" )){
+				is_inside = TRUE;
+			} else {
+				is_inside = g_str_has_prefix( current_folder_uri, path );
+				g_debug( "na_object_profile_is_current_folder_inside: current_folder_uri=%s, path=%s, is_inside=%s", current_folder_uri, path, is_inside ? "True":"False" );
+			}
+		}
+	}
+
+	g_free( current_folder_uri );
+
+	return( is_inside );
 }
 
 static gboolean



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