* Fixes NB#99573, delete the account even though the account name was removed previously
[modest] / src / hildon2 / modest-default-account-settings-dialog.c
index a8a1a09..5ace93e 100644 (file)
@@ -212,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);
 }
@@ -232,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);
@@ -262,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:
@@ -338,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);
@@ -495,7 +496,10 @@ on_button_delete (GtkButton *button, gpointer user_data)
        self = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data);
        priv = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG_GET_PRIVATE (self);
 
-       account_title = get_entered_account_title (self);
+       if (priv->modified)
+               account_title = g_strdup (priv->original_account_title);
+       else
+               account_title = get_entered_account_title (self);
 
        removed = modest_ui_actions_on_delete_account (GTK_WINDOW (self),
                                                       priv->account_name, 
@@ -533,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);
@@ -556,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);
@@ -585,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);
@@ -596,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);
@@ -645,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);
@@ -653,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<small>(", protocol_display_name, ")</small>", 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* 
@@ -695,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);
@@ -773,6 +771,7 @@ 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);
@@ -789,8 +788,10 @@ create_page_outgoing (ModestDefaultAccountSettingsDialog *self)
                        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<small>(SMTP)</small>", 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);