Show confirmation and alert dialogs even though there is no main window
[modest] / src / modest-ui-actions.c
index a1012d4..6c1b443 100644 (file)
@@ -3158,7 +3158,6 @@ modest_ui_actions_on_remove_attachments (GtkAction *action,
                                         ModestMsgEditWindow *window)
 {
        g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (window));
-       g_return_if_fail (GTK_IS_ACTION (action));
 
        modest_msg_edit_window_remove_attachments (window, NULL);
 }
@@ -3262,18 +3261,20 @@ do_create_folder_cb (ModestMailOperation *mail_op,
 
 static void
 do_create_folder (GtkWindow *parent_window, 
-                 TnyFolderStore *parent_folder, 
+                 TnyFolderStore *suggested_parent, 
                  const gchar *suggested_name)
 {
        gint result;
        gchar *folder_name = NULL;
+       TnyFolderStore *parent_folder;
 
        result = modest_platform_run_new_folder_dialog (GTK_WINDOW (parent_window),
-                                                       parent_folder,
+                                                       suggested_parent,
                                                        (gchar *) suggested_name,
-                                                       &folder_name);
+                                                       &folder_name,
+                                                       &parent_folder);
        
-       if (result == GTK_RESPONSE_ACCEPT) {
+       if (result == GTK_RESPONSE_ACCEPT && parent_folder) {
                ModestMailOperation *mail_op;
                
                mail_op  = modest_mail_operation_new ((GObject *) parent_window);
@@ -3286,6 +3287,7 @@ do_create_folder (GtkWindow *parent_window,
                                                     folder_name);
                g_object_unref (mail_op);
        }
+       g_object_unref (parent_folder);
 }
 
 static void
@@ -3316,7 +3318,19 @@ modest_ui_actions_create_folder(GtkWidget *parent_window,
 {
        TnyFolderStore *parent_folder;
 
+#ifdef MODEST_TOOLKIT_HILDON2
+       const gchar *active_account;
+       TnyAccount *account;
+
+       /* In hildon 2.2 we use the current account as default parent */
+       active_account = modest_window_get_active_account (MODEST_WINDOW (parent_window));
+       account = modest_tny_account_store_get_server_account (modest_runtime_get_account_store (),
+                                                              active_account,
+                                                              TNY_ACCOUNT_TYPE_STORE);
+       parent_folder = TNY_FOLDER_STORE (account);
+#else
        parent_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW(folder_view));
+#endif
        
        if (parent_folder) {
                /* The parent folder will be freed in the callback */
@@ -3326,6 +3340,9 @@ modest_ui_actions_create_folder(GtkWidget *parent_window,
                                                               create_folder_performer, 
                                                               parent_folder);
        }
+#ifdef MODEST_TOOLKIT_HILDON2
+       g_object_unref (parent_folder);
+#endif
 }
 
 void