* Added an attribute sent to the msg edit window that specifies that the mail has...
[modest] / src / modest-ui-actions.c
index fe43926..fa1d7b3 100644 (file)
@@ -486,7 +486,7 @@ modest_ui_actions_on_smtp_servers (GtkAction *action, ModestWindow *win)
 void
 modest_ui_actions_on_new_msg (GtkAction *action, ModestWindow *win)
 {
-       ModestWindow *msg_win;
+       ModestWindow *msg_win = NULL;
        TnyMsg *msg = NULL;
        TnyFolder *folder = NULL;
        gchar *account_name = NULL;
@@ -562,6 +562,8 @@ cleanup:
        g_free (account_name);
        g_free (from_str);
        g_free (blank_and_signature);
+       if (msg_win)
+               g_object_unref (msg_win);
        if (account)
                g_object_unref (G_OBJECT(account));
        if (msg)
@@ -652,6 +654,7 @@ open_msg_cb (ModestMailOperation *mail_op,
        if (win != NULL) {
                mgr = modest_runtime_get_window_mgr ();
                modest_window_mgr_register_window (mgr, win);
+               g_object_unref (win);
                gtk_window_set_transient_for (GTK_WINDOW (win), GTK_WINDOW (parent_win));
                gtk_widget_show_all (GTK_WIDGET(win));
        }
@@ -662,7 +665,6 @@ cleanup:
        g_object_unref (parent_win);
        g_object_unref (msg);
        g_object_unref (folder);
-       g_object_unref (header);
 }
 
 /*
@@ -782,11 +784,11 @@ reply_forward_cb (ModestMailOperation *mail_op,
 {
        TnyMsg *new_msg;
        ReplyForwardHelper *rf_helper;
-       ModestWindow *msg_win;
+       ModestWindow *msg_win = NULL;
        ModestEditType edit_type;
-       gchar *from;
+       gchar *from = NULL;
        TnyAccount *account = NULL;
-       ModestWindowMgr *mgr;
+       ModestWindowMgr *mgr = NULL;
        gchar *signature = NULL;
                        
        g_return_if_fail (user_data != NULL);
@@ -857,6 +859,8 @@ reply_forward_cb (ModestMailOperation *mail_op,
        gtk_widget_show_all (GTK_WIDGET (msg_win));
 
 cleanup:
+       if (msg_win)
+               g_object_unref (msg_win);
        if (new_msg)
                g_object_unref (G_OBJECT (new_msg));
        if (account)
@@ -878,11 +882,11 @@ static gboolean
 download_uncached_messages (TnyList *header_list, GtkWindow *win)
 {
        TnyIterator *iter;
-       gboolean found, retval;
+       gboolean retval;
+       gint uncached_messages = 0;
 
        iter = tny_list_create_iterator (header_list);
-       found = FALSE;
-       while (!tny_iterator_is_done (iter) && !found) {
+       while (!tny_iterator_is_done (iter)) {
                TnyHeader *header;
                TnyHeaderFlags flags;
 
@@ -891,7 +895,8 @@ download_uncached_messages (TnyList *header_list, GtkWindow *win)
                /* TODO: is this the right flag?, it seems that some
                   headers that have been previously downloaded do not
                   come with it */
-               found = !(flags & TNY_HEADER_FLAG_CACHED);
+               if (! (flags & TNY_HEADER_FLAG_CACHED))
+                       uncached_messages ++;
                g_object_unref (header);
                tny_iterator_next (iter);
        }
@@ -899,11 +904,13 @@ download_uncached_messages (TnyList *header_list, GtkWindow *win)
 
        /* Ask for user permission to download the messages */
        retval = TRUE;
-       if (found) {
+       if (uncached_messages > 0) {
                GtkResponseType response;
                response = 
                        modest_platform_run_confirmation_dialog (GTK_WINDOW (win),
-                                                                _("mcen_nc_get_multi_msg_txt"));
+                                                                ngettext("mcen_nc_get_msg",
+                                                                         "mcen_nc_get_msgs",
+                                                                        uncached_messages));
                if (response == GTK_RESPONSE_CANCEL)
                        retval = FALSE;
        }
@@ -1227,7 +1234,11 @@ modest_ui_actions_on_header_selected (ModestHeaderView *header_view,
        /* If no header has been selected then exit */
        if (!header)
                return;
-       
+
+       /* Update focus */
+       if (!gtk_widget_is_focus (GTK_WIDGET(header_view)))
+           gtk_widget_grab_focus (GTK_WIDGET(header_view));
+
        /* Update Main window title */
        if (gtk_widget_is_focus (GTK_WIDGET(header_view))) {
                const gchar *subject = tny_header_get_subject (header);
@@ -1535,9 +1546,6 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi
        info_text = g_strdup_printf (_("mail_va_saved_to_drafts"), _("mcen_me_folder_drafts"));
        modest_platform_information_banner (NULL, NULL, info_text);
        g_free (info_text);
-
-       /* Save settings and close the window */
-       gtk_widget_destroy (GTK_WIDGET (edit_window));
 }
 
 /* For instance, when clicking the Send toolbar button when editing a message: */
@@ -1635,6 +1643,7 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window)
        g_object_unref (G_OBJECT (mail_operation));
 
        modest_msg_edit_window_free_msg_data (edit_window, data);
+       modest_msg_edit_window_set_sent (edit_window, TRUE);
 
        /* Save settings and close the window: */
        gtk_widget_destroy (GTK_WIDGET (edit_window));
@@ -2212,6 +2221,10 @@ modest_ui_actions_on_copy (GtkAction *action,
        } else if (MODEST_IS_FOLDER_VIEW (focused_widget)) {
                modest_folder_view_copy_selection (MODEST_FOLDER_VIEW (focused_widget));
        }    
+
+       /* Show information banner */
+       modest_platform_information_banner (NULL, NULL, _CS("ecoc_ib_edwin_copied"));
+       
 }
 
 void
@@ -2747,6 +2760,10 @@ msgs_move_to_confirmation (GtkWindow *win,
                g_object_unref (header);
                g_object_unref (iter);
 
+               /* if no src_folder, message may be an attahcment */
+               if (src_folder == NULL) 
+                       return GTK_RESPONSE_CANCEL;
+
                /* If the source is a remote folder */
                if (!modest_tny_folder_is_local_folder (src_folder)) {
                        const gchar *message;
@@ -2888,8 +2905,9 @@ modest_ui_actions_on_main_window_move_to (GtkAction *action,
                        g_object_unref (headers);
                }
        }
-       g_object_unref (folder_store);
  end:
+       if (folder_store != NULL)
+               g_object_unref (folder_store);
        gtk_widget_destroy (dialog);
 }
 
@@ -2929,6 +2947,7 @@ modest_ui_actions_on_msg_view_window_move_to (GtkAction *action,
 
                /* Create header list */
                header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (win));              
+                       
                headers = tny_simple_list_new ();
                tny_list_prepend (headers, G_OBJECT (header));
                g_object_unref (header);
@@ -3064,7 +3083,7 @@ modest_ui_actions_on_settings (GtkAction *action,
 
        dialog = modest_platform_get_global_settings_dialog ();
        gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (win));
-       gtk_widget_show (dialog);
+       gtk_widget_show_all (dialog);
 
        gtk_dialog_run (GTK_DIALOG (dialog));