2005-04-15 [colin] 1.9.6cvs37
[claws.git] / src / summaryview.c
index 63082d22c3fd0a6c37176e23174e090ff0473209..482e6b14c8f0ddd3e7d500907564e0f277dd2e89 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
 #include "defs.h"
 
 #include <glib.h>
+#include <glib/gi18n.h>
 #include <gdk/gdkkeysyms.h>
 #include <gtk/gtkscrolledwindow.h>
 #include <gtk/gtkwidget.h>
@@ -45,7 +46,6 @@
 #include <string.h>
 #include <ctype.h>
 
-#include "intl.h"
 #include "main.h"
 #include "menu.h"
 #include "mainwindow.h"
@@ -611,8 +611,9 @@ SummaryView *summary_create(void)
 
 void summary_init(SummaryView *summaryview)
 {
-       GtkStyle *style;
        GtkWidget *pixmap;
+       PangoFontDescription *font_desc;
+       gint size;
 
        gtk_widget_realize(summaryview->ctree);
        stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_MARK,
@@ -640,39 +641,21 @@ void summary_init(SummaryView *summaryview)
        stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_GPG_SIGNED,
                         &gpgsignedxpm, &gpgsignedxpmmask);
 
-       if (!small_style) {
-               PangoFontDescription *font_desc = NULL;
+       font_desc = pango_font_description_from_string(NORMAL_FONT);
+       gtk_widget_modify_font(summaryview->ctree, font_desc);
+       pango_font_description_free(font_desc);
 
-               small_style = gtk_style_copy
-                       (gtk_widget_get_style(summaryview->ctree));
-               if (SMALL_FONT)
-                       font_desc = pango_font_description_from_string
-                                               (SMALL_FONT);
-               if (font_desc) {
-                       if (small_style->font_desc)
-                               pango_font_description_free(small_style->font_desc);
-                       small_style->font_desc = font_desc;
-               }
-               small_marked_style = gtk_style_copy(small_style);
-               small_marked_style->fg[GTK_STATE_NORMAL] =
-                       summaryview->color_marked;
-               small_deleted_style = gtk_style_copy(small_style);
-               small_deleted_style->fg[GTK_STATE_NORMAL] =
-                       summaryview->color_dim;
-       }
        if (!bold_style) {
-               PangoFontDescription *font_desc = NULL;
                bold_style = gtk_style_copy
                        (gtk_widget_get_style(summaryview->ctree));
-               if (BOLD_FONT)
-                       font_desc = pango_font_description_from_string
-                                               (BOLD_FONT);
+               font_desc = pango_font_description_from_string(BOLD_FONT);
                if (font_desc) {
-                       if (bold_style->font_desc)
-                               pango_font_description_free
-                                       (bold_style->font_desc);
+                       pango_font_description_free(bold_style->font_desc);
                        bold_style->font_desc = font_desc;
                }
+               
+               pango_font_description_set_weight
+                               (bold_style->font_desc, PANGO_WEIGHT_BOLD);
                bold_marked_style = gtk_style_copy(bold_style);
                bold_marked_style->fg[GTK_STATE_NORMAL] =
                        summaryview->color_marked;
@@ -681,11 +664,14 @@ void summary_init(SummaryView *summaryview)
                        summaryview->color_dim;
        }
 
-       style = gtk_style_copy(gtk_widget_get_style
-                               (summaryview->statlabel_folder));
-       gtk_widget_set_style(summaryview->statlabel_folder, style);
-       gtk_widget_set_style(summaryview->statlabel_select, style);
-       gtk_widget_set_style(summaryview->statlabel_msgs, style);
+       font_desc = pango_font_description_new();
+       size = pango_font_description_get_size
+               (summaryview->statlabel_folder->style->font_desc);
+       pango_font_description_set_size(font_desc, size * PANGO_SCALE_SMALL);
+       gtk_widget_modify_font(summaryview->statlabel_folder, font_desc);
+       gtk_widget_modify_font(summaryview->statlabel_select, font_desc);
+       gtk_widget_modify_font(summaryview->statlabel_msgs, font_desc);
+       pango_font_description_free(font_desc);
 
        pixmap = stock_pixmap_widget(summaryview->hbox_l, STOCK_PIXMAP_DIR_OPEN);
        gtk_box_pack_start(GTK_BOX(summaryview->hbox_l), pixmap, FALSE, FALSE, 4);
