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,
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_or_present (void)
+modest_easysetup_wizard_dialog_new (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);
+ return g_object_new (MODEST_TYPE_EASYSETUP_WIZARD_DIALOG, NULL);
}
static void create_subsequent_customsetup_pages (ModestEasysetupWizardDialog *self)
(G_TYPE_CHECK_CLASS_CAST ((klass), \
MODEST_TYPE_EASYSETUP_WIZARD_DIALOG, ModestEasysetupWizardDialogClass))
-#define ACCOUNT_IS_WIZARD_DIALOG(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- MODEST_TYPE_EASYSETUP_WIZARD_DIALOG))
+#define MODEST_IS_EASYSETUP_WIZARD_DIALOG(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ MODEST_TYPE_EASYSETUP_WIZARD_DIALOG))
#define MODEST_EASYSETUP_IS_WIZARD_DIALOG_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
* 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);
+ModestEasysetupWizardDialog* modest_easysetup_wizard_dialog_new (void);
G_END_DECLS
GtkWidget *delete_button;
GtkWidget *close_button;
ModestAccountView *account_view;
-
- /* We remember this so that we only open one at a time: */
- ModestEasysetupWizardDialog *wizard;
};
#define MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MODEST_TYPE_ACCOUNT_VIEW_WINDOW, \
static void
modest_account_view_window_finalize (GObject *obj)
{
- ModestAccountViewWindowPrivate *priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(obj);
-
- if (priv->wizard) {
- gtk_widget_destroy (GTK_WIDGET (priv->wizard));
- priv->wizard = NULL;
- }
-
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
static void
on_wizard_response (GtkDialog *dialog, gint response, gpointer user_data)
-{
- ModestAccountViewWindow *self = MODEST_ACCOUNT_VIEW_WINDOW (user_data);
- ModestAccountViewWindowPrivate *priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self);
-
+{
/* The response has already been handled by the wizard dialog itself,
* creating the new account.
*/
/* Destroy the dialog: */
- if (priv->wizard) {
- gtk_widget_destroy (GTK_WIDGET (priv->wizard));
- priv->wizard = NULL;
+ if (dialog) {
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ modest_window_mgr_set_easysetup_dialog (
+ modest_runtime_get_window_mgr(), NULL);
}
}
static void
on_new_button_clicked (GtkWidget *button, ModestAccountViewWindow *self)
{
- ModestAccountViewWindowPrivate *priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self);
-
- /* Show the easy-setup wizard: */
+ GtkDialog *wizard;
- if (priv->wizard) {
- /* Just show the existing window: */
- gtk_window_present (GTK_WINDOW (priv->wizard));
+ /* Show the easy-setup wizard: */
+ wizard = modest_window_mgr_get_easysetup_dialog
+ (modest_runtime_get_window_mgr());
+ if (wizard) {
+ /* old wizard is active already;
+ */
+ gtk_window_present (GTK_WINDOW(wizard));
+ return;
} else {
- /* Create and show the dialog: */
- 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__);
- }
+ /* there is no such wizard yet */
+ wizard = GTK_DIALOG(modest_easysetup_wizard_dialog_new ());
+ modest_window_mgr_set_easysetup_dialog
+ (modest_runtime_get_window_mgr(), GTK_DIALOG(wizard));
+ }
+
+ gtk_window_set_transient_for (GTK_WINDOW (wizard), GTK_WINDOW (self));
+ /* Destroy the dialog when it is closed: */
+ g_signal_connect (G_OBJECT (wizard), "response", G_CALLBACK
+ (on_wizard_response), self);
+ gtk_widget_show (GTK_WIDGET (wizard));
}
modest_run_account_setup_wizard (ModestWindow *win)
{
gboolean result = FALSE;
- ModestEasysetupWizardDialog *wizard;
+ GtkDialog *wizard;
- if (!win)
- win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr ());
-
- g_return_val_if_fail (MODEST_IS_WINDOW(win), FALSE);
+ wizard = modest_window_mgr_get_easysetup_dialog
+ (modest_runtime_get_window_mgr());
+ if (wizard) {
+ /* old wizard is active already; present it and
+ * act as if the user cancelled the non-existing
+ * new one
+ */
+ printf ("wizard already active\n");
+ return FALSE;
+ } else {
+ /* there is no such wizard yet */
+ wizard = GTK_DIALOG(modest_easysetup_wizard_dialog_new ());
+ modest_window_mgr_set_easysetup_dialog
+ (modest_runtime_get_window_mgr(), GTK_DIALOG(wizard));
+ }
+
- wizard = modest_easysetup_wizard_dialog_new_or_present ();
+ /* always present a main window in the background
+ * we do it here, so we cannot end up with to wizards (as this
+ * function might be called in modest_window_mgr_get_main_window as well */
+ if (!win)
+ win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr());
- /* 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;
- }
+ /* make sure the mainwindow is visible */
+ gtk_widget_show_all (GTK_WIDGET(win));
+ gtk_window_present (GTK_WINDOW(win));
+
gtk_window_set_transient_for (GTK_WINDOW (wizard), GTK_WINDOW (win));
/* Don't make this a modal window, because secondary windows will then
gtk_widget_destroy (GTK_WIDGET (wizard));
+ /* clear it from the window mgr */
+ modest_window_mgr_set_easysetup_dialog
+ (modest_runtime_get_window_mgr(), NULL);
+
return result;
}
typedef struct _ModestWindowMgrPrivate ModestWindowMgrPrivate;
struct _ModestWindowMgrPrivate {
GList *window_list;
+
ModestWindow *main_window;
+ GtkDialog *easysetup_dialog;
+
gboolean fullscreen_mode;
gboolean show_toolbars;
gboolean show_toolbars_fullscreen;
priv->window_list = NULL;
priv->main_window = NULL;
priv->fullscreen_mode = FALSE;
-
+ priv->easysetup_dialog = NULL;
+
priv->preregistered_uids = NULL;
/* Could not initialize it from gconf, singletons are not
priv->viewer_handlers = NULL;
}
+ if (priv->easysetup_dialog) {
+ g_warning ("%s: forgot to destroy an easysetup dialog somewhere",
+ __FUNCTION__);
+ gtk_widget_destroy (GTK_WIDGET(priv->easysetup_dialog));
+ priv->easysetup_dialog = NULL;
+ }
+
/* Do not unref priv->main_window because it does not hold a
new reference */
+
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
gint *handler_id;
g_return_if_fail (MODEST_IS_WINDOW_MGR (self));
- g_return_if_fail (MODEST_IS_WINDOW (window));
+ g_return_if_fail (GTK_IS_WINDOW (window));
priv = MODEST_WINDOW_MGR_GET_PRIVATE (self);
}
}
+
/* remove from the list of pre-registered uids */
if (MODEST_IS_MSG_VIEW_WINDOW(window)) {
const gchar *uid = modest_msg_view_window_get_message_uid
priv->main_window = NULL;
/* Disconnect all emissions of msg-changed */
- g_hash_table_foreach (priv->viewer_handlers,
- disconnect_msg_changed,
- NULL);
- g_hash_table_destroy (priv->viewer_handlers);
- priv->viewer_handlers = NULL;
+ if (priv->viewer_handlers) {
+ g_hash_table_foreach (priv->viewer_handlers,
+ disconnect_msg_changed,
+ NULL);
+ g_hash_table_destroy (priv->viewer_handlers);
+ priv->viewer_handlers = NULL;
+ }
}
/* Remove the viewer window handler from the hash table. The
return priv->main_window;
}
+
+GtkDialog*
+modest_window_mgr_get_easysetup_dialog (ModestWindowMgr *self)
+{
+ ModestWindowMgrPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_WINDOW_MGR (self), NULL);
+ priv = MODEST_WINDOW_MGR_GET_PRIVATE (self);
+
+ return priv->easysetup_dialog;
+}
+
+
+GtkDialog*
+modest_window_mgr_set_easysetup_dialog (ModestWindowMgr *self, GtkDialog *dialog)
+{
+ ModestWindowMgrPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_WINDOW_MGR (self), NULL);
+ priv = MODEST_WINDOW_MGR_GET_PRIVATE (self);
+
+ return priv->easysetup_dialog = dialog;
+}
+
+
static void
on_nonhibernating_window_hide(GtkWidget *widget, gpointer user_data)
{
G_CALLBACK (on_nonhibernating_window_hide), self);
}
-void modest_window_mgr_prevent_hibernation_while_window_is_shown (ModestWindowMgr *self,
+void
+modest_window_mgr_prevent_hibernation_while_window_is_shown (ModestWindowMgr *self,
GtkWindow *window)
{
g_return_if_fail (MODEST_IS_WINDOW_MGR (self));
}
}
-gboolean modest_window_mgr_get_hibernation_is_prevented (ModestWindowMgr *self)
+gboolean
+modest_window_mgr_get_hibernation_is_prevented (ModestWindowMgr *self)
{
g_return_val_if_fail (MODEST_IS_WINDOW_MGR (self), FALSE);
}
-void modest_window_mgr_save_state_for_all_windows (ModestWindowMgr *self)
+void
+modest_window_mgr_save_state_for_all_windows (ModestWindowMgr *self)
{
g_return_if_fail (MODEST_IS_WINDOW_MGR (self));
void modest_window_mgr_show_toolbars (ModestWindowMgr *self,
gboolean show_toolbars,
gboolean fullscreen);
-
+/**
+ * modest_window_mgr_get_main_window:
+ * @self: a #ModestWindowMgr
+ *
+ * get the main window, or create if it's not there. don't destroy
+ * it.
+ *
+ * Returns: the main window or NULL in case of error
+ **/
ModestWindow* modest_window_mgr_get_main_window (ModestWindowMgr *self);
+
+/**
+ * modest_window_mgr_get_easysetup_dialog:
+ * @self: a #ModestWindowMgr
+ *
+ * get the easysetup dialog; if it's NULL, there's no active dialog
+ *
+ * Returns: the easy setup dialog or NULL
+ **/
+GtkDialog* modest_window_mgr_get_easysetup_dialog (ModestWindowMgr *self);
+
+
+/**
+ * modest_window_mgr_get_easysetup_dialog:
+ * @self: a #ModestWindowMgr
+ *
+ * set the easysetup dialog; set it to NULL after destroying the dialog
+ *
+ * Returns: the easy setup dialog just set
+ **/
+GtkDialog* modest_window_mgr_set_easysetup_dialog (ModestWindowMgr *self,
+ GtkDialog *dialog);
+
+
/**
* modest_window_mgr_prevent_hibernation_while_window_is_shown:
* @self: a #ModestWindowMgr