X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fhildon2%2Fmodest-default-account-settings-dialog.c;h=d4e3d5ce5d4aba1f7ed6c7c46ee947be6eda34d8;hp=857d8f6c37c3388952c9633a5a0cb57323c86cae;hb=448d8d5a3f665e689ceeed19ade2f33a0091a289;hpb=fb5c6df373b44ec85994574b532f1a21e9cdba16 diff --git a/src/hildon2/modest-default-account-settings-dialog.c b/src/hildon2/modest-default-account-settings-dialog.c index 857d8f6..d4e3d5c 100644 --- a/src/hildon2/modest-default-account-settings-dialog.c +++ b/src/hildon2/modest-default-account-settings-dialog.c @@ -54,6 +54,7 @@ #include #include "modest-maemo-utils.h" #include "modest-maemo-security-options-view.h" +#include "modest-ui-actions.h" #include "widgets/modest-ui-constants.h" #include #include @@ -162,16 +163,16 @@ modest_default_account_settings_dialog_finalize (GObject *object) self = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (object); priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self); - + if (priv->account_name) g_free (priv->account_name); - + if (priv->original_account_title) g_free (priv->original_account_title); - + if (priv->account_manager) g_object_unref (G_OBJECT (priv->account_manager)); - + if (priv->signature_dialog) gtk_widget_destroy (priv->signature_dialog); @@ -179,11 +180,11 @@ modest_default_account_settings_dialog_finalize (GObject *object) g_object_unref (priv->settings); priv->settings = NULL; } - + G_OBJECT_CLASS (modest_default_account_settings_dialog_parent_class)->finalize (object); } -static void +static void set_modified (ModestDefaultAccountSettingsDialog *self, gboolean modified) { ModestDefaultAccountSettingsDialogPrivate *priv; @@ -211,16 +212,16 @@ on_modified_checkbutton_toggled (GtkButton *button, gpointer user_data) } static void -on_modified_number_editor_changed (HildonNumberEditor *number_editor, gint new_value, gpointer user_data) +on_modified_number_editor_changed (ModestNumberEditor *number_editor, gint new_value, gpointer user_data) { set_modified (MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data), TRUE); } static void -on_number_editor_notify (HildonNumberEditor *editor, GParamSpec *arg1, gpointer user_data) +on_number_editor_notify (ModestNumberEditor *editor, GParamSpec *arg1, gpointer user_data) { ModestDefaultAccountSettingsDialog *dialog = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data); - gint value = hildon_number_editor_get_value (editor); + gint value = modest_number_editor_get_value (editor); gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, value > 0); } @@ -231,7 +232,7 @@ on_number_editor_notify (HildonNumberEditor *editor, GParamSpec *arg1, gpointer static void connect_for_modified (ModestDefaultAccountSettingsDialog *self, GtkWidget *widget) { - if (HILDON_IS_NUMBER_EDITOR (widget)) { + if (MODEST_IS_NUMBER_EDITOR (widget)) { g_signal_connect (G_OBJECT (widget), "notify::value", G_CALLBACK (on_modified_number_editor_changed), self); g_signal_connect (G_OBJECT (widget), "notify", G_CALLBACK (on_number_editor_notify), self); @@ -261,13 +262,14 @@ create_captioned (ModestDefaultAccountSettingsDialog *self, GtkSizeGroup *title_sizegroup, GtkSizeGroup *value_sizegroup, const gchar *label_text, + gboolean use_markup, GtkWidget *control) { GtkWidget *result; result = modest_maemo_utils_create_captioned (title_sizegroup, value_sizegroup, - label_text, control); + label_text, use_markup, control); /* Connect to the appropriate changed signal for the widget, * so we can ask for the prev/next buttons to be enabled/disabled appropriately: @@ -337,7 +339,7 @@ create_page_account_details (ModestDefaultAccountSettingsDialog *self) hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_account_title), HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_AUTOCAP); GtkWidget *caption = create_captioned (self, title_sizegroup, value_sizegroup, - _("mcen_fi_account_title"), + _("mcen_fi_account_title"), FALSE, priv->entry_account_title); gtk_widget_show (priv->entry_account_title); connect_for_modified (self, priv->entry_account_title); @@ -362,7 +364,7 @@ create_page_account_details (ModestDefaultAccountSettingsDialog *self) g_list_free (list_prevent); modest_validating_entry_set_func(MODEST_VALIDATING_ENTRY(priv->entry_account_title), on_entry_invalid_account_title_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. */ gtk_entry_set_max_length (GTK_ENTRY (priv->entry_account_title), 64); @@ -375,11 +377,11 @@ create_page_account_details (ModestDefaultAccountSettingsDialog *self) HILDON_BUTTON_ARRANGEMENT_VERTICAL)); modest_maemo_utils_set_vbutton_layout (title_sizegroup, _("mcen_fi_advsetup_retrievetype"), priv->retrieve_picker); - + gtk_widget_show (priv->retrieve_picker); connect_for_modified (self, priv->retrieve_picker); gtk_box_pack_start (GTK_BOX (hbox), priv->retrieve_picker, TRUE, TRUE, MODEST_MARGIN_HALF); - + /* The limit-retrieve picker: */ priv->limit_retrieve_picker = GTK_WIDGET (modest_limit_retrieve_picker_new (MODEST_EDITABLE_SIZE, HILDON_BUTTON_ARRANGEMENT_VERTICAL)); @@ -488,55 +490,25 @@ on_button_delete (GtkButton *button, gpointer user_data) { ModestDefaultAccountSettingsDialog *self; ModestDefaultAccountSettingsDialogPrivate *priv; - ModestAccountMgr *account_mgr; - gchar *account_title = NULL; + gchar *account_title; + gboolean removed; self = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data); priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self); - account_mgr = modest_runtime_get_account_mgr(); - if(!priv->account_name) - return; + if (priv->modified) + account_title = g_strdup (priv->original_account_title); + else + account_title = get_entered_account_title (self); - account_title = get_entered_account_title (self); - - /* The warning text depends on the account type: */ - gchar *txt = NULL; - gint response; - ModestProtocol *protocol; + removed = modest_ui_actions_on_delete_account (GTK_WINDOW (self), + priv->account_name, + (const gchar *) account_title); + g_free (account_title); - protocol = modest_protocol_registry_get_protocol_by_type ( - modest_runtime_get_protocol_registry (), - modest_account_mgr_get_store_protocol (account_mgr, priv->account_name)); - txt = modest_protocol_get_translation (protocol, - MODEST_PROTOCOL_TRANSLATION_DELETE_MAILBOX, - account_title); - if (txt == NULL) { - txt = g_strdup_printf (_("emev_nc_delete_mailbox"), - account_title); - } - - response = modest_platform_run_confirmation_dialog (GTK_WINDOW (self), txt); - g_free (txt); - txt = NULL; - - if (response == GTK_RESPONSE_OK) { - /* Remove account. If it succeeds then it also removes - the account from the ModestAccountView: */ - gboolean is_default = FALSE; - gchar *default_account_name = modest_account_mgr_get_default_account (account_mgr); - if (default_account_name && (strcmp (default_account_name, priv->account_name) == 0)) - is_default = TRUE; - g_free (default_account_name); - - gboolean removed = modest_account_mgr_remove_account (account_mgr, priv->account_name); - if (!removed) { - g_warning ("%s: modest_account_mgr_remove_account() failed.\n", __FUNCTION__); - } + /* Close window */ + if (removed) gtk_widget_destroy (GTK_WIDGET (self)); - } - g_free (account_title); - } static GtkWidget* @@ -565,7 +537,7 @@ create_page_user_details (ModestDefaultAccountSettingsDialog *self) on_entry_max, self); GtkWidget *caption = create_captioned (self, title_sizegroup, value_sizegroup, - _("mcen_li_emailsetup_name"), priv->entry_user_name); + _("mcen_li_emailsetup_name"), FALSE, priv->entry_user_name); gtk_widget_show (priv->entry_user_name); connect_for_modified (self, priv->entry_user_name); gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF); @@ -588,7 +560,7 @@ create_page_user_details (ModestDefaultAccountSettingsDialog *self) /* Auto-capitalization is the default, so let's turn it off: */ hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_username), HILDON_GTK_INPUT_MODE_FULL); caption = create_captioned (self, title_sizegroup, value_sizegroup, - _("mail_fi_username"), + _("mail_fi_username"), FALSE, priv->entry_user_username); gtk_widget_show (priv->entry_user_username); connect_for_modified (self, priv->entry_user_username); @@ -617,7 +589,7 @@ create_page_user_details (ModestDefaultAccountSettingsDialog *self) gtk_entry_set_visibility (GTK_ENTRY (priv->entry_user_password), FALSE); /* gtk_entry_set_invisible_char (GTK_ENTRY (priv->entry_user_password), '*'); */ caption = create_captioned (self, title_sizegroup, value_sizegroup, - _("mail_fi_password"), priv->entry_user_password); + _("mail_fi_password"), FALSE, priv->entry_user_password); gtk_widget_show (priv->entry_user_password); connect_for_modified (self, priv->entry_user_password); gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF); @@ -628,7 +600,7 @@ create_page_user_details (ModestDefaultAccountSettingsDialog *self) /* Auto-capitalization is the default, so let's turn it off: */ hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_email), HILDON_GTK_INPUT_MODE_FULL); caption = create_captioned (self, title_sizegroup, value_sizegroup, - _("mcen_li_emailsetup_email_address"), priv->entry_user_email); + _("mcen_li_emailsetup_email_address"), FALSE, priv->entry_user_email); gtk_entry_set_text (GTK_ENTRY (priv->entry_user_email), MODEST_EXAMPLE_EMAIL_ADDRESS); /* Default text. */ gtk_widget_show (priv->entry_user_email); connect_for_modified (self, priv->entry_user_email); @@ -643,13 +615,13 @@ create_page_user_details (ModestDefaultAccountSettingsDialog *self) /* Delete button: */ if (!priv->button_delete) - priv->button_delete = gtk_button_new_with_label (_("mcen_bd_delete")); + priv->button_delete = gtk_button_new_with_label (_HL("wdgt_bd_delete")); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (self)->action_area), priv->button_delete, FALSE, FALSE, 0); /* Signature button: */ if (!priv->button_signature) - priv->button_signature = gtk_button_new_with_label (_("mcen_fi_email_signature")); + priv->button_signature = gtk_button_new_with_label (_("mcen_bd_email_signature")); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (self)->action_area), priv->button_signature, FALSE, FALSE, 0); gtk_widget_show (priv->button_signature); @@ -677,7 +649,6 @@ update_incoming_server_title (ModestDefaultAccountSettingsDialog *self, ModestProtocol *protocol; const gchar *protocol_display_name; gchar* incomingserver_title; - gchar *with_asterisk; ModestDefaultAccountSettingsDialogPrivate *priv; priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self); @@ -685,16 +656,11 @@ update_incoming_server_title (ModestDefaultAccountSettingsDialog *self, protocol_registry = modest_runtime_get_protocol_registry (); protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, protocol_type); protocol_display_name = modest_protocol_get_display_name (protocol); - incomingserver_title = g_strdup_printf(_("mcen_li_emailsetup_servertype"), - protocol_display_name); + incomingserver_title = g_strconcat(_("mcen_li_emailsetup_servertype"), "*", + "\n(", protocol_display_name, ")", NULL); - /* This is a mandatory field, so add a *. This is usually done by - * create_caption_new_with_asterisk() but we can't use that here. */ - with_asterisk = g_strconcat (incomingserver_title, "*", NULL); + modest_maemo_utils_captioned_set_label (priv->caption_incoming, incomingserver_title, TRUE); g_free (incomingserver_title); - - g_object_set (G_OBJECT (priv->caption_incoming), "label", with_asterisk, NULL); - g_free (with_asterisk); } static GtkWidget* @@ -727,7 +693,7 @@ create_page_incoming (ModestDefaultAccountSettingsDialog *self) * so this default text will never be seen: */ /* (Note: Changing the title seems pointless. murrayc) */ priv->caption_incoming = create_captioned (self, title_sizegroup, value_sizegroup, - "Incoming Server", priv->entry_incomingserver); + "Incoming Server", FALSE, priv->entry_incomingserver); gtk_widget_show (priv->entry_incomingserver); connect_for_modified (self, priv->entry_incomingserver); gtk_box_pack_start (GTK_BOX (box), priv->caption_incoming, FALSE, FALSE, MODEST_MARGIN_HALF); @@ -766,7 +732,7 @@ enable_widget_for_checkbutton (GtkWidget *widget, GtkButton* button) { g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (on_check_button_clicked), widget); - + /* Set the starting sensitivity: */ on_check_button_clicked (button, widget); } @@ -784,10 +750,9 @@ on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data) smtp_win = modest_connection_specific_smtp_window_new (); modest_connection_specific_smtp_window_fill_with_connections (smtp_win, priv->account_manager); - /* Show the window: */ + /* Show the window: */ modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (smtp_win), GTK_WINDOW (self)); gtk_widget_show (GTK_WIDGET (smtp_win)); - priv->modified = TRUE; } static void @@ -805,24 +770,27 @@ static GtkWidget* create_page_outgoing (ModestDefaultAccountSettingsDialog *self) { ModestDefaultAccountSettingsDialogPrivate *priv; + gchar *smtp_caption_label; GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE); priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self); - + /* Create a size group to be used by all captions. * Note that HildonCaption does not create a default size group if we do not specify one. * We use GTK_SIZE_GROUP_HORIZONTAL, so that the widths are the same. */ GtkSizeGroup *title_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); GtkSizeGroup *value_sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); - + /* The outgoing server widgets: */ if (!priv->entry_outgoingserver) priv->entry_outgoingserver = hildon_entry_new (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH); /* Auto-capitalization is the default, so let's turn it off: */ hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_outgoingserver), HILDON_GTK_INPUT_MODE_FULL); + smtp_caption_label = g_strconcat (_("mcen_li_emailsetup_smtp"), "\n(SMTP)", NULL); GtkWidget *caption = create_captioned (self, title_sizegroup, value_sizegroup, - _("mcen_li_emailsetup_smtp"), priv->entry_outgoingserver); + smtp_caption_label, TRUE, priv->entry_outgoingserver); + g_free (smtp_caption_label); gtk_widget_show (priv->entry_outgoingserver); connect_for_modified (self, priv->entry_outgoingserver); gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF); @@ -841,7 +809,7 @@ create_page_outgoing (ModestDefaultAccountSettingsDialog *self) GtkWidget *separator = gtk_hseparator_new (); gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, MODEST_MARGIN_HALF); gtk_widget_show (separator); - + /* connection-specific checkbox: */ if (!priv->checkbox_outgoing_smtp_specific) { priv->checkbox_outgoing_smtp_specific = hildon_check_button_new (MODEST_EDITABLE_SIZE); @@ -855,27 +823,27 @@ create_page_outgoing (ModestDefaultAccountSettingsDialog *self) gtk_box_pack_start (GTK_BOX (box), priv->checkbox_outgoing_smtp_specific, FALSE, FALSE, MODEST_MARGIN_HALF); connect_for_modified (self, priv->checkbox_outgoing_smtp_specific); - + /* Connection-specific SMTP-Severs Edit button: */ if (!priv->button_outgoing_smtp_servers) - priv->button_outgoing_smtp_servers = gtk_button_new_with_label (_("mcen_fi_advsetup_optional_smtp")); + priv->button_outgoing_smtp_servers = gtk_button_new_with_label (_("mcen_bd_advsetup_optional_smtp")); hildon_gtk_widget_set_theme_size (priv->button_outgoing_smtp_servers, HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH); gtk_widget_show (priv->button_outgoing_smtp_servers); gtk_box_pack_start (GTK_BOX (box), priv->button_outgoing_smtp_servers, FALSE, FALSE, MODEST_MARGIN_HALF); - + /* Only enable the button when the checkbox is checked: */ enable_widget_for_checkbutton (priv->button_outgoing_smtp_servers, GTK_BUTTON (priv->checkbox_outgoing_smtp_specific)); g_object_unref (title_sizegroup); g_object_unref (value_sizegroup); - + g_signal_connect (G_OBJECT (priv->button_outgoing_smtp_servers), "clicked", G_CALLBACK (on_button_outgoing_smtp_servers), self); - + gtk_widget_show (GTK_WIDGET (box)); - + return GTK_WIDGET (box); } @@ -961,11 +929,31 @@ check_data (ModestDefaultAccountSettingsDialog *self) gtk_editable_select_region (GTK_EDITABLE (priv->entry_outgoingserver), 0, -1); return FALSE; } - + return TRUE; } -static void +static gboolean +on_delete_event (GtkWidget *widget, + GdkEvent *event, + gpointer user_data) +{ + ModestDefaultAccountSettingsDialog *self = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data); + ModestDefaultAccountSettingsDialogPrivate *priv; + ModestSecurityOptionsView *incoming_sec, *outgoing_sec; + + priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self); + + /* Check if security widgets changed */ + incoming_sec = MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security); + outgoing_sec = MODEST_SECURITY_OPTIONS_VIEW (priv->outgoing_security); + + return modest_security_options_view_changed (incoming_sec, priv->settings) || + modest_security_options_view_changed (outgoing_sec, priv->settings) || + priv->modified; +} + +static void on_response (GtkDialog *wizard_dialog, gint response_id, gpointer user_data) @@ -986,14 +974,15 @@ on_response (GtkDialog *wizard_dialog, modest_security_options_view_changed (outgoing_sec, priv->settings); /* Warn about unsaved changes: */ - if (response_id == GTK_RESPONSE_CANCEL && (priv->modified || sec_changed)) { + if ((response_id == GTK_RESPONSE_CANCEL || response_id == GTK_RESPONSE_DELETE_EVENT) && + (priv->modified || sec_changed)) { GtkDialog *dialog = GTK_DIALOG (hildon_note_new_confirmation (GTK_WINDOW (self), _("imum_nc_wizard_confirm_lose_changes"))); /* TODO: These button names will be ambiguous, and not specified in the UI specification. */ - + const gint dialog_response = gtk_dialog_run (dialog); gtk_widget_destroy (GTK_WIDGET (dialog)); - + if (dialog_response != GTK_RESPONSE_OK) prevent_response = TRUE; } @@ -1001,16 +990,16 @@ on_response (GtkDialog *wizard_dialog, else if (response_id != GTK_RESPONSE_CANCEL && !check_data (self)) { prevent_response = TRUE; } - + if (prevent_response) { /* This is a nasty hack. murrayc. */ /* Don't let the dialog close */ g_signal_stop_emission_by_name (wizard_dialog, "response"); - return; + return; } else { modest_tny_account_store_set_send_mail_blocked (modest_runtime_get_account_store (), FALSE); } - + if (response_id == GTK_RESPONSE_OK) { /* Try to save the changes if modified (NB #59251): */ if (priv->modified || sec_changed) { @@ -1030,7 +1019,7 @@ on_response (GtkDialog *wizard_dialog, transport_settings = modest_account_settings_get_transport_settings (priv->settings); store_account_name = modest_server_account_settings_get_account_name (store_settings); transport_account_name = modest_server_account_settings_get_account_name (transport_settings); - + if (store_account_name) { modest_account_mgr_notify_account_update (priv->account_manager, store_account_name); @@ -1041,7 +1030,7 @@ on_response (GtkDialog *wizard_dialog, } g_object_unref (store_settings); g_object_unref (transport_settings); - + modest_platform_information_banner(NULL, NULL, _("mcen_ib_advsetup_settings_saved")); } } else { @@ -1118,15 +1107,11 @@ modest_default_account_settings_dialog_init (ModestDefaultAccountSettingsDialog gtk_dialog_add_button (GTK_DIALOG(self), _HL("wdgt_bd_save"), GTK_RESPONSE_OK); gtk_window_set_default_size (GTK_WINDOW (self), -1, 340); - - /* Connect to the dialog's response signal: */ - /* We use connect-before - * so we can stop the signal emission, - * to stop the default signal handler from closing the dialog. - */ - g_signal_connect (G_OBJECT (self), "response", - G_CALLBACK (on_response), self); - + + /* Connect to the dialog's "response" and "delete-event" signals */ + g_signal_connect (G_OBJECT (self), "response", G_CALLBACK (on_response), self); + g_signal_connect (G_OBJECT (self), "delete-event", G_CALLBACK (on_delete_event), self); + priv->modified = FALSE; /* When this window is shown, hibernation should not be possible, @@ -1138,8 +1123,6 @@ modest_default_account_settings_dialog_init (ModestDefaultAccountSettingsDialog * while sending messages causes an error dialog and we have a lock */ modest_tny_account_store_set_send_mail_blocked (modest_runtime_get_account_store (), TRUE); - hildon_help_dialog_help_enable (GTK_DIALOG(self), "applications_email_accountsettings", - modest_maemo_utils_get_osso_context()); } ModestAccountSettingsDialog*