* bugfix: register the new dialog as the new modal dialog; this
[modest] / src / modest-ui-actions.c
index 32bcee6..a0f44e6 100644 (file)
@@ -197,6 +197,8 @@ msgs_already_deleted_from_server (TnyList *headers, const TnyFolderStore *src_fo
         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.
  */
@@ -204,25 +206,39 @@ gboolean
 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 */
@@ -251,7 +267,7 @@ modest_run_account_setup_wizard (ModestWindow *win)
        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;
@@ -3141,10 +3157,11 @@ modest_ui_actions_on_paste (GtkAction *action,
                        gint response = 0;
 
                        /* Ask for user confirmation */
-                       response = msgs_move_to_confirmation (GTK_WINDOW (window), 
-                                                             TNY_FOLDER (folder_store), 
-                                                             delete,
-                                                             data);
+                       response = 
+                               modest_ui_actions_msgs_move_to_confirmation (GTK_WINDOW (window), 
+                                                                            TNY_FOLDER (folder_store), 
+                                                                            delete,
+                                                                            data);
                        
                        if (response == GTK_RESPONSE_OK) {
                                /* Launch notification */
@@ -3828,10 +3845,10 @@ has_retrieved_msgs (TnyList *list)
  *     drag_and_drop_from_header_view (for d&d in modest_folder_view.c)
  */
 gint
-msgs_move_to_confirmation (GtkWindow *win,
-                          TnyFolder *dest_folder,
-                          gboolean delete,
-                          TnyList *headers)
+modest_ui_actions_msgs_move_to_confirmation (GtkWindow *win,
+                                            TnyFolder *dest_folder,
+                                            gboolean delete,
+                                            TnyList *headers)
 {
        gint response = GTK_RESPONSE_OK;
 
@@ -3997,6 +4014,8 @@ open_msg_for_purge_cb (ModestMailOperation *mail_op,
 
                tny_iterator_next (iter);
        }
+       g_object_unref (iter);
+       
 
        if (pending_purges>0) {
                gint response;
@@ -4004,7 +4023,7 @@ open_msg_for_purge_cb (ModestMailOperation *mail_op,
 
                if (response == GTK_RESPONSE_OK) {
                        modest_platform_information_banner (NULL, NULL, _("mcen_ib_removing_attachment"));
-                       tny_iterator_first (iter);
+                       iter = tny_list_create_iterator (parts);
                        while (!tny_iterator_is_done (iter)) {
                                TnyMimePart *part;
                                
@@ -4023,26 +4042,10 @@ open_msg_for_purge_cb (ModestMailOperation *mail_op,
        } else {
                modest_platform_information_banner (NULL, NULL, _("mail_ib_attachment_already_purged"));
        }
+       g_object_unref (iter);
 
-       /* remove attachments */
-       tny_iterator_first (iter);
-       while (!tny_iterator_is_done (iter)) {
-               TnyMimePart *part;
-                       
-               part = TNY_MIME_PART (tny_iterator_get_current (iter));
-               if (part) {
-                       /* One for the reference given by tny_iterator_get_current(): */
-                       g_object_unref (part);
-
-                       /* TODO: Is this meant to remove the attachment by doing another unref()? 
-                        * Otherwise, this seems useless. */
-               }
-
-               tny_iterator_next (iter);
-       }
        modest_window_mgr_unregister_header (mgr, header);
 
-       g_object_unref (iter);
        g_object_unref (parts);
 }