Fixes NB#120943, remote folders not shown in "New folder" dialog when a local folder...
[modest] / src / hildon2 / modest-platform.c
index 786578a..41e5381 100644 (file)
@@ -692,7 +692,8 @@ folder_chooser_activated (ModestFolderView *folder_view,
 }
 
 static TnyFolderStore *
-folder_chooser_dialog_run (ModestFolderView *original, TnyFolderStore *current)
+folder_chooser_dialog_run (ModestFolderView *original,
+                          TnyFolderStore *current)
 {
        GtkWidget *folder_view;
        FolderChooserData userdata = {NULL, NULL};
@@ -705,23 +706,32 @@ folder_chooser_dialog_run (ModestFolderView *original, TnyFolderStore *current)
 
        gtk_window_set_title (GTK_WINDOW (userdata.dialog), _FM("ckdg_ti_change_folder"));
 
-       modest_folder_view_copy_model (MODEST_FOLDER_VIEW (original), 
+       modest_folder_view_copy_model (MODEST_FOLDER_VIEW (original),
                                       MODEST_FOLDER_VIEW (folder_view));
 
-       if (TNY_IS_FOLDER_STORE (current)) {
-               if (TNY_IS_ACCOUNT (current)) {
+       if (TNY_IS_ACCOUNT (current)) {
+               /* Local folders and MMC account are always shown
+                  along with the currently visible server account */
+               if (modest_tny_account_is_virtual_local_folders (TNY_ACCOUNT (current)) ||
+                   modest_tny_account_is_memory_card_account (TNY_ACCOUNT (current)))
+                       visible_id =
+                               g_strdup (modest_folder_view_get_account_id_of_visible_server_account (MODEST_FOLDER_VIEW (original)));
+               else
                        visible_id = g_strdup (tny_account_get_id (TNY_ACCOUNT (current)));
-               } else if (TNY_IS_FOLDER (current)) {
-                       TnyAccount *account;
-
-                       account = tny_folder_get_account (TNY_FOLDER (current));
-                       if (account) {
-                               visible_id = g_strdup (tny_account_get_id (TNY_ACCOUNT (current)));
+       } else if (TNY_IS_FOLDER (current)) {
+               TnyAccount *account;
+               account = tny_folder_get_account (TNY_FOLDER (current));
+               if (account) {
+                       if (modest_tny_account_is_virtual_local_folders (TNY_ACCOUNT (account)) ||
+                           modest_tny_account_is_memory_card_account (TNY_ACCOUNT (account))) {
+                               visible_id =
+                                       g_strdup (modest_folder_view_get_account_id_of_visible_server_account (MODEST_FOLDER_VIEW (original)));
+                       } else {
+                               visible_id = g_strdup (tny_account_get_id (account));
                        }
+                       g_object_unref (account);
                }
-       }
-
-       if (visible_id == NULL) {
+       } else {
                visible_id = g_strdup (
                        modest_folder_view_get_account_id_of_visible_server_account (MODEST_FOLDER_VIEW(original)));
        }
@@ -1134,14 +1144,16 @@ modest_platform_run_new_folder_dialog (GtkWindow *parent_window,
                                                    suggested_folder);
 
        /* In hildon 2.2 we always suggest the archive folder as parent */
-       acc_store = modest_runtime_get_account_store ();
-       account = modest_tny_account_store_get_mmc_folders_account (acc_store);
-       if (account) {
-               suggested_folder = (TnyFolderStore *)
-                       modest_tny_account_get_special_folder (account,
-                                                              TNY_FOLDER_TYPE_ARCHIVE);
-               g_object_unref (account);
-               account = NULL;
+       if (!suggested_folder) {
+               acc_store = modest_runtime_get_account_store ();
+               account = modest_tny_account_store_get_mmc_folders_account (acc_store);
+               if (account) {
+                       suggested_folder = (TnyFolderStore *)
+                               modest_tny_account_get_special_folder (account,
+                                                                      TNY_FOLDER_TYPE_ARCHIVE);
+                       g_object_unref (account);
+                       account = NULL;
+               }
        }
 
        /* If there is not archive folder then fallback to local folders account */
@@ -1561,11 +1573,18 @@ void
 modest_platform_on_new_headers_received (GList *URI_list,
                                         gboolean show_visual)
 {
-       if (g_list_length (URI_list) == 0)
+       gboolean screen_on, app_in_foreground;
+
+       /* Get the window status */
+       app_in_foreground = hildon_program_get_is_topmost (hildon_program_get_instance ());
+       screen_on = modest_window_mgr_screen_is_on (modest_runtime_get_window_mgr ());
+
+       /* If the screen is on and the app is in the
+          foreground we don't show anything */
+       if (screen_on && app_in_foreground)
                return;
 
-       /* If the window is in the foreground don't do anything */
-       if (hildon_program_get_is_topmost (hildon_program_get_instance ()))
+       if (g_list_length (URI_list) == 0)
                return;
 
 #ifdef MODEST_HAVE_HILDON_NOTIFY