[nautilus-actions] NAImporterAsk, NactAssistantImport: implement NAIOptionsList interface



commit 38d1d1564af330e78041cd2884c765dc12722432
Author: Pierre Wieser <pwieser trychlos org>
Date:   Sun Jan 1 14:00:07 2012 +0100

    NAImporterAsk, NactAssistantImport: implement NAIOptionsList interface

 ChangeLog                        |   17 ++-
 src/core/na-import-mode.c        |   43 +++++-
 src/core/na-import-mode.h        |    2 +
 src/core/na-importer-ask.c       |  165 ++++++++++++--------
 src/core/na-importer-ask.ui      |  168 ++++++--------------
 src/core/na-importer.c           |   95 ++++++------
 src/core/na-ioption.c            |   16 --
 src/core/na-ioption.h            |    4 +-
 src/core/na-ioptions-list.c      |    2 +-
 src/nact/nact-assistant-import.c |  316 +++++++++++---------------------------
 10 files changed, 344 insertions(+), 484 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8694f1d..c2881e6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2012-01-01 Pierre Wieser <pwieser trychlos org>
+
+	* src/core/na-import-mode.c:
+	* src/core/na-import-mode.h (na_import_mode_get_id): New function.
+
+	* src/core/na-importer-ask.c (on_destroy_toplevel): Fix handler signature.
+
+	* src/core/na-importer.c (get_mode_from_struct): Fix GdkPixbuf reference count.
+
+	* src/core/na-ioption.h:
+	* src/core/na-ioptions-list.c: Fix typo.
+
+	* src/core/na-importer-ask.c:
+	* src/nact/nact-assistant-import.c: Implement NAIOptionsList interface.
+
 2011-12-31 Pierre Wieser <pwieser trychlos org>
 
 	* src/core/na-importer.c:
@@ -20,7 +35,7 @@
 	* src/nact/nact-export-ask.c: Updated accordingly.
 
 	* src/nact/nact-preferences-editor.c:
-	Implement NAIOptionsList itnerface for Import mode tab.
+	Implement NAIOptionsList interface for Import mode tab.
 
 	* src/nact/nact-preferences.ui: Updated accordingly.
 
diff --git a/src/core/na-import-mode.c b/src/core/na-import-mode.c
index 76e452c..c1644d1 100644
--- a/src/core/na-import-mode.c
+++ b/src/core/na-import-mode.c
@@ -173,11 +173,10 @@ class_init( NAImportModeClass *klass )
 					G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE ));
 
 	g_object_class_install_property( object_class, NA_IMPORT_PROP_IMAGE_ID,
-			g_param_spec_object(
+			g_param_spec_pointer(
 					NA_IMPORT_PROP_IMAGE,
 					"Import mode image",
 					"The image associated to the import mode, as a GdkPixbuf",
-					G_TYPE_OBJECT,
 					G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE ));
 }
 
@@ -335,7 +334,7 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
 				break;
 
 			case NA_IMPORT_PROP_IMAGE_ID:
-				g_value_set_object( value, self->private->image );
+				g_value_set_pointer( value, self->private->image );
 				break;
 
 			default:
@@ -372,10 +371,7 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
 				break;
 
 			case NA_IMPORT_PROP_IMAGE_ID:
-				if( self->private->image ){
-					g_object_unref( self->private->image );
-				}
-				self->private->image = g_value_get_object( value );
+				self->private->image = g_value_get_pointer( value );
 				break;
 
 			default:
@@ -428,6 +424,14 @@ instance_finalize( GObject *object )
 	}
 }
 
+/*
+ * na_import_mode_new:
+ * @mode_id: the internal identifier of the import mode.
+ *
+ * Returns: a newly allocated #NAImportMode object.
+ *
+ * Since: 3.2
+ */
 NAImportMode *
 na_import_mode_new( guint mode_id )
 {
@@ -439,3 +443,28 @@ na_import_mode_new( guint mode_id )
 
 	return( mode );
 }
+
+/*
+ * na_import_mode_get_id:
+ * @mode: a #NAImportMode object.
+ *
+ * Returns: the internal identifier of the import mode.
+ *
+ * Since: 3.2
+ */
+guint
+na_import_mode_get_id( const NAImportMode *mode )
+{
+	guint id;
+
+	g_return_val_if_fail( NA_IS_IMPORT_MODE( mode ), 0 );
+
+	id = 0;
+
+	if( !mode->private->dispose_has_run ){
+
+		id = mode->private->id;
+	}
+
+	return( id );
+}
diff --git a/src/core/na-import-mode.h b/src/core/na-import-mode.h
index bca0734..1803eee 100644
--- a/src/core/na-import-mode.h
+++ b/src/core/na-import-mode.h
@@ -79,6 +79,8 @@ GType         na_import_mode_get_type( void );
 
 NAImportMode *na_import_mode_new     ( guint mode_id );
 
+guint         na_import_mode_get_id  ( const NAImportMode *mode );
+
 G_END_DECLS
 
 #endif /* __CORE_NA_IMPORT_MODE_H__ */
diff --git a/src/core/na-importer-ask.c b/src/core/na-importer-ask.c
index 30a95a7..84e831e 100644
--- a/src/core/na-importer-ask.c
+++ b/src/core/na-importer-ask.c
@@ -38,8 +38,10 @@
 #include <api/na-object-api.h>
 
 #include "na-gtk-utils.h"
-#include "na-iprefs.h"
+#include "na-import-mode.h"
+#include "na-importer.h"
 #include "na-importer-ask.h"
