[nautilus-actions] Path+parameters are splitted whatever be the I/O importer



commit e04d545528fdc16017e623b6912ff6e7898f122b
Author: Pierre Wieser <pwieser trychlos org>
Date:   Wed Aug 18 15:17:14 2010 +0200

    Path+parameters are splitted whatever be the I/O importer

 ChangeLog                    |    6 ++++++
 src/core/na-object-profile.c |   27 +++++++++++++++++++++++++++
 src/io-desktop/nadp-reader.c |   24 ------------------------
 3 files changed, 33 insertions(+), 24 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 99f48db..e3ceefe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2010-08-18 Pierre Wieser <pwieser trychlos org>
 
+	Path+parameters are splitted whatever be the I/O importer.
+
+	* src/io-desktop/nadp-reader.c (read_done_profile_split_exec): Removed function.
+
+	* src/core/na-object-profile.c (split_path_parameters): New function.
+
 	* src/core/na-data-boxed.c (uint_set_from_string):
 	Fix default uint value when reading null string.
 
diff --git a/src/core/na-object-profile.c b/src/core/na-object-profile.c
index 927f811..8160b90 100644
--- a/src/core/na-object-profile.c
+++ b/src/core/na-object-profile.c
@@ -90,6 +90,7 @@ static gboolean     convert_pre_v3_parameters( NAObjectProfile *profile );
 static gboolean     convert_pre_v3_parameters_str( gchar *str );
 static gboolean     convert_pre_v3_multiple( NAObjectProfile *profile );
 static gboolean     convert_pre_v3_isfiledir( NAObjectProfile *profile );
+static void         split_path_parameters( NAObjectProfile *profile );
 static gboolean     profile_is_valid( const NAObjectProfile *profile );
 static gboolean     is_valid_path_parameters( const NAObjectProfile *profile );
 
@@ -354,6 +355,11 @@ ifactory_object_read_done( NAIFactoryObject *instance, const NAIFactoryProvider
 		}
 	}
 
+	/* split path+parameters
+	 * not done in io-desktop because some actions may have all arguments in path
+	 */
+	split_path_parameters( NA_OBJECT_PROFILE( instance ));
+
 	/* prepare the context after the reading
 	 */
 	na_icontext_read_done( NA_ICONTEXT( instance ));
@@ -585,6 +591,27 @@ convert_pre_v3_isfiledir( NAObjectProfile *profile )
 	return( converted );
 }
 
+static void
+split_path_parameters( NAObjectProfile *profile )
+{
+	gchar *path, *parameters;
+	gchar *exec;
+
+	path = na_object_get_path( profile );
+	parameters = na_object_get_parameters( profile );
+	exec = g_strdup_printf( "%s %s", path, parameters );
+	g_free( parameters );
+	g_free( path );
+
+	na_core_utils_str_split_first_word( exec, &path, &parameters );
+	g_free( exec );
+
+	na_object_set_path( profile, path );
+	na_object_set_parameters( profile, parameters );
+	g_free( parameters );
+	g_free( path );
+}
+
 static gboolean
 profile_is_valid( const NAObjectProfile *profile )
 {
diff --git a/src/io-desktop/nadp-reader.c b/src/io-desktop/nadp-reader.c
index c714e02..72e3679 100644
--- a/src/io-desktop/nadp-reader.c
+++ b/src/io-desktop/nadp-reader.c
@@ -76,7 +76,6 @@ static void              read_start_profile_attach_profile( const NAIFactoryProv
 static gboolean          read_done_item_is_writable( const NAIFactoryProvider *provider, NAObjectItem *item, NadpReaderData *reader_data, GSList **messages );
 static void              read_done_action_read_profiles( const NAIFactoryProvider *provider, NAObjectAction *action, NadpReaderData *data, GSList **messages );
 static void              read_done_action_load_profile( const NAIFactoryProvider *provider, NadpReaderData *reader_data, const gchar *profile_id, GSList **messages );
-static void              read_done_profile_split_exec( const NAIFactoryProvider *provider, NAObjectProfile *profile, NadpReaderData *reader_data, GSList **messages );
 
 /*
  * Returns an unordered list of NAIFactoryObject-derived objects
@@ -608,10 +607,6 @@ nadp_reader_ifactory_provider_read_done( const NAIFactoryProvider *reader, void
 			read_done_action_read_profiles( reader, NA_OBJECT_ACTION( serializable ), ( NadpReaderData * ) reader_data, messages );
 		}
 
-		if( NA_IS_OBJECT_PROFILE( serializable )){
-			read_done_profile_split_exec( reader, NA_OBJECT_PROFILE( serializable ), ( NadpReaderData * ) reader_data, messages );
-		}
-
 		g_debug( "%s: quitting for %s at %p", thisfn, G_OBJECT_TYPE_NAME( serializable ), ( void * ) serializable );
 	}
 }
@@ -674,22 +669,3 @@ read_done_action_load_profile( const NAIFactoryProvider *provider, NadpReaderDat
 			NA_IFACTORY_OBJECT( profile ),
 			messages );
 }
-
-static void
-read_done_profile_split_exec( const NAIFactoryProvider *provider, NAObjectProfile *profile, NadpReaderData *reader_data, GSList **messages )
-{
-	gchar *exec;
-	gchar *path, *parameters;
-
-	exec = na_object_get_path( profile );
-
-	if( exec && g_utf8_strlen( exec, -1 )){
-		na_core_utils_str_split_first_word( exec, &path, &parameters );
-		na_object_set_path( profile, path );
-		na_object_set_parameters( profile, parameters );
-		g_free( parameters );
-		g_free( path );
-	}
-
-	g_free( exec );
-}



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