* make sure only one ModestEasySetupWizardDialog instance can be alive at any time,
letting modest-easysetup-wizard.c keep track of that
* if the we're asked for a new instance, present the old one instead
Fixes: NB#66408, and all other cases where this could happen.
pmo-trunk-r3061
const gboolean created = modest_run_account_setup_wizard (NULL);
printf ("DEBUG1: %s\n", __FUNCTION__);
if (!created) {
- g_debug ("modest: %s: No account exists even after offering.\n", __FUNCTION__);
+ g_debug ("modest: %s: no account exists even after offering, "
+ "or account setup was already underway.\n", __FUNCTION__);
result = FALSE;
}
}
typedef struct _ModestEasysetupWizardDialogPrivate ModestEasysetupWizardDialogPrivate;
+/* global to make sure there is only one of this
+ * dialog at any time
+ */
+static ModestEasysetupWizardDialog *_instance = NULL;
+
typedef enum {
MODEST_EASYSETUP_WIZARD_DIALOG_INCOMING_CHANGED = 0x01,
MODEST_EASYSETUP_WIZARD_DIALOG_OUTGOING_CHANGED = 0x02
g_free (self->saved_account_name);
G_OBJECT_CLASS (modest_easysetup_wizard_dialog_parent_class)->finalize (object);
+
+ _instance = NULL;
}
static void
}
ModestEasysetupWizardDialog*
-modest_easysetup_wizard_dialog_new (void)
-{
- return g_object_new (MODEST_TYPE_EASYSETUP_WIZARD_DIALOG, NULL);
+modest_easysetup_wizard_dialog_new_or_present (void)
+{
+ if (_instance) {
+ g_message ("%s: already instantiated; presenting\n",
+ __FUNCTION__);
+ gtk_window_present (GTK_WINDOW(_instance));
+ return NULL;
+ }
+
+ return _instance = g_object_new (MODEST_TYPE_EASYSETUP_WIZARD_DIALOG, NULL);
}
static void create_subsequent_customsetup_pages (ModestEasysetupWizardDialog *self)
GType modest_easysetup_wizard_dialog_get_type (void);
-ModestEasysetupWizardDialog* modest_easysetup_wizard_dialog_new (void);
+/*
+ * NOTE: can be instantiated only once; after that, this function will
+ * return NULL, until the one before is destroyed; if it returns NULL
+ * it will gtk_window_present the existing one.
+ */
+ModestEasysetupWizardDialog* modest_easysetup_wizard_dialog_new_or_present (void);
G_END_DECLS
/* Show the Account Settings window: */
ModestAccountSettingsDialog *dialog = modest_account_settings_dialog_new ();
+
modest_account_settings_dialog_set_account_name (dialog, account_name);
-
modest_maemo_show_dialog_and_forget (GTK_WINDOW (self), GTK_DIALOG (dialog));
}
gtk_window_present (GTK_WINDOW (priv->wizard));
} else {
/* Create and show the dialog: */
- priv->wizard = modest_easysetup_wizard_dialog_new ();
-
- gtk_window_set_transient_for (GTK_WINDOW (priv->wizard), GTK_WINDOW (self));
-
- /* Destroy the dialog when it is closed: */
- g_signal_connect (G_OBJECT (priv->wizard), "response", G_CALLBACK (on_wizard_response), self);
- gtk_widget_show (GTK_WIDGET (priv->wizard));
+ priv->wizard = modest_easysetup_wizard_dialog_new_or_present ();
+ if (priv->wizard) {
+ gtk_window_set_transient_for (GTK_WINDOW (priv->wizard), GTK_WINDOW (self));
+ /* Destroy the dialog when it is closed: */
+ g_signal_connect (G_OBJECT (priv->wizard), "response", G_CALLBACK (on_wizard_response), self);
+ gtk_widget_show (GTK_WIDGET (priv->wizard));
+ } else
+ /* in this case, the existing one will be topped */
+ g_message ("%s: easysetup dialog already exists; ignoring", __FUNCTION__);
}
}
goto cleanup;
}
- win = modest_main_window_new ();
-
+ /* this will create & register the window */
+ win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr());
if (!win) {
- g_printerr ("modest: failed to create main window\n");
+ g_printerr ("modest: failed to get main window instance\n");
retval = 1;
goto cleanup;
}
if (show_ui_without_top_application_method)
gtk_widget_show_all (GTK_WIDGET(win));
- modest_window_mgr_register_window (modest_runtime_get_window_mgr(),
- win);
- g_object_unref (win);
gtk_main ();
retval = 0;
g_return_val_if_fail (MODEST_IS_WINDOW(win), FALSE);
- wizard = modest_easysetup_wizard_dialog_new ();
+ wizard = modest_easysetup_wizard_dialog_new_or_present ();
+
+ /* if wizard == NULL it means there is already a easy setup thingy running;
+ * in that case, don't do anything here; the call above will present it instead */
+ if (!wizard) {
+ g_message ("%s: easysetup wizard already running", __FUNCTION__);
+ return FALSE;
+ }
+
gtk_window_set_transient_for (GTK_WINDOW (wizard), GTK_WINDOW (win));
-
+
/* Don't make this a modal window, because secondary windows will then
* be unusable, freezing the UI: */
/* gtk_window_set_modal (GTK_WINDOW (wizard), TRUE); */