@@ -821,7 +807,7 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
 
                val = alertpanel(_("Process mark"),
                                 _("Some marks are left. Process it?"),
-                                _("Yes"), _("No"), _("Cancel"));
+                                GTK_STOCK_YES, GTK_STOCK_NO, GTK_STOCK_CANCEL);
                if (G_ALERTDEFAULT == val) {
                        summary_unlock(summaryview);
                        summary_execute(summaryview);
@@ -978,10 +964,8 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
           create the thread */
        summary_set_ctree_from_list(summaryview, mlist);
 
-       g_slist_free(mlist);
 
-       if (summaryview->sort_key != SORT_BY_NONE)
-               summary_sort(summaryview, summaryview->sort_key, summaryview->sort_type);
+       g_slist_free(mlist);
 
        gtk_clist_thaw(GTK_CLIST(ctree));
 
@@ -1284,7 +1268,7 @@ void summary_select_prev_unread(SummaryView *summaryview)
                                val = alertpanel(_("No more unread messages"),
                                                 _("No unread message found. "
                                                   "Search from the end?"),
-                                                _("Yes"), _("No"), NULL);
+                                                GTK_STOCK_YES, GTK_STOCK_NO, NULL);
                                break;
                        case NEXTUNREADMSGDIALOG_ASSUME_YES:
                                val = G_ALERTDEFAULT;
@@ -1336,7 +1320,7 @@ void summary_select_next_unread(SummaryView *summaryview)
                                        val = alertpanel(_("No more unread messages"),
                                                         _("No unread message found. "
                                                           "Go to next folder?"),
-                                                        _("Yes"), _("No"), NULL);
+                                                        GTK_STOCK_YES, GTK_STOCK_NO, NULL);
                                        break;
                                case NEXTUNREADMSGDIALOG_ASSUME_YES:
                                        val = G_ALERTDEFAULT;
@@ -1376,7 +1360,7 @@ void summary_select_prev_new(SummaryView *summaryview)
                val = alertpanel(_("No more new messages"),
                                 _("No new message found. "
                                   "Search from the end?"),
-                                _("Yes"), _("No"), NULL);
+                                GTK_STOCK_YES, GTK_STOCK_NO, NULL);
                if (val != G_ALERTDEFAULT) return;
                node = summary_find_prev_flagged_msg(summaryview, NULL,
                                                     MSG_NEW, FALSE);
@@ -1400,7 +1384,8 @@ void summary_select_next_new(SummaryView *summaryview)
                val = alertpanel(_("No more new messages"),
                                 _("No new message found. "
                                   "Go to next folder?"),
-                                _("Yes"), _("Search again"), _("No"));
+                                GTK_STOCK_YES, _("Search again"),
+                                GTK_STOCK_NO);
                if (val == G_ALERTDEFAULT) {
                        g_signal_stop_emission_by_name(G_OBJECT(ctree),"key_press_event");
                        folderview_select_next_unread(summaryview->folderview);
@@ -1428,7 +1413,7 @@ void summary_select_prev_marked(SummaryView *summaryview)
                val = alertpanel(_("No more marked messages"),
                                 _("No marked message found. "
                                   "Search from the end?"),
-                                _("Yes"), _("No"), NULL);
+                                GTK_STOCK_YES, GTK_STOCK_NO, NULL);
                if (val != G_ALERTDEFAULT) return;
                node = summary_find_prev_flagged_msg(summaryview, NULL,
                                                     MSG_MARKED, TRUE);
