[file-roller] improved the "encrypt header" button usability



commit 30c78519234c0d7cf03c7372788fa34774becace
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Tue Jun 1 09:58:39 2010 +0200

    improved the "encrypt header" button usability
    
    always keep the "encrypt header" button clickable even when the
    password field is void.
    
    [bug #620172]

 src/dlg-batch-add.c |   15 +++++----------
 src/dlg-new.c       |   26 +++++++++++---------------
 src/fr-window.c     |    7 +++++--
 3 files changed, 21 insertions(+), 27 deletions(-)
---
diff --git a/src/dlg-batch-add.c b/src/dlg-batch-add.c
index c5ed4b9..65d9412 100644
--- a/src/dlg-batch-add.c
+++ b/src/dlg-batch-add.c
@@ -46,7 +46,7 @@ typedef struct {
 	FrWindow   *window;
 	GtkBuilder *builder;
 	int        *supported_types;
-	
+
 	GtkWidget  *dialog;
 	GtkWidget  *a_add_to_entry;
 	GtkWidget  *a_location_filechooserbutton;
@@ -86,7 +86,7 @@ destroy_cb (GtkWidget  *widget,
 	eel_gconf_set_string (PREF_BATCH_ADD_DEFAULT_EXTENSION, get_ext (data));
 	/*eel_gconf_set_boolean (PREF_BATCH_OTHER_OPTIONS, data->add_clicked ? FALSE : gtk_expander_get_expanded (GTK_EXPANDER (data->a_other_options_expander)));*/
 	eel_gconf_set_boolean (PREF_ENCRYPT_HEADER, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->a_encrypt_header_checkbutton)));
-	
+
 	if (! data->add_clicked) {
 		fr_window_pop_message (data->window);
 		fr_window_stop_batch (data->window);
@@ -374,6 +374,7 @@ update_sensitivity_for_mime_type (DialogData *data,
 		gtk_widget_set_sensitive (data->a_password_entry, FALSE);
 		gtk_widget_set_sensitive (data->a_password_label, FALSE);
 		gtk_widget_set_sensitive (data->a_encrypt_header_checkbutton, FALSE);
+		gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (data->a_encrypt_header_checkbutton), TRUE);
 		gtk_widget_set_sensitive (data->a_volume_box, FALSE);
 		return;
 	}
@@ -388,6 +389,7 @@ update_sensitivity_for_mime_type (DialogData *data,
 
 			sensitive = mime_type_desc[i].capabilities & FR_COMMAND_CAN_ENCRYPT_HEADER;
 			gtk_widget_set_sensitive (data->a_encrypt_header_checkbutton, sensitive);
+			gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (data->a_encrypt_header_checkbutton), ! sensitive);
 
 			sensitive = mime_type_desc[i].capabilities & FR_COMMAND_CAN_CREATE_VOLUMES;
 			gtk_widget_set_sensitive (data->a_volume_box, sensitive);
@@ -437,13 +439,6 @@ update_archive_type_combo_box_from_ext (DialogData  *data,
 static void
 update_sensitivity (DialogData *data)
 {
-	const char *password;
-	gboolean    void_password;
-
-	password = gtk_entry_get_text (GTK_ENTRY (data->a_password_entry));
-	void_password = (password == NULL) || (strcmp (password, "") == 0);
-	gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (data->a_encrypt_header_checkbutton), void_password);
-	/*gtk_widget_set_sensitive (GTK_WIDGET (data->a_encrypt_header_checkbutton), ! void_password);*/
 	gtk_widget_set_sensitive (data->a_volume_spinbutton, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->a_volume_checkbutton)));
 }
 
