[nautilus-actions] Output the new action to GConf



commit 16520abd4933ebb36dbfcc431eaf019cb737fdf9
Author: Pierre Wieser <pwieser trychlos org>
Date:   Tue Mar 16 21:45:51 2010 +0100

    Output the new action to GConf

 ChangeLog                        |    5 ++-
 src/utils/nautilus-actions-new.c |   55 +++++++++++++++++++++++--------------
 2 files changed, 37 insertions(+), 23 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8af71f4..d287f55 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,8 @@
 2009-03-16 Pierre Wieser <pwieser trychlos org>
 
-	* src/utils/nautilus-actions-new.c (output_to_stdout):
-	Output the new action to stdout.
+	* src/utils/nautilus-actions-new.c
+	(output_to_stdout): Output the new action to stdout.
+	(output_to_gconf): Output the new action to GConf.
 
 	* src/io-xml/naxml-writer.c (naxml_writer_write_start):
 	Add attribute to list node, thus fixing writing of action.
diff --git a/src/utils/nautilus-actions-new.c b/src/utils/nautilus-actions-new.c
index 7dbf085..f53994b 100644
--- a/src/utils/nautilus-actions-new.c
+++ b/src/utils/nautilus-actions-new.c
@@ -140,8 +140,8 @@ static GOptionEntry misc_entries[] = {
 static GOptionEntry   *build_option_entries( const ArgFromDataDef *defs, guint nbdefs, const GOptionEntry *adds, guint nbadds );
 static GOptionContext *init_options( void );
 static NAObjectAction *get_action_from_cmdline( void );
+static gboolean        output_to_gconf( NAObjectAction *action, GSList **msg );
 static gboolean        output_to_stdout( const NAObjectAction *action, GSList **msgs );
-static gboolean        write_to_gconf( NAObjectAction *action, GSList **msg );
 static void            exit_with_usage( void );
 
 int
@@ -229,7 +229,7 @@ main( int argc, char** argv )
 	action = get_action_from_cmdline();
 
 	if( output_gconf ){
-		if( write_to_gconf( action, &msg )){
+		if( output_to_gconf( action, &msg )){
 			/* i18n: Action <action_label> written to...*/
 			g_print( _( "Action '%s' succesfully written to GConf configuration.\n" ), label );
 		}
@@ -457,46 +457,59 @@ get_action_from_cmdline( void )
 	return( action );
 }
 
+/*
+ * initialize GConf as an I/O provider
+ * then writes the action
+ */
 static gboolean
-output_to_stdout( const NAObjectAction *action, GSList **msgs )
+output_to_gconf( NAObjectAction *action, GSList **msgs )
 {
-	gboolean ret;
 	NAUpdater *updater;
-	GQuark format;
-	gchar *buffer;
+	GList *providers;
+	NAIOProvider *provider;
+	guint ret;
+	gboolean code;
 
 	updater = na_updater_new();
-	format = g_quark_from_string( NAXML_FORMAT_GCONF_ENTRY );
-	buffer = na_exporter_to_buffer( NA_PIVOT( updater ), NA_OBJECT_ITEM( action ), format, msgs );
-	ret = ( buffer != NULL );
+	providers = na_io_provider_get_providers_list( NA_PIVOT( updater ));
+	provider = na_io_provider_find_provider_by_id( providers, "na-gconf" );
 
-	if( buffer ){
-		g_printf( "%s", buffer );
+	if( provider ){
+		na_object_set_provider( action, provider );
+		ret = na_updater_write_item( updater, NA_OBJECT_ITEM( action ), msgs );
+		code = ( ret == NA_IIO_PROVIDER_CODE_OK );
+
+	} else {
+		*msgs = g_slist_append( *msgs, _( "Unable to find 'na-gconf' provider." ));
+		code = FALSE;
 	}
 
-	g_free( buffer );
 	g_object_unref( updater );
 
-	return( ret );
+	return( code );
 }
 
-/*
- * initialize GConf as an I/O provider
- * then writes the action
- */
 static gboolean
-write_to_gconf( NAObjectAction *action, GSList **msg )
+output_to_stdout( const NAObjectAction *action, GSList **msgs )
 {
+	gboolean ret;
 	NAUpdater *updater;
-	guint ret;
+	GQuark format;
+	gchar *buffer;
 
 	updater = na_updater_new();
+	format = g_quark_from_string( NAXML_FORMAT_GCONF_ENTRY );
+	buffer = na_exporter_to_buffer( NA_PIVOT( updater ), NA_OBJECT_ITEM( action ), format, msgs );
+	ret = ( buffer != NULL );
 
-	ret = na_updater_write_item( updater, NA_OBJECT_ITEM( action ), msg );
+	if( buffer ){
+		g_printf( "%s", buffer );
+	}
 
+	g_free( buffer );
 	g_object_unref( updater );
 
-	return( ret == NA_IIO_PROVIDER_CODE_OK );
+	return( ret );
 }
 
 /*



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