[file-roller] make the "encrypt header" option insensitive if no password is specified



commit 6f7f14fa112a7c5b2a64bedeeca9d570ffa90968
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sun Jun 17 11:53:29 2012 +0200

    make the "encrypt header" option insensitive if no password is specified

 src/dlg-batch-add.c |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/src/dlg-batch-add.c b/src/dlg-batch-add.c
index 4919094..ed9e202 100644
--- a/src/dlg-batch-add.c
+++ b/src/dlg-batch-add.c
@@ -433,13 +433,23 @@ update_archive_type_combo_box_from_ext (DialogData  *data,
 static void
 update_sensitivity (DialogData *data)
 {
-	gtk_widget_set_sensitive (GET_WIDGET ("a_volume_spinbutton"), gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("a_volume_checkbutton"))));
+	const char *password;
+	gboolean    has_password;
+
+	gtk_widget_set_sensitive (GET_WIDGET ("a_volume_spinbutton"),
+				  gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("a_volume_checkbutton"))));
+
+	password = gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("a_password_entry")));
+	has_password = (password != NULL) && (*password != '\0');
+	gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (GET_WIDGET ("a_encrypt_header_checkbutton")), ! has_password);
+	gtk_widget_set_sensitive (GET_WIDGET ("a_encrypt_header_checkbutton"), has_password);
 }
 
 
 static void
-password_entry_changed_cb (GtkEditable *editable,
-			   gpointer     user_data)
+password_entry_notify_text_cb (GObject    *object,
+			       GParamSpec *spec,
+			       gpointer    user_data)
 {
 	update_sensitivity ((DialogData *) user_data);
 }
@@ -556,8 +566,8 @@ dlg_batch_add_files (FrWindow *window,
 			  G_CALLBACK (archive_type_combo_box_changed_cb),
 			  data);
 	g_signal_connect (GET_WIDGET ("a_password_entry"),
-			  "changed",
-			  G_CALLBACK (password_entry_changed_cb),
+			  "notify::text",
+			  G_CALLBACK (password_entry_notify_text_cb),
 			  data);
 	g_signal_connect (GET_WIDGET ("a_volume_checkbutton"),
 			  "toggled",



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