[file-roller] ask password: simplified the dialog, fixed the window title



commit 0aa65c4a63d51e3d456a66e73ebd2eb5df4f3113
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Wed Jun 20 22:04:49 2012 +0200

    ask password: simplified the dialog, fixed the window title

 src/dlg-ask-password.c   |   45 +++++++++++++++++++++------------------------
 src/fr-window.c          |    7 +++++++
 src/fr-window.h          |    2 ++
 src/ui/batch-password.ui |   44 ++++++++++++++++++--------------------------
 4 files changed, 48 insertions(+), 50 deletions(-)
---
diff --git a/src/dlg-ask-password.c b/src/dlg-ask-password.c
index ba2c89c..35fa965 100644
--- a/src/dlg-ask-password.c
+++ b/src/dlg-ask-password.c
@@ -34,12 +34,13 @@ typedef enum {
 	FR_PASSWORD_TYPE_PASTE_FROM
 } FrPasswordType;
 
+
 typedef struct {
 	GtkBuilder     *builder;
 	FrWindow       *window;
 	FrPasswordType  pwd_type;
 	GtkWidget      *dialog;
-	GtkWidget      *pw_password_entry;
+	GtkWidget      *password_entry;
 } DialogData;
 
 
@@ -62,7 +63,7 @@ ask_password__response_cb (GtkWidget  *dialog,
 
 	switch (response_id) {
 	case GTK_RESPONSE_OK:
-		password = _gtk_entry_get_locale_text (GTK_ENTRY (data->pw_password_entry));
+		password = _gtk_entry_get_locale_text (GTK_ENTRY (data->password_entry));
 		if (data->pwd_type == FR_PASSWORD_TYPE_MAIN)
 			fr_window_set_password (data->window, password);
 		else if (data->pwd_type == FR_PASSWORD_TYPE_PASTE_FROM)
@@ -91,40 +92,35 @@ dlg_ask_password__common (FrWindow       *window,
 			  FrPasswordType  pwd_type)
 {
 	DialogData *data;
-	GtkWidget  *label;
-	char       *text;
-	char       *name;
+	char       *filename;
+	char       *message;
 
 	data = g_new0 (DialogData, 1);
-
 	data->builder = _gtk_builder_new_from_resource ("batch-password.ui");
 	if (data->builder == NULL) {
 		g_free (data);
 		return;
 	}
-
 	data->window = window;
 	data->pwd_type = pwd_type;
 
 	/* Get the widgets. */
 
 	data->dialog = _gtk_builder_get_widget (data->builder, "password_dialog");
-	data->pw_password_entry = _gtk_builder_get_widget (data->builder, "pw_password_entry");
-
-	label = _gtk_builder_get_widget (data->builder, "pw_password_label");
+	data->password_entry = _gtk_builder_get_widget (data->builder, "password_entry");
 
 	/* Set widgets data. */
 
 	if (data->pwd_type == FR_PASSWORD_TYPE_MAIN)
-		name = _g_uri_display_basename (fr_window_get_archive_uri (window));
+		filename = _g_uri_display_basename (fr_window_get_archive_uri (window));
 	else if (data->pwd_type == FR_PASSWORD_TYPE_PASTE_FROM)
-		name = _g_uri_display_basename (fr_window_get_paste_archive_uri (window));
-	text = g_strdup_printf (_("Enter the password for the archive '%s'."), name);
-	gtk_label_set_label (GTK_LABEL (label), text);
-	g_free (text);
-	
+		filename = _g_uri_display_basename (fr_window_get_paste_archive_uri (window));
+	/* Translators: %s is a filename */
+	message = g_strdup_printf (_("Password required for \"%s\""), filename);
+	gtk_label_set_label (GTK_LABEL (_gtk_builder_get_widget (data->builder, "title_label")), message);
+
 	if (fr_window_get_password (window) != NULL)
-		_gtk_entry_set_locale_text (GTK_ENTRY (data->pw_password_entry),
+		_gtk_entry_set_locale_text (GTK_ENTRY (data->password_entry),
 					    fr_window_get_password (window));
 
 	/* Set the signals handlers. */
@@ -133,7 +129,6 @@ dlg_ask_password__common (FrWindow       *window,
 			  "destroy",
 			  G_CALLBACK (destroy_cb),
 			  data);
-
 	g_signal_connect (G_OBJECT (data->dialog),
 			  "response",
 			  G_CALLBACK (ask_password__response_cb),
@@ -141,17 +136,19 @@ dlg_ask_password__common (FrWindow       *window,
 
 	/* Run dialog. */
 
-	gtk_widget_grab_focus (data->pw_password_entry);
+	gtk_widget_grab_focus (data->password_entry);
 	if (gtk_widget_get_realized (GTK_WIDGET (window))) {
 		gtk_window_set_transient_for (GTK_WINDOW (data->dialog),
 					      GTK_WINDOW (window));
 		gtk_window_set_modal (GTK_WINDOW (data->dialog), TRUE);
 	}
-	else 
-		gtk_window_set_title (GTK_WINDOW (data->dialog), name);
-	g_free (name);
-	
+	else
+		gtk_window_set_title (GTK_WINDOW (data->dialog),
+				      fr_window_get_batch_title (window));
 	gtk_widget_show (data->dialog);
+
+	g_free (message);
+	g_free (filename);
 }
 
 
@@ -162,7 +159,7 @@ dlg_ask_password (FrWindow *window)
 }
 
 
-void 
+void
 dlg_ask_password_for_paste_operation (FrWindow *window)
 {
 	dlg_ask_password__common (window, FR_PASSWORD_TYPE_PASTE_FROM);
diff --git a/src/fr-window.c b/src/fr-window.c
index 6312469..93f2971 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -8880,6 +8880,13 @@ fr_window_new_batch (FrWindow   *window,
 }
 
 
+const char *
+fr_window_get_batch_title (FrWindow *window)
+{
+	return window->priv->batch_title;
+}
+
+
 void
 fr_window_set_batch__extract_here (FrWindow   *window,
 				   const char *filename)
diff --git a/src/fr-window.h b/src/fr-window.h
index b27e651..13a4ad5 100644
--- a/src/fr-window.h
+++ b/src/fr-window.h
@@ -283,6 +283,8 @@ void        fr_window_use_progress_dialog         (FrWindow   *window,
 
 void       fr_window_new_batch                    (FrWindow      *window,
 						   const char    *title);
+const char *
+           fr_window_get_batch_title              (FrWindow      *window);
 void       fr_window_set_current_batch_action     (FrWindow      *window,
 						   FrBatchActionType  action,
 						   void          *data,
diff --git a/src/ui/batch-password.ui b/src/ui/batch-password.ui
index bd60905..86ad8fb 100644
--- a/src/ui/batch-password.ui
+++ b/src/ui/batch-password.ui
@@ -75,9 +75,9 @@
                 <property name="spacing">12</property>
                 <child>
                   <object class="GtkImage" id="image2">
+                    <property name="width_request">64</property>
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="yalign">0</property>
                     <property name="stock">gtk-dialog-authentication</property>
                     <property name="icon-size">6</property>
@@ -89,16 +89,17 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkVBox" id="vbox18">
+                  <object class="GtkBox" id="box1">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
+                    <property name="orientation">vertical</property>
                     <property name="spacing">12</property>
                     <child>
-                      <object class="GtkLabel" id="label44">
+                      <object class="GtkLabel" id="title_label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="xalign">0</property>
-                        <property name="label" translatable="yes">Password required</property>
+                        <property name="label" translatable="yes">Password required for "archive.tar.xz"</property>
                         <attributes>
                           <attribute name="weight" value="bold"/>
                           <attribute name="size" value="12000"/>
@@ -106,60 +107,51 @@
                       </object>
                       <packing>
                         <property name="expand">False</property>
-                        <property name="fill">False</property>
+                        <property name="fill">True</property>
                         <property name="position">0</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkLabel" id="pw_password_label">
+                      <object class="GtkBox" id="box2">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="xalign">0</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkHBox" id="hbox18">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="spacing">12</property>
+                        <property name="orientation">vertical</property>
+                        <property name="spacing">2</property>
                         <child>
-                          <object class="GtkLabel" id="label34">
+                          <object class="GtkLabel" id="message_label">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
+                            <property name="xalign">0</property>
                             <property name="label" translatable="yes">_Password:</property>
                             <property name="use_underline">True</property>
-                            <property name="mnemonic_widget">pw_password_entry</property>
+                            <property name="mnemonic_widget">password_entry</property>
                           </object>
                           <packing>
                             <property name="expand">False</property>
-                            <property name="fill">False</property>
+                            <property name="fill">True</property>
                             <property name="position">0</property>
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkEntry" id="pw_password_entry">
+                          <object class="GtkEntry" id="password_entry">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="visibility">False</property>
                             <property name="invisible_char">â</property>
                             <property name="activates_default">True</property>
+                            <property name="width_chars">40</property>
                           </object>
                           <packing>
-                            <property name="expand">True</property>
+                            <property name="expand">False</property>
                             <property name="fill">True</property>
                             <property name="position">1</property>
                           </packing>
                         </child>
                       </object>
                       <packing>
-                        <property name="expand">True</property>
+                        <property name="expand">False</property>
                         <property name="fill">True</property>
-                        <property name="position">2</property>
+                        <property name="position">1</property>
                       </packing>
                     </child>
                   </object>



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