[nautilus-actions] Do not keep 'keep_last_import_mode' as a preference



commit 9f775cfb60c5bb81b0b5474acb0d82f143fe3872
Author: Pierre Wieser <pwieser trychlos org>
Date:   Thu Oct 15 22:52:34 2009 +0200

    Do not keep 'keep_last_import_mode' as a preference
    
    When the user checks the 'keep this last import mode' box, then the last choice is setup
    as a new import mode preference.

 ChangeLog                                |    4 +-
 data/nautilus-actions.schemas.in         |   12 ---
 src/common/na-iprefs.h                   |    1 -
 src/nact/nact-assistant-import-ask.c     |   68 ++++-------------
 src/nact/nact-assistant-import-ask.h     |    1 -
 src/nact/nact-assistant-import.c         |    8 --
 src/nact/nautilus-actions-config-tool.ui |  125 ++++++++++++++++++++++++++++-
 7 files changed, 135 insertions(+), 84 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0e21070..c34c492 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,7 +10,6 @@
 	* data/nautilus-actions.schemas.in:
 	Define new 'import-ask-user' preference schema.
 	Define new 'import-ask-user-last-mode' preference schema.
-	Define new 'import-ask-user-keep-mode' preference schema.
 	Add 'Ask user' new value for 'import-mode' preference.
 	Fix type and default value of 'import-mode'.
 
@@ -25,8 +24,7 @@
 	Define IPREFS_IMPORT_ASK new import mode.
 	na_iprefs_get_import_mode, na_iprefs_set_import_mode now take
 	the preference name as an argument.
-	Define IPREFS_IMPORT_ASK_LAST_MODE, IPREFS_IMPORT_ASK_KEEP_MODE
-	new preferences.
+	Define IPREFS_IMPORT_ASK_LAST_MODE new preference.
 	Check status of imported actions.
 
 	* src/nact/nact-main-window.c
diff --git a/data/nautilus-actions.schemas.in b/data/nautilus-actions.schemas.in
index a3b3240..46ef70a 100644
--- a/data/nautilus-actions.schemas.in
+++ b/data/nautilus-actions.schemas.in
@@ -287,18 +287,6 @@ All schemes used by Nautilus can be used here.</long>
     </schema>
 
     <schema>
-      <key>/schemas/apps/nautilus-actions/preferences/import-ask-user-keep-mode</key>
-      <owner>nautilus-actions</owner>
-      <type>boolean</type>
-      <locale name="C">
-        <short>Keep the last choosen import mode</short>
-        <long>Whether the last choosen import mode should be kept on next import operations.
-This value is always reinitialized at the first import operation, so that the user may choose another import mode.</long>
-      </locale>
-      <default>false</default>
-    </schema>
-
-    <schema>
       <key>/schemas/apps/nautilus-actions/preferences/import-ask-user-last-mode</key>
       <owner>nautilus-actions</owner>
       <type>string</type>
diff --git a/src/common/na-iprefs.h b/src/common/na-iprefs.h
index af821fb..5a92fc2 100644
--- a/src/common/na-iprefs.h
+++ b/src/common/na-iprefs.h
@@ -49,7 +49,6 @@ G_BEGIN_DECLS
  */
 #define IPREFS_IMPORT_ACTIONS_IMPORT_MODE	"import-mode"
 #define IPREFS_IMPORT_ASK_LAST_MODE			"import-ask-user-last-mode"
-#define IPREFS_IMPORT_ASK_KEEP_MODE			"import-ask-user-keep-mode"
 
 /* import mode
  */
diff --git a/src/nact/nact-assistant-import-ask.c b/src/nact/nact-assistant-import-ask.c
index 31b84e2..bf8a2cf 100644
--- a/src/nact/nact-assistant-import-ask.c
+++ b/src/nact/nact-assistant-import-ask.c
@@ -57,7 +57,6 @@ struct NactAssistantImportAskPrivate {
 	NAObjectAction *action;
 	NAObjectItem   *exist;
 	gint            mode;
-	gboolean        keep_mode;
 };
 
 static BaseDialogClass *st_parent_class = NULL;
@@ -229,11 +228,8 @@ assistant_import_ask_new( BaseWindow *parent )
  *
  * Returns: the mode choosen by the user ; it defaults to NO_IMPORT.
  *
