#include "gtkutils.h"
#include "prefs_common.h"
#include "prefs_account.h"
+#include "prefs_filter.h"
+#include "prefs_filtering.h"
+#include "prefs_scoring.h"
+#include "prefs_folder_item.h"
#include "account.h"
#include "folder.h"
#include "inc.h"
static GtkStyle *bold_color_style;
static GtkStyle *bold_tgtfold_style;
-static GdkPixmap *inboxxpm;
+static GdkBitmap *inboxxpm;
static GdkBitmap *inboxxpmmask;
static GdkPixmap *inboxhrmxpm;
static GdkBitmap *inboxhrmxpmmask;
+static GdkPixmap *inboxopenxpm;
+static GdkBitmap *inboxopenxpmmask;
+static GdkPixmap *inboxopenhrmxpm;
+static GdkBitmap *inboxopenhrmxpmmask;
static GdkPixmap *outboxxpm;
static GdkBitmap *outboxxpmmask;
static GdkPixmap *outboxhrmxpm;
static GdkBitmap *outboxhrmxpmmask;
+static GdkPixmap *outboxopenxpm;
+static GdkBitmap *outboxopenxpmmask;
+static GdkPixmap *outboxopenhrmxpm;
+static GdkBitmap *outboxopenhrmxpmmask;
static GdkPixmap *folderxpm;
static GdkBitmap *folderxpmmask;
+static GdkPixmap *folderhrmxpm;
+static GdkBitmap *folderhrmxpmmask;
static GdkPixmap *folderopenxpm;
static GdkBitmap *folderopenxpmmask;
static GdkPixmap *folderopenhrmxpm;
static GdkBitmap *folderopenhrmxpmmask;
+static GdkPixmap *trashopenxpm;
+static GdkBitmap *trashopenxpmmask;
+static GdkPixmap *trashopenhrmxpm;
+static GdkBitmap *trashopenhrmxpmmask;
static GdkPixmap *trashxpm;
static GdkBitmap *trashxpmmask;
static GdkPixmap *trashhrmxpm;
static GdkBitmap *trashhrmxpmmask;
+static GdkPixmap *queuexpm;
+static GdkBitmap *queuexpmmask;
+static GdkPixmap *queuehrmxpm;
+static GdkBitmap *queuehrmxpmmask;
+static GdkPixmap *queueopenxpm;
+static GdkBitmap *queueopenxpmmask;
+static GdkPixmap *queueopenhrmxpm;
+static GdkBitmap *queueopenhrmxpmmask;
static GdkPixmap *newxpm;
static GdkBitmap *newxpmmask;
static GdkPixmap *unreadxpm;
GtkCTreeNode *node,
const gchar *name);
+static gint folderview_clist_compare (GtkCList *clist,
+ gconstpointer ptr1,
+ gconstpointer ptr2);
static gint folderview_compare_name (gconstpointer a,
gconstpointer b);
guint action,
GtkWidget *widget);
+static void mark_all_read_cb (FolderView *folderview,
+ guint action,
+ GtkWidget *widget);
static void folderview_new_folder_cb (FolderView *folderview,
guint action,
GtkWidget *widget);
static void folderview_new_imap_folder_cb(FolderView *folderview,
guint action,
GtkWidget *widget);
-static void folderview_rm_imap_folder_cb (FolderView *folderview,
- guint action,
- GtkWidget *widget);
static void folderview_rm_imap_server_cb (FolderView *folderview,
guint action,
GtkWidget *widget);
guint action,
GtkWidget *widget);
+static void folderview_property_cb (FolderView *folderview,
+ guint action,
+ GtkWidget *widget);
+
static gboolean folderview_drag_motion_cb(GtkWidget *widget,
GdkDragContext *context,
gint x,
GtkWidget *widget);
static void folderview_processing_cb(FolderView *folderview, guint action,
GtkWidget *widget);
-static void folderview_property_cb(FolderView *folderview, guint action, GtkWidget *widget);
static GtkItemFactoryEntry folderview_mbox_popup_entries[] =
{
static GtkItemFactoryEntry folderview_mail_popup_entries[] =
{
+ {N_("/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
+ {N_("/---"), NULL, NULL, 0, "<Separator>"},
{N_("/Create _new folder..."), NULL, folderview_new_folder_cb, 0, NULL},
{N_("/_Rename folder..."), NULL, folderview_rename_folder_cb, 0, NULL},
{N_("/_Delete folder"), NULL, folderview_delete_folder_cb, 0, NULL},
static GtkItemFactoryEntry folderview_imap_popup_entries[] =
{
+ {N_("/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
+ {N_("/---"), NULL, NULL, 0, "<Separator>"},
{N_("/Create _new folder..."), NULL, folderview_new_imap_folder_cb, 0, NULL},
- {N_("/_Rename folder..."), NULL, NULL, 0, NULL},
- {N_("/_Delete folder"), NULL, folderview_rm_imap_folder_cb, 0, NULL},
+ {N_("/_Rename folder..."), NULL, folderview_rename_folder_cb, 0, NULL},
+ {N_("/_Delete folder"), NULL, folderview_delete_folder_cb, 0, NULL},
{N_("/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Check for new messages"),
NULL, folderview_update_tree_cb, 0, NULL},
{N_("/Remove _IMAP4 account"), NULL, folderview_rm_imap_server_cb, 0, NULL},
{N_("/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Search folder..."), NULL, folderview_search_cb, 0, NULL},
- {N_("/_Property..."), NULL, NULL, 0, NULL},
+ {N_("/_Property..."), NULL, folderview_property_cb, 0, NULL},
{N_("/_Processing..."), NULL, folderview_processing_cb, 0, NULL},
{N_("/S_coring..."), NULL, folderview_scoring_cb, 0, NULL}
};
static GtkItemFactoryEntry folderview_news_popup_entries[] =
{
+ {N_("/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
+ {N_("/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Subscribe to newsgroup..."),
NULL, folderview_new_news_group_cb, 0, NULL},
{N_("/_Remove newsgroup"), NULL, folderview_rm_news_group_cb, 0, NULL},
{N_("/Remove _news account"), NULL, folderview_rm_news_server_cb, 0, NULL},
{N_("/---"), NULL, NULL, 0, "<Separator>"},
{N_("/_Search folder..."), NULL, folderview_search_cb, 0, NULL},
- {N_("/_Property..."), NULL, NULL, 0, NULL},
+ {N_("/_Property..."), NULL, folderview_property_cb, 0, NULL},
{N_("/_Processing..."), NULL, folderview_processing_cb, 0, NULL},
{N_("/S_coring..."), NULL, folderview_scoring_cb, 0, NULL}
};
FolderView *folderview;
GtkWidget *scrolledwin;
GtkWidget *ctree;
- gchar *titles[N_FOLDER_COLS] = {_("Folder"), _("New"),
- _("Unread"), _("#")};
+ gchar *titles[N_FOLDER_COLS];
GtkWidget *mail_popup;
GtkWidget *news_popup;
GtkWidget *imap_popup;
debug_print(_("Creating folder view...\n"));
folderview = g_new0(FolderView, 1);
+ titles[COL_FOLDER] = _("Folder");
+ titles[COL_NEW] = _("New");
+ titles[COL_UNREAD] = _("Unread");
+ titles[COL_TOTAL] = _("#");
+
scrolledwin = gtk_scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_ALWAYS);
+ gtk_scrolled_window_set_policy
+ (GTK_SCROLLED_WINDOW(scrolledwin),
+ GTK_POLICY_AUTOMATIC,
+ prefs_common.folderview_vscrollbar_policy);
gtk_widget_set_usize(scrolledwin,
prefs_common.folderview_width,
prefs_common.folderview_height);
gtk_ctree_set_expander_style(GTK_CTREE(ctree),
GTK_CTREE_EXPANDER_SQUARE);
gtk_ctree_set_indent(GTK_CTREE(ctree), CTREE_INDENT);
+ gtk_clist_set_compare_func(GTK_CLIST(ctree), folderview_clist_compare);
/* don't let title buttons take key focus */
for (i = 0; i < N_FOLDER_COLS; i++)
GtkWidget *hbox_new;
GtkWidget *hbox_unread;
- stock_pixmap_gdk(ctree, STOCK_PIXMAP_INBOX, &inboxxpm, &inboxxpmmask);
- stock_pixmap_gdk(ctree, STOCK_PIXMAP_OUTBOX,
- &outboxxpm, &outboxxpmmask);
- stock_pixmap_gdk(ctree, STOCK_PIXMAP_DIR_CLOSE,
- &folderxpm, &folderxpmmask);
- stock_pixmap_gdk(ctree, STOCK_PIXMAP_DIR_OPEN,
- &folderopenxpm, &folderopenxpmmask);
- stock_pixmap_gdk(ctree, STOCK_PIXMAP_TRASH, &trashxpm, &trashxpmmask);
- stock_pixmap_gdk(ctree, STOCK_PIXMAP_INBOX_HRM,
- &inboxhrmxpm, &inboxhrmxpmmask);
- stock_pixmap_gdk(ctree, STOCK_PIXMAP_OUTBOX_HRM,
- &outboxhrmxpm, &outboxhrmxpmmask);
- stock_pixmap_gdk(ctree, STOCK_PIXMAP_DIR_OPEN_HRM,
- &folderopenhrmxpm, &folderopenhrmxpmmask);
- stock_pixmap_gdk(ctree, STOCK_PIXMAP_TRASH_HRM,
- &trashhrmxpm, &trashhrmxpmmask);
+ stock_pixmap_gdk(ctree, STOCK_PIXMAP_INBOX_CLOSE, &inboxxpm, &inboxxpmmask);
+ stock_pixmap_gdk(ctree, STOCK_PIXMAP_INBOX_CLOSE_HRM, &inboxhrmxpm, &inboxhrmxpmmask);
+ stock_pixmap_gdk(ctree, STOCK_PIXMAP_INBOX_OPEN, &inboxopenxpm, &inboxopenxpmmask);
+ stock_pixmap_gdk(ctree, STOCK_PIXMAP_INBOX_OPEN_HRM, &inboxopenhrmxpm, &inboxopenhrmxpmmask);
+ stock_pixmap_gdk(ctree, STOCK_PIXMAP_OUTBOX_CLOSE, &outboxxpm, &outboxxpmmask);
+ stock_pixmap_gdk(ctree, STOCK_PIXMAP_OUTBOX_CLOSE_HRM, &outboxhrmxpm, &outboxhrmxpmmask);
+ stock_pixmap_gdk(ctree, STOCK_PIXMAP_OUTBOX_OPEN, &outboxopenxpm, &outboxopenxpmmask);
+ stock_pixmap_gdk(ctree, STOCK_PIXMAP_OUTBOX_OPEN_HRM, &outboxopenhrmxpm, &outboxopenhrmxpmmask);
+ stock_pixmap_gdk(ctree, STOCK_PIXMAP_DIR_CLOSE, &folderxpm, &folderxpmmask);
+ stock_pixmap_gdk(ctree, STOCK_PIXMAP_DIR_CLOSE_HRM, &folderhrmxpm, &folderhrmxpmmask);
+ stock_pixmap_gdk(ctree, STOCK_PIXMAP_DIR_OPEN, &folderopenxpm, &folderopenxpmmask);
+ stock_pixmap_gdk(ctree, STOCK_PIXMAP_DIR_OPEN_HRM, &folderopenhrmxpm, &folderopenhrmxpmmask);
+ stock_pixmap_gdk(ctree, STOCK_PIXMAP_TRASH_OPEN, &trashopenxpm, &trashopenxpmmask);
+ stock_pixmap_gdk(ctree, STOCK_PIXMAP_TRASH_OPEN_HRM, &trashopenhrmxpm, &trashopenhrmxpmmask);
+ stock_pixmap_gdk(ctree, STOCK_PIXMAP_TRASH_CLOSE, &trashxpm, &trashxpmmask);
+ stock_pixmap_gdk(ctree, STOCK_PIXMAP_TRASH_CLOSE_HRM, &trashhrmxpm, &trashhrmxpmmask);
+ stock_pixmap_gdk(ctree, STOCK_PIXMAP_QUEUE_CLOSE, &queuexpm, &queuexpmmask);
+ stock_pixmap_gdk(ctree, STOCK_PIXMAP_QUEUE_CLOSE_HRM, &queuehrmxpm, &queuehrmxpmmask);
+ stock_pixmap_gdk(ctree, STOCK_PIXMAP_QUEUE_OPEN, &queueopenxpm, &queueopenxpmmask);
+ stock_pixmap_gdk(ctree, STOCK_PIXMAP_QUEUE_OPEN_HRM, &queueopenhrmxpm, &queueopenhrmxpmmask);
/* CLAWS: titles for "New" and "Unread" show new & unread pixmaps
* instead text (text overflows making them unreadable and ugly) */
folder_update_op_count();
}
+static void mark_all_read_cb(FolderView *folderview, guint action,
+ GtkWidget *widget)
+{
+ if (folderview->selected)
+ summary_mark_all_read(folderview->summaryview);
+}
+
static void folderview_select_node(FolderView *folderview, GtkCTreeNode *node)
{
GtkCTree *ctree = GTK_CTREE(folderview->ctree);
folderview_select_node(folderview, node);
}
-void folderview_update_msg_num(FolderView *folderview, GtkCTreeNode *row,
- gint new, gint unread, gint total)
+void folderview_update_msg_num(FolderView *folderview, GtkCTreeNode *row)
{
GtkCTree *ctree = GTK_CTREE(folderview->ctree);
static GtkCTreeNode *prev_row = NULL;
FolderItem *item;
+ gint new, unread, total;
+ gchar *new_str, *unread_str, *total_str;
if (!row) return;
item = gtk_ctree_node_get_row_data(ctree, row);
if (!item) return;
+ gtk_ctree_node_get_text(ctree, row, COL_NEW, &new_str);
+ gtk_ctree_node_get_text(ctree, row, COL_UNREAD, &unread_str);
+ gtk_ctree_node_get_text(ctree, row, COL_TOTAL, &total_str);
+ new = atoi(new_str);
+ unread = atoi(unread_str);
+ total = atoi(total_str);
+
/* CLAWS: don't know why but this always seems to be true
* when deleting messages. Somewhere claws does a folder
* scan which sets all new, unread & total to the correct
if (prev_row == row &&
item->new == new &&
item->unread == unread &&
- item->total == total)
+ item->total == total)
return;
#endif
prev_row = row;
- item->new = new;
- item->unread = unread;
- item->total = total;
-
folderview_update_node(folderview, row);
}
return window;
}
-void folderview_update_tree(Folder *folder)
+void folderview_rescan_tree(Folder *folder)
{
GtkWidget *window;
folder_write_list();
folderview_set_all();
+ folderview_check_new(folder);
+
gtk_widget_destroy(window);
inc_unlock();
}
-void folderview_update_all(void)
+void folderview_rescan_all(void)
{
GList *list;
GtkWidget *window;
for (; list != NULL; list = list->next) {
Folder *folder = list->data;
- if (!folder->scan_tree) continue;
folder_set_ui_func(folder, folderview_scan_tree_func, NULL);
folder->scan_tree(folder);
folder_set_ui_func(folder, NULL, NULL);
folder_write_list();
folderview_set_all();
+
+ list = folder_get_list();
+ for (; list != NULL; list = list->next) {
+ Folder *folder = list->data;
+
+ folderview_check_new(folder);
+ }
+
gtk_widget_destroy(window);
inc_unlock();
}
-void folderview_update_all_node(void)
+void folderview_check_new(Folder *folder)
{
GList *list;
FolderItem *item;
for (node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list);
node != NULL; node = gtkut_ctree_node_next(ctree, node)) {
item = gtk_ctree_node_get_row_data(ctree, node);
- if (!item || !FOLDER_IS_LOCAL(item->folder) ||
- !item->path)
- continue;
+ if (!item || !item->path || !item->folder) continue;
+ if (item->no_select) continue;
+ if (folder && folder != item->folder) continue;
+ if (!folder && !FOLDER_IS_LOCAL(item->folder)) continue;
+
folderview_scan_tree_func(item->folder, item, NULL);
- folder_item_scan(item);
+ if (folder_item_scan(item) < 0) {
+ if (folder && !FOLDER_IS_LOCAL(folder))
+ break;
+ }
folderview_update_node(folderview, node);
}
switch (item->stype) {
case F_INBOX:
- xpm = inboxxpm;
- mask = inboxxpmmask;
if (item->hide_read_msgs) {
- openxpm = inboxhrmxpm;
- openmask = inboxhrmxpmmask;
+ xpm = inboxhrmxpm;
+ mask = inboxhrmxpmmask;
+ openxpm = inboxopenhrmxpm;
+ openmask = inboxopenhrmxpmmask;
} else {
- openxpm = inboxxpm;
- openmask = inboxxpmmask;
+ xpm = inboxxpm;
+ mask = inboxxpmmask;
+ openxpm = inboxopenxpm;
+ openmask = inboxopenxpmmask;
}
- name = g_strdup(_("Inbox"));
+ name = g_strdup(FOLDER_IS_LOCAL(item->folder) &&
+ !strcmp2(item->name, INBOX_DIR) ? _("Inbox") :
+ item->name);
break;
case F_OUTBOX:
- xpm = outboxxpm;
- mask =outboxxpmmask;
if (item->hide_read_msgs) {
- openxpm = outboxhrmxpm;
- openmask = outboxhrmxpmmask;
+ xpm = outboxhrmxpm;
+ mask = outboxhrmxpmmask;
+ openxpm = outboxopenhrmxpm;
+ openmask = outboxopenhrmxpmmask;
} else {
- openxpm = outboxxpm;
- openmask = outboxxpmmask;
+ xpm = outboxxpm;
+ mask = outboxxpmmask;
+ openxpm = outboxopenxpm;
+ openmask = outboxopenxpmmask;
}
- name = g_strdup(_("Outbox"));
+ name = g_strdup(FOLDER_IS_LOCAL(item->folder) &&
+ !strcmp2(item->name, OUTBOX_DIR) ? _("Sent") :
+ item->name);
break;
case F_QUEUE:
- xpm = outboxxpm;
- mask =outboxxpmmask;
if (item->hide_read_msgs) {
- openxpm = outboxhrmxpm;
- openmask = outboxhrmxpmmask;
+ xpm = queuehrmxpm;
+ mask = queuehrmxpmmask;
+ openxpm = queueopenhrmxpm;
+ openmask = queueopenhrmxpmmask;
} else {
- openxpm = outboxxpm;
- openmask = outboxxpmmask;
+ xpm = queuexpm;
+ mask = queuexpmmask;
+ openxpm = queueopenxpm;
+ openmask = queueopenxpmmask;
}
- name = g_strdup(_("Queue"));
+ name = g_strdup(FOLDER_IS_LOCAL(item->folder) &&
+ !strcmp2(item->name, QUEUE_DIR) ? _("Queue") :
+ item->name);
break;
case F_TRASH:
- xpm = trashxpm;
- mask = trashxpmmask;
if (item->hide_read_msgs) {
- openxpm = trashhrmxpm;
- openmask = trashhrmxpmmask;
+ xpm = trashhrmxpm;
+ mask = trashhrmxpmmask;
+ openxpm = trashopenhrmxpm;
+ openmask = trashopenhrmxpmmask;
} else {
- openxpm = trashxpm;
- openmask = trashxpmmask;
+ xpm = trashxpm;
+ mask = trashxpmmask;
+ openxpm = trashopenxpm;
+ openmask = trashopenxpmmask;
}
- name = g_strdup(_("Trash"));
+ name = g_strdup(FOLDER_IS_LOCAL(item->folder) &&
+ !strcmp2(item->name, TRASH_DIR) ? _("Trash") :
+ item->name);
break;
case F_DRAFT:
xpm = folderxpm;
openxpm = folderopenxpm;
openmask = folderopenxpmmask;
}
- name = g_strdup(_("Draft"));
+ name = g_strdup(FOLDER_IS_LOCAL(item->folder) &&
+ !strcmp2(item->name, DRAFT_DIR) ? _("Drafts") :
+ item->name);
break;
default:
- xpm = folderxpm;
- mask = folderxpmmask;
if (item->hide_read_msgs) {
+ xpm = folderhrmxpm;
+ mask = folderhrmxpmmask;
openxpm = folderopenhrmxpm;
openmask = folderopenhrmxpmmask;
} else {
+ xpm = folderxpm;
+ mask = folderxpmmask;
openxpm = folderopenxpm;
openmask = folderopenxpmmask;
}
name = "";
}
name = g_strconcat(item->name, name, NULL);
- } else
- name = g_strdup(item->name);
+ } else {
+ if (item->folder->type == F_NEWS &&
+ item->path &&
+ !strcmp2(item->name, item->path) &&
+ prefs_common.ng_abbrev_len < strlen(item->path))
+ name = get_abbrev_newsgroup_name(item->path);
+ else
+ name = g_strdup(item->name);
+ }
}
if (!GTK_CTREE_ROW(node)->expanded &&
gtk_ctree_node_set_text(ctree, node, COL_TOTAL, itos(item->total));
}
- if (item->stype == F_TRASH)
+ if (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
+ item->stype == F_TRASH) {
use_bold = use_color = FALSE;
- if (item->stype == F_QUEUE) {
+ } else if (item->stype == F_QUEUE) {
/* highlight queue folder if there are any messages */
use_bold = use_color = (item->total > 0);
} else {
#define SET_SPECIAL_FOLDER(ctree, item) \
{ \
if (item) { \
- GtkCTreeNode *node, *sibling; \
+ GtkCTreeNode *node, *parent, *sibling; \
\
node = gtk_ctree_find_by_row_data(ctree, root, item); \
if (!node) \
g_warning("%s not found.\n", item->path); \
else { \
- if (!prev) \
- sibling = GTK_CTREE_ROW(root)->children; \
- else \
+ parent = GTK_CTREE_ROW(node)->parent; \
+ if (prev && parent == GTK_CTREE_ROW(prev)->parent) \
sibling = GTK_CTREE_ROW(prev)->sibling; \
+ else \
+ sibling = GTK_CTREE_ROW(parent)->children; \
if (node != sibling) \
- gtk_ctree_move(ctree, node, root, sibling); \
+ gtk_ctree_move(ctree, node, parent, sibling); \
} \
\
prev = node; \
folderview_rename_mbox_folder_cb(folderview, 0, NULL);
case F_MH:
case F_MAILDIR:
+ case F_IMAP:
folderview_rename_folder_cb(folderview, 0, NULL);
break;
- case F_IMAP:
case F_NEWS:
default:
break;
case F_MH:
case F_MBOX:
case F_MAILDIR:
+ case F_IMAP:
folderview_delete_folder_cb(folderview, 0, NULL);
break;
- case F_IMAP:
- folderview_rm_imap_folder_cb(folderview, 0, NULL);
case F_NEWS:
default:
break;
FolderItem *item;
Folder *folder;
GtkWidget *popup;
+ gboolean mark_all_read = FALSE;
gboolean new_folder = FALSE;
gboolean rename_folder = FALSE;
gboolean delete_folder = FALSE;
gboolean update_tree = FALSE;
gboolean rescan_tree = FALSE;
gboolean remove_tree = FALSE;
+ gboolean search_folder = FALSE;
gboolean folder_property = FALSE;
gboolean folder_processing = FALSE;
gboolean folder_scoring = FALSE;
- gboolean search_folder = FALSE;
if (!event) return;
if (item->parent == NULL)
update_tree = remove_tree = TRUE;
else
- search_folder = TRUE;
+ mark_all_read = search_folder = folder_property = TRUE;
if (FOLDER_IS_LOCAL(folder) || FOLDER_TYPE(folder) == F_IMAP || FOLDER_TYPE(folder) == F_MBOX) {
if (item->parent == NULL)
update_tree = rescan_tree = TRUE;
else if (item->stype == F_NORMAL)
- rename_folder = delete_folder = folder_property = folder_scoring = folder_processing = TRUE;
+ rename_folder = delete_folder = folder_scoring = folder_processing = TRUE;
else if (item->stype == F_INBOX)
- folder_property = folder_scoring = folder_processing = TRUE;
+ folder_scoring = folder_processing = TRUE;
else if (item->stype == F_TRASH)
folder_processing = TRUE;
else if (item->stype == F_OUTBOX)
if (item->parent != NULL)
delete_folder = folder_scoring = folder_processing = TRUE;
}
+ if (item->unread < 1)
+ mark_all_read = FALSE;
}
#define SET_SENS(factory, name, sens) \
menu_set_sensitive(folderview->factory, name, sens)
+
+ mark_all_read = mark_all_read &&
+ (item == folderview->summaryview->folder_item);
if (FOLDER_IS_LOCAL(folder)) {
popup = folderview->mail_popup;
menu_set_insensitive_all(GTK_MENU_SHELL(popup));
+ SET_SENS(mail_factory, "/Mark all read", mark_all_read);
SET_SENS(mail_factory, "/Create new folder...", new_folder);
SET_SENS(mail_factory, "/Rename folder...", rename_folder);
SET_SENS(mail_factory, "/Delete folder", delete_folder);
SET_SENS(mail_factory, "/Check for new messages", update_tree);
SET_SENS(mail_factory, "/Rescan folder tree", rescan_tree);
SET_SENS(mail_factory, "/Remove mailbox", remove_tree);
+ SET_SENS(mail_factory, "/Search folder...", search_folder);
SET_SENS(mail_factory, "/Property...", folder_property);
SET_SENS(mail_factory, "/Processing...", folder_processing);
SET_SENS(mail_factory, "/Scoring...", folder_scoring);
- SET_SENS(mail_factory, "/Search folder...", search_folder);
} else if (FOLDER_TYPE(folder) == F_IMAP) {
popup = folderview->imap_popup;
menu_set_insensitive_all(GTK_MENU_SHELL(popup));
+ SET_SENS(imap_factory, "/Mark all read", mark_all_read);
SET_SENS(imap_factory, "/Create new folder...", new_folder);
SET_SENS(imap_factory, "/Rename folder...", rename_folder);
SET_SENS(imap_factory, "/Delete folder", delete_folder);
SET_SENS(imap_factory, "/Check for new messages", update_tree);
SET_SENS(imap_factory, "/Rescan folder tree", rescan_tree);
SET_SENS(imap_factory, "/Remove IMAP4 account", remove_tree);
+ SET_SENS(imap_factory, "/Search folder...", search_folder);
+ SET_SENS(imap_factory, "/Property...", folder_property);
SET_SENS(imap_factory, "/Processing...", folder_processing);
SET_SENS(imap_factory, "/Scoring...", folder_scoring);
- SET_SENS(imap_factory, "/Search folder...", search_folder);
} else if (FOLDER_TYPE(folder) == F_NEWS) {
popup = folderview->news_popup;
menu_set_insensitive_all(GTK_MENU_SHELL(popup));
+ SET_SENS(news_factory, "/Mark all read", mark_all_read);
SET_SENS(news_factory, "/Subscribe to newsgroup...", new_folder);
SET_SENS(news_factory, "/Remove newsgroup", delete_folder);
#if 0
#endif
SET_SENS(news_factory, "/Remove news account", remove_tree);
SET_SENS(news_factory, "/Search folder...", search_folder);
+ SET_SENS(news_factory, "/Property...", folder_property);
SET_SENS(news_factory, "/Processing...", folder_processing);
SET_SENS(news_factory, "/Scoring...", folder_scoring);
} else if (FOLDER_TYPE(folder) == F_MBOX) {
SET_SENS(mbox_factory, "/Create new folder...", new_folder);
SET_SENS(mbox_factory, "/Rename folder...", rename_folder);
SET_SENS(mbox_factory, "/Delete folder", delete_folder);
+ SET_SENS(news_factory, "/Property...", folder_property);
SET_SENS(mbox_factory, "/Processing...", folder_processing);
SET_SENS(mbox_factory, "/Scoring...", folder_scoring);
} else
}
}
-#define BREAK_ON_MODIFIER_KEY() \
- if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
-
static void folderview_key_pressed(GtkWidget *widget, GdkEventKey *event,
FolderView *folderview)
{
folderview->selected);
}
break;
- case GDK_v:
- case GDK_V:
- case GDK_g:
- case GDK_G:
- case GDK_x:
- case GDK_X:
- case GDK_w:
- case GDK_D:
- case GDK_Q:
- BREAK_ON_MODIFIER_KEY();
- summary_pass_key_press_event(folderview->summaryview, event);
default:
+ break;
}
}
return;
}
- if (!can_select) {
+ if (!can_select || summary_is_locked(folderview->summaryview)) {
gtkut_ctree_set_focus_row(ctree, folderview->opened);
gtk_ctree_select(ctree, folderview->opened);
return;
(folderview->mainwin,
item->folder->type == F_NEWS ?
COMPOSEBUTTON_NEWS : COMPOSEBUTTON_MAIL);
-
+
if (item->path)
debug_print(_("Folder %s is selected\n"), item->path);
gdk_pointer_ungrab(GDK_CURRENT_TIME);
}
+ if((item->folder->type == F_IMAP) || (item->folder->type == F_NEWS)) {
+ folder_item_scan(item);
+ }
+
opened = summary_show(folderview->summaryview, item, FALSE);
+ folder_clean_cache_memory();
+
if (!opened) {
gtkut_ctree_set_focus_row(ctree, folderview->opened);
gtk_ctree_select(ctree, folderview->opened);
- } else
+ } else {
folderview->opened = row;
+ if (gtk_ctree_node_is_visible(ctree, row)
+ != GTK_VISIBILITY_FULL)
+ gtk_ctree_node_moveto(ctree, row, -1, 0.5, 0);
+ }
folderview->open_folder = FALSE;
can_select = TRUE;
prefs_common.folder_col_total = width;
break;
default:
+ break;
}
}
g_return_if_fail(item->folder != NULL);
if (action == 0)
- folderview_update_all_node();
+ folderview_check_new(item->folder);
else
- folderview_update_tree(item->folder);
+ folderview_rescan_tree(item->folder);
}
static void folderview_new_folder_cb(FolderView *folderview, guint action,
FolderItem *item;
FolderItem *new_item;
gchar *new_folder;
+ gchar *name, *name_;
GtkCTreeNode *node;
if (!folderview->selected) return;
}
}
+ name_ = trim_string(new_folder, 32);
+ Xstrdup_a(name, name_, {g_free(new_folder); return;});
+ g_free(name_);
+
/* find whether the directory already exists */
if (folderview_find_by_name(ctree, folderview->selected, new_folder)) {
- alertpanel_error(_("The folder `%s' already exists."),
- new_folder);
+ alertpanel_error(_("The folder `%s' already exists."), name);
g_free(new_folder);
return;
}
new_item = item->folder->create_folder(item->folder, item, new_folder);
if (!new_item) {
- alertpanel_error(_("The folder `%s' could not be created."),
- new_folder);
+ alertpanel_error(_("Can't create the folder `%s'."), name);
g_free(new_folder);
return;
}
GtkCTree *ctree = GTK_CTREE(folderview->ctree);
FolderItem *item;
gchar *new_folder;
+ gchar *name, *name_;
gchar *message;
+ gchar *old_path;
+ gchar *old_id;
+ gchar *new_id;
if (!folderview->selected) return;
g_return_if_fail(item->path != NULL);
g_return_if_fail(item->folder != NULL);
- message = g_strdup_printf(_("Input new name for `%s':"),
- g_basename(item->path));
+ name_ = trim_string(item->name, 32);
+ Xstrdup_a(name, name_, return);
+ g_free(name_);
+ message = g_strdup_printf(_("Input new name for `%s':"), name);
new_folder = input_dialog(_("Rename folder"), message,
g_basename(item->path));
g_free(message);
if (folderview_find_by_name
(ctree, GTK_CTREE_ROW(folderview->selected)->parent,
new_folder)) {
- alertpanel_error(_("The folder `%s' already exists."),
- new_folder);
+ name = trim_string(new_folder, 32);
+ alertpanel_error(_("The folder `%s' already exists."), name);
+ g_free(name);
g_free(new_folder);
return;
}
+ Xstrdup_a(old_path, item->path, {g_free(new_folder); return;});
+ old_id = folder_item_get_identifier(item);
+
if (item->folder->rename_folder(item->folder, item, new_folder) < 0) {
+ g_free(old_id);
g_free(new_folder);
return;
}
g_free(new_folder);
+ if (prefs_common.fltlist) {
+ if (folder_get_default_folder() == item->folder)
+ prefs_filter_rename_path(old_path, item->path);
+ new_id = folder_item_get_identifier(item);
+ prefs_filter_rename_path(old_id, new_id);
+ } else {
+ if (FOLDER_TYPE(item->folder) == F_MH)
+ prefs_filtering_rename_path(old_path, item->path);
+ new_id = folder_item_get_identifier(item);
+ prefs_filtering_rename_path(old_id, new_id);
+ }
+ g_free(old_id);
+ g_free(new_id);
+
gtk_clist_freeze(GTK_CLIST(ctree));
folderview_update_node(folderview, folderview->selected);
folderview_sort_folders(folderview,
GTK_CTREE_ROW(folderview->selected)->parent,
item->folder);
- if (folderview->opened == folderview->selected) {
- if (!GTK_CTREE_ROW(folderview->opened)->children)
- gtk_ctree_expand(ctree, folderview->opened);
- summary_show(folderview->summaryview, item, FALSE);
+ if (folderview->opened == folderview->selected ||
+ gtk_ctree_is_ancestor(ctree,
+ folderview->selected,
+ folderview->opened)) {
+ GtkCTreeNode *node = folderview->opened;
+ folderview_unselect(folderview);
+ folderview_select_node(folderview, node);
}
gtk_clist_thaw(GTK_CLIST(ctree));
{
GtkCTree *ctree = GTK_CTREE(folderview->ctree);
FolderItem *item;
- gchar *message;
+ gchar *message, *name, *name_;
AlertValue avalue;
+ gchar *old_path;
+ gchar *old_id;
if (!folderview->selected) return;
g_return_if_fail(item->path != NULL);
g_return_if_fail(item->folder != NULL);
+ name_ = trim_string(item->name, 32);
+ Xstrdup_a(name, name_, return);
+ g_free(name_);
message = g_strdup_printf
(_("All folder(s) and message(s) under `%s' will be deleted.\n"
- "Do you really want to delete?"),
- g_basename(item->path));
+ "Do you really want to delete?"), name);
avalue = alertpanel(_("Delete folder"), message,
_("Yes"), _("+No"), NULL);
g_free(message);
if (avalue != G_ALERTDEFAULT) return;
+ Xstrdup_a(old_path, item->path, return);
+ old_id = folder_item_get_identifier(item);
+
if (item->folder->remove_folder(item->folder, item) < 0) {
- alertpanel_error(_("Can't remove the folder `%s'."),
- item->path);
+ alertpanel_error(_("Can't remove the folder `%s'."), name);
+ if (folderview->opened == folderview->selected)
+ summary_show(folderview->summaryview,
+ folderview->summaryview->folder_item,
+ FALSE);
+ g_free(old_id);
return;
}
+ if (prefs_common.fltlist) {
+ if (folder_get_default_folder() == item->folder)
+ prefs_filter_delete_path(old_path);
+ prefs_filter_delete_path(old_id);
+ g_free(old_id);
+ } else {
+ if (FOLDER_TYPE(item->folder) == F_MH)
+ prefs_filtering_delete_path(old_path);
+ prefs_filtering_delete_path(old_id);
+ g_free(old_id);
+ }
if (folderview->opened == folderview->selected ||
gtk_ctree_is_ancestor(ctree,
folderview->selected,
GtkCTree *ctree = GTK_CTREE(folderview->ctree);
GtkCTreeNode *node;
FolderItem *item;
+ gchar *name, *name_;
gchar *message;
AlertValue avalue;
g_return_if_fail(item->folder != NULL);
if (item->parent) return;
+ name_ = trim_string(item->folder->name, 32);
+ Xstrdup_a(name, name_, return);
+ g_free(name_);
message = g_strdup_printf
(_("Really remove the mailbox `%s' ?\n"
- "(The messages are NOT deleted from disk)"),
- item->folder->name);
- avalue = alertpanel(_("Remove folder"), message,
+ "(The messages are NOT deleted from the disk)"), name);
+ avalue = alertpanel(_("Remove mailbox"), message,
_("Yes"), _("+No"), NULL);
g_free(message);
if (avalue != G_ALERTDEFAULT) return;
FolderItem *item;
FolderItem *new_item;
gchar *new_folder;
+ gchar *name, *name_;
gchar *p;
if (!folderview->selected) return;
return;
}
+ name_ = trim_string(new_folder, 32);
+ Xstrdup_a(name, name_, return);
+ g_free(name_);
+
/* find whether the directory already exists */
if (folderview_find_by_name(ctree, folderview->selected, new_folder)) {
- alertpanel_error(_("The folder `%s' already exists."),
- new_folder);
+ alertpanel_error(_("The folder `%s' already exists."), name);
g_free(new_folder);
return;
}
new_item = item->folder->create_folder(item->folder, item, new_folder);
if (!new_item) {
- alertpanel_error(_("Can't create the folder `%s'."),
- new_folder);
+ alertpanel_error(_("Can't create the folder `%s'."), name);
g_free(new_folder);
return;
}
folder_write_list();
}
-static void folderview_rm_imap_folder_cb(FolderView *folderview, guint action,
- GtkWidget *widget)
-{
- GtkCTree *ctree = GTK_CTREE(folderview->ctree);
- FolderItem *item;
- gchar *message;
- AlertValue avalue;
-
- if (!folderview->selected) return;
-
- item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
- g_return_if_fail(item != NULL);
- g_return_if_fail(item->folder != NULL);
- g_return_if_fail(item->folder->type == F_IMAP);
- g_return_if_fail(item->folder->account != NULL);
-
- message = g_strdup_printf(_("Really delete folder `%s'?"),
- g_basename(item->path));
- avalue = alertpanel(_("Delete folder"), message,
- _("Yes"), _("+No"), NULL);
- g_free(message);
- if (avalue != G_ALERTDEFAULT) return;
-
- if (item->folder->remove_folder(item->folder, item) < 0) {
- alertpanel_error(_("Can't remove the folder `%s'."),
- item->path);
- if (folderview->opened == folderview->selected)
- summary_show(folderview->summaryview,
- folderview->summaryview->folder_item,
- FALSE);
- return;
- }
-
- if (folderview->opened == folderview->selected ||
- gtk_ctree_is_ancestor(ctree,
- folderview->selected,
- folderview->opened)) {
- summary_clear_all(folderview->summaryview);
- folderview->opened = NULL;
- }
-
- gtk_ctree_remove_node(ctree, folderview->selected);
- folder_write_list();
-}
-
static void folderview_rm_imap_server_cb(FolderView *folderview, guint action,
GtkWidget *widget)
{
GtkCTree *ctree = GTK_CTREE(folderview->ctree);
FolderItem *item;
+ gchar *name, *name_;
gchar *message;
AlertValue avalue;
g_return_if_fail(item->folder->type == F_IMAP);
g_return_if_fail(item->folder->account != NULL);
- message = g_strdup_printf(_("Really delete IMAP4 account `%s'?"),
- item->folder->name);
+ name_ = trim_string(item->folder->name, 32);
+ Xstrdup_a(name, name_, return);
+ g_free(name_);
+ message = g_strdup_printf(_("Really delete IMAP4 account `%s'?"), name);
avalue = alertpanel(_("Delete IMAP4 account"), message,
_("Yes"), _("+No"), NULL);
g_free(message);
gtk_ctree_node_set_row_data(ctree, node, newitem);
}
- gtk_ctree_sort_node(ctree, servernode);
+ folderview_sort_folders(folderview, servernode, folder);
gtk_clist_thaw(GTK_CLIST(ctree));
slist_free_strings(new_subscr);
{
GtkCTree *ctree = GTK_CTREE(folderview->ctree);
FolderItem *item;
+ gchar *name, *name_;
gchar *message;
AlertValue avalue;
g_return_if_fail(item->folder->type == F_NEWS);
g_return_if_fail(item->folder->account != NULL);
- message = g_strdup_printf(_("Really delete newsgroup `%s'?"),
- g_basename(item->path));
+ name_ = trim_string(item->path, 32);
+ Xstrdup_a(name, name_, return);
+ g_free(name_);
+ message = g_strdup_printf(_("Really delete newsgroup `%s'?"), name);
avalue = alertpanel(_("Delete newsgroup"), message,
_("Yes"), _("+No"), NULL);
g_free(message);
{
GtkCTree *ctree = GTK_CTREE(folderview->ctree);
FolderItem *item;
+ gchar *name, *name_;
gchar *message;
AlertValue avalue;
g_return_if_fail(item->folder->type == F_NEWS);
g_return_if_fail(item->folder->account != NULL);
- message = g_strdup_printf(_("Really delete news account `%s'?"),
- item->folder->name);
+ name_ = trim_string(item->folder->name, 32);
+ Xstrdup_a(name, name_, return);
+ g_free(name_);
+ message = g_strdup_printf(_("Really delete news account `%s'?"), name);
avalue = alertpanel(_("Delete news account"), message,
_("Yes"), _("+No"), NULL);
g_free(message);
summary_search(folderview->summaryview);
}
+static void folderview_property_cb(FolderView *folderview, guint action,
+ GtkWidget *widget)
+{
+ GtkCTree *ctree = GTK_CTREE(folderview->ctree);
+ FolderItem *item;
+
+ if (!folderview->selected) return;
+
+ item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
+ g_return_if_fail(item != NULL);
+ g_return_if_fail(item->folder != NULL);
+
+#if CLAWS
+ prefs_folder_item_create(folderview, item);
+#else
+ /*
+ * CLAWS: wait till Hiro has completed his stuff
+ */
+ prefs_folder_item_open(item);
+#endif
+}
+
static gboolean folderview_drag_motion_cb(GtkWidget *widget,
GdkDragContext *context,
gint x,
FolderView *folderview)
{
gint row, column;
- FolderItem *item, *current_item;
+ FolderItem *item, *src_item;
GtkCTreeNode *node = NULL;
gboolean acceptable = FALSE;
- if (gtk_clist_get_selection_info(GTK_CLIST(widget),
- x - 24, y - 24, &row, &column)) {
+ if (gtk_clist_get_selection_info
+ (GTK_CLIST(widget), x - 24, y - 24, &row, &column)) {
node = gtk_ctree_node_nth(GTK_CTREE(widget), row);
item = gtk_ctree_node_get_row_data(GTK_CTREE(widget), node);
- current_item = folderview->summaryview->folder_item;
- if (item != NULL &&
- item->path != NULL &&
- current_item != NULL &&
- current_item != item) {
- switch (item->folder->type){
+ src_item = folderview->summaryview->folder_item;
+ if (item && item->folder && item->path &&
+ src_item && src_item != item) {
+ switch (item->folder->type) {
case F_MH:
- if (current_item->folder->type == F_MH)
- acceptable = TRUE;
- break;
case F_IMAP:
- if (current_item->folder->account == item->folder->account)
- acceptable = TRUE;
+ acceptable = TRUE;
break;
default:
+ break;
}
}
}
if (acceptable) {
- gtk_signal_handler_block_by_func(GTK_OBJECT(widget),GTK_SIGNAL_FUNC(folderview_selected), folderview);
+ gtk_signal_handler_block_by_func
+ (GTK_OBJECT(widget),
+ GTK_SIGNAL_FUNC(folderview_selected), folderview);
gtk_ctree_select(GTK_CTREE(widget), node);
- gtk_signal_handler_unblock_by_func(GTK_OBJECT(widget),GTK_SIGNAL_FUNC(folderview_selected), folderview);
+ gtk_signal_handler_unblock_by_func
+ (GTK_OBJECT(widget),
+ GTK_SIGNAL_FUNC(folderview_selected), folderview);
gdk_drag_status(context,
(context->actions == GDK_ACTION_COPY ?
GDK_ACTION_COPY : GDK_ACTION_MOVE) , time);
FolderView *folderview)
{
gint row, column;
- FolderItem *item;
+ FolderItem *item, *src_item;
GtkCTreeNode *node;
- if (gtk_clist_get_selection_info(GTK_CLIST(widget),
- x - 24, y - 24, &row, &column) == 0)
+ if (gtk_clist_get_selection_info
+ (GTK_CLIST(widget), x - 24, y - 24, &row, &column) == 0)
return;
node = gtk_ctree_node_nth(GTK_CTREE(widget), row);
item = gtk_ctree_node_get_row_data(GTK_CTREE(widget), node);
- if (item != NULL) {
+ src_item = folderview->summaryview->folder_item;
+ if (item && src_item) {
switch (drag_context->action) {
case GDK_ACTION_COPY:
summary_copy_selected_to(folderview->summaryview, item);
case GDK_ACTION_MOVE:
case GDK_ACTION_DEFAULT:
default:
- summary_move_selected_to(folderview->summaryview, item);
- gtk_drag_finish(drag_context, TRUE, TRUE, time);
- break;
+ if (src_item->folder->type != item->folder->type ||
+ (item->folder->type == F_IMAP &&
+ src_item->folder != item->folder))
+ summary_copy_selected_to(folderview->summaryview, item);
+ else
+ summary_move_selected_to(folderview->summaryview, item);
+ gtk_drag_finish(drag_context, TRUE, TRUE, time);
}
} else
gtk_drag_finish(drag_context, FALSE, FALSE, time);
}
+static gint folderview_clist_compare(GtkCList *clist,
+ gconstpointer ptr1, gconstpointer ptr2)
+{
+ FolderItem *item1 = ((GtkCListRow *)ptr1)->data;
+ FolderItem *item2 = ((GtkCListRow *)ptr2)->data;
+
+ if (!item1->name)
+ return (item2->name != NULL);
+ if (!item2->name)
+ return -1;
+
+ return g_strcasecmp(item1->name, item2->name);
+}
+
static gint folderview_compare_name(gconstpointer a, gconstpointer b)
{
const FolderItem *item = a;
g_return_if_fail(item != NULL);
g_return_if_fail(item->folder != NULL);
- prefs_filtering_open(item);
-}
-
-static void folderview_property_cb(FolderView *folderview, guint action,
- GtkWidget *widget)
-{
- GtkCTree *ctree = GTK_CTREE(folderview->ctree);
- FolderItem *item;
-
- if (!folderview->selected) return;
-
- item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
- g_return_if_fail(item != NULL);
- g_return_if_fail(item->folder != NULL);
-
- prefs_folder_item_create(folderview, item);
+ prefs_filtering_open(item, NULL, NULL);
}
void folderview_set_target_folder_color(gint color_op)
}
}
}
+
+void folderview_reflect_prefs_pixmap_theme(FolderView *folderview)
+{
+ folderview_init(folderview);
+ folderview_set_all();
+}