+#include "na-ioptions-list.h"
 #include "na-settings.h"
 
 /* private class data
@@ -63,18 +65,20 @@ static GObjectClass  *st_parent_class = NULL;
 static NAImporterAsk *st_dialog       = NULL;
 static const gchar   *st_uixml        = PKGDATADIR "/na-importer-ask.ui";
 
-static GType      register_type( void );
-static void       class_init( NAImporterAskClass *klass );
-static void       instance_init( GTypeInstance *instance, gpointer klass );
-static void       instance_dispose( GObject *dialog );
-static void       instance_finalize( GObject *dialog );
-
+static GType          register_type( void );
+static void           class_init( NAImporterAskClass *klass );
+static void           ioptions_list_iface_init( NAIOptionsListInterface *iface );
+static GList         *ioptions_list_get_modes( const NAIOptionsList *instance, GtkWidget *container );
+static void           ioptions_list_free_modes( const NAIOptionsList *instance, GtkWidget *container, GList *modes );
+static void           instance_init( GTypeInstance *instance, gpointer klass );
+static void           instance_dispose( GObject *dialog );
+static void           instance_finalize( GObject *dialog );
 static NAImporterAsk *import_ask_new( GtkWindow *parent );
-
-static void       init_dialog( NAImporterAsk *editor );
-static void       get_selected_mode( NAImporterAsk *editor );
-static gboolean   on_destroy_toplevel( GtkWindow *toplevel, GdkEvent *event, NAImporterAsk *dialog );
-static gboolean   on_dialog_response( NAImporterAsk *editor, gint code );
+static void           initialize_gtk( NAImporterAsk *dialog, GtkWindow *toplevel );
+static void           initialize_window( NAImporterAsk *dialog, GtkWindow *toplevel );
+static void           get_selected_mode( NAImporterAsk *editor );
+static void           on_destroy_toplevel( GtkWindow *toplevel, NAImporterAsk *dialog );
+static gboolean       on_dialog_response( NAImporterAsk *editor, gint code );
 
 GType
 na_importer_ask_get_type( void )
@@ -106,10 +110,18 @@ register_type( void )
 		( GInstanceInitFunc ) instance_init
 	};
 
+	static const GInterfaceInfo ioptions_list_iface_info = {
+		( GInterfaceInitFunc ) ioptions_list_iface_init,
+		NULL,
+		NULL
+	};
+
 	g_debug( "%s", thisfn );
 
 	type = g_type_register_static( G_TYPE_OBJECT, "NAImporterAsk", &info, 0 );
 
+	g_type_add_interface_static( type, NA_IOPTIONS_LIST_TYPE, &ioptions_list_iface_info );
+
 	return( type );
 }
 
@@ -131,6 +143,37 @@ class_init( NAImporterAskClass *klass )
 }
 
 static void
+ioptions_list_iface_init( NAIOptionsListInterface *iface )
+{
+	static const gchar *thisfn = "nact_assistant_import_ioptions_list_iface_init";
+
+	g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
+
+	iface->get_options = ioptions_list_get_modes;
+	iface->free_options = ioptions_list_free_modes;
+}
+
+static GList *
+ioptions_list_get_modes( const NAIOptionsList *instance, GtkWidget *container )
+{
+	GList *modes;
+
+	g_return_val_if_fail( NA_IS_IMPORTER_ASK( instance ), NULL );
+
+	modes = na_importer_get_modes();
+
+	return( modes );
+}
+
+static void
+ioptions_list_free_modes( const NAIOptionsList *instance, GtkWidget *container, GList *modes )
+{
+	g_return_if_fail( NA_IS_IMPORTER_ASK( instance ));
+
+	na_importer_free_modes( modes );
+}
+
+static void
 instance_init( GTypeInstance *instance, gpointer klass )
 {
 	static const gchar *thisfn = "na_importer_ask_instance_init";
@@ -237,10 +280,14 @@ import_ask_new( GtkWindow *parent )
 					gtk_window_set_destroy_with_parent( dialog->private->toplevel, TRUE );
 					g_signal_connect(
 							G_OBJECT( dialog->private->toplevel ),
-							"destroy", G_CALLBACK( on_destroy_toplevel ), dialog );
+							"destroy",
+							G_CALLBACK( on_destroy_toplevel ),
+							dialog );
 					st_dialog = dialog;
 				}
 
+				initialize_gtk( dialog, toplevel );
+
 #if !GTK_CHECK_VERSION( 2,22,0 )
 				gtk_dialog_set_has_separator( GTK_DIALOG( toplevel ), FALSE );
 #endif
@@ -298,9 +345,8 @@ 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( NA_IPREFS_IMPORT_ASK_USER_LAST_MODE, NULL );
 
-		init_dialog( dialog );
+		initialize_window( dialog, dialog->private->toplevel );
 
 		do {
 			code = gtk_dialog_run( GTK_DIALOG( dialog->private->toplevel ));
@@ -319,19 +365,33 @@ na_importer_ask_user( const NAObjectItem *importing, const NAObjectItem *existin
 
 	return( mode );
 }
+static void
+initialize_gtk( NAImporterAsk *dialog, GtkWindow *toplevel )
+{
+	static const gchar *thisfn = "na_importer_ask_initialize_gtk";
+	GtkWidget *container;
+
+	g_return_if_fail( NA_IS_IMPORTER_ASK( dialog ));
+
+	g_debug( "%s: dialog=%p, toplevel=%p", thisfn, ( void * ) dialog, ( void * ) toplevel );
+
+	container = na_gtk_utils_find_widget_by_name( GTK_CONTAINER( toplevel ), "AskModeVBox" );
+	na_ioptions_list_gtk_init( NA_IOPTIONS_LIST( dialog ), container, FALSE );
+}
 
 static void
-init_dialog( NAImporterAsk *editor )
+initialize_window( NAImporterAsk *editor, GtkWindow *toplevel )
 {
-	static const gchar *thisfn = "na_importer_ask_init_dialog";
+	static const gchar *thisfn = "na_importer_ask_initialize_window";
 	gchar *imported_label, *existing_label;
 	gchar *label;
 	GtkWidget *widget;
 	GtkWidget *button;
+	gchar *mode_id;
 
 	g_return_if_fail( NA_IS_IMPORTER_ASK( editor ));
 
-	g_debug( "%s: editor=%p", thisfn, ( void * ) editor );
+	g_debug( "%s: editor=%p, toplevel=%p", thisfn, ( void * ) editor, ( void * ) toplevel );
 
 	imported_label = na_object_get_label( editor->private->importing );
 	existing_label = na_object_get_label( editor->private->existing );
@@ -349,55 +409,39 @@ init_dialog( NAImporterAsk *editor )
 				imported_label, editor->private->parms->uri, existing_label );
 	}
 
-	widget = na_gtk_utils_find_widget_by_name( GTK_CONTAINER( editor->private->toplevel ), "ImporterAskLabel" );
+	widget = na_gtk_utils_find_widget_by_name( GTK_CONTAINER( toplevel ), "ImporterAskLabel" );
 	gtk_label_set_text( GTK_LABEL( widget ), label );
 	g_free( label );
 
-	switch( editor->private->mode ){
-		case IMPORTER_MODE_RENUMBER:
-			button = na_gtk_utils_find_widget_by_name( GTK_CONTAINER( editor->private->toplevel ), "AskRenumberButton" );
-			break;
+	widget = na_gtk_utils_find_widget_by_name( GTK_CONTAINER( toplevel ), "AskModeVBox" );
+	mode_id = na_settings_get_string( NA_IPREFS_IMPORT_ASK_USER_LAST_MODE, NULL, NULL );
+	na_ioptions_list_set_default( NA_IOPTIONS_LIST( editor ), widget, mode_id );
+	g_free( mode_id );
 
-		case IMPORTER_MODE_OVERRIDE:
-			button = na_gtk_utils_find_widget_by_name( GTK_CONTAINER( editor->private->toplevel ), "AskOverrideButton" );
-			break;
-
-		case IMPORTER_MODE_NO_IMPORT:
-		default:
-			button = na_gtk_utils_find_widget_by_name( GTK_CONTAINER( editor->private->toplevel ), "AskNoImportButton" );
-			break;
-	}
-	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), TRUE );
-
-	button = na_gtk_utils_find_widget_by_name( GTK_CONTAINER( editor->private->toplevel ), "AskKeepChoiceButton" );
+	button = na_gtk_utils_find_widget_by_name( GTK_CONTAINER( toplevel ), "AskKeepChoiceButton" );
 	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), editor->private->parms->keep_choice );
 
-	na_gtk_utils_restore_window_position( editor->private->toplevel, NA_IPREFS_IMPORT_ASK_USER_WSP );
-	gtk_widget_show_all( GTK_WIDGET( editor->private->toplevel ));
+	na_gtk_utils_restore_window_position( toplevel, NA_IPREFS_IMPORT_ASK_USER_WSP );
+	gtk_widget_show_all( GTK_WIDGET( toplevel ));
 }
 
 static void
 get_selected_mode( NAImporterAsk *editor )
 {
-	guint import_mode;
+	GtkWidget *widget;
+	NAIOption *mode;
+	gchar *mode_id;
 	GtkWidget *button;
 	gboolean keep;
 
-	import_mode = IMPORTER_MODE_NO_IMPORT;
-
-	button = na_gtk_utils_find_widget_by_name( GTK_CONTAINER( editor->private->toplevel ), "AskRenumberButton" );
-	if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ))){
-		import_mode = IMPORTER_MODE_RENUMBER;
+	widget = na_gtk_utils_find_widget_by_name( GTK_CONTAINER( editor->private->toplevel ), "AskModeVBox" );
+	mode = na_ioptions_list_get_selected( NA_IOPTIONS_LIST( editor ), widget );
 
-	} else {
-		button = na_gtk_utils_find_widget_by_name( GTK_CONTAINER( editor->private->toplevel ), "AskOverrideButton" );
-		if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ))){
-			import_mode = IMPORTER_MODE_OVERRIDE;
-		}
-	}
+	mode_id = na_ioption_get_id( mode );
+	na_settings_set_string( NA_IPREFS_IMPORT_ASK_USER_LAST_MODE, mode_id );
+	g_free( mode_id );
 
-	editor->private->mode = import_mode;
-	na_iprefs_set_import_mode( NA_IPREFS_IMPORT_ASK_USER_LAST_MODE, editor->private->mode );
+	editor->private->mode = na_import_mode_get_id( NA_IMPORT_MODE( mode ));
 
 	button = na_gtk_utils_find_widget_by_name( GTK_CONTAINER( editor->private->toplevel ), "AskKeepChoiceButton" );
 	keep = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ));
@@ -409,25 +453,22 @@ get_selected_mode( NAImporterAsk *editor )
  * with a parent window; it has been defined with 'destroy_with_parent'
  * and so we have yet to unref the NAImporterAsk object itself
  */
