From cdc0247db5d354177cf8d230a891b58fde2af99e Mon Sep 17 00:00:00 2001 From: Johannes Schmid Date: Thu, 5 Jul 2007 14:05:32 +0000 Subject: [PATCH] 2007-07-05 Johannes Schmid * 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 | 15 +++++++++++++++ src/maemo/easysetup/modest-easysetup-wizard.c | 17 +++++++++++++++++ src/widgets/modest-validating-entry.c | 22 ++++++++++++++++++++++ src/widgets/modest-validating-entry.h | 4 ++++ 4 files changed, 58 insertions(+) diff --git a/ChangeLog2 b/ChangeLog2 index 26f811a..000f7b9 100644 --- a/ChangeLog2 +++ b/ChangeLog2 @@ -1,3 +1,18 @@ +2007-07-05 Johannes Schmid + + * 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 * src/maemo/modest-account-settings-dialog.c: Use the notify::value diff --git a/src/maemo/easysetup/modest-easysetup-wizard.c b/src/maemo/easysetup/modest-easysetup-wizard.c index c687788..a87c543 100644 --- a/src/maemo/easysetup/modest-easysetup-wizard.c +++ b/src/maemo/easysetup/modest-easysetup-wizard.c @@ -358,6 +358,17 @@ on_entry_max (ModestValidatingEntry *self, gpointer user_data) 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) { @@ -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_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. */ @@ -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); + 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: */ @@ -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)); + 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. */ diff --git a/src/widgets/modest-validating-entry.c b/src/widgets/modest-validating-entry.c index b6af2a4..08994c3 100644 --- a/src/widgets/modest-validating-entry.c +++ b/src/widgets/modest-validating-entry.c @@ -29,6 +29,9 @@ struct _ModestValidatingEntryPrivate gboolean prevent_whitespace; + EasySetupValidatingEntryFunc func; + gpointer 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; + if (priv->func) + { + priv->func(self, iter, priv->func_user_data); + } 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; + if (priv->func) + { + priv->func(self, NULL, priv->func_user_data); + } break; } } @@ -242,3 +253,14 @@ void modest_validating_entry_set_max_func (ModestValidatingEntry *self, EasySetu 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; +} + diff --git a/src/widgets/modest-validating-entry.h b/src/widgets/modest-validating-entry.h index e7c2bf6..3571ac4 100644 --- a/src/widgets/modest-validating-entry.h +++ b/src/widgets/modest-validating-entry.h @@ -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); +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); -- 1.7.9.5