* Fixes NB#83478, show "invalid character" info banner when editing accounts
authorSergio Villar Senin <svillar@igalia.com>
Tue, 8 Apr 2008 10:42:29 +0000 (10:42 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Tue, 8 Apr 2008 10:42:29 +0000 (10:42 +0000)
* Refactored the show invalid character notification management

pmo-trunk-r4378

src/maemo/easysetup/modest-easysetup-wizard-dialog.c
src/maemo/modest-account-settings-dialog.c
src/maemo/modest-maemo-utils.c
src/maemo/modest-maemo-utils.h

index 36f9e9d..94845c1 100644 (file)
@@ -464,21 +464,6 @@ on_entry_max (ModestValidatingEntry *self, gpointer user_data)
        show_error (GTK_WIDGET (self), _CS("ckdg_ib_maximum_characters_reached"));
 }
 
-static void
-on_entry_invalid_character (ModestValidatingEntry *self, const gchar* character, gpointer user_data)
-{
-       const gchar *show_char = NULL;
-       if (character)
-         show_char = character;
-       else {
-         show_char = "' '";
-       }
-       
-       /* TODO: Should this show just this one bad character or all the not-allowed characters? */
-       gchar *message = g_strdup_printf (_CS("ckdg_ib_illegal_characters_entered"), show_char);
-       show_error (GTK_WIDGET (self), message);
-}
-
 static gint
 get_default_country_code(void)
 {
@@ -609,7 +594,7 @@ create_page_account_details (ModestEasysetupWizardDialog *self)
        g_list_free (list_prevent);
        list_prevent = NULL;
        modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_account_title),
-                                                                                                                                        on_entry_invalid_character, self);
+                                                                                                                                        modest_maemo_utils_on_entry_invalid_character, self);
        
        /* Set max length as in the UI spec:
         * The UI spec seems to want us to show a dialog if we hit the maximum. */
@@ -663,7 +648,7 @@ create_page_user_details (ModestEasysetupWizardDialog *self)
        modest_validating_entry_set_unallowed_characters (
                MODEST_VALIDATING_ENTRY (priv->entry_user_name), list_prevent);
        modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_user_name),
-               on_entry_invalid_character, self);
+               modest_maemo_utils_on_entry_invalid_character, self);
        g_list_free (list_prevent);
        
        /* The username widgets: */     
@@ -683,7 +668,7 @@ create_page_user_details (ModestEasysetupWizardDialog *self)
        modest_validating_entry_set_unallowed_characters_whitespace (
                MODEST_VALIDATING_ENTRY (priv->entry_user_username));
        modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_user_username),
-               on_entry_invalid_character, self);
+               modest_maemo_utils_on_entry_invalid_character, self);
        
        /* Set max length as in the UI spec:
         * The UI spec seems to want us to show a dialog if we hit the maximum. */
index bb1701b..c9260c4 100644 (file)
@@ -523,6 +523,9 @@ create_page_user_details (ModestAccountSettingsDialog *self)
         * as required by our UI specification: */
        modest_validating_entry_set_unallowed_characters_whitespace (
                MODEST_VALIDATING_ENTRY (self->entry_user_username));
+       modest_validating_entry_set_func (MODEST_VALIDATING_ENTRY (self->entry_user_username), 
+                                         modest_maemo_utils_on_entry_invalid_character, 
+                                         self);
        
        /* Set max length as in the UI spec:
         * The UI spec seems to want us to show a dialog if we hit the maximum. */
index 19ba8ef..b2190ad 100644 (file)
@@ -49,6 +49,7 @@
 
 #include <modest-defs.h>
 #include "modest-maemo-utils.h"
+#include "modest-text-utils.h"
 #include "modest-platform.h"
 
 /*
@@ -287,3 +288,21 @@ modest_maemo_utils_get_manager_menubar_as_menu (GtkUIManager *manager,
 
        return new_menu;
 }
+
+void 
+modest_maemo_utils_on_entry_invalid_character (ModestValidatingEntry *self, 
+                                              const gchar* character, 
+                                              gpointer user_data)
+{
+       gchar *message = NULL;
+       const gchar *show_char = NULL;
+
+       if (character)
+               show_char = character;
+       else {
+               show_char = "' '";
+       }
+       
+       message = g_strdup_printf (_CS("ckdg_ib_illegal_characters_entered"), show_char);
+       hildon_banner_show_information(GTK_WIDGET (self), NULL, message);
+}
index 28802a6..95a9697 100644 (file)
@@ -37,6 +37,7 @@
 #include <tny-fs-stream.h>
 #include <libosso.h>
 #include "widgets/modest-global-settings-dialog.h"
+#include "widgets/modest-validating-entry.h"
 
 #define MODEST_MAEMO_UTILS_MYDOCS_FOLDER "MyDocs"
 #define MODEST_MAEMO_UTILS_DEFAULT_IMAGE_FOLDER ".images"
@@ -123,4 +124,8 @@ void modest_maemo_utils_set_osso_context (osso_context_t *osso_context);
  */
 GtkWidget *modest_maemo_utils_get_manager_menubar_as_menu (GtkUIManager *manager, const gchar *item_name);
 
+void modest_maemo_utils_on_entry_invalid_character (ModestValidatingEntry *self, 
+                                                   const gchar* character, 
+                                                   gpointer user_data);
+
 #endif /*__MODEST_MAEMO_UTILS_H__*/