[nautilus-actions] Let the user choose if he wants keep its last choice



commit d5c6f037e7bb84f843ffb50f51915045d0f3184e
Author: Pierre Wieser <pwieser trychlos org>
Date:   Thu Oct 15 19:07:23 2009 +0200

    Let the user choose if he wants keep its last choice

 src/nact/nact-assistant-import-ask.c     |   38 ++++++++++++++++++++++++++--
 src/nact/nact-assistant-import-ask.h     |    1 +
 src/nact/nact-assistant-import.c         |    6 ++++
 src/nact/nautilus-actions-config-tool.ui |   40 ++++++++++++++++++++++++++---
 4 files changed, 77 insertions(+), 8 deletions(-)
---
diff --git a/src/nact/nact-assistant-import-ask.c b/src/nact/nact-assistant-import-ask.c
index 573128f..c1f9aef 100644
--- a/src/nact/nact-assistant-import-ask.c
+++ b/src/nact/nact-assistant-import-ask.c
@@ -223,8 +223,7 @@ assistant_import_ask_new( NactApplication *application )
 
 /**
  * nact_assistant_import_ask_run:
- * @parent: the BaseWindow parent of this dialog
- * (usually the NactMainWindow).
+ * @parent: the NactMainWindow parent of this dialog.
  *
  * Initializes and runs the dialog.
  *
@@ -268,7 +267,9 @@ nact_assistant_import_ask_user( NactMainWindow *parent, const gchar *uri, NAObje
 		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" ));
-			if( !already_ran || editor->private->keep_mode ){
+			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 ));
 			}
 		}
@@ -282,6 +283,31 @@ nact_assistant_import_ask_user( NactMainWindow *parent, const gchar *uri, NAObje
 	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 )
+{
+	NactApplication *application;
+	NactAssistantImportAsk *editor;
+	GtkWindow *window;
+
+	application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( parent )));
+	editor = assistant_import_ask_new( application );
+
+	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 )
 {
@@ -346,6 +372,9 @@ 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 );
+
 	base_window_signal_connect_by_name(
 			BASE_WINDOW( editor ),
 			"CancelButton1",
@@ -405,6 +434,9 @@ 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 ));
 }
 
 static gboolean
diff --git a/src/nact/nact-assistant-import-ask.h b/src/nact/nact-assistant-import-ask.h
index 70d3152..35adff1 100644
--- a/src/nact/nact-assistant-import-ask.h
+++ b/src/nact/nact-assistant-import-ask.h
@@ -75,6 +75,7 @@ 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 e4d34e0..230f8fd 100644
--- a/src/nact/nact-assistant-import.c
+++ b/src/nact/nact-assistant-import.c
@@ -47,6 +47,8 @@
 #include "nact-application.h"
 #include "nact-iactions-list.h"
 #include "nact-assistant-import.h"
+#include "nact-assistant-import-ask.h"
+#include "nact-main-window.h"
 #include "nact-xml-reader.h"
 
 /* Import Assistant
@@ -455,6 +457,7 @@ runtime_init_duplicates( NactAssistantImport *window, GtkAssistant *assistant )
 {
 	static const gchar *thisfn = "nact_assistant_import_runtime_init_duplicates";
 	NactApplication *application;
+	NactMainWindow *main_window;
 	NAPivot *pivot;
 	GtkWidget *page;
 	gint mode;
@@ -468,6 +471,9 @@ runtime_init_duplicates( NactAssistantImport *window, GtkAssistant *assistant )
 
 	page = gtk_assistant_get_nth_page( assistant, ASSIST_PAGE_DUPLICATES );
 	gtk_assistant_set_page_complete( assistant, page, TRUE );
+
+	main_window = NACT_MAIN_WINDOW( base_application_get_main_window( BASE_APPLICATION( application )));
+	nact_assistant_import_ask_reset_keep_mode( main_window );
 }
 
 static void
diff --git a/src/nact/nautilus-actions-config-tool.ui b/src/nact/nautilus-actions-config-tool.ui
index e68c542..db1f2e4 100644
--- a/src/nact/nautilus-actions-config-tool.ui
+++ b/src/nact/nautilus-actions-config-tool.ui
@@ -1301,7 +1301,7 @@ Be warned: this mode may be dangerous. You will not be prompted another time.</p
           </packing>
         </child>
         <child>
-          <object class="GtkHSeparator" id="hseparator1">
+          <object class="GtkHSeparator" id="hseparator2">
             <property name="visible">True</property>
           </object>
           <packing>
@@ -2201,6 +2201,36 @@ Be warned: this mode may be dangerous. You will not be prompted another time.</p
                 <property name="position">1</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkHSeparator" id="hseparator1">
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkVBox" id="vbox40">
+                <property name="visible">True</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_underline">True</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">3</property>
+              </packing>
+            </child>
           </object>
           <packing>
             <property name="position">2</property>
@@ -2254,16 +2284,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="ProfileLabelLabel"/>
-      <widget name="CommandPathLabel"/>
-      <widget name="CommandParametersLabel"/>
       <widget name="CommandExamplePreLabel"/>
+      <widget name="CommandParametersLabel"/>
+      <widget name="CommandPathLabel"/>
+      <widget name="ProfileLabelLabel"/>
     </widgets>
   </object>
   <object class="GtkSizeGroup" id="CommandButtonSizeGroup">
     <widgets>
-      <widget name="CommandPathButton"/>
       <widget name="CommandLegendButton"/>
+      <widget name="CommandPathButton"/>
     </widgets>
   </object>
 </interface>



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