- * A flag is set against the dialog box widget itself. When this flag
- * is not present (the first time this dialog is ran), we ask the user
- * for its choices. Next time, the flag will be set and we will follow
- * the user's preferences, i.e. whether last choice should be
- * automatically applied or not.
+ * When the user selects 'Keep same choice without asking me', this choice
+ * becomes his preference import mode.
  */
 gint
 nact_assistant_import_ask_user( NactMainWindow *parent, const gchar *uri, NAObjectAction *action, NAObjectItem *exist )
@@ -242,9 +238,7 @@ nact_assistant_import_ask_user( NactMainWindow *parent, const gchar *uri, NAObje
 	NactApplication *application;
 	NAPivot *pivot;
 	NactAssistantImportAsk *editor;
-	GtkWindow *window;
 	gint mode;
-	gboolean already_ran;
 
 	g_debug( "%s: parent=%p", thisfn, ( void * ) parent );
 	g_return_val_if_fail( BASE_IS_WINDOW( parent ), IPREFS_IMPORT_NO_IMPORT );
@@ -261,51 +255,16 @@ nact_assistant_import_ask_user( NactMainWindow *parent, const gchar *uri, NAObje
 	editor->private->action = action;
 	editor->private->exist = exist;
 	editor->private->mode = na_iprefs_get_import_mode( NA_IPREFS( pivot ), IPREFS_IMPORT_ASK_LAST_MODE );
-	editor->private->keep_mode = na_iprefs_read_bool( NA_IPREFS( pivot ), IPREFS_IMPORT_ASK_KEEP_MODE, FALSE );
-
-	if( base_window_init( BASE_WINDOW( editor ))){
-		g_object_get( G_OBJECT( editor ), BASE_WINDOW_PROP_TOPLEVEL_WIDGET, &window, NULL );
-		if( window && GTK_IS_WINDOW( window )){
-			already_ran = ( gboolean ) GPOINTER_TO_INT( g_object_get_data( G_OBJECT( window ), "nact-assistant-import-ask-user" ));
-			g_debug( "%s: already_ran=%s", thisfn, already_ran ? "True":"False" );
-			g_debug( "%s: keep_mode=%s", thisfn, editor->private->keep_mode ? "True":"False" );
-			if( !already_ran || !editor->private->keep_mode ){
-				base_window_run( BASE_WINDOW( editor ));
-			}
-		}
-	}
+
+	base_window_run( BASE_WINDOW( editor ));
 
 	na_iprefs_set_import_mode( NA_IPREFS( pivot ), IPREFS_IMPORT_ASK_LAST_MODE, editor->private->mode );
-	na_iprefs_write_bool( NA_IPREFS( pivot ), IPREFS_IMPORT_ASK_KEEP_MODE, editor->private->keep_mode );
 	mode = editor->private->mode;
 	g_object_unref( editor );
 
 	return( mode );
 }
 
-/**
- * nact_assistant_import_ask_reset_keep_mode:
- * @parent: the NactMainWindow parent of this dialog.
- *
- * Reset the 'first time' flag, so taht the user will be asked next time
- * an imort operation is done.
- */
-void
-nact_assistant_import_ask_reset_keep_mode( NactMainWindow *parent )
-{
-	NactAssistantImportAsk *editor;
-	GtkWindow *window;
-
-	editor = assistant_import_ask_new( BASE_WINDOW( parent ));
-
-	if( base_window_init( BASE_WINDOW( editor ))){
-		g_object_get( G_OBJECT( editor ), BASE_WINDOW_PROP_TOPLEVEL_WIDGET, &window, NULL );
-		if( window && GTK_IS_WINDOW( window )){
-			g_object_set_data( G_OBJECT( window ), "nact-assistant-import-ask-user", GINT_TO_POINTER( FALSE ));
-		}
-	}
-}
-
 static gchar *
 base_get_iprefs_window_id( BaseWindow *window )
 {
@@ -335,7 +294,6 @@ on_base_runtime_init_dialog( NactAssistantImportAsk *editor, gpointer user_data
 	gchar *label;
 	GtkWidget *widget;
 	GtkWidget *button;
-	GtkWindow *window;
 
 	g_debug( "%s: editor=%p, user_data=%p", thisfn, ( void * ) editor, ( void * ) user_data );
 	g_return_if_fail( NACT_IS_ASSISTANT_IMPORT_ASK( editor ));
@@ -369,7 +327,7 @@ on_base_runtime_init_dialog( NactAssistantImportAsk *editor, gpointer user_data
 	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), TRUE );
 
 	button = base_window_get_widget( BASE_WINDOW( editor ), "AskKeepChoiceButton" );
-	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), editor->private->keep_mode );
+	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), FALSE );
 
 	base_window_signal_connect_by_name(
 			BASE_WINDOW( editor ),
@@ -382,9 +340,6 @@ on_base_runtime_init_dialog( NactAssistantImportAsk *editor, gpointer user_data
 			"OKButton1",
 			"clicked",
 			G_CALLBACK( on_ok_clicked ));
-
-	window = base_window_get_toplevel( BASE_WINDOW( editor ));
-	g_object_set_data( G_OBJECT( window ), "nact-assistant-import-ask-user", GINT_TO_POINTER( TRUE ));
 }
 
 static void