-static gboolean
-on_destroy_toplevel( GtkWindow *toplevel, GdkEvent *event, NAImporterAsk *dialog )
+static void
+on_destroy_toplevel( GtkWindow *toplevel, NAImporterAsk *dialog )
 {
 	static const gchar *thisfn = "na_importer_ask_on_destroy_toplevel";
 
-	g_debug( "%s: toplevel=%p, event=%p, dialog=%p",
-			thisfn, ( void * ) toplevel, ( void * ) event, ( void * ) dialog );
+	g_debug( "%s: toplevel=%p, dialog=%p",
+			thisfn, ( void * ) toplevel, ( void * ) dialog );
 
-	g_return_val_if_fail( NA_IS_IMPORTER_ASK( dialog ), FALSE );
+	g_return_if_fail( NA_IS_IMPORTER_ASK( dialog ));
+	g_return_if_fail( toplevel == dialog->private->toplevel );
 
 	if( !dialog->private->dispose_has_run ){
-		if( toplevel == dialog->private->toplevel ){
-			dialog->private->toplevel = NULL;
-		}
+
+		dialog->private->toplevel = NULL;
 		g_object_unref( dialog );
 	}
-
-	/* let the event be propagated */
-	return( FALSE );
 }
 
 static gboolean
diff --git a/src/core/na-importer-ask.ui b/src/core/na-importer-ask.ui
index 924dd0d..5affcc8 100644
--- a/src/core/na-importer-ask.ui
+++ b/src/core/na-importer-ask.ui
@@ -1,218 +1,146 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0"?>
 <interface>
-  <!-- interface-requires gtk+ 2.20 -->
+  <requires lib="gtk+" version="2.20"/>
+  <!-- interface-naming-policy toplevel-contextual -->
   <object class="GtkDialog" id="ImporterAskDialog">
-    <property name="can_focus">False</property>
     <property name="border_width">5</property>
     <property name="title" translatable="yes">Already existing item</property>
     <property name="modal">True</property>
     <property name="window_position">center-on-parent</property>
     <property name="type_hint">dialog</property>
     <child internal-child="vbox">
-      <object class="GtkBox" id="dialog-vbox1">
+      <object class="GtkVBox" id="dialog-vbox1">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
         <property name="orientation">vertical</property>
         <property name="spacing">2</property>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="dialog-action_area11">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="CancelButton">
-                <property name="label">gtk-cancel</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="OKButton">
-                <property name="label">gtk-ok</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
         <child>
           <object class="GtkVBox" id="vbox11">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