@@ -1453,7 +1438,7 @@ void summary_select_next_marked(SummaryView *summaryview)
                val = alertpanel(_("No more marked messages"),
                                 _("No marked message found. "
                                   "Search from the beginning?"),
-                                _("Yes"), _("No"), NULL);
+                                GTK_STOCK_YES, GTK_STOCK_NO, NULL);
                if (val != G_ALERTDEFAULT) return;
                node = summary_find_next_flagged_msg(summaryview, NULL,
                                                     MSG_MARKED, TRUE);
@@ -1478,7 +1463,7 @@ void summary_select_prev_labeled(SummaryView *summaryview)
                val = alertpanel(_("No more labeled messages"),
                                 _("No labeled message found. "
                                   "Search from the end?"),
-                                _("Yes"), _("No"), NULL);
+                                GTK_STOCK_YES, GTK_STOCK_NO, NULL);
                if (val != G_ALERTDEFAULT) return;
                node = summary_find_prev_flagged_msg(summaryview, NULL,
                                                     MSG_CLABEL_FLAG_MASK, TRUE);
@@ -1503,7 +1488,7 @@ void summary_select_next_labeled(SummaryView *summaryview)
                val = alertpanel(_("No more labeled messages"),
                                 _("No labeled message found. "
                                   "Search from the beginning?"),
-                                _("Yes"), _("No"), NULL);
+                                GTK_STOCK_YES, GTK_STOCK_NO, NULL);
                if (val != G_ALERTDEFAULT) return;
                node = summary_find_next_flagged_msg(summaryview, NULL,
                                                     MSG_CLABEL_FLAG_MASK, TRUE);
@@ -2076,12 +2061,13 @@ void summary_sort(SummaryView *summaryview,
        if (summaryview->sort_key == SORT_BY_NONE)
                return;
 
-       if(cmp_func != NULL) {
+       if (cmp_func != NULL) {
                debug_print("Sorting summary...");
                STATUSBAR_PUSH(summaryview->mainwin, _("Sorting summary..."));
 
                main_window_cursor_wait(summaryview->mainwin);
 
+                gtk_clist_freeze(clist);
                gtk_clist_set_compare_func(clist, cmp_func);
 
                gtk_clist_set_sort_type(clist, (GtkSortType)sort_type);
@@ -2091,6 +2077,7 @@ void summary_sort(SummaryView *summaryview,
                gtk_ctree_node_moveto(ctree, summaryview->selected, -1, 0.5, 0);
 
                main_window_cursor_normal(summaryview->mainwin);
+                gtk_clist_thaw(clist);
 
                debug_print("done.\n");
                STATUSBAR_POP(summaryview->mainwin);
@@ -2177,7 +2164,7 @@ static void summary_set_ctree_from_list(SummaryView *summaryview,
                }
 
                g_node_destroy(root);
-
+                
                summary_thread_init(summaryview);
        } else {
                gchar *text[N_SUMMARY_COLS];
@@ -2226,6 +2213,8 @@ static void summary_set_ctree_from_list(SummaryView *summaryview,
                debug_print("\tsubject hash table size = %d\n",
                            g_hash_table_size(subject_table));
        }
+
+       summary_sort(summaryview, summaryview->sort_key, summaryview->sort_type);
 }
 
 static gchar *summary_complete_address(const gchar *addr)
@@ -2413,12 +2402,13 @@ static void summary_display_msg_full(SummaryView *summaryview,
                msgview = summaryview->messageview;
 
                summaryview->displayed = row;
-               if (!messageview_is_visible(msgview))
+               if (!messageview_is_visible(msgview)) {
                        main_window_toggle_message_view(summaryview->mainwin);
+                       GTK_EVENTS_FLUSH();
+               }
                val = messageview_show(msgview, msginfo, all_headers);
                if (GTK_CLIST(msgview->mimeview->ctree)->row_list == NULL)
                        gtk_widget_grab_focus(summaryview->ctree);
-               GTK_EVENTS_FLUSH();
                gtkut_ctree_node_move_if_on_the_edge(ctree, row);
        }
 
@@ -2504,37 +2494,37 @@ void summary_reedit(SummaryView *summaryview)
        compose_reedit(msginfo);
 }
 
-void summary_step(SummaryView *summaryview, GtkScrollType type)
+gboolean summary_step(SummaryView *summaryview, GtkScrollType type)
 {
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
        GtkCTreeNode *node;
 
-       if (summary_is_locked(summaryview)) return;
+       if (summary_is_locked(summaryview)) return FALSE;
 
        if (type == GTK_SCROLL_STEP_FORWARD) {
                node = gtkut_ctree_node_next(ctree, summaryview->selected);
                if (node)
                        gtkut_ctree_expand_parent_all(ctree, node);
                else
-                       return;
+                       return FALSE;
        } else {
                if (summaryview->selected) {
                        node = GTK_CTREE_NODE_PREV(summaryview->selected);
-                       if (!node) return;
+                       if (!node) return FALSE;
                }
        }
 
        if (messageview_is_visible(summaryview->messageview))
                summaryview->display_msg = TRUE;
 
-       g_signal_emit_by_name(G_OBJECT(ctree), "scroll_vertical",
-                             type, 0.0);
+       g_signal_emit_by_name(G_OBJECT(ctree), "scroll_vertical", type, 0.0);
 
        if (GTK_CLIST(ctree)->selection)
                gtk_sctree_set_anchor_row
                        (GTK_SCTREE(ctree),
                         GTK_CTREE_NODE(GTK_CLIST(ctree)->selection->data));
 
+       return TRUE;
 }
 
 void summary_toggle_view(SummaryView *summaryview)
@@ -2780,8 +2770,12 @@ void summary_mark(SummaryView *summaryview)
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
        GList *cur;
 
+       folder_item_update_freeze();
+       gtk_clist_freeze(GTK_CLIST(summaryview->ctree));
        for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next)
                summary_mark_row(summaryview, GTK_CTREE_NODE(cur->data));
+       folder_item_update_thaw();
+       gtk_clist_thaw(GTK_CLIST(summaryview->ctree));
 
        /* summary_step(summaryview, GTK_SCROLL_STEP_FORWARD); */
        summary_status_show(summaryview);
@@ -2867,6 +2861,11 @@ void summary_mark_all_read(SummaryView *summaryview)
        for (node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list); node != NULL;
             node = gtkut_ctree_node_next(ctree, node))
                summary_mark_row_as_read(summaryview, node);