@@ -560,7 +555,7 @@ dlg_batch_add_files (FrWindow *window,
 	else
 		data->supported_types = save_type;
 	sort_mime_types_by_extension (data->supported_types);
-	
+
 	for (i = 0; data->supported_types[i] != -1; i++)
 		gtk_combo_box_append_text (GTK_COMBO_BOX (data->a_archive_type_combo_box),
 					   mime_type_desc[data->supported_types[i]].default_ext);
diff --git a/src/dlg-new.c b/src/dlg-new.c
index 1cfc1ca..5b9337e 100644
--- a/src/dlg-new.c
+++ b/src/dlg-new.c
@@ -53,12 +53,8 @@ destroy_cb (GtkWidget  *widget,
 static void
 update_sensitivity (DlgNewData *data)
 {
-	const char *password;
-	gboolean    void_password;
-
-	password = gtk_entry_get_text (GTK_ENTRY (data->n_password_entry));
-	void_password = (password == NULL) || (strcmp (password, "") == 0);
-	gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (data->n_encrypt_header_checkbutton), ! data->can_encrypt || ! data->can_encrypt_header || void_password);
+	gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (data->n_encrypt_header_checkbutton), ! data->can_encrypt_header);
+	gtk_widget_set_sensitive (data->n_encrypt_header_checkbutton, data->can_encrypt_header);
 	gtk_widget_set_sensitive (data->n_volume_spinbutton, ! data->can_create_volumes || gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->n_volume_checkbutton)));
 }
 
@@ -99,7 +95,7 @@ update_sensitivity_for_ext (DlgNewData *data,
 			break;
 		}
 	}
-	
+
 	update_sensitivity (data);
 }
 
@@ -140,33 +136,33 @@ archive_type_combo_box_changed_cb (GtkComboBox *combo_box,
 	int         idx;
 
 	uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (data->dialog));
-	
+
 	ext = get_archive_filename_extension (uri);
 	idx = gtk_combo_box_get_active (GTK_COMBO_BOX (data->n_archive_type_combo_box)) - 1;
 	if ((ext == NULL) && (idx >= 0))
 		ext = mime_type_desc[data->supported_types[idx]].default_ext;
-		
+
 	update_sensitivity_for_ext (data, ext);
-	
+
 	if ((idx >= 0) && (uri != NULL)) {
 		const char *new_ext;
 		const char *basename;
 		char       *basename_noext;
 		char       *new_basename;
 		char       *new_basename_uft8;
-			
+
 		new_ext = mime_type_desc[data->supported_types[idx]].default_ext;
 		basename = file_name_from_path (uri);
-		if (g_str_has_suffix (basename, ext)) 
+		if (g_str_has_suffix (basename, ext))
 			basename_noext = g_strndup (basename, strlen (basename) - strlen (ext));
 		else
 			basename_noext = g_strdup (basename);
 		new_basename = g_strconcat (basename_noext, new_ext, NULL);
 		new_basename_uft8 = g_uri_unescape_string (new_basename, NULL);
-	
+
 		gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (data->dialog), new_basename_uft8);
 		update_sensitivity_for_ext (data, new_ext);
-	
+
 		g_free (new_basename_uft8);
 		g_free (new_basename);
 		g_free (basename_noext);
@@ -289,7 +285,7 @@ dlg_new_archive (FrWindow  *window,
 	data->window = window;
 	data->supported_types = supported_types;
 	sort_mime_types_by_description (data->supported_types);
-	
+
 	/* Get the widgets. */
 
 	data->dialog = _gtk_builder_get_widget (data->builder, "filechooserdialog");
diff --git a/src/fr-window.c b/src/fr-window.c
index d8fb08e..ef132f2 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -6220,9 +6220,12 @@ fr_window_archive_save_as (FrWindow   *window,
 
 	g_return_if_fail (window->priv->convert_data.new_archive->command != NULL);
 
-	if (password != NULL)
+	if (password != NULL) {
 		window->priv->convert_data.password = g_strdup (password);
-	window->priv->convert_data.encrypt_header = encrypt_header;
+		window->priv->convert_data.encrypt_header = encrypt_header;
+	}
+	else
+		window->priv->convert_data.encrypt_header = FALSE;
 	window->priv->convert_data.volume_size = volume_size;
 
 	fr_window_set_current_batch_action (window,



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