add 'Re-edit' to the message context menu in the Drafts folder
[claws.git] / src / summaryview.c
index 96016b9d0c9247e26ae9d2d8bc488c1536179479..d10ef7888b81575a58ffc0b722e8278dcfde7217 100644 (file)
@@ -420,12 +420,14 @@ GtkTargetEntry summary_drag_types[3] =
        {"claws-mail/msg-path-list", 0, TARGET_MAIL_CM_PATH_LIST},
 };
 
+static void summary_reedit_cb(GtkAction *gaction, gpointer data);
 static void summary_reply_cb(GtkAction *gaction, gpointer data);
 
 /* Only submenus and specifically-handled menu entries here */
 static GtkActionEntry summary_popup_entries[] =
 {
        {"SummaryViewPopup",                      NULL, "SummaryViewPopup", NULL, NULL, NULL },
+       {"SummaryViewPopup/Reedit",               NULL, N_("Re-edit"), NULL, NULL, G_CALLBACK(summary_reedit_cb) },
        {"SummaryViewPopup/Reply",                NULL, N_("_Reply"), NULL, NULL, G_CALLBACK(summary_reply_cb) }, /* COMPOSE_REPLY */
        {"SummaryViewPopup/ReplyTo",              NULL, N_("Repl_y to"), NULL, NULL, NULL },
        {"SummaryViewPopup/ReplyTo/All",          NULL, N_("_All"), NULL, NULL, G_CALLBACK(summary_reply_cb) }, /* COMPOSE_REPLY_TO_ALL */
@@ -710,6 +712,7 @@ SummaryView *summary_create(MainWindow *mainwin)
                        G_N_ELEMENTS(summary_popup_entries), (gpointer)summaryview);
 
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus", "SummaryViewPopup", "SummaryViewPopup", GTK_UI_MANAGER_MENU)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/SummaryViewPopup", "Reedit", "SummaryViewPopup/Reedit", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/SummaryViewPopup", "Reply", "SummaryViewPopup/Reply", GTK_UI_MANAGER_MENUITEM)
 #ifndef GENERIC_UMPC
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menus/SummaryViewPopup", "ReplyTo", "SummaryViewPopup/ReplyTo", GTK_UI_MANAGER_MENU)
@@ -1511,52 +1514,43 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
 
        g_slist_free(mlist);
 
