X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmaemo%2Fmodest-account-settings-dialog.c;h=bf542636b697e3b2f7d2a32f7472cea693741187;hp=505e91f5474fac37e3a323f28457d22b6da61e2b;hb=aab65ff35930f7c7d33ec080ae179f09150fabe2;hpb=2caed3203797912254d845115d0f2e8a2b507dd8 diff --git a/src/maemo/modest-account-settings-dialog.c b/src/maemo/modest-account-settings-dialog.c index 505e91f..bf54263 100644 --- a/src/maemo/modest-account-settings-dialog.c +++ b/src/maemo/modest-account-settings-dialog.c @@ -27,6 +27,7 @@ #include "modest-account-mgr-helpers.h" /* For modest_account_mgr_get_account_data(). */ #include "modest-runtime.h" /* For modest_runtime_get_account_mgr(). */ #include "maemo/modest-connection-specific-smtp-window.h" +#include "maemo/modest-signature-editor-dialog.h" #include #include #include /* For strlen(). */ @@ -98,6 +99,9 @@ modest_account_settings_dialog_finalize (GObject *object) if (self->specific_window) gtk_widget_destroy (self->specific_window); + + if (self->signature_dialog) + gtk_widget_destroy (self->signature_dialog); G_OBJECT_CLASS (modest_account_settings_dialog_parent_class)->finalize (object); } @@ -212,6 +216,14 @@ static GtkWidget* create_caption_new_with_asterix(ModestAccountSettingsDialog *s return caption; } + +static void +on_entry_max (EasysetupValidatingEntry *self, gpointer user_data) +{ + ModestAccountSettingsDialog *dialog = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data); + show_error (GTK_WINDOW (dialog), _("ckdg_ib_maximum_characters_reached")); +} + static GtkWidget* create_page_account_details (ModestAccountSettingsDialog *self) { @@ -253,8 +265,10 @@ create_page_account_details (ModestAccountSettingsDialog *self) g_list_free (list_prevent); /* Set max length as in the UI spec: - * TODO: The UI spec seems to want us to show a dialog if we hit the maximum. */ + * The UI spec seems to want us to show a dialog if we hit the maximum. */ gtk_entry_set_max_length (GTK_ENTRY (self->entry_account_title), 64); + easysetup_validating_entry_set_max_func (EASYSETUP_VALIDATING_ENTRY (self->entry_account_title), + on_entry_max, self); /* The retrieve combobox: */ self->combo_retrieve = GTK_WIDGET (modest_retrieve_combo_box_new ()); @@ -290,7 +304,37 @@ create_page_account_details (ModestAccountSettingsDialog *self) static void on_button_signature (GtkButton *button, gpointer user_data) { + ModestAccountSettingsDialog * self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data); + /* Create the window, if necessary: */ + if (!(self->signature_dialog)) { + self->signature_dialog = GTK_WIDGET (modest_signature_editor_dialog_new ()); + + gboolean use_signature = FALSE; + gchar *signature = modest_account_mgr_get_signature(self->account_manager, self->account_name, + &use_signature); + const gchar* account_title = gtk_entry_get_text (GTK_ENTRY (self->entry_account_title)); + modest_signature_editor_dialog_set_settings ( + MODEST_SIGNATURE_EDITOR_DIALOG (self->signature_dialog), + use_signature, signature, account_title); + g_free (signature); + signature = NULL; + } + + /* Show the window: */ + gtk_window_set_transient_for (GTK_WINDOW (self->signature_dialog), GTK_WINDOW (self)); + gtk_window_set_modal (GTK_WINDOW (self->signature_dialog), TRUE); + const gint response = gtk_dialog_run (GTK_DIALOG (self->signature_dialog)); + gtk_widget_hide (self->signature_dialog); + if (response != GTK_RESPONSE_OK) { + /* Destroy the widget now, and its data: */ + gtk_widget_destroy (self->signature_dialog); + self->signature_dialog = NULL; + } + else { + /* Mark modified, so we use the dialog's data later: */ + self->modified = TRUE; + } } static GtkWidget* @@ -305,9 +349,13 @@ create_page_user_details (ModestAccountSettingsDialog *self) /* The name widgets: */ self->entry_user_name = GTK_WIDGET (easysetup_validating_entry_new ()); + /* Auto-capitalization is the default, so let's turn it off: */ + hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_user_name), HILDON_GTK_INPUT_MODE_FULL); /* Set max length as in the UI spec: - * TODO: The UI spec seems to want us to show a dialog if we hit the maximum. */ + * The UI spec seems to want us to show a dialog if we hit the maximum. */ gtk_entry_set_max_length (GTK_ENTRY (self->entry_user_name), 64); + easysetup_validating_entry_set_max_func (EASYSETUP_VALIDATING_ENTRY (self->entry_user_name), + on_entry_max, self); GtkWidget *caption = create_caption_new_with_asterix (self, sizegroup, _("mcen_li_emailsetup_name"), self->entry_user_name, NULL, HILDON_CAPTION_OPTIONAL); gtk_widget_show (self->entry_user_name); @@ -326,6 +374,8 @@ create_page_user_details (ModestAccountSettingsDialog *self) /* The username widgets: */ self->entry_user_username = GTK_WIDGET (easysetup_validating_entry_new ()); + /* Auto-capitalization is the default, so let's turn it off: */ + hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_user_username), HILDON_GTK_INPUT_MODE_FULL); caption = create_caption_new_with_asterix (self, sizegroup, _("mail_fi_username"), self->entry_user_username, NULL, HILDON_CAPTION_MANDATORY); gtk_widget_show (self->entry_user_username); @@ -339,11 +389,15 @@ create_page_user_details (ModestAccountSettingsDialog *self) EASYSETUP_VALIDATING_ENTRY (self->entry_user_username)); /* Set max length as in the UI spec: - * TODO: The UI spec seems to want us to show a dialog if we hit the maximum. */ + * The UI spec seems to want us to show a dialog if we hit the maximum. */ gtk_entry_set_max_length (GTK_ENTRY (self->entry_user_username), 64); + easysetup_validating_entry_set_max_func (EASYSETUP_VALIDATING_ENTRY (self->entry_user_username), + on_entry_max, self); /* The password widgets: */ self->entry_user_password = gtk_entry_new (); + /* Auto-capitalization is the default, so let's turn it off: */ + hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_user_password), HILDON_GTK_INPUT_MODE_FULL); gtk_entry_set_visibility (GTK_ENTRY (self->entry_user_password), FALSE); /* gtk_entry_set_invisible_char (GTK_ENTRY (self->entry_user_password), '*'); */ caption = create_caption_new_with_asterix (self, sizegroup, @@ -355,6 +409,8 @@ create_page_user_details (ModestAccountSettingsDialog *self) /* The email address widgets: */ self->entry_user_email = GTK_WIDGET (easysetup_validating_entry_new ()); + /* Auto-capitalization is the default, so let's turn it off: */ + hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_user_email), HILDON_GTK_INPUT_MODE_FULL); caption = create_caption_new_with_asterix (self, sizegroup, _("mcen_li_emailsetup_email_address"), self->entry_user_email, NULL, HILDON_CAPTION_MANDATORY); gtk_entry_set_text (GTK_ENTRY (self->entry_user_email), EXAMPLE_EMAIL_ADDRESS); /* Default text. */ @@ -364,9 +420,10 @@ create_page_user_details (ModestAccountSettingsDialog *self) gtk_widget_show (caption); /* Set max length as in the UI spec: - * TODO: The UI spec seems to want us to show a dialog if we hit the maximum. */ + * The UI spec seems to want us to show a dialog if we hit the maximum. */ gtk_entry_set_max_length (GTK_ENTRY (self->entry_user_email), 64); - + easysetup_validating_entry_set_max_func (EASYSETUP_VALIDATING_ENTRY (self->entry_user_email), + on_entry_max, self); /* Signature button: */ if (!self->button_signature) @@ -428,6 +485,8 @@ static GtkWidget* create_page_incoming (ModestAccountSettingsDialog *self) /* The incoming server widgets: */ if(!self->entry_incomingserver) self->entry_incomingserver = gtk_entry_new (); + /* Auto-capitalization is the default, so let's turn it off: */ + hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_incomingserver), HILDON_GTK_INPUT_MODE_FULL); if (self->caption_incoming) gtk_widget_destroy (self->caption_incoming); @@ -579,6 +638,8 @@ static GtkWidget* create_page_outgoing (ModestAccountSettingsDialog *self) /* The outgoing server widgets: */ if (!self->entry_outgoingserver) self->entry_outgoingserver = gtk_entry_new (); + /* Auto-capitalization is the default, so let's turn it off: */ + hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_outgoingserver), HILDON_GTK_INPUT_MODE_FULL); GtkWidget *caption = create_caption_new_with_asterix (self, sizegroup, _("mcen_li_emailsetup_smtp"), self->entry_outgoingserver, NULL, HILDON_CAPTION_OPTIONAL); gtk_widget_show (self->entry_outgoingserver); @@ -601,6 +662,8 @@ static GtkWidget* create_page_outgoing (ModestAccountSettingsDialog *self) /* The username widgets: */ self->entry_outgoing_username = GTK_WIDGET (easysetup_validating_entry_new ()); + /* Auto-capitalization is the default, so let's turn it off: */ + hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_outgoing_username), HILDON_GTK_INPUT_MODE_FULL); self->caption_outgoing_username = create_caption_new_with_asterix (self, sizegroup, _("mail_fi_username"), self->entry_outgoing_username, NULL, HILDON_CAPTION_MANDATORY); gtk_widget_show (self->entry_outgoing_username); @@ -614,11 +677,15 @@ static GtkWidget* create_page_outgoing (ModestAccountSettingsDialog *self) EASYSETUP_VALIDATING_ENTRY (self->entry_outgoing_username)); /* Set max length as in the UI spec: - * TODO: The UI spec seems to want us to show a dialog if we hit the maximum. */ + * The UI spec seems to want us to show a dialog if we hit the maximum. */ gtk_entry_set_max_length (GTK_ENTRY (self->entry_outgoing_username), 64); - + easysetup_validating_entry_set_max_func (EASYSETUP_VALIDATING_ENTRY (self->entry_outgoing_username), + on_entry_max, self); + /* The password widgets: */ self->entry_outgoing_password = gtk_entry_new (); + /* Auto-capitalization is the default, so let's turn it off: */ + hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_outgoing_password), HILDON_GTK_INPUT_MODE_FULL); gtk_entry_set_visibility (GTK_ENTRY (self->entry_outgoing_password), FALSE); /* gtk_entry_set_invisible_char (GTK_ENTRY (self->entry_outgoing_password), '*'); */ self->caption_outgoing_password = create_caption_new_with_asterix (self, sizegroup, @@ -1008,6 +1075,18 @@ save_configuration (ModestAccountSettingsDialog *dialog) MODEST_ACCOUNT_EMAIL, emailaddress, FALSE /* not server account */); if (!test) return FALSE; + + /* Signature: */ + if (dialog->signature_dialog) { + gboolean use_signature = FALSE; + gchar *signature = modest_signature_editor_dialog_get_settings ( + MODEST_SIGNATURE_EDITOR_DIALOG (dialog->signature_dialog), + &use_signature); + + modest_account_mgr_set_signature(dialog->account_manager, account_name, + signature, use_signature); + g_free (signature); + } gchar *retrieve = modest_retrieve_combo_box_get_active_retrieve_conf ( MODEST_RETRIEVE_COMBO_BOX (dialog->combo_retrieve));