[file-roller] password dialog: show an error message when the password is wrong
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller] password dialog: show an error message when the password is wrong
- Date: Sat, 11 Aug 2012 20:48:00 +0000 (UTC)
commit 55fff04890e29e7cd2c077d47e3e16890b99d4e5
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sat Aug 11 22:46:00 2012 +0200
password dialog: show an error message when the password is wrong
src/dlg-ask-password.c | 32 ++++++++++++++++++++++++++------
src/fr-window.c | 11 +++++++++++
src/fr-window.h | 5 ++++-
src/ui/ask-password.ui | 17 ++++++++++++++++-
4 files changed, 57 insertions(+), 8 deletions(-)
---
diff --git a/src/dlg-ask-password.c b/src/dlg-ask-password.c
index e20d766..a0a4e49 100644
--- a/src/dlg-ask-password.c
+++ b/src/dlg-ask-password.c
@@ -29,6 +29,9 @@
#include "gtk-utils.h"
+#define GET_WIDGET(x) (_gtk_builder_get_widget (data->builder, (x)))
+
+
typedef enum {
FR_PASSWORD_TYPE_MAIN_ARCHIVE,
FR_PASSWORD_TYPE_SECOND_ARCHIVE
@@ -94,6 +97,7 @@ dlg_ask_password__common (FrWindow *window,
{
DialogData *data;
GFile *file;
+ const char *old_password;
char *filename;
char *message;
@@ -108,23 +112,39 @@ dlg_ask_password__common (FrWindow *window,
/* Get the widgets. */
- data->dialog = _gtk_builder_get_widget (data->builder, "password_dialog");
- data->password_entry = _gtk_builder_get_widget (data->builder, "password_entry");
+ data->dialog = GET_WIDGET ("password_dialog");
+ data->password_entry = GET_WIDGET ("password_entry");
/* Set widgets data. */
- if (data->pwd_type == FR_PASSWORD_TYPE_MAIN_ARCHIVE)
+ if (data->pwd_type == FR_PASSWORD_TYPE_MAIN_ARCHIVE) {
file = fr_window_get_archive_file (window);
- else if (data->pwd_type == FR_PASSWORD_TYPE_SECOND_ARCHIVE)
+ old_password = fr_window_get_password (window);
+ }
+ else if (data->pwd_type == FR_PASSWORD_TYPE_SECOND_ARCHIVE) {
file = fr_window_get_archive_file_for_paste (window);
+ old_password = fr_window_get_password_for_second_archive (window);
+ }
+
filename = _g_file_get_display_basename (file);
/* 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);
+ gtk_label_set_label (GTK_LABEL (GET_WIDGET ("title_label")), message);
+
+ if (old_password != NULL) {
+ GtkWidget *info_bar;
+ GtkWidget *label;
+
+ info_bar = gtk_info_bar_new ();
+ label = gtk_label_new (_("Wrong password."));
+ gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar))), label);
+ gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_ERROR);
+ gtk_box_pack_start (GTK_BOX (GET_WIDGET ("error_box")), info_bar, TRUE, TRUE, 0);
+ gtk_widget_show_all (GET_WIDGET ("error_box"));
- if (fr_window_get_password (window) != NULL)
_gtk_entry_set_locale_text (GTK_ENTRY (data->password_entry),
fr_window_get_password (window));
+ }
/* Set the signals handlers. */
diff --git a/src/fr-window.c b/src/fr-window.c
index f606fc6..11af0bb 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -6860,6 +6860,7 @@ fr_window_set_password (FrWindow *window,
window->priv->password = g_strdup (password);
}
+
void
fr_window_set_password_for_second_archive (FrWindow *window,
const char *password)
@@ -6875,6 +6876,7 @@ fr_window_set_password_for_second_archive (FrWindow *window,
window->priv->second_password = g_strdup (password);
}
+
const char *
fr_window_get_password (FrWindow *window)
{
@@ -6884,6 +6886,15 @@ fr_window_get_password (FrWindow *window)
}
+const char *
+fr_window_get_password_for_second_archive (FrWindow *window)
+{
+ g_return_val_if_fail (window != NULL, NULL);
+
+ return window->priv->second_password;
+}
+
+
void
fr_window_set_encrypt_header (FrWindow *window,
gboolean encrypt_header)
diff --git a/src/fr-window.h b/src/fr-window.h
index 25c69bc..7e2c171 100644
--- a/src/fr-window.h
+++ b/src/fr-window.h
@@ -158,9 +158,12 @@ void fr_window_archive_encrypt (FrWindow *window,
void fr_window_set_password (FrWindow *window,
const char *password);
-void fr_window_set_password_for_second_archive (FrWindow *window,
+void fr_window_set_password_for_second_archive
+ (FrWindow *window,
const char *password);
const char * fr_window_get_password (FrWindow *window);
+const char * fr_window_get_password_for_second_archive
+ (FrWindow *window);
void fr_window_set_encrypt_header (FrWindow *window,
gboolean encrypt_header);
gboolean fr_window_get_encrypt_header (FrWindow *window);
diff --git a/src/ui/ask-password.ui b/src/ui/ask-password.ui
index 54ca5cf..154cf2e 100644
--- a/src/ui/ask-password.ui
+++ b/src/ui/ask-password.ui
@@ -112,6 +112,21 @@
</packing>
</child>
<child>
+ <object class="GtkBox" id="error_box">
+ <property name="visible">True</property>
+ <property name="app_paintable">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkBox" id="box2">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -151,7 +166,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]