+            <property name="orientation">vertical</property>
             <property name="spacing">6</property>
             <child>
               <object class="GtkVBox" id="vbox111">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
                 <property name="spacing">6</property>
                 <child>
                   <object class="GtkLabel" id="ImporterAskLabel">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
                     <property name="xalign">0</property>
                     <property name="xpad">6</property>
                     <property name="wrap">True</property>
                   </object>
                   <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
                     <property name="position">0</property>
                   </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="label1111">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
                     <property name="xalign">0</property>
                     <property name="xpad">6</property>
                     <property name="label" translatable="yes">What should I do with this ?</property>
                   </object>
                   <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
                     <property name="position">1</property>
                   </packing>
                 </child>
               </object>
               <packing>
                 <property name="expand">False</property>
-                <property name="fill">True</property>
                 <property name="position">0</property>
               </packing>
             </child>
             <child>
-              <object class="GtkVBox" id="vbox112">
+              <object class="GtkVBox" id="AskModeVBox">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
                 <child>
-                  <object class="GtkRadioButton" id="AskNoImportButton">
-                    <property name="label" translatable="yes">Do _not import the action</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="use_underline">True</property>
-                    <property name="xalign">0</property>
-                    <property name="active">True</property>
-                    <property name="draw_indicator">True</property>
-                  </object>
-                  <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkRadioButton" id="AskRenumberButton">
-                    <property name="label" translatable="yes">Import the action, _renumbering it</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="use_underline">True</property>
-                    <property name="xalign">0</property>
-                    <property name="draw_indicator">True</property>
-                    <property name="group">AskNoImportButton</property>
-                  </object>
-                  <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkRadioButton" id="AskOverrideButton">
-                    <property name="label" translatable="yes">_Override the existing action</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="use_underline">True</property>
-                    <property name="xalign">0</property>
-                    <property name="draw_indicator">True</property>
-                    <property name="group">AskNoImportButton</property>
-                  </object>
-                  <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
-                    <property name="position">2</property>
-                  </packing>
+                  <placeholder/>
                 </child>
               </object>
               <packing>
                 <property name="expand">False</property>
-                <property name="fill">True</property>
                 <property name="position">1</property>
               </packing>
             </child>
             <child>
               <object class="GtkHSeparator" id="hseparator1121">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
               </object>
               <packing>
                 <property name="expand">False</property>
-                <property name="fill">True</property>
                 <property name="position">2</property>
               </packing>
             </child>
             <child>
               <object class="GtkVBox" id="vbox113">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
                 <child>
                   <object class="GtkCheckButton" id="AskKeepChoiceButton">
                     <property name="label" translatable="yes">Re_member my choice in future import operations</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
                     <property name="use_underline">True</property>
                     <property name="xalign">0</property>
                     <property name="draw_indicator">True</property>
                   </object>
                   <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
                     <property name="position">0</property>
                   </packing>
                 </child>
               </object>
               <packing>
                 <property name="expand">False</property>
-                <property name="fill">True</property>
                 <property name="position">3</property>
               </packing>
             </child>
           </object>
           <packing>
             <property name="expand">False</property>
-            <property name="fill">True</property>
             <property name="position">2</property>
           </packing>
         </child>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area11">
+            <property name="visible">True</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="CancelButton">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="OKButton">
+                <property name="label">gtk-ok</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
       </object>
     </child>
     <action-widgets>
