#include "imap.h"
#include "addressbook.h"
#include "addr_compl.h"
-#include "scoring.h"
#include "folder_item_prefs.h"
#include "filtering.h"
#include "string_match.h"
#include "matcher_parser.h"
#include "hooks.h"
#include "description_window.h"
-#include "folder.h"
+#include "folderutils.h"
#define SUMMARY_COL_MARK_WIDTH 10
#define SUMMARY_COL_STATUS_WIDTH 13
GtkCTreeNode *row,
FolderItem *to_folder);
-static void summary_delete_duplicated_func
- (GtkCTree *ctree,
- GtkCTreeNode *node,
- SummaryView *summaryview);
-
static void summary_execute_move (SummaryView *summaryview);
static void summary_execute_move_func (GtkCTree *ctree,
GtkCTreeNode *node,
static void summary_create_filter_cb (SummaryView *summaryview,
guint action,
GtkWidget *widget);
+static void summary_create_processing_cb(SummaryView *summaryview,
+ guint action,
+ GtkWidget *widget);
static void summary_mark_clicked (GtkWidget *button,
SummaryView *summaryview);
NULL, summary_create_filter_cb, FILTER_BY_TO, NULL},
{N_("/Create f_ilter rule/by _Subject"),
NULL, summary_create_filter_cb, FILTER_BY_SUBJECT, NULL},
+ {N_("/Create processing rule"), NULL, NULL, 0, "<Branch>"},
+ {N_("/Create processing rule/_Automatically"),
+ NULL, summary_create_processing_cb, FILTER_BY_AUTO, NULL},
+ {N_("/Create processing rule/by _From"),
+ NULL, summary_create_processing_cb, FILTER_BY_FROM, NULL},
+ {N_("/Create processing rule/by _To"),
+ NULL, summary_create_processing_cb, FILTER_BY_TO, NULL},
+ {N_("/Create processing rule/by _Subject"),
+ NULL, summary_create_processing_cb, FILTER_BY_SUBJECT, NULL},
{N_("/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_View"), NULL, NULL, 0, "<Branch>"},
{N_("/_View/Open in new _window"),
*/
static gchar *search_descr_strings[] = {
"a", N_("all messages"),
- "ag #", N_("messages whose age is greather than #"),
- "al #", N_("messages whose age is greather than #"),
+ "ag #", N_("messages whose age is greater than #"),
+ "al #", N_("messages whose age is less than #"),
"b S", N_("messages which contain S in the message body"),
"B S", N_("messages which contain S in the whole message"),
"c S", N_("messages carbon-copied to S"),
"T", N_("marked messages"),
"U", N_("unread messages"),
"x S", N_("messages which contain S in References header"),
+ "X cmd", N_("messages returning 0 when passed to command"),
"y S", N_("messages which contain S in X-Label header"),
"", "" ,
"&", N_("logical AND operator"),
(gtk_widget_get_style(summaryview->ctree));
if (!smallfont)
smallfont = gtkut_font_load(SMALL_FONT);
- small_style->font = smallfont;
+ if (smallfont)
+ small_style->font = smallfont;
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;
+
+ gtk_widget_set_style(summaryview->ctree, small_style);
}
style = gtk_style_copy(gtk_widget_get_style
}
+#if 0
GtkCTreeNode * summary_find_next_important_score(SummaryView *summaryview,
GtkCTreeNode *current_node)
{
else
return best_node;
}
+#endif
#define CURRENTLY_DISPLAYED(m) \
( (m->msgnum == displayed_msgnum) \
guint selected_msgnum = 0;
guint displayed_msgnum = 0;
GSList *cur;
+ GSList *not_killed;
if (summary_is_locked(summaryview)) return FALSE;
summary_set_column_titles(summaryview);
buf = NULL;
- if (!item || !item->path || !item->parent || item->no_select) {
+ if (!item || !item->path || !folder_item_parent(item) || item->no_select) {
g_free(buf);
debug_print("empty folder\n\n");
summary_set_hide_read_msgs_menu(summaryview, FALSE);
BY OTHER PROGRAMS TO THE FOLDER
*/
mlist = folder_item_get_msg_list(item);
-#if 0
- summary_processing(summaryview, mlist);
-#endif
- for(cur = mlist ; cur != NULL ; cur = g_slist_next(cur)) {
- MsgInfo * msginfo = (MsgInfo *) cur->data;
-
- msginfo->score = score_message(global_scoring, msginfo);
- if (msginfo->score != MAX_SCORE &&
- msginfo->score != MIN_SCORE) {
- msginfo->score += score_message(item->prefs->scoring,
- msginfo);
- }
- }
if (summaryview->folder_item->hide_read_msgs) {
GSList *not_killed;
g_slist_free(mlist);
mlist = not_killed;
}
-
+
+#if 0
if ((global_scoring || item->prefs->scoring)) {
GSList *not_killed;
gint kill_score;
g_slist_free(mlist);
mlist = not_killed;
}
+#endif
+ not_killed = NULL;
+ for(cur = mlist ; cur != NULL ; cur = g_slist_next(cur)) {
+ MsgInfo * msginfo = (MsgInfo *) cur->data;
+
+ if (!msginfo->hidden)
+ not_killed = g_slist_prepend(not_killed, msginfo);
+ else
+ procmsg_msginfo_free(msginfo);
+ }
+ g_slist_free(mlist);
+ mlist = not_killed;
STATUSBAR_POP(summaryview->mainwin);
}
} else {
/* select first unread message */
+#if 0
if (summaryview->sort_key == SORT_BY_SCORE)
node = summary_find_next_important_score(summaryview,
NULL);
else
+#endif
node = summary_find_next_flagged_msg(summaryview, NULL,
MSG_UNREAD, FALSE);
if (node == NULL && GTK_CLIST(ctree)->row_list != NULL) {
if (prefs_common.open_unread_on_enter ||
prefs_common.always_show_msg) {
summary_unlock(summaryview);
- summary_select_node(summaryview, node, TRUE, TRUE);
+ summary_select_node(summaryview, node,
+ messageview_is_visible(summaryview->messageview),
+ TRUE);
summary_lock(summaryview);
} else
summary_select_node(summaryview, node, FALSE, TRUE);
{"/Add sender to address book" , M_SINGLE_TARGET_EXIST},
{"/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
+ {"/Create processing rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
{"/View" , M_SINGLE_TARGET_EXIST},
{"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
menuitem = gtk_item_factory_get_widget(ifactory, "/View/All header");
gtk_check_menu_item_set_active
(GTK_CHECK_MENU_ITEM(menuitem),
- summaryview->messageview->textview->show_all_headers);
+ summaryview->messageview->mimeview->textview->show_all_headers);
summary_unlock(summaryview);
}
msginfo = gtk_ctree_node_get_row_data(ctree, node);
- if (MSG_IS_NEWS(msginfo->flags))
+ if (msginfo->folder && msginfo->folder->folder &&
+ msginfo->folder->folder->klass->type == F_NEWS)
news_flag_crosspost(msginfo);
if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags)
cmp_func = (GtkCListCompareFunc)summary_cmp_by_locked;
break;
case SORT_BY_NONE:
- cmp_func = NULL;
- return;
+ break;
default:
return;
}
summary_set_column_titles(summaryview);
summary_set_menu_sensitive(summaryview);
+
+ /* allow fallback to don't sort */
+ if (summaryview->sort_key == SORT_BY_NONE)
+ return;
+
if(cmp_func != NULL) {
debug_print("Sorting summary...");
STATUSBAR_PUSH(summaryview->mainwin, _("Sorting summary..."));
text[col_pos[S_COL_FROM]] = msginfo->fromname ? msginfo->fromname :
_("(No From)");
- if (prefs_common.swap_from && msginfo->from && msginfo->to &&
- !MSG_IS_NEWS(msginfo->flags)) {
+ if (prefs_common.swap_from && msginfo->from && msginfo->to) {
gchar *addr = NULL;
Xstrdup_a(addr, msginfo->from, return);
GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
MsgInfo *msginfo;
MsgFlags flags;
+ gint val;
if (!new_window) {
if (summaryview->displayed == row)
msginfo = gtk_ctree_node_get_row_data(ctree, row);
- if (new_window || !prefs_common.mark_as_read_on_new_window) {
- if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags)
- && procmsg_msg_has_marked_parent(msginfo))
- summaryview->unreadmarked--;
- if (MSG_IS_NEW(msginfo->flags) || MSG_IS_UNREAD(msginfo->flags)) {
- procmsg_msginfo_unset_flags
- (msginfo, MSG_NEW | MSG_UNREAD, 0);
- summary_set_row_marks(summaryview, row);
- gtk_clist_thaw(GTK_CLIST(ctree));
- summary_status_show(summaryview);
-
- flags = msginfo->flags;
- }
- }
-
if (new_window) {
MessageView *msgview;
msgview = messageview_create_with_new_window(summaryview->mainwin);
- messageview_show(msgview, msginfo, all_headers);
+ val = messageview_show(msgview, msginfo, all_headers);
} else {
MessageView *msgview;
summaryview->displayed = row;
if (!messageview_is_visible(msgview))
main_window_toggle_message_view(summaryview->mainwin);
- messageview_show(msgview, msginfo, all_headers);
- if (msgview->type == MVIEW_TEXT ||
- (msgview->type == MVIEW_MIME &&
- (GTK_CLIST(msgview->mimeview->ctree)->row_list == NULL ||
- gtk_notebook_get_current_page
- (GTK_NOTEBOOK(msgview->mimeview->notebook)) == 0)))
+ 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);
}
+ if (val == 0 &&
+ (new_window || !prefs_common.mark_as_read_on_new_window)) {
+ if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags)
+ && procmsg_msg_has_marked_parent(msginfo))
+ summaryview->unreadmarked--;
+ if (MSG_IS_NEW(msginfo->flags) || MSG_IS_UNREAD(msginfo->flags)) {
+ procmsg_msginfo_unset_flags
+ (msginfo, MSG_NEW | MSG_UNREAD, 0);
+ summary_set_row_marks(summaryview, row);
+ gtk_clist_thaw(GTK_CLIST(ctree));
+ summary_status_show(summaryview);
+
+ flags = msginfo->flags;
+ }
+ }
+
summary_set_menu_sensitive(summaryview);
toolbar_main_set_sensitive(summaryview->mainwin);
}
gtk_ctree_node_set_foreground
(ctree, row, &summaryview->color_marked);
+#if 0
} else if ((global_scoring ||
summaryview->folder_item->prefs->scoring) &&
(msginfo->score >= summaryview->important_score) &&
gtk_ctree_node_set_text(ctree, row, S_COL_MARK, "!");
gtk_ctree_node_set_foreground(ctree, row,
&summaryview->color_important);
+#endif
} else {
gtk_ctree_node_set_text(ctree, row, col_pos[S_COL_MARK], NULL);
}
} else {
gtk_ctree_node_set_text(ctree, row, col_pos[S_COL_MIME], NULL);
}
- if (!style)
+ if (!style)
style = small_style;
gtk_ctree_node_set_row_style(ctree, row, style);
&& procmsg_msg_has_marked_parent(msginfo))
summaryview->unreadmarked++;
- procmsg_msginfo_unset_flags(msginfo, MSG_REPLIED | MSG_FORWARDED, 0);
procmsg_msginfo_set_flags(msginfo, MSG_UNREAD, 0);
debug_print("Message %d is marked as unread\n",
msginfo->msgnum);
GtkCTreeNode *node;
if (!item) return;
-#if 0
- if (!item || item->folder->type == F_NEWS) return;
-#endif
if (summary_is_locked(summaryview)) return;
main_window_cursor_normal(summaryview->mainwin);
}
-void summary_delete_duplicated(SummaryView *summaryview)
-{
- if (!summaryview->folder_item ||
- FOLDER_TYPE(summaryview->folder_item->folder) == F_NEWS) return;
- if (summaryview->folder_item->stype == F_TRASH) return;
-
- main_window_cursor_wait(summaryview->mainwin);
- debug_print("Deleting duplicated messages...");
- STATUSBAR_PUSH(summaryview->mainwin,
- _("Deleting duplicated messages..."));
-
- folder_item_update_freeze();
-
- gtk_ctree_pre_recursive(GTK_CTREE(summaryview->ctree), NULL,
- GTK_CTREE_FUNC(summary_delete_duplicated_func),
- summaryview);
-
- if (prefs_common.immediate_exec)
- summary_execute(summaryview);
- else
- summary_status_show(summaryview);
-
- folder_item_update_thaw();
-
- debug_print("done.\n");
- STATUSBAR_POP(summaryview->mainwin);
- main_window_cursor_normal(summaryview->mainwin);
-}
-
-static void summary_delete_duplicated_func(GtkCTree *ctree, GtkCTreeNode *node,
- SummaryView *summaryview)
-{
- GtkCTreeNode *found;
- MsgInfo *msginfo;
- MsgInfo *dup_msginfo;
-
- msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
-
- if (!msginfo || !msginfo->msgid || !*msginfo->msgid) return;
-
- found = g_hash_table_lookup(summaryview->msgid_table, msginfo->msgid);
-
- if (found && found != node) {
- dup_msginfo = gtk_ctree_node_get_row_data(ctree, found);
- /* prefer to delete the unread one */
- if ((MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_UNREAD(dup_msginfo->flags))
- || (MSG_IS_UNREAD(msginfo->flags) == MSG_IS_UNREAD(dup_msginfo->flags)))
- summary_delete_row(summaryview, node);
- }
-}
-
static void summary_unmark_row(SummaryView *summaryview, GtkCTreeNode *row)
{
GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
void summary_filter(SummaryView *summaryview)
{
- if (!global_processing) {
+ if (!filtering_rules) {
alertpanel_error(_("No filter rules defined."));
return;
}
gtk_clist_freeze(GTK_CLIST(summaryview->ctree));
- if (global_processing == NULL) {
+ if (filtering_rules == NULL) {
gtk_ctree_pre_recursive(GTK_CTREE(summaryview->ctree), NULL,
GTK_CTREE_FUNC(summary_filter_func),
summaryview);
* CLAWS: summary_show() only valid after having a lock. ideally
* we want the lock to be context aware...
*/
- if (global_processing) {
+ if (filtering_rules) {
summary_show(summaryview, summaryview->folder_item);
}
}
{
MsgInfo *msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
- filter_message_by_msginfo(global_processing, msginfo);
+ filter_message_by_msginfo(filtering_rules, msginfo);
}
-void summary_filter_open(SummaryView *summaryview, PrefsFilterType type)
+void summary_msginfo_filter_open(FolderItem * item, MsgInfo *msginfo,
+ PrefsFilterType type, gint processing_rule)
{
- MsgInfo *msginfo;
gchar *header = NULL;
gchar *key = NULL;
+ procmsg_get_filter_keyword(msginfo, &header, &key, type);
+
+ if (processing_rule) {
+ if (item == NULL)
+ prefs_filtering_open(&pre_global_processing,
+ _("Processing rules to apply before folder rules"),
+ header, key);
+ else
+ prefs_filtering_open(&item->prefs->processing,
+ _("Processing configuration"),
+ header, key);
+ }
+ else {
+ prefs_filtering_open(&filtering_rules,
+ _("Filtering configuration"),
+ header, key);
+ }
+
+ g_free(header);
+ g_free(key);
+}
+
+void summary_filter_open(SummaryView *summaryview, PrefsFilterType type,
+ gint processing_rule)
+{
+ MsgInfo *msginfo;
+ FolderItem * item;
+
if (!summaryview->selected) return;
msginfo = gtk_ctree_node_get_row_data(GTK_CTREE(summaryview->ctree),
summaryview->selected);
if (!msginfo) return;
-
- procmsg_get_filter_keyword(msginfo, &header, &key, type);
- prefs_filtering_open(NULL, header, key);
-
- g_free(header);
- g_free(key);
+
+ item = summaryview->folder_item;
+ summary_msginfo_filter_open(item, msginfo, type, processing_rule);
}
/* color label */
GtkCTreeNode *node;
MessageView *messageview;
TextView *textview;
+ GtkAdjustment *adj;
if (summary_is_locked(summaryview)) return TRUE;
if (!event) return TRUE;
switch (event->keyval) {
case GDK_Left: /* Move focus */
+ adj = gtk_scrolled_window_get_hadjustment
+ (GTK_SCROLLED_WINDOW(summaryview->scrolledwin));
+ if (adj->lower != adj->value)
+ break;
+ /* FALLTHROUGH */
case GDK_Escape:
gtk_widget_grab_focus(summaryview->folderview->ctree);
return TRUE;
}
messageview = summaryview->messageview;
- if (messageview->type == MVIEW_MIME &&
- gtk_notebook_get_current_page
- (GTK_NOTEBOOK(messageview->mimeview->notebook)) == 1)
- textview = messageview->mimeview->textview;
- else
- textview = messageview->textview;
+ textview = messageview->mimeview->textview;
switch (event->keyval) {
case GDK_space: /* Page down or go to the next */
textview_scroll_one_line
(textview, (event->state & GDK_MOD1_MASK) != 0);
break;
- case GDK_asterisk: /* Mark */
- summary_mark(summaryview);
- break;
- case GDK_exclam: /* Mark as unread */
- summary_mark_as_unread(summaryview);
- break;
case GDK_Delete:
BREAK_ON_MODIFIER_KEY();
summary_delete(summaryview);
static void summary_create_filter_cb(SummaryView *summaryview,
guint action, GtkWidget *widget)
{
- summary_filter_open(summaryview, (PrefsFilterType)action);
+ summary_filter_open(summaryview, (PrefsFilterType)action, 0);
+}
+
+static void summary_create_processing_cb(SummaryView *summaryview,
+ guint action, GtkWidget *widget)
+{
+ summary_filter_open(summaryview, (PrefsFilterType)action, 1);
}
static void summary_sort_by_column_click(SummaryView *summaryview,
#undef CMP_FUNC_DEF
-static gint summary_cmp_by_subject(GtkCList *clist, \
- gconstpointer ptr1, \
- gconstpointer ptr2) \
-{ \
- MsgInfo *msginfo1 = ((GtkCListRow *)ptr1)->data; \
- MsgInfo *msginfo2 = ((GtkCListRow *)ptr2)->data; \
- \
- if (!msginfo1->subject) \
- return (msginfo2->subject != NULL); \
- if (!msginfo2->subject) \
- return -1; \
- \
- return subject_compare_for_sort \
- (msginfo1->subject, msginfo2->subject); \
+static gint summary_cmp_by_subject(GtkCList *clist,
+ gconstpointer ptr1,
+ gconstpointer ptr2)
+{
+ MsgInfo *msginfo1 = ((GtkCListRow *)ptr1)->data;
+ MsgInfo *msginfo2 = ((GtkCListRow *)ptr2)->data;
+
+ if (!msginfo1->subject)
+ return (msginfo2->subject != NULL);
+ if (!msginfo2->subject)
+ return -1;
+
+ return subject_compare_for_sort
+ (msginfo1->subject, msginfo2->subject);
}
- static gint summary_cmp_by_from(GtkCList *clist, gconstpointer ptr1,
- gconstpointer ptr2)
- {
+static gint summary_cmp_by_from(GtkCList *clist, gconstpointer ptr1,
+ gconstpointer ptr2)
+{
const gchar *str1, *str2;
const GtkCListRow *r1 = (const GtkCListRow *) ptr1;
const GtkCListRow *r2 = (const GtkCListRow *) ptr2;
return -1;
return strcasecmp(str1, str2);
- }
+}
- static gint summary_cmp_by_simplified_subject
+static gint summary_cmp_by_simplified_subject
(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
{
const FolderItemPrefs *prefs;
if (!prefs)
return -1;
- return strcasecmp(str1, str2);
+ return subject_compare_for_sort(str1, str2);
}
static gint summary_cmp_by_score(GtkCList *clist,
GString *line;
gpointer key;
gpointer value;
- Folder *mff = msginfo->folder->folder;
+ Folder *mff;
+
+ g_return_if_fail(msginfo != NULL);
+ g_return_if_fail(msginfo->folder != NULL);
+ g_return_if_fail(msginfo->folder->folder != NULL);
+ mff = msginfo->folder->folder;
+ g_return_if_fail(mff->klass->type == F_NEWS);
- if (mff->account->mark_crosspost_read && MSG_IS_NEWS(msginfo->flags)) {
+ if (mff->account->mark_crosspost_read) {
line = g_string_sized_new(128);
g_string_sprintf(line, "%s:%d", msginfo->folder->path, msginfo->msgnum);
debug_print("nfcp: checking <%s>", line->str);
folderview_unselect(summaryview->folderview);
folderview_select(summaryview->folderview, summaryview->folder_item);
+ summary_set_column_titles(summaryview);
}
/*
summaryview->thread_collapsed = item->thread_collapsed;
/* Scoring */
+#if 0
if (global_scoring || item->prefs->scoring) {
summaryview->important_score = prefs_common.important_score;
if (item->prefs->important_score >
summaryview->important_score =
item->prefs->important_score;
}
+#endif
}
void summary_save_prefs_to_folderitem(SummaryView *summaryview, FolderItem *item)