summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZenWalker <[email protected]>2016-08-10 00:16:52 +0200
committerZenWalker <[email protected]>2016-08-10 00:16:52 +0200
commitdd3529f648ba643924b94857fe16afd37147788d (patch)
tree29d19d73b0eb1a2820750237a8580d6d161852a5 /src
parent314e5ac0907287c7933cb7425834a4c00d5ab7f0 (diff)
downloadengrampa-dd3529f648ba643924b94857fe16afd37147788d.tar.bz2
engrampa-dd3529f648ba643924b94857fe16afd37147788d.tar.xz
make the "encrypt header" option insensitive if no password is specified
based on file-roller commit: https://git.gnome.org/browse/file-roller/commit/?id=6f7f14fa112a7c5b2a64bedeeca9d570ffa90968 and I add some code to work changing the combo box with the compressed file types
Diffstat (limited to 'src')
-rw-r--r--src/dlg-batch-add.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/dlg-batch-add.c b/src/dlg-batch-add.c
index ae82eee..55d3b42 100644
--- a/src/dlg-batch-add.c
+++ b/src/dlg-batch-add.c
@@ -41,6 +41,9 @@
#define BAD_CHARS "/\\*"
#define GET_WIDGET(x) (_gtk_builder_get_widget (data->builder, (x)))
+static gboolean has_password = FALSE;
+static gboolean can_encrypt_header = FALSE;
+
typedef struct {
FrWindow *window;
@@ -379,8 +382,9 @@ update_sensitivity_for_mime_type (DialogData *data,
gtk_widget_set_sensitive (GET_WIDGET ("a_password_label"), sensitive);
sensitive = mime_type_desc[i].capabilities & FR_COMMAND_CAN_ENCRYPT_HEADER;
- gtk_widget_set_sensitive (GET_WIDGET ("a_encrypt_header_checkbutton"), sensitive);
- gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (GET_WIDGET ("a_encrypt_header_checkbutton")), ! sensitive);
+ can_encrypt_header = sensitive;
+ gtk_widget_set_sensitive (GET_WIDGET ("a_encrypt_header_checkbutton"), sensitive ? has_password : FALSE);
+ gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (GET_WIDGET ("a_encrypt_header_checkbutton")), sensitive ? (!has_password) : TRUE);
sensitive = mime_type_desc[i].capabilities & FR_COMMAND_CAN_CREATE_VOLUMES;
gtk_widget_set_sensitive (GET_WIDGET ("a_volume_box"), sensitive);
@@ -436,13 +440,22 @@ 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;
+
+ 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")), can_encrypt_header ? (!has_password) : TRUE);
+ gtk_widget_set_sensitive (GET_WIDGET ("a_encrypt_header_checkbutton"), can_encrypt_header ? has_password : FALSE);
}
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);
}
@@ -561,8 +574,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",