diff --git a/src/core/na-importer.c b/src/core/na-importer.c
index 3c9d544..2b12f4f 100644
--- a/src/core/na-importer.c
+++ b/src/core/na-importer.c
@@ -93,7 +93,7 @@ static NAImportModeStr st_import_ask_mode = {
 			IMPORT_MODE_ASK_STR,
 			N_( "_Ask me" ),
 			N_( "You will be asked each time an imported ID already exists." ),
-			"import-mode-no-import.png"
+			"import-mode-ask.png"
 };
 
 typedef struct {
@@ -109,6 +109,7 @@ extern gboolean iimporter_finalized;		/* defined in na-iimporter.c */
 static guint         import_from_uri( const NAPivot *pivot, GList *modules, NAImporterParms *parms, const gchar *uri, NAImporterResult **result );
 static NAObjectItem *is_importing_already_exists( const NAObjectItem *importing, ImporterExistsStr *parms );
 static guint         ask_user_for_mode( const NAObjectItem *importing, const NAObjectItem *existing, NAImporterAskUserParms *parms );
+static NAIOption    *get_mode_from_struct( const NAImportModeStr *str );
 
 /* i18n: '%s' stands for the file URI */
 #define ERR_NOT_LOADABLE	_( "%s is not loadable (empty or too big or not a regular file)" )
@@ -334,56 +335,25 @@ ask_user_for_mode( const NAObjectItem *importing, const NAObjectItem *existing,
 GList *
 na_importer_get_modes( void )
 {
+	static const gchar *thisfn = "na_importer_get_modes";
 	GList *modes;
-	NAImportMode *mode;
+	NAIOption *mode;
 	guint i;
-	gint width, height;
-	gchar *fname;
-	GdkPixbuf *pixbuf;
 
-	modes = NULL;
-	pixbuf = NULL;
+	g_debug( "%s", thisfn );
 
-	if( !gtk_icon_size_lookup( GTK_ICON_SIZE_DIALOG, &width, &height )){
-		width = height = 48;
-	}
+	modes = NULL;
 
 	for( i = 0 ; st_import_modes[i].id ; ++i ){
-		mode = na_import_mode_new( st_import_modes[i].id );
-		if( st_import_modes[i].image ){
-			fname = g_strdup_printf( "%s/%s", PKGDATADIR, st_import_modes[i].image );
-			pixbuf = gdk_pixbuf_new_from_file_at_size( fname, width, height, NULL );
-			g_free( fname );
-		}
-		g_object_set( G_OBJECT( mode ),
-				NA_IMPORT_PROP_MODE,        st_import_modes[i].mode,
-				NA_IMPORT_PROP_LABEL,       gettext( st_import_modes[i].label ),
-				NA_IMPORT_PROP_DESCRIPTION, gettext( st_import_modes[i].description ),
-				NA_IMPORT_PROP_IMAGE,       pixbuf,
-				NULL );
-		if( pixbuf ){
-			g_object_unref( pixbuf );
-		}
+		mode = get_mode_from_struct( st_import_modes+i );
 		modes = g_list_prepend( modes, mode );
 	}
 
 	return( modes );
 }
 
-void
-na_importer_free_modes( GList *modes )
-{
-	g_list_foreach( modes, ( GFunc ) g_object_unref, NULL );
-	g_list_free( modes );
-}
-
-/*
- * na_importer_get_ask_mode:
- *
- * Returns: a #NAImportMode object which describes the 'Ask me' option.
- */
-NAIOption *
-na_importer_get_ask_mode( void )
+static NAIOption *
+get_mode_from_struct( const NAImportModeStr *str )
 {
 	NAImportMode *mode;
 	gint width, height;
@@ -394,23 +364,52 @@ na_importer_get_ask_mode( void )
 		width = height = 48;
 	}
 
-	mode = na_import_mode_new( st_import_ask_mode.id );
+	mode = na_import_mode_new( str->id );
 	pixbuf = NULL;
 
-	if( st_import_ask_mode.image ){
-		fname = g_strdup_printf( "%s/%s", PKGDATADIR, st_import_ask_mode.image );
+	if( str->image && g_utf8_strlen( str->image, -1 )){
+		fname = g_strdup_printf( "%s/%s", PKGDATADIR, str->image );
 		pixbuf = gdk_pixbuf_new_from_file_at_size( fname, width, height, NULL );
 		g_free( fname );
 	}
 	g_object_set( G_OBJECT( mode ),
-		NA_IMPORT_PROP_MODE,        st_import_ask_mode.mode,
-		NA_IMPORT_PROP_LABEL,       gettext( st_import_ask_mode.label ),
-		NA_IMPORT_PROP_DESCRIPTION, gettext( st_import_ask_mode.description ),
+		NA_IMPORT_PROP_MODE,        str->mode,
+		NA_IMPORT_PROP_LABEL,       gettext( str->label ),
+		NA_IMPORT_PROP_DESCRIPTION, gettext( str->description ),
 		NA_IMPORT_PROP_IMAGE,       pixbuf,
 		NULL );
-	if( pixbuf ){
-		g_object_unref( pixbuf );
-	}
 
 	return( NA_IOPTION( mode ));
 }
+
+/*
+ * na_importer_free_modes:
+ * @modes: a #GList of #NAImportMode items, as returned by na_importer_get_modes().
+ *
+ * Releases the resources allocated to the @modes list.
+ */
+void
+na_importer_free_modes( GList *modes )
+{
+	static const gchar *thisfn = "na_importer_free_modes";
+
+	g_debug( "%s: modes=%p", thisfn, ( void * ) modes );
+
+	g_list_foreach( modes, ( GFunc ) g_object_unref, NULL );
+	g_list_free( modes );
+}
+
+/*
+ * na_importer_get_ask_mode:
+ *
+ * Returns: a #NAImportMode object which describes the 'Ask me' option.
+ */
+NAIOption *
+na_importer_get_ask_mode( void )
+{
+	static const gchar *thisfn = "na_importer_get_ask_mode";
+
+	g_debug( "%s", thisfn );
+
+	return( get_mode_from_struct( &st_import_ask_mode ));
+}
diff --git a/src/core/na-ioption.c b/src/core/na-ioption.c
index cbe3d97..82f61b5 100644
--- a/src/core/na-ioption.c
+++ b/src/core/na-ioption.c
@@ -288,19 +288,3 @@ na_ioption_get_pixbuf( const NAIOption *option )
 
 	return( pixbuf );
 }
-
-#if 0
-/*
- * na_ioption_free_option:
- * @option: this #NAIOption instance.
- *
- * Release the resources associated to the @option.
- */
-void
-na_ioption_free_option( NAIOption *option )
-{
-	g_return_if_fail( NA_IS_IOPTION( option ));
-
-	g_object_unref( option );
-}
-#endif
diff --git a/src/core/na-ioption.h b/src/core/na-ioption.h
index 16b4330..8a14f03 100644
--- a/src/core/na-ioption.h
+++ b/src/core/na-ioption.h
@@ -161,9 +161,7 @@ typedef struct {
 }
 	NAIOptionInterface;
 
-#define NA_IOPTION_PROP_OPTION
-
-GType      na_ioption_get_type( void );
+GType      na_ioption_get_type       ( void );
 
 gchar     *na_ioption_get_id         ( const NAIOption *option );
 gchar     *na_ioption_get_label      ( const NAIOption *option );
diff --git a/src/core/na-ioptions-list.c b/src/core/na-ioptions-list.c
index 2b4eeeb..d98acb7 100644
--- a/src/core/na-ioptions-list.c
+++ b/src/core/na-ioptions-list.c
@@ -661,7 +661,7 @@ tree_view_create_model( const NAIOptionsList *instance, GtkWidget *container_par
 static void
 tree_view_populate( const NAIOptionsList *instance, GtkWidget *container_parent, gboolean with_ask )
 {
-	static const gchar *thisfn = "nact_export_format_tree_view_populate";
+	static const gchar *thisfn = "na_ioptions_list_tree_view_populate";
 	GtkTreeModel *model;
 	NAIOption *option;
 	GList *options, *iopt;
diff --git a/src/nact/nact-assistant-import.c b/src/nact/nact-assistant-import.c
index 8b3c25c..0d85289 100644
--- a/src/nact/nact-assistant-import.c
+++ b/src/nact/nact-assistant-import.c
@@ -39,9 +39,11 @@
 #include <api/na-object-api.h>
 #include <api/na-core-utils.h>
 
+#include <core/na-import-mode.h>
 #include <core/na-importer.h>
-#include <core/na-iprefs.h>
+#include <core/na-ioptions-list.h>
 #include <core/na-gtk-utils.h>
+#include <core/na-settings.h>
 
 #include "nact-application.h"
 #include "nact-assistant-import.h"
@@ -77,47 +79,6 @@ enum {
 	N_COLUMN
 };
 
-/* import modes
- */
-typedef struct {
-	guint  mode;
-	gchar *label;
-	gchar *tooltip;
-	gchar *image;
-}
-	ImportModeDefs;
-
-static ImportModeDefs st_import_modes[] = {
-		{ IMPORTER_MODE_NO_IMPORT,
-				N_( "Do not import the item whose ID already exists" ),
-				N_( "This used to be the historical behavior.\n" \
-					"The selected file will be marked as \"NOT OK\" in the Summary page.\n" \
-					"The existing item will not be modified." ),
-				"import-mode-no-import.png"
-		},
-		{ IMPORTER_MODE_RENUMBER,
-				N_( "Allocate a new identifier for the imported item" ),
-				N_( "The selected file will be imported with a slightly " \
-					"modified label indicating the renumbering.\n" \
-					"The existing item will not be modified." ),
-				"import-mode-renumber.png"
-		},
-		{ IMPORTER_MODE_OVERRIDE,
-				N_( "Override the existing item" ),
-				N_( "The item found in the selected file will silently " \
-					"override the current one which has the same identifier.\n" \
-					"Be warned: this mode may be dangerous. " \
-					"You will not be prompted another time." ),
-				"import-mode-override.png"
-		},
-		{ IMPORTER_MODE_ASK,
-				N_( "Ask me" ),
-				N_( "You will be asked each time an imported ID already exists." ),
-				"import-mode-ask.png"
-		},
-		{ 0 }
-};
-
 /* private class data
  */
 struct _NactAssistantImportClassPrivate {
@@ -130,8 +91,7 @@ struct _NactAssistantImportPrivate {
 	gboolean     dispose_has_run;
 	GtkWidget   *file_chooser;
 	GtkTreeView *duplicates_listview;
-	guint        mode;
-	guint        index_mode;
+	NAIOption   *mode;
 	GList       *results;
 };
 
@@ -143,6 +103,10 @@ static BaseAssistantClass *st_parent_class   = NULL;
 
 static GType         register_type( void );
 static void          class_init( NactAssistantImportClass *klass );
+static void          ioptions_list_iface_init( NAIOptionsListInterface *iface );
+static GList        *ioptions_list_get_modes( const NAIOptionsList *instance, GtkWidget *container );
+static void          ioptions_list_free_modes( const NAIOptionsList *instance, GtkWidget *container, GList *modes );
+static NAIOption    *ioptions_list_get_ask_option( const NAIOptionsList *instance, GtkWidget *container );
 static void          instance_init( GTypeInstance *instance, gpointer klass );
 static void          instance_dispose( GObject *application );
 static void          instance_finalize( GObject *application );
@@ -155,11 +119,6 @@ static void          runtime_init_file_selector( NactAssistantImport *window, Gt
 static void          on_file_selection_changed( GtkFileChooser *chooser, gpointer user_data );
 static gboolean      has_loadable_files( GSList *uris );
 static void          runtime_init_duplicates( NactAssistantImport *window, GtkAssistant *assistant );
-static void          clear_duplicates_treeview( NactAssistantImport *window );
-static void          populate_duplicates_treeview( NactAssistantImport *window );
-static void          on_duplicates_selection_changed( GtkTreeSelection *selection, NactAssistantImport *window );
-static void          select_import_mode( NactAssistantImport *window );
-static gboolean      iter_on_model_for_select( GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, NactAssistantImport *window );
 
 static void          assistant_prepare( BaseAssistant *window, GtkAssistant *assistant, GtkWidget *page );
 static void          prepare_confirm( NactAssistantImport *window, GtkAssistant *assistant, GtkWidget *page );
@@ -202,10 +161,18 @@ register_type( void )
 		( GInstanceInitFunc ) instance_init
 	};
 
+	static const GInterfaceInfo ioptions_list_iface_info = {
+		( GInterfaceInitFunc ) ioptions_list_iface_init,
+		NULL,
+		NULL
+	};
+
 	g_debug( "%s", thisfn );
 
 	type = g_type_register_static( BASE_ASSISTANT_TYPE, "NactAssistantImport", &info, 0 );
 
+	g_type_add_interface_static( type, NA_IOPTIONS_LIST_TYPE, &ioptions_list_iface_info );
+
 	return( type );
 }
 
@@ -232,6 +199,42 @@ class_init( NactAssistantImportClass *klass )
 }
 
 static void
+ioptions_list_iface_init( NAIOptionsListInterface *iface )
+{
+	static const gchar *thisfn = "nact_assistant_import_ioptions_list_iface_init";
+
+	g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
+
+	iface->get_options = ioptions_list_get_modes;
+	iface->free_options = ioptions_list_free_modes;
+	iface->get_ask_option = ioptions_list_get_ask_option;
+}
+
+static GList *
+ioptions_list_get_modes( const NAIOptionsList *instance, GtkWidget *container )
+{
+	GList *modes;
+
+	g_return_val_if_fail( NACT_IS_ASSISTANT_IMPORT( instance ), NULL );
+
+	modes = na_importer_get_modes();
+
+	return( modes );
+}
+
+static void
+ioptions_list_free_modes( const NAIOptionsList *instance, GtkWidget *container, GList *modes )
+{
+	na_importer_free_modes( modes );
+}
+
+static NAIOption *
+ioptions_list_get_ask_option( const NAIOptionsList *instance, GtkWidget *container )
+{
+	return( na_importer_get_ask_mode());
+}
+
+static void
 instance_init( GTypeInstance *instance, gpointer klass )
 {
 	static const gchar *thisfn = "nact_assistant_import_instance_init";
@@ -248,11 +251,17 @@ instance_init( GTypeInstance *instance, gpointer klass )
 
 	self->private->results = NULL;
 
-	base_window_signal_connect( BASE_WINDOW( instance ),
-			G_OBJECT( instance ), BASE_SIGNAL_INITIALIZE_GTK, G_CALLBACK( on_base_initialize_gtk ));
+	base_window_signal_connect(
+			BASE_WINDOW( instance ),
+			G_OBJECT( instance ),
+			BASE_SIGNAL_INITIALIZE_GTK,
+			G_CALLBACK( on_base_initialize_gtk ));
 
-	base_window_signal_connect( BASE_WINDOW( instance ),
-			G_OBJECT( instance ), BASE_SIGNAL_INITIALIZE_WINDOW, G_CALLBACK( on_base_initialize_base_window ));
+	base_window_signal_connect(
+			BASE_WINDOW( instance ),
+			G_OBJECT( instance ),
+			BASE_SIGNAL_INITIALIZE_WINDOW,
+			G_CALLBACK( on_base_initialize_base_window ));
 
 	self->private->dispose_has_run = FALSE;
 }
@@ -272,8 +281,6 @@ instance_dispose( GObject *window )
 
 		self->private->dispose_has_run = TRUE;
 
-		clear_duplicates_treeview( self );
-
 		/* chain up to the parent class */
 		if( G_OBJECT_CLASS( st_parent_class )->dispose ){
 			G_OBJECT_CLASS( st_parent_class )->dispose( window );
@@ -372,9 +379,6 @@ static void
 create_duplicates_treeview_model( NactAssistantImport *dialog )
 {
 	static const gchar *thisfn = "nact_assistant_import_create_duplicates_treeview_model";
-	GtkListStore *model;
-	GtkTreeViewColumn *column;
-	GtkTreeSelection *selection;
 
 	g_return_if_fail( NACT_IS_ASSISTANT_IMPORT( dialog ));
 	g_return_if_fail( !dialog->private->dispose_has_run );
@@ -384,30 +388,7 @@ create_duplicates_treeview_model( NactAssistantImport *dialog )
 	dialog->private->duplicates_listview = get_duplicates_treeview_from_assistant_import( dialog );
 	g_return_if_fail( GTK_IS_TREE_VIEW( dialog->private->duplicates_listview ));
 
-	model = gtk_list_store_new( N_COLUMN, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT );
-	gtk_tree_view_set_model( dialog->private->duplicates_listview, GTK_TREE_MODEL( model ));
-	g_object_unref( model );
-
-	/* create visible columns on the tree view
-	 */
-	column = gtk_tree_view_column_new_with_attributes(
-			"image",
-			gtk_cell_renderer_pixbuf_new(),
-			"pixbuf", IMAGE_COLUMN,
-			NULL );
-	gtk_tree_view_append_column( dialog->private->duplicates_listview, column );
-
-	column = gtk_tree_view_column_new_with_attributes(
-			"label",
-			gtk_cell_renderer_text_new(),
-			"text", LABEL_COLUMN,
-			NULL );
-	gtk_tree_view_append_column( dialog->private->duplicates_listview, column );
-
-	g_object_set( G_OBJECT( dialog->private->duplicates_listview ), "tooltip-column", TOOLTIP_COLUMN, NULL );
-
-	selection = gtk_tree_view_get_selection( dialog->private->duplicates_listview );
-	gtk_tree_selection_set_mode( selection, GTK_SELECTION_BROWSE );
+	na_ioptions_list_gtk_init( NA_IOPTIONS_LIST( dialog ), GTK_WIDGET( dialog->private->duplicates_listview ), TRUE );
 }
 
 static void
@@ -552,158 +533,29 @@ static void
 runtime_init_duplicates( NactAssistantImport *window, GtkAssistant *assistant )
 {
 	static const gchar *thisfn = "nact_assistant_import_runtime_init_duplicates";
-	guint mode;
-	GtkTreeSelection *selection;
+	gchar *import_mode;
 	GtkWidget *page;
+	gboolean mandatory;
 
 	g_return_if_fail( GTK_IS_TREE_VIEW( window->private->duplicates_listview ));
 
 	g_debug( "%s: window=%p, assistant=%p",
 			thisfn, ( void * ) window, ( void * ) assistant );
 
-	clear_duplicates_treeview( window );
-	populate_duplicates_treeview( window );
-
-	mode = na_iprefs_get_import_mode( NA_IPREFS_IMPORT_PREFERRED_MODE, NULL );
-	window->private->mode = mode;
-	select_import_mode( window );
-
-	/* monitors the selection */
-	selection = gtk_tree_view_get_selection( window->private->duplicates_listview );
-	base_window_signal_connect( BASE_WINDOW( window ),
-			G_OBJECT( selection ), "changed", G_CALLBACK( on_duplicates_selection_changed ));
+	import_mode = na_settings_get_string( NA_IPREFS_IMPORT_PREFERRED_MODE, NULL, &mandatory );
+	na_ioptions_list_set_editable(
+			NA_IOPTIONS_LIST( window ), GTK_WIDGET( window->private->duplicates_listview ),
+			!mandatory );
+	na_ioptions_list_set_default(
+			NA_IOPTIONS_LIST( window ), GTK_WIDGET( window->private->duplicates_listview ),
+			import_mode );
+	g_free( import_mode );
 
 	page = gtk_assistant_get_nth_page( assistant, ASSIST_PAGE_DUPLICATES );
 	gtk_assistant_set_page_complete( assistant, page, TRUE );
 }
 
 static void
-clear_duplicates_treeview( NactAssistantImport *window )
-{
-	static const gchar *thisfn = "nact_assistant_import_clear_duplicates_treeview";
-	GtkTreeModel *model;
-	GtkTreeSelection *selection;
-
-	g_return_if_fail( GTK_IS_TREE_VIEW( window->private->duplicates_listview ));
-
-	g_debug( "%s: window=%p", thisfn, ( void * ) window );
-
-	selection = gtk_tree_view_get_selection( window->private->duplicates_listview );
-	gtk_tree_selection_unselect_all( selection );
-
-	model = gtk_tree_view_get_model( window->private->duplicates_listview );
-	gtk_list_store_clear( GTK_LIST_STORE( model ));
-}
-
-static void
-populate_duplicates_treeview( NactAssistantImport *window )
-{
-	static const gchar *thisfn = "nact_assistant_import_populate_duplicates_treeview";
-	GtkTreeModel *model;
-	GtkTreeIter iter;
-	guint i;
-	gchar *image_file;
-	gint width, height;
-	GdkPixbuf *pixbuf;
-
-	g_return_if_fail( GTK_IS_TREE_VIEW( window->private->duplicates_listview ));
-
-	g_debug( "%s: window=%p", thisfn, ( void * ) window );
-
-	model = gtk_tree_view_get_model( window->private->duplicates_listview );
-
-	if( !gtk_icon_size_lookup( GTK_ICON_SIZE_DIALOG, &width, &height )){
-		width = height = 48;
-	}
-
-	for( i=0 ; st_import_modes[i].mode ; ++i ){
-		image_file = g_strdup_printf( "%s/%s", PKGDATADIR, st_import_modes[i].image );
-		pixbuf = gdk_pixbuf_new_from_file_at_size( image_file, width, height, NULL );
-		gtk_list_store_append( GTK_LIST_STORE( model ), &iter );
-		gtk_list_store_set(
-				GTK_LIST_STORE( model ),
-				&iter,
-				IMAGE_COLUMN, pixbuf,
-				LABEL_COLUMN, st_import_modes[i].label,
-				TOOLTIP_COLUMN, st_import_modes[i].tooltip,
-				MODE_COLUMN, st_import_modes[i].mode,
-				INDEX_COLUMN, i,
-				-1 );
-		g_object_unref( pixbuf );
-		g_free( image_file );
-	}
-}
-
-/*
- * handles the "changed" signal emitted on the GtkTreeSelection
- */
-static void
-on_duplicates_selection_changed( GtkTreeSelection *selection, NactAssistantImport *window )
-{
-	static const gchar *thisfn = "nact_assistant_import_on_duplicates_selection_changed";
-	GList *selected_rows;
-	GtkTreeModel *model;
-	GtkTreeIter iter;
-	guint mode;
-	guint index_mode;
-
-	g_return_if_fail( GTK_IS_TREE_VIEW( window->private->duplicates_listview ));
-
-	g_debug( "%s: selection=%p, window=%p", thisfn, ( void * ) selection, ( void * ) window );
-
-	selected_rows = gtk_tree_selection_get_selected_rows( selection, &model );
-
-	if( g_list_length( selected_rows ) == 1 ){
-		model = gtk_tree_view_get_model( window->private->duplicates_listview );
-		gtk_tree_model_get_iter( model, &iter, ( GtkTreePath * ) selected_rows->data );
-		gtk_tree_model_get( model, &iter, MODE_COLUMN, &mode, INDEX_COLUMN, &index_mode, -1 );
-		window->private->mode = mode;
-		window->private->index_mode = index_mode;
-	}
-
-	g_list_foreach( selected_rows, ( GFunc ) gtk_tree_path_free, NULL );
-	g_list_free( selected_rows );
-}
-
-/*
- * initial selection of the default import mode
- */
-static void
-select_import_mode( NactAssistantImport *window )
-{
-	GtkTreeModel *model;
-
-	g_return_if_fail( GTK_IS_TREE_VIEW( window->private->duplicates_listview ));
-
-	model = gtk_tree_view_get_model( window->private->duplicates_listview );
-	gtk_tree_model_foreach( model, ( GtkTreeModelForeachFunc ) iter_on_model_for_select, window );
-}
-
-/*
- * walks through the rows of the model until the function returns %TRUE
- */
-static gboolean
-iter_on_model_for_select( GtkTreeModel *model,
-		GtkTreePath *path, GtkTreeIter *iter, NactAssistantImport *window )
-{
-	gboolean stop;
-	guint mode;
-	guint index;
-	GtkTreeSelection *selection;
-
-	stop = FALSE;
-	gtk_tree_model_get( model, iter, MODE_COLUMN, &mode, INDEX_COLUMN, &index, -1 );
-	if( mode == window->private->mode ){
-		window->private->index_mode = index;
-		selection = gtk_tree_view_get_selection( window->private->duplicates_listview );
-		gtk_tree_selection_select_iter( selection, iter );
-		stop = TRUE;
-	}
-
-	return( stop );
-}
-
-static void
 assistant_prepare( BaseAssistant *window, GtkAssistant *assistant, GtkWidget *page )
 {
 	static const gchar *thisfn = "nact_assistant_import_assistant_prepare";
@@ -735,6 +587,7 @@ prepare_confirm( NactAssistantImport *window, GtkAssistant *assistant, GtkWidget
 	gchar *text, *tmp;
 	GSList *uris, *is;
 	GtkWidget *label;
+	gchar *mode_label, *label2, *mode_description;
 
 	g_debug( "%s: window=%p, assistant=%p, page=%p",
 			thisfn, ( void * ) window, ( void * ) assistant, ( void * ) page );
@@ -774,11 +627,18 @@ prepare_confirm( NactAssistantImport *window, GtkAssistant *assistant, GtkWidget
 	 */
 	label = find_widget_from_page( page, "p3-ConfirmImportMode" );
 	g_return_if_fail( GTK_IS_LABEL( label ));
-	text = g_markup_printf_escaped( "%s\n\n<span style=\"italic\">%s</span>",
-			gettext( st_import_modes[window->private->index_mode].label ),
-			gettext( st_import_modes[window->private->index_mode].tooltip ));
+	window->private->mode = na_ioptions_list_get_selected(
+			NA_IOPTIONS_LIST( window ), GTK_WIDGET( window->private->duplicates_listview ));
+	g_return_if_fail( NA_IS_IMPORT_MODE( window->private->mode ));
+	mode_label = na_ioption_get_label( window->private->mode );
+	label2 = na_core_utils_str_remove_char( mode_label, "_" );
+	mode_description = na_ioption_get_description( window->private->mode );
+	text = g_markup_printf_escaped( "%s\n\n<span style=\"italic\">%s</span>", label2, mode_description );
 	gtk_label_set_markup( GTK_LABEL( label ), text );
 	g_free( text );
+	g_free( mode_description );
+	g_free( mode_label );
+	g_free( label2 );
 
 	gtk_assistant_set_page_complete( assistant, page, TRUE );
 }
@@ -811,7 +671,7 @@ assistant_apply( BaseAssistant *wnd, GtkAssistant *assistant )
 	g_object_get( G_OBJECT( wnd ), BASE_PROP_PARENT, &main_window, NULL );
 	importer_parms.parent = base_window_get_gtk_toplevel( BASE_WINDOW( wnd ));
 	importer_parms.uris = gtk_file_chooser_get_uris( GTK_FILE_CHOOSER( window->private->file_chooser ));
-	importer_parms.mode = window->private->mode;
+	importer_parms.mode = na_import_mode_get_id( NA_IMPORT_MODE( window->private->mode ));
 	importer_parms.check_fn = ( NAIImporterCheckFn ) check_for_existence;
 	importer_parms.check_fn_data = main_window;
 	application = NACT_APPLICATION( base_window_get_application( main_window ));
@@ -882,6 +742,7 @@ prepare_importdone( NactAssistantImport *window, GtkAssistant *assistant, GtkWid
 	NAImporterResult *result;
 	gchar *text, *id, *item_label, *text2, *tmp;
 	const gchar *color;
+	gchar *mode_id;
 
 	g_debug( "%s: window=%p, assistant=%p, page=%p",
 			thisfn, ( void * ) window, ( void * ) assistant, ( void * ) page );
@@ -962,8 +823,11 @@ prepare_importdone( NactAssistantImport *window, GtkAssistant *assistant, GtkWid
 		gtk_box_pack_start( GTK_BOX( file_vbox ), file_report, FALSE, FALSE, 0 );
 	}
 
+	mode_id = na_ioption_get_id( window->private->mode );
+	na_settings_set_string( NA_IPREFS_IMPORT_PREFERRED_MODE, mode_id );
+	g_free( mode_id );
+
 	g_object_set( G_OBJECT( window ), BASE_PROP_WARN_ON_ESCAPE, FALSE, NULL );
-	na_iprefs_set_import_mode( NA_IPREFS_IMPORT_PREFERRED_MODE, window->private->mode );
 	gtk_assistant_set_page_complete( assistant, page, TRUE );
 	gtk_widget_show_all( page );
 }



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