+       for (node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list); node != NULL;
+            node = gtkut_ctree_node_next(ctree, node)) {
+               if (!GTK_CTREE_ROW(node)->expanded)
+                       summary_set_row_marks(summaryview, node);
+       }
        folder_item_update_thaw();
        gtk_clist_thaw(clist);
 
@@ -3042,7 +3041,7 @@ void summary_delete(SummaryView *summaryview)
 
                aval = alertpanel(_("Delete message(s)"),
                                  _("Do you really want to delete message(s) from the trash?"),
-                                 _("Yes"), _("No"), NULL);
+                                 GTK_STOCK_YES, GTK_STOCK_NO, NULL);
                if (aval != G_ALERTDEFAULT) return;
 
                for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next) {
@@ -3110,9 +3109,15 @@ void summary_unmark(SummaryView *summaryview)
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
        GList *cur;
 
+       folder_item_update_freeze();
+       gtk_clist_freeze(GTK_CLIST(summaryview->ctree)); 
+
        for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next)
                summary_unmark_row(summaryview, GTK_CTREE_NODE(cur->data));
 
+       folder_item_update_thaw();
+       gtk_clist_thaw(GTK_CLIST(summaryview->ctree));
+
        summary_status_show(summaryview);
 }
 
@@ -3159,11 +3164,17 @@ void summary_move_selected_to(SummaryView *summaryview, FolderItem *to_folder)
                return;
        }
 
+       folder_item_update_freeze();
+       gtk_clist_freeze(GTK_CLIST(summaryview->ctree)); 
+
        for (cur = GTK_CLIST(summaryview->ctree)->selection;
             cur != NULL; cur = cur->next)
                summary_move_row_to
                        (summaryview, GTK_CTREE_NODE(cur->data), to_folder);
 
