#include "folderview.h"
#include "summaryview.h"
#include "inputdialog.h"
+#include "grouplistdialog.h"
#include "manage_window.h"
#include "alertpanel.h"
#include "menu.h"
#include "prefs_account.h"
#include "account.h"
#include "folder.h"
-#include "grouplist_dialog.h"
#include "pixmaps/inbox.xpm"
#include "pixmaps/outbox.xpm"
static GdkFont *normalfont;
static GdkFont *boldfont;
+static GtkStyle *normal_style;
+static GtkStyle *normal_color_style;
+static GtkStyle *bold_style;
+static GtkStyle *bold_color_style;
+
static GdkPixmap *inboxxpm;
static GdkBitmap *inboxxpmmask;
static GdkPixmap *outboxxpm;
FolderView *folderview);
static void folderview_scoring_cb(FolderView *folderview, guint action,
GtkWidget *widget);
+static void folderview_property_cb(FolderView *folderview, guint action, GtkWidget *widget);
static GtkItemFactoryEntry folderview_mbox_popup_entries[] =
{
{N_("/_Update folder tree"), NULL, folderview_update_tree_cb, 0, NULL},
{N_("/Remove _mailbox"), NULL, folderview_remove_mailbox_cb, 0, NULL},
{N_("/---"), NULL, NULL, 0, "<Separator>"},
- {N_("/_Property..."), NULL, NULL, 0, NULL},
+ {N_("/_Property..."), NULL, folderview_property_cb, 0, NULL},
{N_("/_Scoring..."), NULL, folderview_scoring_cb, 0, NULL}
};
normalfont = gdk_fontset_load(NORMAL_FONT);
if (!boldfont)
boldfont = gdk_fontset_load(BOLD_FONT);
+
+ if (!bold_style) {
+ bold_style = gtk_style_copy(gtk_widget_get_style(ctree));
+ bold_style->font = boldfont;
+ bold_color_style = gtk_style_copy(bold_style);
+ bold_color_style->fg[GTK_STATE_NORMAL] = folderview->color_new;
+ }
+ if (!normal_style) {
+ normal_style = gtk_style_copy(gtk_widget_get_style(ctree));
+ normal_style->font = normalfont;
+ normal_color_style = gtk_style_copy(normal_style);
+ normal_color_style->fg[GTK_STATE_NORMAL] = folderview->color_new;
+ }
+
}
void folderview_set(FolderView *folderview)
{
GtkCTree *ctree = GTK_CTREE(folderview->ctree);
GtkCTreeNode *node;
+ GtkCTreeNode *old_selected = folderview->selected;
if (!item) return;
node = gtk_ctree_find_by_row_data(ctree, NULL, item);
if (node) folderview_select_node(folderview, node);
+
+ if (old_selected != node)
+ folder_update_op_count();
}
static void folderview_select_node(FolderView *folderview, GtkCTreeNode *node)
else
gtk_widget_grab_focus(folderview->ctree);
- while ((node = gtkut_ctree_find_collapsed_parent(ctree, node))
- != NULL)
- gtk_ctree_expand(ctree, node);
+ gtkut_ctree_expand_parent_all(ctree, node);
}
void folderview_unselect(FolderView *folderview)
GList *list;
gchar *rootpath;
- if (folder->type == F_MH || folder->type == F_MBOX ||
- folder->type == F_MAILDIR)
+ if (FOLDER_IS_LOCAL(folder))
rootpath = LOCAL_FOLDER(folder)->rootpath;
else if (folder->type == F_IMAP && folder->account &&
folder->account->recv_server)
gtk_widget_destroy(window);
}
+void folderview_update_all_node(void)
+{
+ GList *list;
+ FolderItem *item;
+ FolderView *folderview;
+ GtkCTree *ctree;
+ GtkCTreeNode *node;
+ GtkWidget *window;
+
+ window = label_window_create(_("Updating all folders..."));
+
+ for (list = folderview_list; list != NULL; list = list->next) {
+ folderview = (FolderView *)list->data;
+ ctree = GTK_CTREE(folderview->ctree);
+
+ 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;
+ folderview_scan_tree_func(item->folder, item, NULL);
+ folder_item_scan(item);
+ folderview_update_node(folderview, node);
+ }
+ }
+
+ folder_write_list();
+ gtk_widget_destroy(window);
+}
+
static gboolean folderview_search_new_recursive(GtkCTree *ctree,
GtkCTreeNode *node)
{
static void folderview_update_node(FolderView *folderview, GtkCTreeNode *node)
{
GtkCTree *ctree = GTK_CTREE(folderview->ctree);
- GtkStyle *style, *prev_style, *ctree_style;
+ GtkStyle *style = NULL;
GtkCTreeNode *parent;
FolderItem *item;
GdkPixmap *xpm, *openxpm;
gtk_ctree_node_set_text(ctree, node, COL_TOTAL, itos(item->total));
}
- ctree_style = gtk_widget_get_style(GTK_WIDGET(ctree));
- prev_style = gtk_ctree_node_get_row_style(ctree, node);
- if (!prev_style)
- prev_style = ctree_style;
- style = gtk_style_copy(prev_style);
- if (!style) return;
+ if (item->stype == F_TRASH) return;
if (item->stype == F_QUEUE) {
/* highlight queue folder if there are any messages */
use_bold = use_color = (item->total > 0);
- } else if (item->stype == F_TRASH) {
- /* Never highlight trash */
- use_bold = FALSE;
- use_color = FALSE;
} else {
/* if unread messages exist, print with bold font */
use_bold = (item->unread > 0) || add_unread_mark;
folderview_have_new_children(folderview, node));
}
- if (use_bold && boldfont)
- style->font = boldfont;
- else
- style->font = normalfont;
-
- if (use_color) {
- style->fg[GTK_STATE_NORMAL] = folderview->color_new;
- style->fg[GTK_STATE_SELECTED] = folderview->color_new;
+ gtk_ctree_node_set_foreground(ctree, node, NULL);
+
+ if (use_bold && use_color)
+ style = bold_color_style;
+ else if (use_bold) {
+ style = bold_style;
+ if (item->op_count > 0) {
+ gtk_ctree_node_set_foreground(ctree, node,
+ &folderview->color_op);
+ } else {
+ style = bold_style;
+ }
+ }
+ else if (use_color) {
+ style = normal_color_style;
+ gtk_ctree_node_set_foreground(ctree, node,
+ &folderview->color_new);
+ }
+ else if (item->op_count > 0) {
+ style = normal_color_style;
+ gtk_ctree_node_set_foreground(ctree, node,
+ &folderview->color_op);
} else {
- style->fg[GTK_STATE_NORMAL] =
- ctree_style->fg[GTK_STATE_NORMAL];
- style->fg[GTK_STATE_SELECTED] =
- ctree_style->fg[GTK_STATE_SELECTED];
+ style = normal_style;
}
gtk_ctree_node_set_row_style(ctree, node, style);
menu_set_insensitive_all(GTK_MENU_SHELL(folderview->news_popup));
menu_set_insensitive_all(GTK_MENU_SHELL(folderview->mbox_popup));
- if (folder->type == F_MH && item->parent == NULL) {
+ if (FOLDER_IS_LOCAL(folder) && item->parent == NULL) {
menu_set_sensitive(folderview->mail_factory,
"/Create new folder...", TRUE);
menu_set_sensitive(folderview->mail_factory,
"/Update folder tree", TRUE);
menu_set_sensitive(folderview->mail_factory,
"/Remove mailbox", TRUE);
- } else if (folder->type == F_MH && item->stype != F_NORMAL) {
+ } else if (FOLDER_IS_LOCAL(folder) && item->stype != F_NORMAL) {
menu_set_sensitive(folderview->mail_factory,
"/Create new folder...", TRUE);
menu_set_sensitive(folderview->mail_factory,
"/Scoring...", TRUE);
- } else if (folder->type == F_MH) {
+ } else if (FOLDER_IS_LOCAL(folder)) {
menu_set_sensitive(folderview->mail_factory,
"/Create new folder...", TRUE);
menu_set_sensitive(folderview->mail_factory,
"/Delete folder", TRUE);
menu_set_sensitive(folderview->mail_factory,
"/Scoring...", TRUE);
+ menu_set_sensitive(folderview->mail_factory,
+ "/Property...", TRUE);
} else if (folder->type == F_IMAP && item->parent == NULL) {
menu_set_sensitive(folderview->imap_factory,
"/Create new folder...", TRUE);
"/Scoring...", TRUE);
}
- if (folder->type == F_MH)
+ if (FOLDER_IS_LOCAL(folder))
gtk_menu_popup(GTK_MENU(folderview->mail_popup), NULL, NULL,
NULL, NULL, event->button, event->time);
else if (folder->type == F_IMAP)
g_return_if_fail(item->folder->type == F_NEWS);
g_return_if_fail(item->folder->account != NULL);
- new_group = grouplist_dialog(item);
+ new_group = grouplist_dialog(item->folder);
if (!new_group) return;
if (GTK_CTREE_ROW(folderview->selected)->parent != NULL)
prefs_scoring_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(item);
+}
+
+void folderview_set_target_folder_color(gint color_op) {
+ GList *list;
+ FolderView *folderview;
+
+ for (list = folderview_list; list != NULL; list = list->next) {
+ folderview = (FolderView *)list->data;
+ gtkut_convert_int_to_gdk_color(color_op, &folderview->color_op);
+ }
+}