[nautilus-actions] Update import modules to new NAIPrefs API



commit a4665f2e6ff815680a59c84c113d38b2bf79694e
Author: Pierre <pierre vfedora13 virtuals pwi>
Date:   Thu Jan 13 12:52:17 2011 +0100

    Update import modules to new NAIPrefs API

 ChangeLog                  |    5 +++++
 src/api/na-iimporter.h     |   10 +++++-----
 src/core/na-importer-ask.c |   16 +++-------------
 src/core/na-importer-ask.h |   22 ++++++++++++----------
 4 files changed, 25 insertions(+), 28 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 399fa7e..d54086b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -34,6 +34,11 @@
 	* src/core/na-iprefs.c:
 	* src/core/na-iprefs.h: NAIPrefs is no more an interface.
 
+	* src/api/na-iimporter.h:
+	* src/core/na-importer-ask.c:
+	* src/core/na-importer-ask.h:
+	* src/core/na-importer.c: Updated accordingly.
+
 2011-01-12 Pierre Wieser <pwieser trychlos org>
 
 	* src/nact/nact-iprefs.c:
diff --git a/src/api/na-iimporter.h b/src/api/na-iimporter.h
index b373799..d60b0eb 100644
--- a/src/api/na-iimporter.h
+++ b/src/api/na-iimporter.h
@@ -201,13 +201,13 @@ typedef NAObjectItem * ( *NAIImporterCheckFn )( const NAObjectItem *, void * );
  * @existing: an already existing #NAObjectItem with same id.
  * @fn_data: some data to be passed to the function.
  *
- * This function may be provided by the caller in order the #NAIImporter
- * provider be able to ask the user to know what to do in the case of a
+ * This function may be provided by the caller as a convenience way for
+ * the #NAIImporter to ask the user to know what to do in the case of a
  * duplicate id.
  *
- * If this function is not provided, then the #NAIImporter provider will
- * not be able to ask the user. In this case, the duplicated id should be
- * systematically regenerated as a unique id.
+ * If this function is not provided, and the #NAIImporter does not have
+ * any other way to ask the user, then a 'no import' policy should be
+ * preferred when managing duplicate identifiers.
  *
  * Returns: the import mode choosen by the user, which must not be
  * %IMPORTER_MODE_ASK.
diff --git a/src/core/na-importer-ask.c b/src/core/na-importer-ask.c
index 21c57ac..8220820 100644
--- a/src/core/na-importer-ask.c
+++ b/src/core/na-importer-ask.c
@@ -32,11 +32,8 @@
 #include <config.h>
 #endif
 
-#include <gconf/gconf-client.h>
 #include <glib/gi18n.h>
-#include <gtk/gtk.h>
 
-#include <api/na-gconf-utils.h>
 #include <api/na-iimporter.h>
 #include <api/na-object-api.h>
 
@@ -60,7 +57,6 @@ struct _NAImporterAskPrivate {
 	NAObjectItem           *existing;
 	NAImporterAskUserParms *parms;
 	guint                   mode;
-	GConfClient            *gconf;
 	gint                    dialog_code;
 };
 
@@ -162,8 +158,6 @@ instance_init( GTypeInstance *instance, gpointer klass )
 		self->private->toplevel = GTK_WINDOW( gtk_builder_get_object( self->private->builder, "ImporterAskDialog" ));
 	}
 
-	self->private->gconf = gconf_client_get_default();
-
 	self->private->dispose_has_run = FALSE;
 }
 
@@ -183,7 +177,6 @@ instance_dispose( GObject *dialog )
 
 		self->private->dispose_has_run = TRUE;
 
-		g_object_unref( self->private->gconf );
 		g_object_unref( self->private->builder );
 
 		/* chain up to the parent class */