+       folder_item_update_thaw();
+       gtk_clist_thaw(GTK_CLIST(summaryview->ctree));
+
        summary_step(summaryview, GTK_SCROLL_STEP_FORWARD);
 
        if (prefs_common.immediate_exec)
@@ -3236,11 +3247,17 @@ void summary_copy_selected_to(SummaryView *summaryview, FolderItem *to_folder)
                return;
        }
 
+       folder_item_update_freeze();
+       gtk_clist_freeze(GTK_CLIST(summaryview->ctree)); 
+
        for (cur = GTK_CLIST(summaryview->ctree)->selection;
             cur != NULL; cur = cur->next)
                summary_copy_row_to
                        (summaryview, GTK_CTREE_NODE(cur->data), to_folder);
 
+       folder_item_update_thaw();
+       gtk_clist_thaw(GTK_CLIST(summaryview->ctree));
+
        summary_step(summaryview, GTK_SCROLL_STEP_FORWARD);
 
        if (prefs_common.immediate_exec)
@@ -3339,11 +3356,11 @@ void summary_save_as(SummaryView *summaryview)
                subst_for_filename(filename);
        }
        if (g_getenv ("G_BROKEN_FILENAMES") &&
-           filename && g_utf8_validate(filename, -1, NULL)) {
+           filename && !g_utf8_validate(filename, -1, NULL)) {
                gchar *oldstr = filename;
                filename = conv_codeset_strdup(filename,
-                                              CS_UTF_8,
-                                              conv_get_current_charset_str());
+                                              conv_get_locale_charset_str(),
+                                              CS_UTF_8);
                if (!filename) {
                        g_warning("summary_save_as(): faild to convert character set.");
                        filename = g_strdup(oldstr);
@@ -3357,7 +3374,8 @@ void summary_save_as(SummaryView *summaryview)
        if (is_file_exist(dest)) {
                aval = alertpanel(_("Append or Overwrite"),
                                  _("Append or overwrite existing file?"),
-                                 _("Append"), _("Overwrite"), _("Cancel"));
+                                 _("Append"), _("Overwrite"),
+                                 GTK_STOCK_CANCEL);
                if (aval != 0 && aval != 1)
                        return;
        }
@@ -3646,6 +3664,7 @@ void summary_thread_build(SummaryView *summaryview)
        GtkCTreeNode *next;
        GtkCTreeNode *parent;
        MsgInfo *msginfo;
+        GSList *reflist;
 
        summary_lock(summaryview);
 
@@ -3665,12 +3684,18 @@ void summary_thread_build(SummaryView *summaryview)
 
                parent = NULL;
 