-       if (is_refresh) {
-               if (!quicksearch_is_in_typing(summaryview->quicksearch)) {
-                       summaryview->displayed =
-                               summary_find_msg_by_msgnum(summaryview,
-                                                          displayed_msgnum);
-                       if (!summaryview->displayed)
-                               messageview_clear(summaryview->messageview);
+       if (quicksearch_is_in_typing(summaryview->quicksearch) ||
+           quicksearch_is_running(summaryview->quicksearch)) {
+               summaryview->displayed =
+                       summary_find_msg_by_msgnum(summaryview,
+                                                  displayed_msgnum);
+               if (!summaryview->displayed)
+                       messageview_clear(summaryview->messageview);
+               summary_unlock(summaryview);
+
+               if (quicksearch_is_running(summaryview->quicksearch))
+                       summary_select_by_msgnum(summaryview, selected_msgnum,
+                                       OPEN_SELECTED_ON_SEARCH_RESULTS);
+               else
+                       summary_select_by_msgnum(summaryview, selected_msgnum,
+                                       FALSE);
+
+               summary_lock(summaryview);
+               if (!summaryview->selected) {
+                       /* no selected message - select first unread
+                          message, but do not display it */
+                       node = summary_find_next_flagged_msg(summaryview, NULL,
+                                                            MSG_UNREAD, FALSE);
+                       if (node == NULL && GTK_CMCLIST(ctree)->row_list != NULL)
+                               node = gtk_cmctree_node_nth
+                                       (ctree,
+                                        item->sort_type == SORT_DESCENDING
+                                        ? 0 : GTK_CMCLIST(ctree)->rows - 1);
                        summary_unlock(summaryview);
 
                        if (quicksearch_is_running(summaryview->quicksearch))
-                               summary_select_by_msgnum(summaryview, selected_msgnum,
+                               summary_select_node(summaryview, node,
                                                OPEN_SELECTED_ON_SEARCH_RESULTS);
                        else
-                               summary_select_by_msgnum(summaryview, selected_msgnum,
-                                               FALSE);
+                               summary_select_node(summaryview, node,
+                                               OPEN_SELECTED_ON_FOLDER_OPEN);
 
                        summary_lock(summaryview);
-                       if (!summaryview->selected) {
-                               /* no selected message - select first unread
-                                  message, but do not display it */
-                               node = summary_find_next_flagged_msg(summaryview, NULL,
-                                                                    MSG_UNREAD, FALSE);
-                               if (node == NULL && GTK_CMCLIST(ctree)->row_list != NULL)
-                                       node = gtk_cmctree_node_nth
-                                               (ctree,
-                                                item->sort_type == SORT_DESCENDING
-                                                ? 0 : GTK_CMCLIST(ctree)->rows - 1);
-                               summary_unlock(summaryview);
-
-                               if (quicksearch_is_running(summaryview->quicksearch))
-                                       summary_select_node(summaryview, node,
-                                                       OPEN_SELECTED_ON_SEARCH_RESULTS);
-                               else
-                                       summary_select_node(summaryview, node,
-                                                       OPEN_SELECTED_ON_FOLDER_OPEN);
-
-                               summary_lock(summaryview);
-                       }
-               } else {
-                       /* just select first/last */
-                       if (GTK_CMCLIST(ctree)->row_list != NULL)
-                               node = gtk_cmctree_node_nth
-                                       (ctree,
-                                        item->sort_type == SORT_DESCENDING
-                                        ? 0 : GTK_CMCLIST(ctree)->rows - 1);
-                       summary_select_node(summaryview, node, OPEN_SELECTED_ON_SEARCH_RESULTS);
                }
        } else {
                /* backward compat */
@@ -1662,12 +1656,10 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
 
                if (node) {
                        gint open_selected = -1;
-                       if (!is_refresh) {
-                               if (OPEN_SELECTED_ON_FOLDER_OPEN)
-                                       open_selected = 1;
-                               else
-                                       open_selected = 0;
-                       }
+                       if (OPEN_SELECTED_ON_FOLDER_OPEN)
+                               open_selected = 1;
+                       else
+                               open_selected = 0;
                        summary_select_node(summaryview, node, open_selected);
                }
 
@@ -1827,9 +1819,9 @@ void summary_set_menu_sensitive(SummaryView *summaryview)
        gint i;
 
 #ifndef GENERIC_UMPC
-#define N_ENTRIES 39
+#define N_ENTRIES 40
 #else
-#define N_ENTRIES 28
+#define N_ENTRIES 29
 #endif
        static struct {
                const gchar *entry;
@@ -1842,6 +1834,7 @@ do { \
        entry[i].entry = (const gchar *) entry_str; entry[i++].cond = main_window_get_mask(__VA_ARGS__, -1); \
 } while (0)
 
+       FILL_TABLE("Menus/SummaryViewPopup/Reedit", M_TARGET_EXIST, M_DRAFT);
        FILL_TABLE("Menus/SummaryViewPopup/Reply", M_HAVE_ACCOUNT, M_TARGET_EXIST);
 #ifndef GENERIC_UMPC
        FILL_TABLE("Menus/SummaryViewPopup/ReplyTo", M_HAVE_ACCOUNT, M_TARGET_EXIST);
@@ -3430,7 +3423,7 @@ static inline void summary_set_header(SummaryView *summaryview, gchar *text[],
        static gchar date_modified[80];
        static gchar col_score[11];
        static gchar from_buf[BUFFSIZE], to_buf[BUFFSIZE];
-       static gchar tmp1[BUFFSIZE], tmp2[BUFFSIZE], tmp3[BUFFSIZE];
+       static gchar tmp1[BUFFSIZE], tmp2[BUFFSIZE+4], tmp3[BUFFSIZE];
        gint *col_pos = summaryview->col_pos;
        gchar *from_text = NULL, *to_text = NULL, *tags_text = NULL;
        gboolean should_swap = FALSE;
@@ -3576,7 +3569,7 @@ static inline void summary_set_header(SummaryView *summaryview, gchar *text[],
                                to_text = to_text ? to_text : _("(No From)");
                        }
                }
-               snprintf(tmp2, BUFFSIZE-1, "➜ %s", to_text);
+               snprintf(tmp2, BUFFSIZE+4, "➜ %s", to_text);
                tmp2[BUFFSIZE-1]='\0';
                text[col_pos[S_COL_FROM]] = tmp2;
        }
@@ -8532,6 +8525,12 @@ void summaryview_unlock(SummaryView *summaryview, FolderItem *item)
        gtk_widget_set_sensitive(summaryview->ctree, TRUE);
 }
 
+static void summary_reedit_cb(GtkAction *gaction, gpointer data)
+{
+       SummaryView *summaryview = (SummaryView *)data;
+       summary_reedit(summaryview);
+}
+
 #define DO_ACTION(name, act)   { if (!strcmp(a_name, name)) action = act; }
 static void summary_reply_cb(GtkAction *gaction, gpointer data)
 {