#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"
#define SUMMARY_COL_MARK_WIDTH 10
#define SUMMARY_COL_STATUS_WIDTH 13
#define SUMMARY_COL_LOCKED_WIDTH 13
#define SUMMARY_COL_MIME_WIDTH 11
+
static GtkStyle *bold_style;
static GtkStyle *bold_marked_style;
static GtkStyle *bold_deleted_style;
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"),
void summary_init(SummaryView *summaryview)
{
+ static GdkFont *boldfont = NULL;
+ static GdkFont *smallfont = NULL;
GtkStyle *style;
GtkWidget *pixmap;
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);
}
+#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_clear_list(summaryview);
summary_set_column_titles(summaryview);
- if (!is_refresh)
- messageview_clear(summaryview->messageview);
buf = NULL;
if (!item || !item->path || !item->parent || item->no_select) {
g_free(buf);
debug_print("empty folder\n\n");
summary_set_hide_read_msgs_menu(summaryview, FALSE);
- if (is_refresh)
- messageview_clear(summaryview->messageview);
summary_clear_all(summaryview);
summaryview->folder_item = item;
gtk_clist_thaw(GTK_CLIST(ctree));
}
g_free(buf);
+ if (!is_refresh)
+ messageview_clear(summaryview->messageview);
+
summaryview->folder_item = item;
item->opened = TRUE;
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;
if (strlen(gtk_entry_get_text(GTK_ENTRY(summaryview->search_string))) > 0) {
GSList *not_killed;
- gint search_type = GPOINTER_TO_INT(gtk_object_get_user_data(
+ gint search_type = GPOINTER_TO_INT(g_object_get_data(
GTK_OBJECT(GTK_MENU_ITEM(gtk_menu_get_active(
- GTK_MENU(summaryview->search_type))))));
+ GTK_MENU(summaryview->search_type)))), MENU_VAL_ID));
const gchar *search_string = gtk_entry_get_text(GTK_ENTRY(summaryview->search_string));
gchar *searched_header = NULL;
MatcherList * tmp_list = NULL;
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);
void summary_clear_all(SummaryView *summaryview)
{
+ messageview_clear(summaryview->messageview);
summary_clear_list(summaryview);
summary_set_menu_sensitive(summaryview);
toolbar_main_set_sensitive(summaryview->mainwin);
{"/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..."));
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);
void summary_open_msg(SummaryView *summaryview)
{
if (!summaryview->selected) return;
-
+
+ /* CLAWS: if separate message view, don't open a new window
+ * but rather use the current separated message view */
summary_display_msg_full(summaryview, summaryview->selected,
- TRUE, FALSE);
+ prefs_common.sep_msg ? FALSE : TRUE,
+ FALSE);
}
void summary_view_source(SummaryView * summaryview)
}
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);
GtkCTreeNode *node;
if (!item) return;
-#if 0
- if (!item || item->folder->type == F_NEWS) return;
-#endif
if (summary_is_locked(summaryview)) return;
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 */
#define BREAK_ON_MODIFIER_KEY() \
if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
-#define RETURN_IF_LOCKED() \
- if (summaryview->mainwin->lock_count) return TRUE
-
static gboolean summary_key_pressed(GtkWidget *widget, GdkEventKey *event,
- SummaryView *summaryview)
+ SummaryView *summaryview)
{
GtkCTree *ctree = GTK_CTREE(widget);
GtkCTreeNode *node;
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;
+ next = (event->keyval == GDK_Down)
+ ? gtkut_ctree_node_next(ctree, node)
+ : gtkut_ctree_node_prev(ctree, node);
+ if (next) {
+ gtk_sctree_select(GTK_SCTREE(ctree), next);
+ return TRUE;
+ }
+ }
+ break;
default:
break;
}
}
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:
- RETURN_IF_LOCKED();
BREAK_ON_MODIFIER_KEY();
summary_delete(summaryview);
break;
static void summary_searchtype_changed(GtkMenuItem *widget, gpointer data)
{
SummaryView *sw = (SummaryView *)data;
- prefs_common.summary_quicksearch_type = GPOINTER_TO_INT(gtk_object_get_user_data(
+ prefs_common.summary_quicksearch_type = GPOINTER_TO_INT(g_object_get_data(
GTK_OBJECT(GTK_MENU_ITEM(gtk_menu_get_active(
- GTK_MENU(sw->search_type))))));
+ GTK_MENU(sw->search_type)))), MENU_VAL_ID));
/* Show extended search description button, only when Extended is selected */
if (prefs_common.summary_quicksearch_type == S_SEARCH_EXTENDED) {
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,
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);
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)