-               /* alfons - claws seems to prefer subject threading before
-                * inreplyto threading. we should look more deeply in this,
-                * because inreplyto should have precedence... */
                if (msginfo && msginfo->inreplyto) {
                        parent = g_hash_table_lookup(summaryview->msgid_table,
                                                     msginfo->inreplyto);
+                                                     
+                       if (!parent && msginfo->references) {
+                               for (reflist = msginfo->references;
+                                    reflist != NULL; reflist = reflist->next)
+                                       if ((parent = g_hash_table_lookup
+                                               (summaryview->msgid_table,
+                                                reflist->data)))
+                                               break;
+                       }
                }
 
                if (prefs_common.thread_by_subject && parent == NULL) {
@@ -3721,7 +3746,7 @@ static void summary_thread_init(SummaryView *summaryview)
                while (node) {
                        next = GTK_CTREE_ROW(node)->sibling;
                        if (GTK_CTREE_ROW(node)->children)
-                               gtk_ctree_expand(ctree, node);
+                               gtk_ctree_expand_recursive(ctree, node);
                        node = next;
                }
        } else if (prefs_common.bold_unread) {
@@ -3877,11 +3902,6 @@ void summary_collapse_threads(SummaryView *summaryview)
 
 void summary_filter(SummaryView *summaryview, gboolean selected_only)
 {
-       if (!filtering_rules) {
-               alertpanel_error(_("No filter rules defined."));
-               return;
-       }
-
        summary_lock(summaryview);
 
        folder_item_update_freeze();
@@ -3892,37 +3912,21 @@ void summary_filter(SummaryView *summaryview, gboolean selected_only)
 
        gtk_clist_freeze(GTK_CLIST(summaryview->ctree));
 
-       if (filtering_rules == NULL) {
+       if (selected_only) {
+               GList *cur;
+
+               for (cur = GTK_CLIST(summaryview->ctree)->selection;
+                    cur != NULL; cur = cur->next) {
+                       summary_filter_func(GTK_CTREE(summaryview->ctree),
+                                           GTK_CTREE_NODE(cur->data),
+                                           summaryview);
+               }
+       } else {
                gtk_ctree_pre_recursive(GTK_CTREE(summaryview->ctree), NULL,
                                        GTK_CTREE_FUNC(summary_filter_func),
                                        summaryview);
-               
-               gtk_clist_thaw(GTK_CLIST(summaryview->ctree));
-               
-               if (prefs_common.immediate_exec) {
-                       summary_unlock(summaryview);
-                       summary_execute(summaryview);
-                       summary_lock(summaryview);
-               } else
-                       summary_status_show(summaryview);
-       }
-       else {
-               if (selected_only) {
-                       GList *cur;
-
-                       for (cur = GTK_CLIST(summaryview->ctree)->selection;
-                            cur != NULL; cur = cur->next) {
-                               summary_filter_func(GTK_CTREE(summaryview->ctree),
-                                                   GTK_CTREE_NODE(cur->data),
-                                                   summaryview);
-                       }
-               } else {
-                       gtk_ctree_pre_recursive(GTK_CTREE(summaryview->ctree), NULL,
-                                               GTK_CTREE_FUNC(summary_filter_func),
-                                               summaryview);
-               }
-               gtk_clist_thaw(GTK_CLIST(summaryview->ctree));
        }
+       gtk_clist_thaw(GTK_CLIST(summaryview->ctree));
 
        folder_item_update_thaw();
        debug_print("done.\n");
@@ -3935,16 +3939,19 @@ void summary_filter(SummaryView *summaryview, gboolean selected_only)
         * CLAWS: summary_show() only valid after having a lock. ideally
         * we want the lock to be context aware...  
         */
-       if (filtering_rules) {
-               summary_show(summaryview, summaryview->folder_item);
-       }               
+       summary_show(summaryview, summaryview->folder_item);
 }
 
 static void summary_filter_func(GtkCTree *ctree, GtkCTreeNode *node,
                                gpointer data)
 {
+       MailFilteringData mail_filtering_data;
        MsgInfo *msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
 
+       mail_filtering_data.msginfo = msginfo;
+       if (hooks_invoke(MAIL_MANUAL_FILTERING_HOOKLIST, &mail_filtering_data))
+               return;
+
        filter_message_by_msginfo(filtering_rules, msginfo);
 }
 
@@ -4256,7 +4263,7 @@ static GtkWidget *summary_ctree_create(SummaryView *summaryview)
        gtk_ctree_set_expander_style(GTK_CTREE(ctree),
                                     GTK_CTREE_EXPANDER_TRIANGLE);
 #endif
-       gtk_ctree_set_indent(GTK_CTREE(ctree), 16);
+       gtk_ctree_set_indent(GTK_CTREE(ctree), 12);
        g_object_set_data(G_OBJECT(ctree), "user_data", summaryview);
 
        for (pos = 0; pos < N_SUMMARY_COLS; pos++) {
@@ -4402,7 +4409,7 @@ void summary_pass_key_press_event(SummaryView *summaryview, GdkEventKey *event)
        if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
 
 static gboolean summary_key_pressed(GtkWidget *widget, GdkEventKey *event,
-                               SummaryView *summaryview)
+                                   SummaryView *summaryview)
 {
        GtkCTree *ctree = GTK_CTREE(widget);
        GtkCTreeNode *node;
@@ -4427,28 +4434,6 @@ static gboolean summary_key_pressed(GtkWidget *widget, GdkEventKey *event,
        case GDK_Escape:
                gtk_widget_grab_focus(summaryview->folderview->ctree);
                return TRUE;
-       case GDK_Up:
-       case GDK_Down:
-               if ((node = summaryview->selected) != NULL) {
-                       GtkCTreeNode *next = NULL;
-                       do {
-                               next = (event->keyval == GDK_Down)
-                                       ? gtkut_ctree_node_next(ctree, next ? next:node)
-                                       : gtkut_ctree_node_prev(ctree, next ? next:node);
-                       } while (next && !gtk_ctree_is_viewable(ctree, next));
-
-                       if (next) {
-                               gtk_sctree_select_with_state
-                                       (GTK_SCTREE(ctree), next, event->state);
-                               
-                               /* Deprecated - what are the non-deprecated equivalents? */
-                               if (gtk_ctree_node_is_visible(GTK_CTREE(ctree), next) != GTK_VISIBILITY_FULL)
-                                       gtk_ctree_node_moveto(GTK_CTREE(ctree), next, 0, 0, 0);
-                               summaryview->selected = next;
-                               return TRUE;
-                       }
-               }
-               break;
        case GDK_Home:
        case GDK_End:
                if ((node = summaryview->selected) != NULL) {
@@ -4465,10 +4450,9 @@ static gboolean summary_key_pressed(GtkWidget *widget, GdkEventKey *event,
                                if (gtk_ctree_node_is_visible(GTK_CTREE(ctree), next) != GTK_VISIBILITY_FULL)
                                        gtk_ctree_node_moveto(GTK_CTREE(ctree), next, 0, 0, 0);
                                summaryview->selected = next;
-                               return TRUE;
                        }
                }
-               break;
+               return TRUE;
        default:
                break;
        }
@@ -4484,6 +4468,9 @@ static gboolean summary_key_pressed(GtkWidget *widget, GdkEventKey *event,
        messageview = summaryview->messageview;
        textview = messageview->mimeview->textview;
 
+       mod_pressed =
+               ((event->state & (GDK_SHIFT_MASK|GDK_MOD1_MASK)) != 0);
+
        switch (event->keyval) {
        case GDK_space:         /* Page down or go to the next */
                if (event->state & GDK_SHIFT_MASK) 
@@ -4494,8 +4481,6 @@ static gboolean summary_key_pressed(GtkWidget *widget, GdkEventKey *event,
                                                    summaryview->selected);
                                break;
                        }
-                       mod_pressed = ((event->state & 
-                                       (GDK_SHIFT_MASK|GDK_MOD1_MASK)) != 0);
                        if (mod_pressed) {
                                if (!textview_scroll_page(textview, TRUE))
                                        summary_select_prev_unread(summaryview);
@@ -4514,9 +4499,7 @@ static gboolean summary_key_pressed(GtkWidget *widget, GdkEventKey *event,
                                            summaryview->selected);
                        break;
                }
-               textview_scroll_one_line
-                       (textview, (event->state &
-                                   (GDK_SHIFT_MASK|GDK_MOD1_MASK)) != 0);
+               textview_scroll_one_line(textview, mod_pressed);
                break;
        case GDK_Delete:
                BREAK_ON_MODIFIER_KEY();
@@ -4683,17 +4666,12 @@ static void summary_reply_cb(SummaryView *summaryview, guint action,
 {
        MessageView *msgview = (MessageView*)summaryview->messageview;
        GSList *msginfo_list;
-       gchar *body;
 
        g_return_if_fail(msgview != NULL);
 
        msginfo_list = summary_get_selection(summaryview);
        g_return_if_fail(msginfo_list != NULL);
-
-       body = messageview_get_selection(msgview);
-
-       compose_reply_mode((ComposeMode)action, msginfo_list, body);
-       g_free(body);
+       compose_reply_from_messageview(msgview, msginfo_list, action);
        g_slist_free(msginfo_list);
 }