2007-06-03 Christian Kellner <ckellner@openismus.com>
[modest] / src / maemo / modest-account-settings-dialog.c
index c5ad061..50d747b 100644 (file)
@@ -205,19 +205,18 @@ on_caption_combobox_changed (GtkComboBox *widget, gpointer user_data)
 /** This is a convenience function to create a caption containing a mandatory widget.
  * When the widget is edited, the enable_buttons() vfunc will be called.
  */
-static GtkWidget* create_caption_new_with_asterix(ModestAccountSettingsDialog *self,
+static GtkWidget* create_caption_new_with_asterisk(ModestAccountSettingsDialog *self,
        GtkSizeGroup *group,
        const gchar *value,
        GtkWidget *control,
        GtkWidget *icon,
        HildonCaptionStatus flag)
 {
-  GtkWidget *caption = hildon_caption_new (group, value, control, icon, flag);
+       GtkWidget *caption = NULL;
   
-/* The translated strings seem to already contain the *,
- * but this code can be used if that is not true in future.
- */
-#if 0
+       /* Note: Previously, the translated strings already contained the "*",
+        * Comment out this code if they do again.
+        */
        /* Add a * character to indicate mandatory fields,
         * as specified in our "Email UI Specification": */
        if (flag == HILDON_CAPTION_MANDATORY) {
@@ -227,7 +226,6 @@ static GtkWidget* create_caption_new_with_asterix(ModestAccountSettingsDialog *s
        }       
        else
                caption = hildon_caption_new (group, value, control, icon, flag);
-#endif
 
        /* Connect to the appropriate changed signal for the widget, 
         * so we can ask for the prev/next buttons to be enabled/disabled appropriately:
@@ -271,7 +269,7 @@ create_page_account_details (ModestAccountSettingsDialog *self)
        /* Do use auto-capitalization: */
        hildon_gtk_entry_set_input_mode (GTK_ENTRY (self->entry_account_title), 
                HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_AUTOCAP);
-       GtkWidget *caption = create_caption_new_with_asterix (self, sizegroup, _("mcen_fi_account_title"), 
+       GtkWidget *caption = create_caption_new_with_asterisk (self, sizegroup, _("mcen_fi_account_title"), 
                self->entry_account_title, NULL, HILDON_CAPTION_MANDATORY);
        gtk_widget_show (self->entry_account_title);
        connect_for_modified (self, self->entry_account_title);
@@ -304,7 +302,7 @@ create_page_account_details (ModestAccountSettingsDialog *self)
        
        /* The retrieve combobox: */
        self->combo_retrieve = GTK_WIDGET (modest_retrieve_combo_box_new ());
-       caption = create_caption_new_with_asterix (self, sizegroup, _("mcen_fi_advsetup_retrievetype"), 
+       caption = create_caption_new_with_asterisk (self, sizegroup, _("mcen_fi_advsetup_retrievetype"), 
                self->combo_retrieve, NULL, HILDON_CAPTION_MANDATORY);
        gtk_widget_show (self->combo_retrieve);
        connect_for_modified (self, self->combo_retrieve);
@@ -313,7 +311,7 @@ create_page_account_details (ModestAccountSettingsDialog *self)
        
        /* The limit-retrieve combobox: */
        self->combo_limit_retrieve = GTK_WIDGET (modest_limit_retrieve_combo_box_new ());
-       caption = create_caption_new_with_asterix (self, sizegroup, _("mcen_fi_advsetup_limit_retrieve"), 
+       caption = create_caption_new_with_asterisk (self, sizegroup, _("mcen_fi_advsetup_limit_retrieve"), 
                self->combo_limit_retrieve, NULL, HILDON_CAPTION_MANDATORY);
        gtk_widget_show (self->combo_limit_retrieve);
        connect_for_modified (self, self->combo_limit_retrieve);
@@ -324,7 +322,7 @@ create_page_account_details (ModestAccountSettingsDialog *self)
        if(!self->checkbox_leave_messages)
                self->checkbox_leave_messages = gtk_check_button_new ();
        if (!self->caption_leave_messages) {
-               self->caption_leave_messages = create_caption_new_with_asterix (self, sizegroup, _("mcen_fi_advsetup_leave_on_server"), 
+               self->caption_leave_messages = create_caption_new_with_asterisk (self, sizegroup, _("mcen_fi_advsetup_leave_on_server"), 
                        self->checkbox_leave_messages, NULL, HILDON_CAPTION_MANDATORY);
        }
                        
@@ -393,7 +391,7 @@ create_page_user_details (ModestAccountSettingsDialog *self)
        gtk_entry_set_max_length (GTK_ENTRY (self->entry_user_name), 64);
        modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (self->entry_user_name), 
                on_entry_max, self);
-       GtkWidget *caption = create_caption_new_with_asterix (self, sizegroup, 
+       GtkWidget *caption = create_caption_new_with_asterisk (self, sizegroup, 
                _("mcen_li_emailsetup_name"), self->entry_user_name, NULL, HILDON_CAPTION_OPTIONAL);
        gtk_widget_show (self->entry_user_name);
        connect_for_modified (self, self->entry_user_name);
@@ -413,7 +411,7 @@ create_page_user_details (ModestAccountSettingsDialog *self)
        self->entry_user_username = GTK_WIDGET (modest_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"), 
+       caption = create_caption_new_with_asterisk (self, sizegroup, _("mail_fi_username"), 
                self->entry_user_username, NULL, HILDON_CAPTION_MANDATORY);
        gtk_widget_show (self->entry_user_username);
        connect_for_modified (self, self->entry_user_username);
@@ -438,7 +436,7 @@ create_page_user_details (ModestAccountSettingsDialog *self)
                HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
        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, 
+       caption = create_caption_new_with_asterisk (self, sizegroup, 
                _("mail_fi_password"), self->entry_user_password, NULL, HILDON_CAPTION_OPTIONAL);
        gtk_widget_show (self->entry_user_password);
        connect_for_modified (self, self->entry_user_password);
@@ -449,7 +447,7 @@ create_page_user_details (ModestAccountSettingsDialog *self)
        self->entry_user_email = GTK_WIDGET (modest_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, 
+       caption = create_caption_new_with_asterisk (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. */
        gtk_widget_show (self->entry_user_email);
@@ -496,8 +494,14 @@ static void update_incoming_server_title (ModestAccountSettingsDialog *self, Mod
         * because the compiler does not know that the translated string will have a %s in it.
         * I do not see a way to avoid the warning while still using these Logical IDs. murrayc. */
        gchar* incomingserver_title = g_strdup_printf(_("mcen_li_emailsetup_servertype"), type);
-       g_object_set (G_OBJECT (self->caption_incoming), "label", incomingserver_title, NULL);
-       g_free(incomingserver_title);
+       
+       /* 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. */
+       gchar *with_asterisk = g_strconcat (incomingserver_title, "*", NULL);
+       g_free (incomingserver_title);
+       
+       g_object_set (G_OBJECT (self->caption_incoming), "label", with_asterisk, NULL);
+       g_free(with_asterisk);
 }
 
 /** Change the caption title for the incoming server, 
@@ -532,7 +536,7 @@ static GtkWidget* create_page_incoming (ModestAccountSettingsDialog *self)
        /* The caption title will be updated in update_incoming_server_title().
         * so this default text will never be seen: */
        /* (Note: Changing the title seems pointless. murrayc) */
-       self->caption_incoming = create_caption_new_with_asterix (self, sizegroup, 
+       self->caption_incoming = create_caption_new_with_asterisk (self, sizegroup, 
                "Incoming Server", self->entry_incomingserver, NULL, HILDON_CAPTION_MANDATORY);
        gtk_widget_show (self->entry_incomingserver);
        connect_for_modified (self, self->entry_incomingserver);
@@ -680,7 +684,7 @@ static GtkWidget* create_page_outgoing (ModestAccountSettingsDialog *self)
                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, 
+       GtkWidget *caption = create_caption_new_with_asterisk (self, sizegroup, 
                _("mcen_li_emailsetup_smtp"), self->entry_outgoingserver, NULL, HILDON_CAPTION_OPTIONAL);
        gtk_widget_show (self->entry_outgoingserver);
        connect_for_modified (self, self->entry_outgoingserver);
@@ -704,7 +708,7 @@ static GtkWidget* create_page_outgoing (ModestAccountSettingsDialog *self)
        self->entry_outgoing_username = GTK_WIDGET (modest_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->caption_outgoing_username = create_caption_new_with_asterisk (self, sizegroup, _("mail_fi_username"), 
                self->entry_outgoing_username, NULL, HILDON_CAPTION_MANDATORY);
        gtk_widget_show (self->entry_outgoing_username);
        connect_for_modified (self, self->entry_outgoing_username);
@@ -729,7 +733,7 @@ static GtkWidget* create_page_outgoing (ModestAccountSettingsDialog *self)
                HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
        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, 
+       self->caption_outgoing_password = create_caption_new_with_asterisk (self, sizegroup, 
                _("mail_fi_password"), self->entry_outgoing_password, NULL, HILDON_CAPTION_OPTIONAL);
        gtk_widget_show (self->entry_outgoing_password);
        connect_for_modified (self, self->entry_outgoing_password);
@@ -904,9 +908,6 @@ modest_account_settings_dialog_init (ModestAccountSettingsDialog *self)
         * Each page of the notebook will be a page of the wizard: */
        GtkNotebook *notebook = GTK_NOTEBOOK (gtk_notebook_new());
 
-    
-    gtk_window_set_title (GTK_WINDOW (self), _("mcen_ti_emailsetup"));
-       
        /* Get the account manager object, 
         * so we can check for existing accounts,
         * and create new accounts: */
@@ -1134,7 +1135,21 @@ void modest_account_settings_dialog_set_account_name (ModestAccountSettingsDialo
                        GTK_TOGGLE_BUTTON (dialog->checkbox_outgoing_smtp_specific), 
                        has_specific);
        }
-       
+
+       /* Set window title according to account: */
+       /* TODO: Is this the correct way to find a human-readable name for
+        * the protocol used? */
+       const gchar* proto_str = modest_protocol_info_get_transport_store_protocol_name (dialog->incoming_protocol);
+       gchar *proto_name = g_utf8_strup(proto_str, -1);
+       gchar *account_title = modest_account_mgr_get_display_name(dialog->account_manager, account_name);
+
+       gchar *title = g_strdup_printf(_("mcen_ti_account_settings"), proto_name, account_title);
+       g_free (proto_name);
+       g_free (account_title);
+
+       gtk_window_set_title (GTK_WINDOW (dialog), title);
+       g_free (title);
+
        /* account_data->is_enabled,  */
        /*account_data->is_default,  */