[nautilus-actions] Split Exec key to get Path and Parameters data
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Split Exec key to get Path and Parameters data
- Date: Sat, 7 Aug 2010 18:52:38 +0000 (UTC)
commit 08c3ed0827f59b44f0b0a0c30b7e67bcf724d50d
Author: pierre <pierre vfedora10 virtuals pwi>
Date: Thu Aug 5 12:16:49 2010 +0200
Split Exec key to get Path and Parameters data
ChangeLog | 9 ++++++
src/api/na-core-utils.h | 2 +-
src/core/na-core-utils.c | 57 ++++++++++++++++++++----------------------
src/io-desktop/nadp-reader.c | 21 +++++++++++++++
4 files changed, 58 insertions(+), 31 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8d59b55..a3019cd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2010-08-05 Pierre Wieser <pwieser trychlos org>
+ * src/api/na-core-utils.h:
+ * src/core/na-core-utils.c
+ (na_core_utils_str_get_first_word): Removed function.
+ (na_core_utils_str_split_first_word): New function.
+
+ * src/io-desktop/nadp-reader.c
+ (nadp_reader_ifactory_provider_read_done):
+ Split the Exec content to get Path and Parameters data.
+
* src/core/na-object-profile-factory.c:
Review the description of the NAFO_DATA_PARAMETERS data.
diff --git a/src/api/na-core-utils.h b/src/api/na-core-utils.h
index 1fff3fa..dd0da13 100644
--- a/src/api/na-core-utils.h
+++ b/src/api/na-core-utils.h
@@ -49,9 +49,9 @@ gboolean na_core_utils_boolean_from_string( const gchar *string );
*/
gchar *na_core_utils_str_add_prefix( const gchar *prefix, const gchar *str );
int na_core_utils_str_collate( const gchar *str1, const gchar *str2 );
-gchar *na_core_utils_str_get_first_word( const gchar *string );
gchar *na_core_utils_str_remove_char( const gchar *string, const gchar *to_remove );
gchar *na_core_utils_str_remove_suffix( const gchar *string, const gchar *suffix );
+void na_core_utils_str_split_first_word( const gchar *string, gchar **first, gchar **other );
/* some functions to get or set GSList list of strings
*/
diff --git a/src/core/na-core-utils.c b/src/core/na-core-utils.c
index e276f42..0218ff2 100644
--- a/src/core/na-core-utils.c
+++ b/src/core/na-core-utils.c
@@ -112,36 +112,6 @@ na_core_utils_str_collate( const gchar *str1, const gchar *str2 )
}
/**
- * na_core_utils_str_get_first_word:
- * @string: a space-separated string.
- *
- * Returns: the first word of @string, as a newly allocated string which
- * should be g_free() by the caller.
- */
-gchar *
-na_core_utils_str_get_first_word( const gchar *string )
-{
- gchar **splitted, **iter;
- gchar *word, *tmp;
-
- splitted = g_strsplit( string, " ", 0 );
- iter = splitted;
- word = NULL;
-
- while( *iter ){
- tmp = g_strstrip( *iter );
- if( g_utf8_strlen( tmp, -1 )){
- word = g_strdup( tmp );
- break;
- }
- iter++;
- }
-
- g_strfreev( splitted );
- return( word );
-}
-
-/**
* na_core_utils_str_remove_char:
* @string: source string.
* @to_remove: the character to remove.
@@ -209,6 +179,33 @@ na_core_utils_str_remove_suffix( const gchar *string, const gchar *suffix )
return( removed );
}
+/**
+ * na_core_utils_str_split_first_word:
+ * @string: a space-separated string.
+ * @first: a pointer to a gchar *.
+ * @other: a pointer to a gchar *.
+ *
+ * Split the @string string into two components:
+ * - the first word which is allocated in @first,
+ * - the rest of the string which is allocated in @other.
+ *
+ * The two allocated strings should be g_free() by the caller.
+ */
+void
+na_core_utils_str_split_first_word( const gchar *string, gchar **first, gchar **other )
+{
+ gchar **splitted, **iter;
+
+ splitted = g_strsplit( string, " ", 2 );
+ iter = splitted;
+
+ *first = g_strdup( *iter );
+ iter++;
+ *other = g_strdup( *iter );
+
+ g_strfreev( splitted );
+}
+
void
na_core_utils_slist_add_message( GSList **messages, const gchar *format, ... )
{
diff --git a/src/io-desktop/nadp-reader.c b/src/io-desktop/nadp-reader.c
index c1ffa4b..d9ee5ca 100644
--- a/src/io-desktop/nadp-reader.c
+++ b/src/io-desktop/nadp-reader.c
@@ -76,6 +76,7 @@ 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
@@ -607,6 +608,10 @@ 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 );
}
}
@@ -669,3 +674,19 @@ 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 );
+ na_core_utils_str_split_first_word( exec, &path, ¶meters );
+ 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]