/* Destroy the dialog: */
if (dialog) {
gtk_widget_destroy (GTK_WIDGET (dialog));
- modest_window_mgr_set_easysetup_dialog (
+ modest_window_mgr_set_modal_dialog (
modest_runtime_get_window_mgr(), NULL);
}
}
static void
on_new_button_clicked (GtkWidget *button, ModestAccountViewWindow *self)
{
- GtkDialog *wizard;
+ GtkDialog *wizard, *dialog;
/* Show the easy-setup wizard: */
- wizard = modest_window_mgr_get_easysetup_dialog (modest_runtime_get_window_mgr());
- if (wizard) {
+ dialog = modest_window_mgr_get_modal_dialog (modest_runtime_get_window_mgr());
+ if (dialog && MODEST_IS_EASYSETUP_WIZARD_DIALOG(dialog)) {
/* old wizard is active already;
*/
- gtk_window_present (GTK_WINDOW(wizard));
+ gtk_window_present (GTK_WINDOW(dialog));
return;
- } 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));
- }
+ }
+
+ /* there is no such wizard yet */
+ wizard = GTK_DIALOG(modest_easysetup_wizard_dialog_new ());
+ modest_window_mgr_set_modal_dialog (modest_runtime_get_window_mgr(),
+ GTK_DIALOG(wizard));
+
+ /* if there is already another modal dialog, make it non-modal */
+ if (dialog)
+ gtk_window_set_modal (GTK_WINDOW(dialog), FALSE);
gtk_window_set_modal (GTK_WINDOW (wizard), TRUE);
gtk_window_set_transient_for (GTK_WINDOW (wizard), GTK_WINDOW (self));
}
+
static gint
modest_platform_run_folder_name_dialog (GtkWindow *parent_window,
TnyFolderStore *parent,
hbox, FALSE, FALSE, 0);
gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
-
gtk_window_set_transient_for (GTK_WINDOW (dialog), parent_window);
-
-
-
+
result = gtk_dialog_run (GTK_DIALOG(dialog));
if (result == GTK_RESPONSE_ACCEPT)
*folder_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
folder_name);
}
+
+
+static void
+on_destroy_dialog (GtkDialog *dialog)
+{
+ if (dialog == modest_window_mgr_get_modal_dialog (modest_runtime_get_window_mgr()))
+ modest_window_mgr_set_modal_dialog (modest_runtime_get_window_mgr(),
+ NULL);
+ gtk_widget_destroy (GTK_WIDGET(dialog));
+}
+
+
+/* is there already a modal dialog? if so, return TRUE, if not set this
+ * dialog to be the registered one */
+static void
+check_modal_and_set_maybe (GtkDialog *dialog)
+{
+ GtkDialog *old_modal;
+
+ old_modal =
+ modest_window_mgr_get_modal_dialog (modest_runtime_get_window_mgr());
+
+ if (!old_modal) {
+ gtk_window_set_modal (GTK_WINDOW(dialog), TRUE);
+ modest_window_mgr_set_modal_dialog (modest_runtime_get_window_mgr(),
+ dialog);
+ } else {
+ /* un-modalize the old one; the one on top should be the
+ * modal one */
+ gtk_window_set_modal (GTK_WINDOW(old_modal), FALSE);
+ gtk_window_set_modal (GTK_WINDOW(dialog), TRUE);
+ }
+
+}
+
gint
modest_platform_run_confirmation_dialog (GtkWindow *parent_window,
const gchar *message)
{
GtkWidget *dialog;
gint response;
-
+
dialog = hildon_note_new_confirmation (parent_window, message);
- gtk_window_set_modal (GTK_WINDOW(dialog), TRUE);
+ check_modal_and_set_maybe (GTK_DIALOG(dialog));
response = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (GTK_WIDGET (dialog));
-
+ on_destroy_dialog (GTK_DIALOG(dialog));
+
while (gtk_events_pending ())
gtk_main_iteration ();
return response;
}
-
+
gint
modest_platform_run_yes_no_dialog (GtkWindow *parent_window,
const gchar *message)
{
GtkWidget *dialog;
gint response;
-
+
dialog = hildon_note_new_confirmation_add_buttons (parent_window, message,
_("mcen_bd_yes"), GTK_RESPONSE_YES,
_("mcen_bd_no"), GTK_RESPONSE_NO,
NULL);
- gtk_window_set_modal (GTK_WINDOW(dialog), TRUE);
-
+ check_modal_and_set_maybe (GTK_DIALOG(dialog));
response = gtk_dialog_run (GTK_DIALOG (dialog));
-
- gtk_widget_destroy (GTK_WIDGET (dialog));
+
+ on_destroy_dialog (GTK_DIALOG(dialog));
while (gtk_events_pending ())
gtk_main_iteration ();
return response;
}
+
+
void
modest_platform_run_information_dialog (GtkWindow *parent_window,
const gchar *message)
{
- GtkWidget *dialog;
-
- dialog = hildon_note_new_information (parent_window, message);
-
- g_signal_connect_swapped (dialog,
+ GtkWidget *note;
+
+ note = hildon_note_new_information (parent_window, message);
+ check_modal_and_set_maybe (GTK_DIALOG(note));
+
+ g_signal_connect_swapped (note,
"response",
- G_CALLBACK (gtk_widget_destroy),
- dialog);
+ G_CALLBACK (on_destroy_dialog),
+ note);
- gtk_widget_show_all (dialog);
+ gtk_widget_show_all (note);
}
/* Build dialog */
dialog = hildon_sort_dialog_new (parent_window);
- gtk_window_set_modal (GTK_WINDOW(dialog), TRUE);
+ check_modal_and_set_maybe (GTK_DIALOG(dialog));
/* Fill sort keys */
switch (type) {
}
/* Free */
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ on_destroy_dialog (GTK_DIALOG(dialog));
}
g_signal_connect (G_OBJECT(note), "response",
G_CALLBACK(on_cert_dialog_response),
(gpointer) certificate);
+
+ check_modal_and_set_maybe (GTK_DIALOG(note));
response = gtk_dialog_run(GTK_DIALOG(note));
- gtk_widget_destroy(GTK_WIDGET(note));
+ on_destroy_dialog (GTK_DIALOG(note));
g_free (question);
return response;
* so we know what buttons to show. */
GtkWidget *dialog = GTK_WIDGET (hildon_note_new_confirmation (GTK_WINDOW (main_window),
prompt));
+ check_modal_and_set_maybe (GTK_DIALOG(dialog));
+
const int response = gtk_dialog_run (GTK_DIALOG (dialog));
retval = (response == GTK_RESPONSE_YES) || (response == GTK_RESPONSE_OK);
- gtk_widget_destroy (dialog);
-
+ on_destroy_dialog (GTK_DIALOG(dialog));
} else {
/* Just show the error text and use the default response: */
modest_platform_run_information_dialog (GTK_WINDOW (main_window),
return (src_is_pop && !uncached_msgs);
}
+
+/* FIXME: this should be merged with the similar code in modest-account-view-window */
/* Show the account creation wizard dialog.
* returns: TRUE if an account was created. FALSE if the user cancelled.
*/
modest_run_account_setup_wizard (ModestWindow *win)
{
gboolean result = FALSE;
- GtkDialog *wizard;
-
- 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
+ GtkDialog *wizard, *dialog;
+
+ /* Show the easy-setup wizard: */
+ dialog = modest_window_mgr_get_modal_dialog (modest_runtime_get_window_mgr());
+ if (dialog && MODEST_IS_EASYSETUP_WIZARD_DIALOG(dialog)) {
+ /* old wizard is active already;
*/
- printf ("wizard already active\n");
+ gtk_window_present (GTK_WINDOW(dialog));
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));
- }
+ }
+
+ /* there is no such wizard yet */
+
+ wizard = GTK_DIALOG(modest_easysetup_wizard_dialog_new ());
+ if (!wizard) {
+ g_printerr ("modest: failed to create easysetup wizard\n");
+ return FALSE;
+ }
+ modest_window_mgr_set_modal_dialog
+ (modest_runtime_get_window_mgr(), GTK_DIALOG(wizard));
+
+
+ /* there is no such wizard yet */
+ wizard = GTK_DIALOG(modest_easysetup_wizard_dialog_new ());
+ modest_window_mgr_set_modal_dialog (modest_runtime_get_window_mgr(),
+ GTK_DIALOG(wizard));
+
+ /* make it non-modal; if though we register it as a modal dialog above
+ * apparently, making it modal *at all* gives hangs -- FIXME: check this*/
+ gtk_window_set_modal (GTK_WINDOW(dialog), FALSE);
+
/* 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 */
gtk_widget_destroy (GTK_WIDGET (wizard));
/* clear it from the window mgr */
- modest_window_mgr_set_easysetup_dialog
+ modest_window_mgr_set_modal_dialog
(modest_runtime_get_window_mgr(), NULL);
return result;
GList *window_list;
ModestWindow *main_window;
- GtkDialog *easysetup_dialog;
+ GtkDialog *modal_dialog;
gboolean fullscreen_mode;
priv->window_list = NULL;
priv->main_window = NULL;
priv->fullscreen_mode = FALSE;
- priv->easysetup_dialog = NULL;
+ priv->modal_dialog = NULL;
priv->preregistered_uids = NULL;
priv->viewer_handlers = NULL;
}
- if (priv->easysetup_dialog) {
- g_warning ("%s: forgot to destroy an easysetup dialog somewhere",
+ if (priv->modal_dialog) {
+ g_warning ("%s: forgot to destroy a modal dialog somewhere",
__FUNCTION__);
- gtk_widget_destroy (GTK_WIDGET(priv->easysetup_dialog));
- priv->easysetup_dialog = NULL;
+ gtk_widget_destroy (GTK_WIDGET(priv->modal_dialog));
+ priv->modal_dialog = NULL;
}
/* Do not unref priv->main_window because it does not hold a
gpointer value,
gpointer user_data)
{
- gulong *handler_id;
-
- handler_id = (gulong *) value;
- g_signal_handler_disconnect (G_OBJECT (key), *handler_id);
+ guint handler_id;
+ handler_id = GPOINTER_TO_UINT(value);
+
+ if (key && G_IS_OBJECT(key))
+ g_signal_handler_disconnect (G_OBJECT (key), handler_id);
}
GtkDialog*
-modest_window_mgr_get_easysetup_dialog (ModestWindowMgr *self)
+modest_window_mgr_get_modal_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;
+ return priv->modal_dialog;
}
GtkDialog*
-modest_window_mgr_set_easysetup_dialog (ModestWindowMgr *self, GtkDialog *dialog)
+modest_window_mgr_set_modal_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;
+ return priv->modal_dialog = dialog;
}
/**
- * modest_window_mgr_get_easysetup_dialog:
+ * modest_window_mgr_get_modal_dialog:
* @self: a #ModestWindowMgr
*
- * get the easysetup dialog; if it's NULL, there's no active dialog
+ * get the modal dialog; if it's NULL, there's no active dialog
*
- * Returns: the easy setup dialog or NULL
+ * Returns: the modal dialog or NULL
**/
-GtkDialog* modest_window_mgr_get_easysetup_dialog (ModestWindowMgr *self);
+GtkDialog* modest_window_mgr_get_modal_dialog (ModestWindowMgr *self);
/**
* modest_window_mgr_get_easysetup_dialog:
* @self: a #ModestWindowMgr
*
- * set the easysetup dialog; set it to NULL after destroying the dialog
+ * set the modal dialog; set it to NULL after destroying the dialog
*
- * Returns: the easy setup dialog just set
+ * Returns: the modal dialog just set
**/
-GtkDialog* modest_window_mgr_set_easysetup_dialog (ModestWindowMgr *self,
- GtkDialog *dialog);
+GtkDialog* modest_window_mgr_set_modal_dialog (ModestWindowMgr *self,
+ GtkDialog *dialog);
/**