2007-07-05 Johannes Schmid <johannes.schmid@openismus.com>
authorJohannes Schmid <johannes.schmid@openismus.com>
Thu, 5 Jul 2007 14:05:32 +0000 (14:05 +0000)
committerJohannes Schmid <johannes.schmid@openismus.com>
Thu, 5 Jul 2007 14:05:32 +0000 (14:05 +0000)
* src/maemo/easysetup/modest-easysetup-wizard.c:
(on_entry_invalid_character), (create_page_account_details),
(create_page_user_details):
Use new API of ModestValidatingEntry. But for some reason the banner is
not shown. I will have to investigate that further.

* src/widgets/modest-validating-entry.c: (on_insert_text),
(modest_validating_entry_set_func):
* src/widgets/modest-validating-entry.h:
Added a new callback function to be able to react to prevented
characters whitespaces to e.g show a banner.

pmo-trunk-r2592

ChangeLog2
src/maemo/easysetup/modest-easysetup-wizard.c
src/widgets/modest-validating-entry.c
src/widgets/modest-validating-entry.h

index 26f811a..000f7b9 100644 (file)
@@ -1,3 +1,18 @@
+2007-07-05  Johannes Schmid <johannes.schmid@openismus.com>
+
+       * src/maemo/easysetup/modest-easysetup-wizard.c:
+       (on_entry_invalid_character), (create_page_account_details),
+       (create_page_user_details):
+       Use new API of ModestValidatingEntry. But for some reason the banner is
+       not shown. I will have to investigate that further.
+
+       * src/widgets/modest-validating-entry.c: (on_insert_text),
+       (modest_validating_entry_set_func):
+       * src/widgets/modest-validating-entry.h:
+       Added a new callback function to be able to react to prevented 
+       characters whitespaces to e.g show a banner.
+
+
 2007-07-05  Armin Burgmeier  <armin@openismus.com>
 
        * src/maemo/modest-account-settings-dialog.c: Use the notify::value
 2007-07-05  Armin Burgmeier  <armin@openismus.com>
 
        * src/maemo/modest-account-settings-dialog.c: Use the notify::value
index c687788..a87c543 100644 (file)
@@ -358,6 +358,17 @@ on_entry_max (ModestValidatingEntry *self, gpointer user_data)
        show_error (GTK_WINDOW (dialog), _("ckdg_ib_maximum_characters_reached"));
 }
 
        show_error (GTK_WINDOW (dialog), _("ckdg_ib_maximum_characters_reached"));
 }
 
+static void
+on_entry_invalid_character (ModestValidatingEntry *self, const gchar* character, gpointer user_data)
+{
+       ModestEasysetupWizardDialog *dialog = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);       
+       /* We could add a special case for whitespace here 
+       if (character == NULL) ...
+       */
+       hildon_banner_show_information (
+                                               GTK_WIDGET(dialog), NULL, _("ckdg_ib_illegal_characters_entered"));
+}
+
 static GtkWidget*
 create_page_account_details (ModestEasysetupWizardDialog *self)
 {
 static GtkWidget*
 create_page_account_details (ModestEasysetupWizardDialog *self)
 {
@@ -483,6 +494,8 @@ create_page_account_details (ModestEasysetupWizardDialog *self)
        modest_validating_entry_set_unallowed_characters (
                MODEST_VALIDATING_ENTRY (self->entry_account_title), list_prevent);
        g_list_free (list_prevent);
        modest_validating_entry_set_unallowed_characters (
                MODEST_VALIDATING_ENTRY (self->entry_account_title), list_prevent);
        g_list_free (list_prevent);
+       modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(self->entry_account_title),
+                                                                                                                                        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. */
        
        /* Set max length as in the UI spec:
         * The UI spec seems to want us to show a dialog if we hit the maximum. */
@@ -529,6 +542,8 @@ create_page_user_details (ModestEasysetupWizardDialog *self)
        list_prevent = g_list_append (list_prevent, ">");
        modest_validating_entry_set_unallowed_characters (
                MODEST_VALIDATING_ENTRY (self->entry_user_name), list_prevent);
        list_prevent = g_list_append (list_prevent, ">");
        modest_validating_entry_set_unallowed_characters (
                MODEST_VALIDATING_ENTRY (self->entry_user_name), list_prevent);
+       modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(self->entry_account_title),
+                                                                                                                                        on_entry_invalid_character, self);
        g_list_free (list_prevent);
        
        /* The username widgets: */     
        g_list_free (list_prevent);
        
        /* The username widgets: */     
@@ -547,6 +562,8 @@ create_page_user_details (ModestEasysetupWizardDialog *self)
         * as required by our UI specification: */
        modest_validating_entry_set_unallowed_characters_whitespace (
                MODEST_VALIDATING_ENTRY (self->entry_user_username));
         * 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_account_title),
