From 40a8f5cbe03bd040fe3403dbfa6806df4fb6bc8a Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Fri, 3 Aug 2007 09:52:31 +0000 Subject: [PATCH] * check for a valid foldername Fixes: NB#58923 pmo-trunk-r2920 --- src/maemo/modest-platform.c | 38 +++++++++++--------------------------- src/modest-text-utils.c | 1 - 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/src/maemo/modest-platform.c b/src/maemo/modest-platform.c index 73d4c1f..b1a8227 100644 --- a/src/maemo/modest-platform.c +++ b/src/maemo/modest-platform.c @@ -573,28 +573,16 @@ entry_insert_text (GtkEditable *editable, hildon_banner_show_information (gtk_widget_get_parent (GTK_WIDGET (data)), NULL, _CS("ckdg_ib_maximum_characters_reached")); } else { - gboolean is_valid = FALSE; - - if (!text) - is_valid = FALSE; - else if (strlen(text) == 0 && g_str_has_prefix (chars, " ")) - is_valid = FALSE; - else - is_valid = !g_str_has_prefix(text, " "); + GtkWidget *ok_button; + GList *buttons; - /* A blank space is not valid as first character */ - if (is_valid) { - GtkWidget *ok_button; - GList *buttons; - - /* Show OK button */ - buttons = gtk_container_get_children (GTK_CONTAINER (GTK_DIALOG (data)->action_area)); - ok_button = GTK_WIDGET (buttons->next->data); - gtk_widget_set_sensitive (ok_button, TRUE); - g_list_free (buttons); + buttons = gtk_container_get_children (GTK_CONTAINER (GTK_DIALOG (data)->action_area)); + ok_button = GTK_WIDGET (buttons->next->data); + + gtk_widget_set_sensitive (ok_button, + modest_text_utils_validate_folder_name (chars)); + g_list_free (buttons); - } - /* Write the text in the entry */ g_signal_handlers_block_by_func (editable, (gpointer) entry_insert_text, data); @@ -621,15 +609,11 @@ entry_changed (GtkEditable *editable, g_return_if_fail (chars != NULL); - /* Dimm OK button. Do not allow also the "/" */ - if (strlen (chars) == 0 || strchr (chars, '/')) - gtk_widget_set_sensitive (ok_button, FALSE); - - else if (g_utf8_strlen (chars,-1) >= 21) + if (g_utf8_strlen (chars,-1) >= 21) hildon_banner_show_information (gtk_widget_get_parent (GTK_WIDGET (user_data)), NULL, _CS("ckdg_ib_maximum_characters_reached")); - else /* explicitely enable it, because with a previous entry_changed, it might have been turned off */ - gtk_widget_set_sensitive (ok_button, TRUE); + else + gtk_widget_set_sensitive (ok_button, modest_text_utils_validate_folder_name(chars)); /* Free */ g_list_free (buttons); diff --git a/src/modest-text-utils.c b/src/modest-text-utils.c index da5859d..aaa025d 100644 --- a/src/modest-text-utils.c +++ b/src/modest-text-utils.c @@ -1114,7 +1114,6 @@ modest_text_utils_validate_folder_name (const gchar *folder_name) /* cannot contain a forbidden word */ if (len <= 4) { for (cursor = forbidden_names; cursor && *cursor; ++cursor) { - g_warning ("%s", *cursor); if (g_ascii_strcasecmp (folder_name, *cursor) == 0) return FALSE; } -- 1.7.9.5