@@ -400,7 +355,6 @@ static void
 on_cancel_clicked( GtkButton *button, NactAssistantImportAsk *editor )
 {
 	GtkWindow *toplevel = base_window_get_toplevel( BASE_WINDOW( editor ));
-
 	gtk_dialog_response( GTK_DIALOG( toplevel ), GTK_RESPONSE_CLOSE );
 }
 
@@ -408,7 +362,6 @@ static void
 on_ok_clicked( GtkButton *button, NactAssistantImportAsk *editor )
 {
 	GtkWindow *toplevel = base_window_get_toplevel( BASE_WINDOW( editor ));
-
 	gtk_dialog_response( GTK_DIALOG( toplevel ), GTK_RESPONSE_OK );
 }
 
@@ -416,7 +369,10 @@ static void
 get_mode( NactAssistantImportAsk *editor )
 {
 	gint import_mode;
+	NactApplication *application;
+	NAPivot *pivot;
 	GtkWidget *button;
+	gboolean keep;
 
 	import_mode = IPREFS_IMPORT_NO_IMPORT;
 	button = base_window_get_widget( BASE_WINDOW( editor ), "AskRenumberButton" );
@@ -432,7 +388,12 @@ get_mode( NactAssistantImportAsk *editor )
 	editor->private->mode = import_mode;
 
 	button = base_window_get_widget( BASE_WINDOW( editor ), "AskKeepChoiceButton" );
-	editor->private->keep_mode = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ));
+	keep = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ));
+	if( keep ){
+		application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( editor )));
+		pivot = nact_application_get_pivot( application );
+		na_iprefs_set_import_mode( NA_IPREFS( pivot ), IPREFS_IMPORT_ACTIONS_IMPORT_MODE, import_mode );
+	}
 }
 
 static gboolean
@@ -452,7 +413,6 @@ base_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window )
 		case GTK_RESPONSE_CANCEL:
 
 			editor->private->mode = IPREFS_IMPORT_NO_IMPORT;
-			editor->private->keep_mode = FALSE;
 			return( TRUE );
 			break;
 
diff --git a/src/nact/nact-assistant-import-ask.h b/src/nact/nact-assistant-import-ask.h
index 35adff1..70d3152 100644
--- a/src/nact/nact-assistant-import-ask.h
+++ b/src/nact/nact-assistant-import-ask.h
@@ -75,7 +75,6 @@ typedef struct {
 GType nact_assistant_import_ask_get_type( void );
 
 gint  nact_assistant_import_ask_user( NactMainWindow *window, const gchar *uri, NAObjectAction *new_action, NAObjectItem *current );
-void  nact_assistant_import_ask_reset_keep_mode( NactMainWindow *window );
 
 G_END_DECLS
 
diff --git a/src/nact/nact-assistant-import.c b/src/nact/nact-assistant-import.c
index 38cc109..04b03c8 100644
--- a/src/nact/nact-assistant-import.c
+++ b/src/nact/nact-assistant-import.c
@@ -269,15 +269,7 @@ nact_assistant_import_run( BaseWindow *main_window )
 	assist = assist_new( main_window );
 	g_object_set( G_OBJECT( assist ), BASE_WINDOW_PROP_HAS_OWN_BUILDER, TRUE, NULL );
 
-	/* Reset the 'keep_last_choice' flag before and after the assistant
-	 * has run, so that drop operation have a chance to actually ask the
-	 * user...
-	 */
-	nact_assistant_import_ask_reset_keep_mode( NACT_MAIN_WINDOW( main_window ));
-
 	base_window_run( BASE_WINDOW( assist ));
-
-	nact_assistant_import_ask_reset_keep_mode( NACT_MAIN_WINDOW( main_window ));
 }
 
 static gchar *
