+ modest_folder_view_unset_filter (MODEST_FOLDER_VIEW (folder_view),
+ MODEST_FOLDER_VIEW_FILTER_HIDE_MCC_FOLDERS);
+ modest_folder_view_unset_filter (MODEST_FOLDER_VIEW (folder_view),
+ MODEST_FOLDER_VIEW_FILTER_HIDE_LOCAL_FOLDERS);
+ modest_folder_view_unset_filter (MODEST_FOLDER_VIEW (folder_view),
+ MODEST_FOLDER_VIEW_FILTER_HIDE_ACCOUNTS);
+ modest_folder_view_set_filter (MODEST_FOLDER_VIEW (folder_view),
+ MODEST_FOLDER_VIEW_FILTER_HIDE_FOLDERS);
+ hildon_pannable_area_jump_to (HILDON_PANNABLE_AREA (pannable), 0, 0);
+}
+
+static void
+move_to_dialog_show_folders (GtkWidget *dialog, TnyFolderStore *folder_store)
+{
+ GtkWidget *back_button;
+ GtkWidget *folder_view;
+ TnyAccount *account;
+ const gchar *account_id;
+ GtkWidget *pannable;
+ GtkWidget *action_button;
+
+ back_button =
+ GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), MOVE_TO_DIALOG_BACK_BUTTON));
+ action_button =
+ GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), MOVE_TO_DIALOG_ACTION_BUTTON));
+ folder_view =
+ GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), MOVE_TO_DIALOG_FOLDER_VIEW));
+ pannable =
+ GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), MOVE_TO_DIALOG_PANNABLE));
+
+ gtk_widget_set_sensitive (back_button, TRUE);
+ gtk_widget_set_sensitive (action_button, TRUE);
+
+ /* Need to set this here, otherwise callbacks called because
+ of filtering won't perform correctly */
+ g_object_set_data (G_OBJECT (dialog),
+ MOVE_TO_DIALOG_SHOWING_FOLDERS,
+ GINT_TO_POINTER (TRUE));
+
+ account = TNY_ACCOUNT (folder_store);
+ if (modest_tny_account_is_virtual_local_folders (account)) {
+ account_id = tny_account_get_id (account);
+ modest_folder_view_set_filter (MODEST_FOLDER_VIEW (folder_view),
+ MODEST_FOLDER_VIEW_FILTER_HIDE_MCC_FOLDERS);
+ } else if (modest_tny_account_is_memory_card_account (account)) {
+ account_id = tny_account_get_id (account);
+ modest_folder_view_set_filter (MODEST_FOLDER_VIEW (folder_view),
+ MODEST_FOLDER_VIEW_FILTER_HIDE_LOCAL_FOLDERS);
+ } else {
+ account_id = tny_account_get_id (account);
+ modest_folder_view_set_filter (MODEST_FOLDER_VIEW (folder_view),
+ MODEST_FOLDER_VIEW_FILTER_HIDE_LOCAL_FOLDERS);
+ modest_folder_view_set_filter (MODEST_FOLDER_VIEW (folder_view),
+ MODEST_FOLDER_VIEW_FILTER_HIDE_MCC_FOLDERS);
+ }
+
+ move_to_dialog_set_selected_folder_store (dialog, folder_store);
+ modest_folder_view_set_account_id_of_visible_server_account (MODEST_FOLDER_VIEW (folder_view),
+ account_id);
+
+ modest_folder_view_show_non_move_folders (MODEST_FOLDER_VIEW (folder_view), FALSE);
+ modest_folder_view_set_style (MODEST_FOLDER_VIEW (folder_view), MODEST_FOLDER_VIEW_STYLE_SHOW_ONE);
+ modest_folder_view_set_filter (MODEST_FOLDER_VIEW (folder_view), MODEST_FOLDER_VIEW_FILTER_HIDE_ACCOUNTS);
+ modest_folder_view_unset_filter (MODEST_FOLDER_VIEW (folder_view), MODEST_FOLDER_VIEW_FILTER_HIDE_FOLDERS);
+ hildon_pannable_area_jump_to (HILDON_PANNABLE_AREA (pannable), 0, 0);
+}
+
+static void
+on_move_to_dialog_back_clicked (GtkButton *button,
+ gpointer userdata)
+{
+ GtkWidget *dialog = (GtkWidget *) userdata;
+
+ /* Back to show accounts */
+ move_to_dialog_show_accounts (dialog);
+}
+
+static void
+on_move_to_dialog_row_activated (GtkTreeView *tree_view,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ gpointer user_data)
+{
+ TnyFolderStore *selected = NULL;
+ GtkWidget *dialog;
+ GtkWidget *folder_view;
+ gboolean showing_folders;
+
+ dialog = (GtkWidget *) user_data;
+ showing_folders = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dialog),
+ MOVE_TO_DIALOG_SHOWING_FOLDERS));
+
+ folder_view = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog),
+ MOVE_TO_DIALOG_FOLDER_VIEW));
+
+ selected = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
+ if (!selected)
+ return;
+
+ if (!showing_folders) {
+ gboolean valid = TRUE;
+
+ if (TNY_IS_ACCOUNT (selected) &&
+ modest_tny_folder_store_is_remote (TNY_FOLDER_STORE (selected))) {
+ ModestProtocolType protocol_type;
+
+ protocol_type = modest_tny_account_get_protocol_type (TNY_ACCOUNT (selected));
+ valid = !modest_protocol_registry_protocol_type_has_tag
+ (modest_runtime_get_protocol_registry (),
+ protocol_type,
+ MODEST_PROTOCOL_REGISTRY_STORE_FORBID_INCOMING_XFERS);
+ }
+ if (valid)
+ move_to_dialog_show_folders (dialog, selected);
+ } else {
+ move_to_dialog_set_selected_folder_store (dialog, selected);
+ }
+ g_object_unref (selected);
+}
+
+static void
+on_move_to_dialog_selection_changed (GtkTreeSelection *selection,
+ gpointer user_data)
+{
+ gboolean showing_folders;
+ GtkWidget *dialog;
+
+ dialog = (GtkWidget *) user_data;
+ showing_folders = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dialog), MOVE_TO_DIALOG_SHOWING_FOLDERS));
+ if (showing_folders) {
+ TnyFolderStore *selected;
+ GtkWidget *folder_view;
+
+ folder_view = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), MOVE_TO_DIALOG_FOLDER_VIEW));
+ selected = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
+
+ if (selected) {
+ move_to_dialog_set_selected_folder_store (dialog, selected);
+ g_object_unref (selected);
+ }
+ }
+}
+
+static void
+on_move_to_dialog_action_clicked (GtkButton *selection,
+ gpointer user_data)
+{
+ GtkWidget *dialog;
+ gboolean showing_folders;
+
+ dialog = (GtkWidget *) user_data;
+ showing_folders = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dialog), MOVE_TO_DIALOG_SHOWING_FOLDERS));
+ if (showing_folders) {
+ TnyFolderStore *selected;
+ GtkWidget *folder_view;
+
+ folder_view = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), MOVE_TO_DIALOG_FOLDER_VIEW));
+ selected = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
+
+ if (selected) {
+ /* It's not possible to select root folders as
+ targets unless they're the local account or
+ the memory card account */
+ if ((TNY_IS_FOLDER (selected) && !TNY_IS_MERGE_FOLDER (selected)) ||
+ (TNY_IS_ACCOUNT (selected) &&
+ (modest_tny_account_is_virtual_local_folders (TNY_ACCOUNT (selected)) ||
+ modest_tny_account_is_memory_card_account (TNY_ACCOUNT (selected)))))
+ gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+ g_object_unref (selected);
+ }
+ }
+}
+
+static void
+move_to_dialog_activity_changed (ModestFolderView *folder_view, gboolean activity, GtkDialog *dialog)
+{
+ hildon_gtk_window_set_progress_indicator (GTK_WINDOW (dialog), activity?1:0);