[nautilus-actions] Replace base_iprefs_xxx_string with na_iprefs equivalents



commit 687bf7d571c61b9da49f31a90dcc263b649a7132
Author: Pierre Wieser <pwieser trychlos org>
Date:   Wed Sep 30 22:09:40 2009 +0200

    Replace base_iprefs_xxx_string with na_iprefs equivalents

 ChangeLog                        |    9 ++++
 src/nact/base-iprefs.c           |   85 --------------------------------------
 src/nact/base-iprefs.h           |    3 -
 src/nact/nact-assistant-export.c |   18 ++++++--
 src/nact/nact-assistant-import.c |   13 +++++-
 src/nact/nact-icommand-tab.c     |   10 ++++-
 6 files changed, 42 insertions(+), 96 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c95a848..3b93c48 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -26,6 +26,15 @@
 	* src/nact/nact-main-menubar.c:
 	* src/nact/nact-main-window.c: Updated accordingly.
 
+	* src/nact/base-iprefs.c:
+	* src/nact/base-iprefs.h
+	(base_iprefs_get_string, base_iprefs_set_string): Removed functions.
+
+	* src/nact/nact-assistant-export.c:
+	* src/nact/nact-assistant-import.c:
+	* src/nact/nact-icommand-tab.c:
+	Move base_iprefs_xxx_string() to na_iprefs_xxx equivalents.
+
 	* src/nact/nact-assistant-import.c:
 	Import mode preference is now stored as a string.
 
diff --git a/src/nact/base-iprefs.c b/src/nact/base-iprefs.c
index 35613d0..70deb6b 100644
--- a/src/nact/base-iprefs.c
+++ b/src/nact/base-iprefs.c
@@ -63,12 +63,10 @@ static gboolean    remove_entry( GConfClient *client, const gchar *path, const g
 static gboolean    read_bool( BaseIPrefs *instance, const gchar *name );
 static gint        read_int( BaseWindow *window, const gchar *name );
 static GSList     *read_int_list( BaseWindow *window, const gchar *key );
-static gchar      *read_str( BaseWindow *window, const gchar *key );
 
 static void        write_bool( BaseIPrefs *instance, const gchar *name, gboolean value );
 static void        write_int( BaseWindow *window, const gchar *name, gint value );
 static void        write_int_list( BaseWindow *window, const gchar *key, GSList *list );
-static void        write_str( BaseWindow *window, const gchar *key, const gchar *text );
 
 static void        int_list_to_position( BaseWindow *window, GSList *list, gint *x, gint *y, gint *width, gint *height );
 static GSList     *position_to_int_list( BaseWindow *window, gint x, gint y, gint width, gint height );
@@ -396,48 +394,6 @@ base_iprefs_set_int( BaseWindow *window, const gchar *name, gint value )
 	}
 }
 
-/**
- * base_iprefs_get_string:
- * @window: this #BaseWindow-derived window.
- * @name: entry of the string value.
- *
- * Returns the required string if any, or NULL.
- * The returned string must be g_free() by the caller.
- */
-gchar *
-base_iprefs_get_string( BaseWindow *window, const gchar *name )
-{
-	gchar *string = NULL;
-
-	g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
-	g_return_val_if_fail( BASE_IS_IPREFS( window ), NULL );
-
-	if( st_initialized && !st_finalized ){
-		string = read_str( window, name );
-	}
-
-	return( string );
-}
-
-/**
- * base_iprefs_set_string:
- * @window: this #BaseWindow-derived window.
- * @name: entry of the string value.
- * @string: value to save.
- *
- * Saves the required string.
- */
-void
-base_iprefs_set_string( BaseWindow *window, const gchar *name, const gchar *string )
-{
-	g_return_if_fail( BASE_IS_WINDOW( window ));
-	g_return_if_fail( BASE_IS_IPREFS( window ));
-
-	if( st_initialized && !st_finalized ){
-		write_str( window, name, string );
-	}
-}
-
 static gchar *
 v_iprefs_get_window_id( BaseWindow *window )
 {
@@ -580,28 +536,6 @@ read_int_list( BaseWindow *window, const gchar *key )
 	return( list );
 }
 
-static gchar *
-read_str( BaseWindow *window, const gchar *key )
-{
-	static const gchar *thisfn = "base_iprefs_read_str";
-	GError *error = NULL;
-	gchar *path;
-	gchar *text;
-
-	path = g_strdup_printf( "%s/%s", NA_GCONF_PREFS_PATH, key );
-
-	text = gconf_client_get_string( BASE_IPREFS_GET_INTERFACE( window )->private->client, path, &error );
-
-	if( error ){
-		g_warning( "%s: key=%s, %s", thisfn, key, error->message );
-		g_error_free( error );
-		text = NULL;
-	}
-
-	g_free( path );
-	return( text );
-}
-
 static void
 write_bool( BaseIPrefs *instance, const gchar *name, gboolean value )
 {
@@ -654,25 +588,6 @@ write_int_list( BaseWindow *window, const gchar *key, GSList *list )
 	g_free( path );
 }
 
