* remove some annoying debug warnings
[modest] / src / modest-ui-actions.c
index f8a5fec..3653d3a 100644 (file)
@@ -1,5 +1,5 @@
 /* Copyright (c) 2006, Nokia Corporation
- * All rights reserved.
+ * All rights reserved. 
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -103,6 +103,11 @@ typedef struct _ReplyForwardHelper {
        GtkWidget *parent_window;
 } ReplyForwardHelper;
 
+typedef struct _MoveToHelper {
+       ModestMailOperation *mail_op;
+       TnyFolder *folder;
+} MoveToHelper;
+
 typedef struct _PasteAsAttachmentHelper {
        ModestMsgEditWindow *window;
        GtkWidget *banner;
@@ -1104,9 +1109,7 @@ free_reply_forward_helper (gpointer data)
 }
 
 static void
-reply_forward_cb (ModestMailOperation *mail_op, 
-                 TnyHeader *header, 
-                 TnyMsg *msg,
+reply_forward_cb (ModestMailOperation *mail_op,  TnyHeader *header, TnyMsg *msg,
                  gpointer user_data)
 {
        TnyMsg *new_msg;
@@ -1849,15 +1852,9 @@ folder_refreshed_cb (ModestMailOperation *mail_op,
        /* Check if folder is empty and set headers view contents style */
        folder_empty = (tny_folder_get_all_count (folder) == 0);
        all_marked_as_deleted = modest_header_view_is_empty (MODEST_HEADER_VIEW(header_view));
-       folder_empty = folder_empty || all_marked_as_deleted ;
-       if (folder_empty) {
-
-               printf ("DEBUG: %s: tny_folder_get_all_count() returned 0.\n", __FUNCTION__);
+       if (folder_empty || all_marked_as_deleted)
                modest_main_window_set_contents_style (win,
                                                       MODEST_MAIN_WINDOW_CONTENTS_STYLE_EMPTY);
-       } else {
-               printf ("DEBUG: %s: tny_folder_get_all_count() returned >0.\n", __FUNCTION__);
-       }
 }
 
 void 
@@ -2974,6 +2971,7 @@ paste_msgs_cb (const GObject *object, gpointer user_data)
        gtk_widget_destroy (GTK_WIDGET(user_data));
 }
 
+
 static void
 paste_as_attachment_free (gpointer data)
 {
@@ -3824,6 +3822,8 @@ void
 modest_ui_actions_move_folder_error_handler (ModestMailOperation *mail_op, 
                                             gpointer user_data)
 {
+       ModestMainWindow *main_window = NULL;
+       GtkWidget *folder_view = NULL;
        GObject *win = modest_mail_operation_get_source (mail_op);
        const GError *error = NULL;
        const gchar *message = NULL;
@@ -3836,6 +3836,14 @@ modest_ui_actions_move_folder_error_handler (ModestMailOperation *mail_op,
                message = _("mail_in_ui_folder_move_target_error");
        }
        
+       /* Disable next automatic folder selection */
+       if (MODEST_IS_MAIN_WINDOW (user_data)) {
+               main_window = MODEST_MAIN_WINDOW(user_data);
+               folder_view = modest_main_window_get_child_widget (main_window,
+                                                          MODEST_WIDGET_TYPE_FOLDER_VIEW);     
+               modest_folder_view_disable_next_folder_selection (MODEST_FOLDER_VIEW(folder_view));             
+       }
+
        /* Show notification dialog */
        modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL, message);
        g_object_unref (win);
@@ -4134,10 +4142,15 @@ modest_ui_actions_on_main_window_move_to (GtkAction *action,
                           modest_mail_operation_new_with_error_handling (MODEST_MAIL_OPERATION_TYPE_RECEIVE,
                                                                          G_OBJECT(win),
                                                                          modest_ui_actions_move_folder_error_handler,
-                                                                         NULL);
+                                                                         win);
                         modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
                                                          mail_op);
 
