#include <gtk/gtkcheckbutton.h>
#include <gtk/gtkmessagedialog.h>
#include <gtk/gtkseparator.h>
-#include <hildon-widgets/hildon-caption.h>
#include "maemo/easysetup/modest-easysetup-country-combo-box.h"
#include "maemo/easysetup/modest-easysetup-provider-combo-box.h"
#include "maemo/easysetup/modest-easysetup-servertype-combo-box.h"
#include "modest-runtime.h" /* For modest_runtime_get_account_mgr(). */
#include "maemo/modest-connection-specific-smtp-window.h"
#include "maemo/modest-maemo-ui-constants.h"
+#include "maemo/modest-account-settings-dialog.h"
#include <gconf/gconf-client.h>
#include <string.h> /* For strlen(). */
if (self->specific_window)
gtk_widget_destroy (self->specific_window);
+
+ g_free (self->saved_account_name);
G_OBJECT_CLASS (modest_easysetup_wizard_dialog_parent_class)->finalize (object);
}
show_error (GtkWindow *parent_window, const gchar* text);
static gboolean
-create_account (ModestEasysetupWizardDialog *self);
+create_account (ModestEasysetupWizardDialog *self, gboolean enabled);
static void
create_subsequent_easysetup_pages (ModestEasysetupWizardDialog *self);
static GtkWidget*
create_page_welcome (ModestEasysetupWizardDialog *self)
{
- GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_HALF);
+ GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
GtkWidget *label = gtk_label_new(_("mcen_ia_emailsetup_intro"));
gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
gtk_widget_show (label);
static GtkWidget*
create_page_account_details (ModestEasysetupWizardDialog *self)
{
- GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_HALF);
+ GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
GtkWidget *label = gtk_label_new(_("mcen_ia_accountdetails"));
gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, MODEST_MARGIN_HALF);
gtk_widget_show (label);
/* The description widgets: */
self->entry_account_title = GTK_WIDGET (modest_validating_entry_new ());
+ /* 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);
/* Set a default account title, choosing one that does not already exist: */
/* Note that this is irrelevant to the non-user visible name, which we will create later. */
static GtkWidget*
create_page_user_details (ModestEasysetupWizardDialog *self)
{
- GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_HALF);
+ GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
/* 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.
static GtkWidget* create_page_complete_easysetup (ModestEasysetupWizardDialog *self)
{
- GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_HALF);
+ GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
GtkWidget *label = gtk_label_new(_("mcen_ia_emailsetup_setup_complete"));
gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
gtk_widget_show (label);
static GtkWidget* create_page_custom_incoming (ModestEasysetupWizardDialog *self)
{
- GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_HALF);
+ GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
/* 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.
if(!self->checkbox_incoming_auth)
self->checkbox_incoming_auth = gtk_check_button_new ();
caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_authentication"),
- self->combo_incoming_security, NULL, HILDON_CAPTION_OPTIONAL);
+ self->checkbox_incoming_auth, NULL, HILDON_CAPTION_OPTIONAL);
gtk_widget_show (self->checkbox_incoming_auth);
gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
gtk_widget_show (caption);
static GtkWidget* create_page_custom_outgoing (ModestEasysetupWizardDialog *self)
{
- GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_HALF);
+ GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
/* 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.
gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
gtk_widget_show (caption);
+ 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 (!self->checkbox_outgoing_smtp_specific) {
self->checkbox_outgoing_smtp_specific = gtk_check_button_new ();
gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
gtk_widget_show (caption);
- GtkWidget *separator = gtk_hseparator_new ();
- gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, MODEST_MARGIN_HALF);
- gtk_widget_show (separator);
-
/* Connection-specific SMTP-Severs Edit button: */
if (!self->button_outgoing_smtp_servers)
self->button_outgoing_smtp_servers = gtk_button_new_with_label (_("mcen_bd_edit"));
return GTK_WIDGET (box);
}
+static gboolean
+on_timeout_show_advanced_edit(gpointer user_data)
+{
+ ModestEasysetupWizardDialog * self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
+
+ if (!(self->saved_account_name))
+ return FALSE;
+
+ /* Show the Account Settings window: */
+ ModestAccountSettingsDialog *dialog = modest_account_settings_dialog_new ();
+ modest_account_settings_dialog_set_account_name (dialog, self->saved_account_name);
+
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (self));
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+
+ /* TODO: The hide() is not necessary.
+ * It is just here to show that it doesn't work,
+ * just as destroy doesn't work.
+ */
+ gtk_widget_hide (GTK_WIDGET(dialog));
+
+ /* TODO: The dialog remains on screen, not allowing any interaction.
+ * But gtk_widget_destroy() should always destroy.
+ */
+ printf("debug: destroying settings dialog\n");
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ printf("debug: after destroying settings dialog (doesn't seem to work).\n");
+
+ return FALSE; /* Do not call this timeout callback again. */
+}
+
+static void
+on_button_edit_advanced_settings (GtkButton *button, gpointer user_data)
+{
+ ModestEasysetupWizardDialog * self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
+
+ /* Save the new account, so we can edit it with ModestAccountSettingsDialog,
+ * without recoding it to use non-gconf information.
+ * This account will be deleted if Finish is never actually clicked. */
+
+ gboolean saved = TRUE;
+ gboolean was_already_saved = TRUE;
+ if (!(self->saved_account_name)) {
+ saved = create_account (self, FALSE);
+ was_already_saved = FALSE;
+ }
+
+ if (!saved)
+ return;
+
+ if (!(self->saved_account_name))
+ return;
+
+ /* Show the Account Settings window: */
+ if (was_already_saved) {
+ /* Just show the dialog immediately: */
+ on_timeout_show_advanced_edit(self);
+ }
+ else
+ {
+ printf ("debug: waiting for gconf to update its local cache. "
+ "This is a hack to work around a maemo gconf bug in maemo bora.\n");
+
+ g_timeout_add (5000, on_timeout_show_advanced_edit, self);
+ }
+}
static GtkWidget* create_page_complete_custom (ModestEasysetupWizardDialog *self)
{
- GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_HALF);
+ GtkWidget *box = gtk_vbox_new (FALSE, MODEST_MARGIN_NONE);
GtkWidget *label = gtk_label_new(_("mcen_ia_emailsetup_setup_complete"));
gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
gtk_widget_show (label);
gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
gtk_widget_show (caption);
+ g_signal_connect (G_OBJECT (self->button_edit), "clicked",
+ G_CALLBACK (on_button_edit_advanced_settings), self);
+
gtk_widget_show (GTK_WIDGET (box));
return GTK_WIDGET (box);
}
gpointer user_data)
{
ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (wizard_dialog);
+
+ if (response_id == GTK_RESPONSE_CANCEL) {
+ /* Remove any temporarily-saved account that will not actually be needed: */
+ if (self->saved_account_name) {
+ modest_account_mgr_remove_account (self->account_manager,
+ self->saved_account_name, FALSE);
+ }
+ }
+
invoke_enable_buttons_vfunc (self);
}
*/
if(!next_page) /* This is NULL when this is a click on Finish. */
{
- create_account (account_wizard);
+ if (account_wizard->saved_account_name) {
+ /* Just enable the already-saved account (temporarily created when
+ * editing advanced settings): */
+ modest_account_mgr_set_enabled (account_wizard->account_manager,
+ account_wizard->saved_account_name, TRUE);
+ } else {
+ create_account (account_wizard, TRUE /* enabled */);
+ }
}
enable_next = FALSE;
}
- /* Enable the buttons,
- * identifying them via their associated response codes:
- */
- GtkDialog *dialog_base = GTK_DIALOG (dialog);
- gtk_dialog_set_response_sensitive (dialog_base,
- MODEST_WIZARD_DIALOG_NEXT,
- enable_next);
-
+ /* Enable the buttons,
+ * identifying them via their associated response codes: */
+
/* Disable the Finish button until we are on the last page,
* because HildonWizardDialog enables this for all but the first page: */
GtkNotebook *notebook = NULL;
+ GtkDialog *dialog_base = GTK_DIALOG (dialog);
g_object_get (dialog_base, "wizard-notebook", ¬ebook, NULL);
gint current = gtk_notebook_get_current_page (notebook);
gint last = gtk_notebook_get_n_pages (notebook) - 1;
- gboolean is_last = (current == last);
+ const gboolean is_last = (current == last);
if(!is_last) {
gtk_dialog_set_response_sensitive (dialog_base,
MODEST_WIZARD_DIALOG_FINISH,
FALSE);
+ } else
+ {
+ /* Disable Next on the last page: */
+ enable_next = FALSE;
}
+
+ gtk_dialog_set_response_sensitive (dialog_base,
+ MODEST_WIZARD_DIALOG_NEXT,
+ enable_next);
}
static void
static void
show_error (GtkWindow *parent_window, const gchar* text)
{
+ GtkDialog *dialog = GTK_DIALOG (hildon_note_new_information (parent_window, text));
+ /*
GtkDialog *dialog = GTK_DIALOG (gtk_message_dialog_new (parent_window,
(GtkDialogFlags)0,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
text ));
+ */
- gtk_dialog_run (dialog);
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_dialog_run (dialog);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
}
/** Attempt to create the account from the information that the user has entered.
* @result: TRUE if the account was successfully created.
*/
gboolean
-create_account (ModestEasysetupWizardDialog *self)
+create_account (ModestEasysetupWizardDialog *self, gboolean enabled)
{
ModestEasysetupWizardDialogPrivate *priv = WIZARD_DIALOG_GET_PRIVATE (self);
/* Sanity check: */
/* There must be at least one account now: */
- GSList *account_names = modest_account_mgr_account_names (self->account_manager);
+ /* Note, when this fails is is caused by a Maemo gconf bug that has been
+ * fixed in versions after 3.1. */
+ GSList *account_names = modest_account_mgr_account_names (self->account_manager, FALSE);
if(!account_names)
{
g_warning ("modest_account_mgr_account_names() returned NULL after adding an account.");
/* Create the account, which will contain the two "server accounts": */
created = modest_account_mgr_add_account (self->account_manager, account_name,
store_name, /* The name of our POP/IMAP server account. */
- transport_name /* The name of our SMTP server account. */);
+ transport_name, /* The name of our SMTP server account. */
+ enabled);
g_free (store_name);
g_free (transport_name);
MODEST_ACCOUNT_DISPLAY_NAME, display_name, FALSE /* not server account */);
/* Save the connection-specific SMTP server accounts. */
+ gboolean result = TRUE;
if (self->specific_window)
- return modest_connection_specific_smtp_window_save_server_accounts (
+ result = modest_connection_specific_smtp_window_save_server_accounts (
MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (self->specific_window), account_name);
+ g_free (self->saved_account_name);
+ self->saved_account_name = g_strdup (account_name);
+
g_free (account_name);
- return FALSE;
+ return result;
}