-static void
-write_str( BaseWindow *window, const gchar *key, const gchar *text )
-{
-	static const gchar *thisfn = "base_iprefs_write_str";
-	GError *error = NULL;
-	gchar *path;
-
-	path = g_strdup_printf( "%s/%s", NA_GCONF_PREFS_PATH, key );
-
-	gconf_client_set_string( BASE_IPREFS_GET_INTERFACE( window )->private->client, path, text, &error );
-
-	if( error ){
-		g_warning( "%s: key=%s, %s", thisfn, key, error->message );
-		g_error_free( error );
-	}
-
-	g_free( path );
-}
-
 /*
  * extract the position of the window from the list of GConfValue
  */
diff --git a/src/nact/base-iprefs.h b/src/nact/base-iprefs.h
index 3f93bc6..7d54f45 100644
--- a/src/nact/base-iprefs.h
+++ b/src/nact/base-iprefs.h
@@ -87,9 +87,6 @@ void     base_iprefs_set_bool( BaseIPrefs *instance, const gchar *key, gboolean
 gint     base_iprefs_get_int( BaseWindow *window, const gchar *key );
 void     base_iprefs_set_int( BaseWindow *window, const gchar *key, gint value );
 
-gchar   *base_iprefs_get_string( BaseWindow *window, const gchar *name );
-void     base_iprefs_set_string( BaseWindow *window, const gchar *name, const gchar *string );
-
 G_END_DECLS
 
 #endif /* __BASE_IPREFS_H__ */
diff --git a/src/nact/nact-assistant-export.c b/src/nact/nact-assistant-export.c
index 11bf083..7f49d2c 100644
--- a/src/nact/nact-assistant-export.c
+++ b/src/nact/nact-assistant-export.c
@@ -38,6 +38,7 @@
 
 #include <common/na-iprefs.h>
 #include <common/na-object-api.h>
+#include <common/na-pivot.h>
 #include <common/na-utils.h>
 #include <common/na-xml-names.h>
 #include <common/na-xml-writer.h>
@@ -558,13 +559,18 @@ static void
 assist_runtime_init_target_folder( NactAssistantExport *window, GtkAssistant *assistant )
 {
 	GtkFileChooser *chooser;
+	NactApplication *application;
+	NAPivot *pivot;
 	gchar *uri;
 	GtkWidget *content;
 
 	chooser = get_folder_chooser( window );
 	gtk_file_chooser_unselect_all( chooser );
 
-	uri = base_iprefs_get_string( BASE_WINDOW( window ), IPREFS_EXPORT_ACTIONS_FOLDER_URI );
+	application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
+	pivot = nact_application_get_pivot( application );
+
+	uri = na_iprefs_read_string( NA_IPREFS( pivot ), IPREFS_EXPORT_ACTIONS_FOLDER_URI, "file:///tmp" );
 	if( uri && strlen( uri )){
 		gtk_file_chooser_set_uri( GTK_FILE_CHOOSER( chooser ), uri );
 	}
@@ -596,6 +602,8 @@ on_folder_selection_changed( GtkFileChooser *chooser, gpointer user_data )
 {
 	static const gchar *thisfn = "nact_assistant_export_on_folder_selection_changed";
 	GtkAssistant *assistant;
+	NactApplication *application;
+	NAPivot *pivot;
 	gint pos;
 	gchar *uri;
 	gboolean enabled;
@@ -604,8 +612,9 @@ on_folder_selection_changed( GtkFileChooser *chooser, gpointer user_data )
 
 	g_debug( "%s: chooser=%p, user_data=%p", thisfn, ( void * ) chooser, ( void * ) user_data );
 	g_assert( NACT_IS_ASSISTANT_EXPORT( user_data ));
+	assist = NACT_ASSISTANT_EXPORT( user_data );
 
-	assistant = GTK_ASSISTANT( base_window_get_toplevel( BASE_WINDOW( user_data )));
+	assistant = GTK_ASSISTANT( base_window_get_toplevel( BASE_WINDOW( assist )));
 	pos = gtk_assistant_get_current_page( assistant );
 	if( pos == ASSIST_PAGE_FOLDER_SELECTION ){
 
@@ -614,10 +623,11 @@ on_folder_selection_changed( GtkFileChooser *chooser, gpointer user_data )
 		enabled = ( uri && strlen( uri ) && na_utils_is_writable_dir( uri ));
 
 		if( enabled ){
-			assist = NACT_ASSISTANT_EXPORT( user_data );
 			g_free( assist->private->uri );
 			assist->private->uri = g_strdup( uri );
-			base_iprefs_set_string( BASE_WINDOW( user_data ), IPREFS_EXPORT_ACTIONS_FOLDER_URI, uri );
+			application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( assist )));
+			pivot = nact_application_get_pivot( application );
+			na_iprefs_write_string( NA_IPREFS( pivot ), IPREFS_EXPORT_ACTIONS_FOLDER_URI, uri );
 		}
 
 		g_free( uri );
diff --git a/src/nact/nact-assistant-import.c b/src/nact/nact-assistant-import.c
index 537cd0f..174831d 100644
--- a/src/nact/nact-assistant-import.c
+++ b/src/nact/nact-assistant-import.c
@@ -342,6 +342,8 @@ static void
 runtime_init_file_selector( NactAssistantImport *window, GtkAssistant *assistant )
 {
 	static const gchar *thisfn = "nact_assistant_import_runtime_init_file_selector";
+	NactApplication *application;
+	NAPivot *pivot;
 	GtkWidget *page;
 	GtkWidget *chooser;
 	gchar *uri;
@@ -351,8 +353,11 @@ runtime_init_file_selector( NactAssistantImport *window, GtkAssistant *assistant
 	g_debug( "%s: window=%p, assistant=%p, page=%p",
 			thisfn, ( void * ) window, ( void * ) assistant, ( void * ) page );
 
+	application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
+	pivot = nact_application_get_pivot( application );
+
 	chooser = base_window_get_widget( BASE_WINDOW( window ), "ImportFileChooser" );
-	uri = base_iprefs_get_string( BASE_WINDOW( window ), IPREFS_IMPORT_ACTIONS_FOLDER_URI );
+	uri = na_iprefs_read_string( NA_IPREFS( pivot ), IPREFS_IMPORT_ACTIONS_FOLDER_URI, "file:///tmp" );
 	if( uri && strlen( uri )){
 		gtk_file_chooser_set_current_folder_uri( GTK_FILE_CHOOSER( chooser ), uri );
 	}
@@ -374,6 +379,8 @@ on_file_selection_changed( GtkFileChooser *chooser, gpointer user_data )
 	g_debug( "%s: chooser=%p, user_data=%p", thisfn, chooser, user_data );*/
 
 	GtkAssistant *assistant;
+	NactApplication *application;
+	NAPivot *pivot;
 	gint pos;
 	GSList *uris;
 	gboolean enabled;
@@ -390,7 +397,9 @@ on_file_selection_changed( GtkFileChooser *chooser, gpointer user_data )
 
 		if( enabled ){
 			folder = gtk_file_chooser_get_current_folder_uri( GTK_FILE_CHOOSER( chooser ));
-			base_iprefs_set_string( BASE_WINDOW( user_data ), IPREFS_IMPORT_ACTIONS_FOLDER_URI, folder );
+			application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( user_data )));
+			pivot = nact_application_get_pivot( application );
+			na_iprefs_write_string( NA_IPREFS( pivot ), IPREFS_IMPORT_ACTIONS_FOLDER_URI, folder );
 			g_free( folder );
 		}
 
diff --git a/src/nact/nact-icommand-tab.c b/src/nact/nact-icommand-tab.c
index 2e19847..3db02c3 100644
--- a/src/nact/nact-icommand-tab.c
+++ b/src/nact/nact-icommand-tab.c
@@ -37,6 +37,7 @@
 
 #include <common/na-object-api.h>
 #include <common/na-object-profile.h>
+#include <common/na-iprefs.h>
 #include <common/na-utils.h>
 
 #include "base-window.h"
@@ -507,11 +508,16 @@ on_path_browse( GtkButton *button, NactICommandTab *instance )
 {
 	gboolean set_current_location = FALSE;
 	gchar *uri = NULL;
+	NactApplication *application;
+	NAPivot *pivot;
 	GtkWidget *dialog;
 	GtkWidget *path_entry;
 	const gchar *path;
 	gchar *filename;
 
+	application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( instance )));
+	pivot = nact_application_get_pivot( application );
+
 	dialog = gtk_file_chooser_dialog_new(
 			_( "Choosing a command" ),
 			NULL,
@@ -530,7 +536,7 @@ on_path_browse( GtkButton *button, NactICommandTab *instance )
 		set_current_location = gtk_file_chooser_set_filename( GTK_FILE_CHOOSER( dialog ), path );
 
 	} else {
-		uri = base_iprefs_get_string( BASE_WINDOW( instance ), IPREFS_FOLDER_URI );
+		uri = na_iprefs_read_string( NA_IPREFS( pivot ), IPREFS_FOLDER_URI, "file:///bin" );
 		gtk_file_chooser_set_current_folder_uri( GTK_FILE_CHOOSER( dialog ), uri );
 		g_free( uri );
 	}
@@ -542,7 +548,7 @@ on_path_browse( GtkButton *button, NactICommandTab *instance )
 	  }
 
 	uri = gtk_file_chooser_get_current_folder_uri( GTK_FILE_CHOOSER( dialog ));
-	base_iprefs_set_string( BASE_WINDOW( instance ), IPREFS_FOLDER_URI, uri );
+	na_iprefs_write_string( NA_IPREFS( pivot ), IPREFS_FOLDER_URI, uri );
 	g_free( uri );
 
 	base_iprefs_save_named_window_position( BASE_WINDOW( instance ), GTK_WINDOW( dialog ), IPREFS_COMMAND_CHOOSER );



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