Fixes NB#63571
authorFelipe Erias Morandeira <femorandeira@igalia.com>
Mon, 26 Nov 2007 16:09:46 +0000 (16:09 +0000)
committerFelipe Erias Morandeira <femorandeira@igalia.com>
Mon, 26 Nov 2007 16:09:46 +0000 (16:09 +0000)
Changed the name modest_platform_connect_and_perform_if_network_folderstore(..), that now is modest_platform_connect_if_remote_and_perform(..).
Removed modest_platform_connect_and_perform_if_network_account, because the above function performs the same task.
Changed modest_ui_actions_create_folder to use the asynchronous call modest_platform_connect_if_remote_and_perform(..).
Added a call to gtk_tree_model_filter_refilter(tree_model) by the end of on_row_inserted_maybe_select_folder(..) in modest-folder-view.c, so the folder with the new name is shown.

pmo-trunk-r3815

src/maemo/modest-platform.c
src/modest-platform.h
src/modest-ui-actions.c
src/widgets/modest-folder-view.c

index 4c9af84..8ee6646 100644 (file)
@@ -1957,43 +1957,16 @@ modest_platform_connect_and_perform (GtkWindow *parent_window,
        
        return;
 }
        
        return;
 }
-void 
-modest_platform_connect_and_perform_if_network_account (GtkWindow *parent_window, 
-                                                       TnyAccount *account,
-                                                       ModestConnectedPerformer callback, 
-                                                       gpointer user_data)
-{
-       if (tny_account_get_account_type (account) == TNY_ACCOUNT_TYPE_STORE) {
-               if (!TNY_IS_CAMEL_POP_STORE_ACCOUNT (account) &&
-                   !TNY_IS_CAMEL_IMAP_STORE_ACCOUNT (account)) {
-                       
-                       /* This IS a local account like a maildir account, which does not require 
-                        * a connection. (original comment had a vague assumption in its language
-                        * usage. There's no assuming needed, this IS what it IS: a local account), */
-                       /* We promise to instantly perform the callback, so ... */
-                       if (callback) {
-                               callback (FALSE, NULL, parent_window, account, user_data);
-                       }
-                       
-                       return;
-               }
-       }
-       modest_platform_connect_and_perform (parent_window, account, callback, user_data);
-       return;
-}
+
 void
 void