+                       /* Select *after* the changes */
+                       /* TODO: this function hangs UI after transfer */ 
+/*                     modest_folder_view_select_folder (MODEST_FOLDER_VIEW(folder_view), */
+/*                                                       TNY_FOLDER (src_folder), TRUE); */
+                       
                         modest_mail_operation_xfer_folder (mail_op,
                                                            TNY_FOLDER (src_folder),
                                                            dst_folder,
@@ -4349,49 +4362,42 @@ modest_ui_actions_on_help (GtkAction *action,
        const gchar *help_id = NULL;
 
        if (MODEST_IS_MAIN_WINDOW (win)) {
-               const gchar *action_name;
-               action_name = gtk_action_get_name (action);
-
-               if (!strcmp (action_name, "FolderViewCSMHelp") ||
-                   !strcmp (action_name, "HeaderViewCSMHelp")) {
-                       GtkWidget *folder_view;
-                       TnyFolderStore *folder_store;
-                       /* Get selected folder */
-                       folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
-                                                                          MODEST_WIDGET_TYPE_FOLDER_VIEW);
-                       folder_store = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
-
-                       /* Switch help_id */
-                       if (TNY_IS_FOLDER (folder_store)) {
-                               switch (modest_tny_folder_guess_folder_type (TNY_FOLDER (folder_store))) {
-                               case TNY_FOLDER_TYPE_NORMAL:
-                                       help_id = "applications_email_managefolders";
-                                       break;
-                               case TNY_FOLDER_TYPE_INBOX:
-                                       help_id = "applications_email_inbox";
-                                       break;
-                               case TNY_FOLDER_TYPE_OUTBOX:
-                                       help_id = "applications_email_outbox";
-                                       break;
-                               case TNY_FOLDER_TYPE_SENT:
-                                       help_id = "applications_email_sent";
-                                       break;
-                               case TNY_FOLDER_TYPE_DRAFTS:
-                                       help_id = "applications_email_drafts";
-                                       break;
-                               case TNY_FOLDER_TYPE_ARCHIVE:
-                                       help_id = "applications_email_managefolders";
-                                       break;
-                               default:
-                                       help_id = "applications_email_managefolders";
-                               }
-                       } else {
-                               help_id = "applications_email_mainview";        
+               GtkWidget *folder_view;
+               TnyFolderStore *folder_store;
+               
+               /* Get selected folder */
+               folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
+                                                                  MODEST_WIDGET_TYPE_FOLDER_VIEW);
+               folder_store = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
+
+               /* Switch help_id */
+               if (TNY_IS_FOLDER (folder_store)) {
+                       switch (modest_tny_folder_guess_folder_type (TNY_FOLDER (folder_store))) {
+                       case TNY_FOLDER_TYPE_NORMAL:
+                               help_id = "applications_email_managefolders";
+                               break;
+                       case TNY_FOLDER_TYPE_INBOX:
+                               help_id = "applications_email_inbox";
+                               break;
+                       case TNY_FOLDER_TYPE_OUTBOX:
+                               help_id = "applications_email_outbox";
+                               break;
+                       case TNY_FOLDER_TYPE_SENT:
+                               help_id = "applications_email_sent";
+                               break;
+                       case TNY_FOLDER_TYPE_DRAFTS:
+                               help_id = "applications_email_drafts";
+                               break;
+                       case TNY_FOLDER_TYPE_ARCHIVE:
+                               help_id = "applications_email_managefolders";
+                               break;
+                       default:
+                               help_id = "applications_email_managefolders";
                        }
-                       g_object_unref (folder_store);
                } else {
-                       help_id = "applications_email_mainview";        
+                       help_id = "applications_email_mainview";
                }
+               g_object_unref (folder_store);
        } else if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
                help_id = "applications_email_viewer";
        } else if (MODEST_IS_MSG_EDIT_WINDOW (win))