+                                                                                                                                        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. */
        
        /* 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 b6af2a4..08994c3 100644 (file)
@@ -29,6 +29,9 @@ struct _ModestValidatingEntryPrivate
        
        gboolean prevent_whitespace;
        
        
        gboolean prevent_whitespace;
        
+       EasySetupValidatingEntryFunc func;
+       gpointer func_user_data;
+
        EasySetupValidatingEntryMaxFunc max_func;
        gpointer max_func_user_data;
 };
        EasySetupValidatingEntryMaxFunc max_func;
        gpointer max_func_user_data;
 };
@@ -131,6 +134,10 @@ on_insert_text(GtkEditable *editable,
                        GList *found = g_list_find_custom(priv->list_prevent, &one_char, &on_list_compare);
                        if(found) {
                                allow = FALSE;
                        GList *found = g_list_find_custom(priv->list_prevent, &one_char, &on_list_compare);
                        if(found) {
                                allow = FALSE;
+                               if (priv->func)
+                               {
+                                       priv->func(self, iter, priv->func_user_data);
+                               }
                                break;
                        }       
                }
                                break;
                        }       
                }
@@ -140,6 +147,10 @@ on_insert_text(GtkEditable *editable,
                        gunichar one_char = g_utf8_get_char (iter);
                        if (g_unichar_isspace (one_char)) {
                                allow = FALSE;
                        gunichar one_char = g_utf8_get_char (iter);
                        if (g_unichar_isspace (one_char)) {
                                allow = FALSE;
+                               if (priv->func)
+                               {
+                                       priv->func(self, NULL, priv->func_user_data);
+                               }
                                break;
                        }
                }
                                break;
                        }
                }
@@ -242,3 +253,14 @@ void modest_validating_entry_set_max_func (ModestValidatingEntry *self, EasySetu
        priv->max_func_user_data = user_data;
 }
 
        priv->max_func_user_data = user_data;
 }
 
+/** Set a callback to be called when a character was prevented so that a
+ * note can be shown by the application to inform the user. For whitespaces,
+ * character will be NULL
+ */
+void modest_validating_entry_set_func (ModestValidatingEntry *self, EasySetupValidatingEntryFunc func, gpointer user_data)
+{
+       ModestValidatingEntryPrivate *priv = VALIDATING_ENTRY_GET_PRIVATE (self);
+       priv->func = func;
+       priv->func_user_data = user_data;
+}
+
index e7c2bf6..3571ac4 100644 (file)
@@ -46,6 +46,10 @@ ModestValidatingEntry* modest_validating_entry_new (void);
 
 void modest_validating_entry_set_unallowed_characters (ModestValidatingEntry *self, GList *list);
 void modest_validating_entry_set_unallowed_characters_whitespace (ModestValidatingEntry *self);
 
 void modest_validating_entry_set_unallowed_characters (ModestValidatingEntry *self, GList *list);
 void modest_validating_entry_set_unallowed_characters_whitespace (ModestValidatingEntry *self);
+typedef void (* EasySetupValidatingEntryFunc) (ModestValidatingEntry *self, const gchar* character, gpointer user_data);
+void modest_validating_entry_set_func (ModestValidatingEntry *self, EasySetupValidatingEntryFunc func, gpointer user_data);
+
+
 
 typedef void (* EasySetupValidatingEntryMaxFunc) (ModestValidatingEntry *self, gpointer user_data);
 void modest_validating_entry_set_max_func (ModestValidatingEntry *self, EasySetupValidatingEntryMaxFunc func, gpointer user_data);
 
 typedef void (* EasySetupValidatingEntryMaxFunc) (ModestValidatingEntry *self, gpointer user_data);
 void modest_validating_entry_set_max_func (ModestValidatingEntry *self, EasySetupValidatingEntryMaxFunc func, gpointer user_data);