diff --git a/src/nact/nautilus-actions-config-tool.ui b/src/nact/nautilus-actions-config-tool.ui
index b857862..706e7dd 100644
--- a/src/nact/nautilus-actions-config-tool.ui
+++ b/src/nact/nautilus-actions-config-tool.ui
@@ -2041,10 +2041,125 @@ Be warned: this mode may be dangerous. You will not be prompted another time.</p
               </packing>
             </child>
             <child type="tab">
+              <object class="GtkLabel" id="label48">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">_Import</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="position">2</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkVBox" id="vbox41">
+                <property name="visible">True</property>
+                <property name="orientation">vertical</property>
+                <child>
+                  <object class="GtkFrame" id="frame5">
+                    <property name="visible">True</property>
+                    <property name="border_width">6</property>
+                    <property name="label_xalign">0</property>
+                    <property name="shadow_type">in</property>
+                    <child>
+                      <object class="GtkAlignment" id="alignment5">
+                        <property name="visible">True</property>
+                        <property name="left_padding">12</property>
+                        <child>
+                          <object class="GtkVBox" id="vbox42">
+                            <property name="visible">True</property>
+                            <property name="border_width">6</property>
+                            <property name="orientation">vertical</property>
+                            <property name="homogeneous">True</property>
+                            <child>
+                              <object class="GtkRadioButton" id="PrefsNoImportButton1">
+                                <property name="label" translatable="yes">Do _not import actions whose UUID already exists.</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_underline">True</property>
+                                <property name="active">True</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkRadioButton" id="PrefsRenumberButton1">
+                                <property name="label" translatable="yes">_Renumber imported actions whose UUID already exists.</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_underline">True</property>
+                                <property name="draw_indicator">True</property>
+                                <property name="group">PrefsNoImportButton</property>
+                              </object>
+                              <packing>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkRadioButton" id="PrefsOverrideButton1">
+                                <property name="label" translatable="yes">_Override existing actions when importing with same UUID.</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_underline">True</property>
+                                <property name="draw_indicator">True</property>
+                                <property name="group">PrefsNoImportButton</property>
+                              </object>
+                              <packing>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkRadioButton" id="PrefsAskButton1">
+                                <property name="label" translatable="yes">_Ask me.</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_underline">True</property>
+                                <property name="draw_indicator">True</property>
+                                <property name="group">PrefsNoImportButton</property>
+                              </object>
+                              <packing>
+                                <property name="position">3</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="label49">
+                        <property name="visible">True</property>
+                        <property name="xpad">4</property>
+                        <property name="label" translatable="yes">&lt;b&gt;Export mode&lt;/b&gt;</property>
+                        <property name="use_markup">True</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+              </object>
+              <packing>
+                <property name="position">3</property>
+              </packing>
+            </child>
+            <child type="tab">
               <object class="GtkLabel" id="label43">
                 <property name="visible">True</property>
                 <property name="tooltip_text" translatable="yes">There preferences are used by assistants and drag and drop operations.</property>
-                <property name="label" translatable="yes">_Tools</property>
+                <property name="label" translatable="yes">_Export</property>
                 <property name="use_underline">True</property>
               </object>
               <packing>
@@ -2285,16 +2400,16 @@ Be warned: this mode may be dangerous. You will not be prompted another time.</p
   </object>
   <object class="GtkSizeGroup" id="CommandLabelSizeGroup">
     <widgets>
-      <widget name="CommandExamplePreLabel"/>
-      <widget name="CommandParametersLabel"/>
-      <widget name="CommandPathLabel"/>
       <widget name="ProfileLabelLabel"/>
+      <widget name="CommandPathLabel"/>
+      <widget name="CommandParametersLabel"/>
+      <widget name="CommandExamplePreLabel"/>
     </widgets>
   </object>
   <object class="GtkSizeGroup" id="CommandButtonSizeGroup">
     <widgets>
-      <widget name="CommandLegendButton"/>
       <widget name="CommandPathButton"/>
+      <widget name="CommandLegendButton"/>
     </widgets>
   </object>
 </interface>



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