-modest_platform_connect_and_perform_if_network_folderstore (GtkWindow *parent_window, 
+modest_platform_connect_if_remote_and_perform (GtkWindow *parent_window, 
                                                            TnyFolderStore *folder_store, 
                                                            ModestConnectedPerformer callback, 
                                                            gpointer user_data)
 {
                                                            TnyFolderStore *folder_store, 
                                                            ModestConnectedPerformer callback, 
                                                            gpointer user_data)
 {
-       if (!folder_store) {
+       TnyAccount *account = NULL;
+       
+       if (!folder_store) {
                /* We promise to instantly perform the callback, so ... */
                if (callback) {
                        callback (FALSE, NULL, parent_window, NULL, user_data);
                /* We promise to instantly perform the callback, so ... */
                if (callback) {
                        callback (FALSE, NULL, parent_window, NULL, user_data);
@@ -2003,19 +1976,32 @@ modest_platform_connect_and_perform_if_network_folderstore (GtkWindow *parent_wi
                /* Original comment: Maybe it is something local. */
                /* PVH's comment: maybe we should KNOW this in stead of assuming? */
                
                /* Original comment: Maybe it is something local. */
                /* PVH's comment: maybe we should KNOW this in stead of assuming? */
                
-       }
-       
-       if (TNY_IS_FOLDER (folder_store)) {
+       } else if (TNY_IS_FOLDER (folder_store)) {
                /* Get the folder's parent account: */
                /* Get the folder's parent account: */
-               TnyAccount *account = tny_folder_get_account(TNY_FOLDER (folder_store));
-               if (account != NULL) {
-                       modest_platform_connect_and_perform_if_network_account (NULL, account, callback, user_data);
-                       g_object_unref (account);
-               }
+               account = tny_folder_get_account(TNY_FOLDER (folder_store));
        } else if (TNY_IS_ACCOUNT (folder_store)) {
                /* Use the folder store as an account: */
        } else if (TNY_IS_ACCOUNT (folder_store)) {
                /* Use the folder store as an account: */
-               modest_platform_connect_and_perform_if_network_account (NULL, TNY_ACCOUNT (folder_store), callback, user_data);
+               account = TNY_ACCOUNT (folder_store);
+       }
+       if (tny_account_get_account_type (account) == TNY_ACCOUNT_TYPE_STORE) {
+               if (!TNY_IS_CAMEL_POP_STORE_ACCOUNT (account) &&
+                   !TNY_IS_CAMEL_IMAP_STORE_ACCOUNT (account)) {
+                       
+                       /* This IS a local account like a maildir account, which does not require 
+                        * a connection. (original comment had a vague assumption in its language
+                        * usage. There's no assuming needed, this IS what it IS: a local account), */
+                       /* We promise to instantly perform the callback, so ... */
+                       if (callback) {
+                               callback (FALSE, NULL, parent_window, account, user_data);
+                       }
+                       
+                       return;
+               }
        }
  
        }
  
+       modest_platform_connect_and_perform (parent_window, account, callback, user_data);
        return;
 }
        return;
 }
index 2caba01..8268d73 100644 (file)
@@ -404,23 +404,7 @@ void modest_platform_connect_and_perform (GtkWindow *parent_window,
                                          gpointer user_data);
                
 /*
                                          gpointer user_data);
                
 /*
- * modest_platform_connect_and_perform_if_network_account:
- * @parent_window: the parent #GtkWindow for any interactive or progress feedback UI.
- * @account: The account that might need a connection in subsequent operations.
- * @callback: will be called when finished, can be NULL
- * @user_data: user data for @callback
- * 
- * Like modest_platform_connect_and_perform(), but only attempts to make a connection if the 
- * @account uses the network. For instance, this just returns for local maildir accounts. It
- * will in that case instantly perform the @callback.
- */
-void modest_platform_connect_and_perform_if_network_account (GtkWindow *parent_window, 
-                                                            TnyAccount *account,
-                                                            ModestConnectedPerformer callback, 
-                                                            gpointer user_data);
-/*
- * modest_platform_connect_and_perform_if_network_folderstore:
+ * modest_platform_connect_if_remote_and_perform:
  * @parent_window: the parent #GtkWindow for any interactive or progress feedback UI.
  * @folder_store: The folder store (folder or account) that might need a connection in subsequent operations.
  * @callback: will be called when finished, can be NULL
  * @parent_window: the parent #GtkWindow for any interactive or progress feedback UI.
  * @folder_store: The folder store (folder or account) that might need a connection in subsequent operations.
  * @callback: will be called when finished, can be NULL
@@ -428,9 +412,9 @@ void modest_platform_connect_and_perform_if_network_account (GtkWindow *parent_w
  * 
  * Like modest_platform_connect_and_perform(), but only attempts to make a connection if the 
  * folder store uses the network. For instance, this just returns for local maildir folders. It
  * 
  * Like modest_platform_connect_and_perform(), but only attempts to make a connection if the 
  * folder store uses the network. For instance, this just returns for local maildir folders. It
- * will in that case instantly perform the @callback
+ * will in that case synchronously and instantly perform the @callback
  */
  */
-void modest_platform_connect_and_perform_if_network_folderstore (GtkWindow *parent_window, 
+void modest_platform_connect_if_remote_and_perform (GtkWindow *parent_window, 
                                                                 TnyFolderStore *folder_store,
                                                                 ModestConnectedPerformer callback, 
                                                                 gpointer user_data);
                                                                 TnyFolderStore *folder_store,
                                                                 ModestConnectedPerformer callback, 
                                                                 gpointer user_data);
index 97f07ac..049da20 100644 (file)
@@ -2690,6 +2690,59 @@ modest_ui_actions_rename_folder_error_handler (ModestMailOperation *mail_op,
        modest_platform_information_banner (GTK_WIDGET (window), NULL, message);
 }
 
        modest_platform_information_banner (GTK_WIDGET (window), NULL, message);
 }
 
+typedef struct {
+       TnyFolderStore *folder;
+       gchar *new_name;
+} RenameFolderInfo;
+
+static void
+on_rename_folder_cb (gboolean canceled, GError *err, GtkWindow *parent_window, 
+               TnyAccount *account, gpointer user_data)
+{
+       ModestMailOperation *mail_op = NULL;
+       GtkTreeSelection *sel = NULL;
+       GtkWidget *folder_view = NULL;
+       RenameFolderInfo *data = (RenameFolderInfo*)user_data;
+
+       if (MODEST_IS_MAIN_WINDOW(parent_window)) {
+
+               folder_view = modest_main_window_get_child_widget (
+                               MODEST_MAIN_WINDOW (parent_window),
+                               MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
+
+               mail_op = 
+                       modest_mail_operation_new_with_error_handling (G_OBJECT(parent_window),
+                                       modest_ui_actions_rename_folder_error_handler,
+                                       parent_window, NULL);
+
+               modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
+                               mail_op);
+
+               /* Clear the headers view */
+               sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (folder_view));
+               gtk_tree_selection_unselect_all (sel);
+
+               /* Select *after* the changes */
+               modest_folder_view_select_folder (MODEST_FOLDER_VIEW(folder_view),
+                               TNY_FOLDER(data->folder), TRUE);
+
+               /* Actually rename the folder */
+               modest_mail_operation_rename_folder (mail_op,
+                               TNY_FOLDER (data->folder),
+                               (const gchar *) (data->new_name));
+               
+               /* TODO folder view filter refilter */
+               /* 
+               GtkTreeModel *tree_model = gtk_tree_view_get_model (GTK_TREE_VIEW (folder_view));
+               if (GTK_IS_TREE_MODEL_FILTER (tree_model))
+                       gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (tree_model)); */
+       }
+
+       g_object_unref (mail_op);
+       g_free (data->new_name);
+       g_free (data);
+}
+
 void 
 modest_ui_actions_on_rename_folder (GtkAction *action,
                                     ModestMainWindow *main_window)
 void 
 modest_ui_actions_on_rename_folder (GtkAction *action,
                                     ModestMainWindow *main_window)
@@ -2721,7 +2774,7 @@ modest_ui_actions_on_rename_folder (GtkAction *action,
                gint response;
                const gchar *current_name;
                TnyFolderStore *parent;
                gint response;
                const gchar *current_name;
                TnyFolderStore *parent;
-                gboolean do_rename = TRUE;
+               gboolean do_rename = TRUE;
 
                current_name = tny_folder_get_name (TNY_FOLDER (folder));
                parent = tny_folder_get_folder_store (TNY_FOLDER (folder));
 
                current_name = tny_folder_get_name (TNY_FOLDER (folder));
                parent = tny_folder_get_folder_store (TNY_FOLDER (folder));
@@ -2730,42 +2783,14 @@ modest_ui_actions_on_rename_folder (GtkAction *action,
                                                                     &folder_name);
                g_object_unref (parent);
 
                                                                     &folder_name);
                g_object_unref (parent);
 
-                if (response != GTK_RESPONSE_ACCEPT || strlen (folder_name) == 0) {
-                        do_rename = FALSE;
-                } else if (modest_tny_folder_store_is_remote(folder) &&
-                           !tny_device_is_online (modest_runtime_get_device())) {
-                        TnyAccount *account = tny_folder_get_account(TNY_FOLDER(folder));
-                        do_rename = modest_platform_connect_and_wait(GTK_WINDOW(main_window), account);
-                        g_object_unref(account);
-                }
-
-               if (do_rename) {
-                       ModestMailOperation *mail_op;
-                       GtkTreeSelection *sel = NULL;
-
-                       mail_op = 
-                               modest_mail_operation_new_with_error_handling (G_OBJECT(main_window),
-                                                                              modest_ui_actions_rename_folder_error_handler,
-                                                                              main_window, NULL);
-
-                       modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
-                                                        mail_op);
-
-                       /* Clear the headers view */
-                       sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (folder_view));
-                       gtk_tree_selection_unselect_all (sel);
-
-                       /* Select *after* the changes */
-                       modest_folder_view_select_folder (MODEST_FOLDER_VIEW(folder_view),
-                                                         TNY_FOLDER(folder), TRUE);
-
-                       /* Actually rename the folder */
-                       modest_mail_operation_rename_folder (mail_op,
-                                                            TNY_FOLDER (folder),
-                                                            (const gchar *) folder_name);
-
-                       g_object_unref (mail_op);
-                       g_free (folder_name);
+               if (response != GTK_RESPONSE_ACCEPT || strlen (folder_name) == 0) {
+                       do_rename = FALSE;
+               } else {
+                       RenameFolderInfo *rename_folder_data = g_new0 (RenameFolderInfo, 1);
+                       rename_folder_data->folder = folder;
+                       rename_folder_data->new_name = folder_name;
+                       modest_platform_connect_if_remote_and_perform (GTK_WINDOW(main_window), 
+                                       folder, on_rename_folder_cb, rename_folder_data);
                }
        }
        g_object_unref (folder);
                }
        }
        g_object_unref (folder);
