[nautilus-actions] NAImporterAsk: now cancel on Esc key



commit 4542851e4b075f60c29bddb9fdebeb8ea5d25048
Author: Pierre Wieser <pwieser trychlos org>
Date:   Mon Nov 28 23:32:14 2011 +0100

    NAImporterAsk: now cancel on Esc key

 ChangeLog                   |    4 +
 src/core/na-importer-ask.c  |   53 ++----------------
 src/core/na-importer-ask.ui |  129 +++++++++++++++++++++++++++----------------
 3 files changed, 91 insertions(+), 95 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7d3c156..30f0ab6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2011-11-28 Pierre Wieser <pwieser trychlos org>
 
+	* src/core/na-importer-ask.c:
+	* src/core/na-importer-ask.ui: Make NAImporterAsk normally answer to
+	response codes, and quit on Esc.
+
 	* nact/nact-export-format.c (draw_in_vbox): Use gtk_misc functions.
 
 	* run-autogen.sh:
diff --git a/src/core/na-importer-ask.c b/src/core/na-importer-ask.c
index eb4aad9..7b400e6 100644
--- a/src/core/na-importer-ask.c
+++ b/src/core/na-importer-ask.c
@@ -57,7 +57,6 @@ struct _NAImporterAskPrivate {
 	NAObjectItem           *existing;
 	NAImporterAskUserParms *parms;
 	guint                   mode;
-	gint                    dialog_code;
 };
 
 static GtkDialogClass *st_parent_class = NULL;
@@ -71,8 +70,8 @@ static void       instance_finalize( GObject *dialog );
 static NAImporterAsk *import_ask_new();
 
 static void       init_dialog( NAImporterAsk *editor );
-static void       on_cancel_clicked( GtkButton *button, NAImporterAsk *editor );
-static void       on_ok_clicked( GtkButton *button, NAImporterAsk *editor );
+/*static void       on_cancel_clicked( GtkButton *button, NAImporterAsk *editor );
+static void       on_ok_clicked( GtkButton *button, NAImporterAsk *editor );*/
 static void       get_selected_mode( NAImporterAsk *editor );
 static gboolean   on_dialog_response( NAImporterAsk *editor, gint code );
 
@@ -325,20 +324,6 @@ init_dialog( NAImporterAsk *editor )
 	button = na_gtk_utils_search_for_child_widget( GTK_CONTAINER( editor->private->toplevel ), "AskKeepChoiceButton" );
 	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), editor->private->parms->keep_choice );
 
-	button = na_gtk_utils_search_for_child_widget( GTK_CONTAINER( editor->private->toplevel ), "OKButton" );
-	g_signal_connect(
-			G_OBJECT( button ),
-			"clicked",
-			G_CALLBACK( on_ok_clicked ),
-			editor );
-
-	button = na_gtk_utils_search_for_child_widget( GTK_CONTAINER( editor->private->toplevel ), "CancelButton" );
-	g_signal_connect(
-			G_OBJECT( button ),
-			"clicked",
-			G_CALLBACK( on_cancel_clicked ),
-			editor );
-
 	if( editor->private->parms->parent ){
 		gtk_window_set_transient_for( editor->private->toplevel, editor->private->parms->parent );
 	}
@@ -347,26 +332,6 @@ init_dialog( NAImporterAsk *editor )
 }
 
 static void
-on_cancel_clicked( GtkButton *button, NAImporterAsk *editor )
-{
-	g_debug( "na_importer_ask_on_cancel_clicked" );
-
-	editor->private->dialog_code = GTK_RESPONSE_CANCEL;
-
-	gtk_dialog_response( GTK_DIALOG( editor ), GTK_RESPONSE_CANCEL );
-}
-
-static void
-on_ok_clicked( GtkButton *button, NAImporterAsk *editor )
-{
-	g_debug( "na_importer_ask_on_ok_clicked" );
-
-	editor->private->dialog_code = GTK_RESPONSE_OK;
-
-	gtk_dialog_response( GTK_DIALOG( editor ), GTK_RESPONSE_OK );
-}
-
-static void
 get_selected_mode( NAImporterAsk *editor )
 {
 	guint import_mode;
@@ -394,10 +359,6 @@ get_selected_mode( NAImporterAsk *editor )
 	na_settings_set_boolean( NA_IPREFS_IMPORT_ASK_USER_KEEP_LAST_CHOICE, keep );
 }
 
-/*
- * very curiously, the code sent by on_cancel_clicked() and
- * on_ok_clicked() arrives here at zero ! we so rely on a private one !
- */
 static gboolean
 on_dialog_response( NAImporterAsk *editor, gint code )
 {
@@ -407,7 +368,10 @@ on_dialog_response( NAImporterAsk *editor, gint code )
 
 	g_debug( "%s: editor=%p, code=%d", thisfn, ( void * ) editor, code );
 
-	switch( editor->private->dialog_code ){
+	switch( code ){
+		case GTK_RESPONSE_NONE:
+		case GTK_RESPONSE_DELETE_EVENT:
+		case GTK_RESPONSE_CLOSE:
 		case GTK_RESPONSE_CANCEL:
 			editor->private->mode = IMPORTER_MODE_NO_IMPORT;
 			return( TRUE );
@@ -417,11 +381,6 @@ on_dialog_response( NAImporterAsk *editor, gint code )
 			get_selected_mode( editor );
 			return( TRUE );
 			break;
-
-		case GTK_RESPONSE_NONE:
-		case GTK_RESPONSE_DELETE_EVENT:
-		case GTK_RESPONSE_CLOSE:
-			break;
 	}
 
 	return( FALSE );
diff --git a/src/core/na-importer-ask.ui b/src/core/na-importer-ask.ui
index 44754e9..b272efa 100644
--- a/src/core/na-importer-ask.ui
+++ b/src/core/na-importer-ask.ui
@@ -1,71 +1,126 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 2.12 -->
-  <!-- interface-naming-policy project-wide -->
   <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="GtkVBox" id="dialog-vbox1">
+      <object class="GtkBox" 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="orientation">vertical</property>
+            <property name="can_focus">False</property>
             <property name="spacing">6</property>
             <child>
               <object class="GtkVBox" id="vbox111">
                 <property name="visible">True</property>
-                <property name="orientation">vertical</property>
+                <property name="can_focus">False</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">
                 <property name="visible">True</property>
-                <property name="orientation">vertical</property>
+                <property name="can_focus">False</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>
@@ -75,11 +130,15 @@
                     <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>
@@ -89,102 +148,76 @@
                     <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>
                 </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="orientation">vertical</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>
-      <action-widget response="0">CancelButton</action-widget>
-      <action-widget response="0">OKButton</action-widget>
+      <action-widget response="-6">CancelButton</action-widget>
+      <action-widget response="-5">OKButton</action-widget>
     </action-widgets>
   </object>
 </interface>



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