[file-roller/gnome-3-28] keep "create" button disabled until a file name is entered
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller/gnome-3-28] keep "create" button disabled until a file name is entered
- Date: Sun, 15 Jul 2018 08:10:16 +0000 (UTC)
commit 7edcc1f7223ac0f0a45fbff0aa2688224f26047a
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Jul 15 09:56:01 2018 +0200
keep "create" button disabled until a file name is entered
[bug #789766]
src/dlg-add.c | 30 ++++++------------------------
src/fr-new-archive-dialog.c | 11 ++++++++---
src/glib-utils.c | 21 +++++++++++++++++++++
src/glib-utils.h | 4 ++++
4 files changed, 39 insertions(+), 27 deletions(-)
---
diff --git a/src/dlg-add.c b/src/dlg-add.c
index 53799e94..85dfdd63 100644
--- a/src/dlg-add.c
+++ b/src/dlg-add.c
@@ -57,24 +57,6 @@ file_selector_destroy_cb (GtkWidget *widget,
}
-static gboolean
-utf8_only_spaces (const char *text)
-{
- const char *scan;
-
- if (text == NULL)
- return TRUE;
-
- for (scan = text; *scan != 0; scan = g_utf8_next_char (scan)) {
- gunichar c = g_utf8_get_char (scan);
- if (! g_unichar_isspace (c))
- return FALSE;
- }
-
- return TRUE;
-}
-
-
static void dlg_add_folder_save_last_options (DialogData *data);
@@ -127,15 +109,15 @@ file_selector_response_cb (GtkWidget *widget,
follow_links = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET
("follow_links_checkbutton")));
include_files = gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("include_files_entry")));
- if (utf8_only_spaces (include_files))
+ if (_g_utf8_all_spaces (include_files))
include_files = "*";
exclude_files = gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("exclude_files_entry")));
- if (utf8_only_spaces (exclude_files))
+ if (_g_utf8_all_spaces (exclude_files))
exclude_files = NULL;
exclude_folders = gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("exclude_folders_entry")));
- if (utf8_only_spaces (exclude_folders))
+ if (_g_utf8_all_spaces (exclude_folders))
exclude_folders = NULL;
files = fr_file_selector_dialog_get_selected_files (FR_FILE_SELECTOR_DIALOG (data->dialog));
@@ -491,15 +473,15 @@ get_options_from_widgets (DialogData *data,
*no_symlinks = ! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET
("follow_links_checkbutton")));
*include_files = gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("include_files_entry")));
- if (utf8_only_spaces (*include_files))
+ if (_g_utf8_all_spaces (*include_files))
*include_files = "";
*exclude_files = gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("exclude_files_entry")));
- if (utf8_only_spaces (*exclude_files))
+ if (_g_utf8_all_spaces (*exclude_files))
*exclude_files = "";
*exclude_folders = gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("exclude_folders_entry")));
- if (utf8_only_spaces (*exclude_folders))
+ if (_g_utf8_all_spaces (*exclude_folders))
*exclude_folders = "";
}
diff --git a/src/fr-new-archive-dialog.c b/src/fr-new-archive-dialog.c
index 3c8bd7db..c29059a7 100644
--- a/src/fr-new-archive-dialog.c
+++ b/src/fr-new-archive-dialog.c
@@ -126,6 +126,7 @@ fr_new_archive_dialog_init (FrNewArchiveDialog *self)
static void
_fr_new_archive_dialog_update_sensitivity (FrNewArchiveDialog *self)
{
+ gtk_widget_set_sensitive (gtk_dialog_get_widget_for_response (GTK_DIALOG (self), GTK_RESPONSE_OK), !
_g_utf8_all_spaces (gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("filename_entry")))));
gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (GET_WIDGET ("encrypt_header_checkbutton")), !
self->priv->can_encrypt_header);
gtk_widget_set_sensitive (GET_WIDGET ("encrypt_header_checkbutton"), self->priv->can_encrypt_header);
gtk_widget_set_sensitive (GET_WIDGET ("volume_spinbutton"), ! self->priv->can_create_volumes ||
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("volume_checkbutton"))));
@@ -133,8 +134,8 @@ _fr_new_archive_dialog_update_sensitivity (FrNewArchiveDialog *self)
static void
-password_entry_changed_cb (GtkEditable *editable,
- gpointer user_data)
+entry_changed_cb (GtkEditable *editable,
+ gpointer user_data)
{
_fr_new_archive_dialog_update_sensitivity (FR_NEW_ARCHIVE_DIALOG (user_data));
}
@@ -279,9 +280,13 @@ _fr_new_archive_dialog_construct (FrNewArchiveDialog *self,
/* Set the signals handlers. */
+ g_signal_connect (GET_WIDGET ("filename_entry"),
+ "changed",
+ G_CALLBACK (entry_changed_cb),
+ self);
g_signal_connect (GET_WIDGET ("password_entry"),
"changed",
- G_CALLBACK (password_entry_changed_cb),
+ G_CALLBACK (entry_changed_cb),
self);
g_signal_connect (GET_WIDGET ("volume_checkbutton"),
"toggled",
diff --git a/src/glib-utils.c b/src/glib-utils.c
index d7bd51c6..f2faebb9 100644
--- a/src/glib-utils.c
+++ b/src/glib-utils.c
@@ -390,6 +390,27 @@ _g_str_get_static (const char *s)
}
+/* utf8 */
+
+
+gboolean
+_g_utf8_all_spaces (const char *text)
+{
+ const char *scan;
+
+ if (text == NULL)
+ return TRUE;
+
+ for (scan = text; *scan != 0; scan = g_utf8_next_char (scan)) {
+ gunichar c = g_utf8_get_char (scan);
+ if (! g_unichar_isspace (c))
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
/* string vector */
diff --git a/src/glib-utils.h b/src/glib-utils.h
index 7db48ba3..4d4bcad8 100644
--- a/src/glib-utils.h
+++ b/src/glib-utils.h
@@ -90,6 +90,10 @@ const char * _g_str_get_last_field (const char *line,
int last_field);
const char * _g_str_get_static (const char *s);
+/* utf8 */
+
+gboolean _g_utf8_all_spaces (const char *text);
+
/* string vector */
char ** _g_strv_prepend (char **str_array,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]