index 3634ea0..f91f587 100644 (file)
@@ -2148,7 +2148,7 @@ drag_and_drop_from_folder_view_dst_folder_performer (gboolean canceled,
        }
 
        /* Connect to source folder and perform the copy/move */
        }
 
        /* Connect to source folder and perform the copy/move */
-       modest_platform_connect_and_perform_if_network_folderstore (NULL, 
+       modest_platform_connect_if_remote_and_perform (NULL, 
                                                                    info->src_folder,
                                                                    drag_and_drop_from_folder_view_src_folder_performer,
                                                                    info);
                                                                    info->src_folder,
                                                                    drag_and_drop_from_folder_view_src_folder_performer,
                                                                    info);
@@ -2232,7 +2232,7 @@ drag_and_drop_from_folder_view (GtkTreeModel     *source_model,
        info->helper = helper;
 
        /* Connect to the destination folder and perform the copy/move */
        info->helper = helper;
 
        /* Connect to the destination folder and perform the copy/move */
-       modest_platform_connect_and_perform_if_network_folderstore (GTK_WINDOW (win), 
+       modest_platform_connect_if_remote_and_perform (GTK_WINDOW (win), 
                                                                    dest_folder,
                                                                    drag_and_drop_from_folder_view_dst_folder_performer,
                                                                    info);
                                                                    dest_folder,
                                                                    drag_and_drop_from_folder_view_dst_folder_performer,
                                                                    info);
@@ -2828,6 +2828,9 @@ on_row_inserted_maybe_select_folder (GtkTreeModel *tree_model, GtkTreePath  *pat
                modest_folder_view_disable_next_folder_selection (self);
 /*             g_object_unref (priv->folder_to_select); */
 /*             priv->folder_to_select = NULL; */
                modest_folder_view_disable_next_folder_selection (self);
 /*             g_object_unref (priv->folder_to_select); */
 /*             priv->folder_to_select = NULL; */
+               
+               /* Refilter the model */
+               gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (tree_model));
        }
 }
 
        }
 }
 
@@ -2862,7 +2865,6 @@ modest_folder_view_select_folder (ModestFolderView *self, TnyFolder *folder,
        priv = MODEST_FOLDER_VIEW_GET_PRIVATE (self);
 
        if (after_change) {
        priv = MODEST_FOLDER_VIEW_GET_PRIVATE (self);
 
        if (after_change) {
-
                sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (self));
                gtk_tree_selection_unselect_all (sel);
 
                sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (self));
                gtk_tree_selection_unselect_all (sel);