@@ -258,7 +251,7 @@ na_importer_ask_user( const NAObjectItem *importing, const NAObjectItem *existin
 		dialog->private->importing = ( NAObjectItem * ) importing;
 		dialog->private->existing = ( NAObjectItem * ) existing;
 		dialog->private->parms = parms;
-		dialog->private->mode = na_iprefs_get_import_mode( dialog->private->gconf, IPREFS_IMPORT_ASK_LAST_MODE );
+		dialog->private->mode = na_iprefs_get_import_mode( parms->pivot, NA_IPREFS_IMPORT_ASK_USER_LAST_MODE );
 
 		init_dialog( dialog );
 		/* toplevel is modal, not dialog
@@ -379,7 +372,6 @@ get_selected_mode( NAImporterAsk *editor )
 	guint import_mode;
 	GtkWidget *button;
 	gboolean keep;
-	gchar *path;
 
 	import_mode = IMPORTER_MODE_NO_IMPORT;
 
@@ -395,13 +387,11 @@ get_selected_mode( NAImporterAsk *editor )
 	}
 
 	editor->private->mode = import_mode;
-	na_iprefs_set_import_mode( editor->private->gconf, IPREFS_IMPORT_ASK_LAST_MODE, editor->private->mode );
+	na_iprefs_set_import_mode( editor->private->parms->pivot, NA_IPREFS_IMPORT_ASK_USER_LAST_MODE, editor->private->mode );
 
 	button = na_gtk_utils_search_for_child_widget( GTK_CONTAINER( editor->private->toplevel ), "AskKeepChoiceButton" );
 	keep = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ));
-	path = gconf_concat_dir_and_key( IPREFS_GCONF_PREFS_PATH, IPREFS_IMPORT_KEEP_CHOICE );
-	na_gconf_utils_write_bool( editor->private->gconf, path, keep, NULL );
-	g_free( path );
+	na_settings_set_boolean( na_pivot_get_settings( editor->private->parms->pivot ), NA_IPREFS_IMPORT_MODE_KEEP_LAST_CHOICE, keep );
 }
 
 /*
diff --git a/src/core/na-importer-ask.h b/src/core/na-importer-ask.h
index 61a8dc0..0222810 100644
--- a/src/core/na-importer-ask.h
+++ b/src/core/na-importer-ask.h
@@ -33,10 +33,10 @@
 
 /* @title: NAImporterAsk
  * @short_description: The #NAImporterAsk Class Definition
- * @include: core/na-iimporter-ask.h
+ * @include: core/na-importer-ask.h
  *
- * This class reates and manages a dialog. It is ran each time an
- * imported action as the same ID as an existing one, and the user
+ * This class creates and manages a dialog. It is ran each time an
+ * imported action as the same Id as an existing one, and the user
  * want to be ask to known what to do with it.
  */
 
@@ -44,6 +44,8 @@
 
 #include <api/na-object-item.h>
 
+#include "na-pivot.h"
+
 G_BEGIN_DECLS
 
 #define NA_IMPORTER_ASK_TYPE                 ( na_importer_ask_get_type())
@@ -53,7 +55,8 @@ G_BEGIN_DECLS
 #define NA_IS_IMPORTER_ASK_CLASS( klass )    ( G_TYPE_CHECK_CLASS_TYPE(( klass ), NA_IMPORTER_ASK_TYPE ))
 #define NA_IMPORTER_ASK_GET_CLASS( object )  ( G_TYPE_INSTANCE_GET_CLASS(( object ), NA_IMPORTER_ASK_TYPE, NAImporterAskClass ))
 
-typedef struct _NAImporterAskPrivate      NAImporterAskPrivate;
+typedef struct _NAImporterAskPrivate         NAImporterAskPrivate;
+typedef struct _NAImporterAskClassPrivate    NAImporterAskClassPrivate;
 
 typedef struct {
 	/*< private >*/
@@ -62,8 +65,6 @@ typedef struct {
 }
 	NAImporterAsk;
 
-typedef struct _NAImporterAskClassPrivate NAImporterAskClassPrivate;
-
 typedef struct {
 	/*< private >*/
 	GtkDialogClass             parent;
@@ -72,10 +73,11 @@ typedef struct {
 	NAImporterAskClass;
 
 typedef struct {
-	GtkWindow    *parent;
-	gchar        *uri;
-	guint         count;
-	gboolean      keep_choice;
+	GtkWindow *parent;
+	gchar     *uri;
+	guint      count;
+	gboolean   keep_choice;
+	NAPivot   *pivot;
 }
 	NAImporterAskUserParms;
 



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