aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2010-07-29 07:01:32 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2010-07-29 07:01:32 +0000
commit03d5278cdd2fd4fd7b6caef33aa53b28e71ffc1c (patch)
tree56859ef1a0ac0310a47f9670113e2b2f2e0f7524
parentf105a6dc818de10f476cf5f48c9c590428c661ef (diff)
added 'Junk' special folder and automatically create it when not exist.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2638 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog13
-rw-r--r--libsylph/defs.h1
-rw-r--r--libsylph/folder.c92
-rw-r--r--libsylph/folder.h5
-rw-r--r--libsylph/mh.c5
-rw-r--r--src/foldersel.c6
-rw-r--r--src/folderview.c6
-rw-r--r--src/icons/Makefile.am2
-rw-r--r--src/prefs_folder_item.c7
-rw-r--r--src/stock_pixmap.c2
-rw-r--r--src/stock_pixmap.h1
11 files changed, 130 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 80dfea03..ea4ecff9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2010-07-29
+
+ * libsylph/mh.c
+ libsylph/folder.[ch]
+ libsylph/defs.h
+ src/icons/stock_spam_16.png
+ src/icons/Makefile.am
+ src/foldersel.c
+ src/prefs_folder_item.c
+ src/stock_pixmap.[ch]
+ src/folderview.c: added 'Junk' special folder and automatically
+ create it when not exist.
+
2010-07-28
* src/folderview.c: folderview_menu_popup(): show/hide needless items
diff --git a/libsylph/defs.h b/libsylph/defs.h
index 0b39d778..c3790a18 100644
--- a/libsylph/defs.h
+++ b/libsylph/defs.h
@@ -43,6 +43,7 @@
#define QUEUE_DIR "queue"
#define DRAFT_DIR "draft"
#define TRASH_DIR "trash"
+#define JUNK_DIR "junk"
#ifdef G_OS_WIN32
# define RC_DIR "Sylpheed"
#else
diff --git a/libsylph/folder.c b/libsylph/folder.c
index 29a3a9ee..c6cb8a74 100644
--- a/libsylph/folder.c
+++ b/libsylph/folder.c
@@ -1,6 +1,6 @@
/*
* LibSylph -- E-Mail client library
- * Copyright (C) 1999-2009 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2010 Hiroyuki Yamamoto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -43,11 +43,22 @@
#include "prefs_account.h"
#include "sylmain.h"
+typedef struct _FolderPrivData FolderPrivData;
+
+struct _FolderPrivData {
+ Folder *folder;
+ FolderItem *junk;
+ gpointer data;
+};
+
static GList *folder_list = NULL;
+static GList *folder_priv_list = NULL;
static void folder_init (Folder *folder,
const gchar *name);
+static FolderPrivData *folder_get_priv (Folder *folder);
+
static gboolean folder_read_folder_func (GNode *node,
gpointer data);
static gchar *folder_get_list_path (void);
@@ -115,6 +126,8 @@ void folder_remote_folder_init(Folder *folder, const gchar *name,
void folder_destroy(Folder *folder)
{
+ FolderPrivData *priv;
+
g_return_if_fail(folder != NULL);
g_return_if_fail(folder->klass->destroy != NULL);
@@ -122,6 +135,10 @@ void folder_destroy(Folder *folder)
folder_list = g_list_remove(folder_list, folder);
+ priv = folder_get_priv(folder);
+ folder_priv_list = g_list_remove(folder_priv_list, priv);
+ g_free(priv);
+
folder_tree_destroy(folder);
g_free(folder->name);
g_free(folder);
@@ -312,6 +329,8 @@ void folder_item_destroy(FolderItem *item)
folder->queue = NULL;
else if (folder->trash == item)
folder->trash = NULL;
+ else if (folder_get_junk(folder) == item)
+ folder_set_junk(folder, NULL);
}
g_free(item->name);
@@ -398,6 +417,9 @@ void folder_add(Folder *folder)
Folder *cur_folder;
GList *cur;
gint i;
+ FolderPrivData *priv;
+
+ debug_print("Adding folder (%p) to folder list\n", folder);
g_return_if_fail(folder != NULL);
@@ -416,6 +438,9 @@ void folder_add(Folder *folder)
}
folder_list = g_list_insert(folder_list, folder, i);
+ priv = g_new0(FolderPrivData, 1);
+ priv->folder = folder;
+ folder_priv_list = g_list_insert(folder_priv_list, priv, i);
}
GList *folder_get_list(void)
@@ -858,6 +883,57 @@ FolderItem *folder_get_default_trash(void)
return folder->trash;
}
+FolderItem *folder_get_default_junk(void)
+{
+ FolderPrivData *priv;
+
+ if (!folder_list) return NULL;
+ if (!folder_priv_list) return NULL;
+ priv = (FolderPrivData *)folder_priv_list->data;
+ g_return_val_if_fail(priv != NULL, NULL);
+ g_return_val_if_fail(priv->folder != NULL, NULL);
+ return priv->junk;
+}
+
+static FolderPrivData *folder_get_priv(Folder *folder)
+{
+ FolderPrivData *priv;
+ GList *cur;
+
+ g_return_val_if_fail(folder != NULL, NULL);
+
+ for (cur = folder_priv_list; cur != NULL; cur = cur->next) {
+ priv = (FolderPrivData *)cur->data;
+ if (priv->folder == folder)
+ return priv;
+ }
+
+ g_warning("folder_get_priv: private data for Folder (%p) not found.",
+ folder);
+
+ return NULL;
+}
+
+FolderItem *folder_get_junk(Folder *folder)
+{
+ FolderPrivData *priv;
+
+ priv = folder_get_priv(folder);
+ if (priv)
+ return priv->junk;
+
+ return NULL;
+}
+
+void folder_set_junk(Folder *folder, FolderItem *item)
+{
+ FolderPrivData *priv;
+
+ priv = folder_get_priv(folder);
+ if (priv)
+ priv->junk = item;
+}
+
#define CREATE_FOLDER_IF_NOT_EXIST(member, dir, type) \
{ \
if (!folder->member) { \
@@ -882,7 +958,7 @@ void folder_set_missing_folders(void)
g_return_if_fail(rootitem != NULL);
if (folder->inbox && folder->outbox && folder->draft &&
- folder->queue && folder->trash)
+ folder->queue && folder->trash && folder_get_junk(folder))
continue;
if (folder_create_tree(folder) < 0) {
@@ -896,7 +972,13 @@ void folder_set_missing_folders(void)
CREATE_FOLDER_IF_NOT_EXIST(draft, DRAFT_DIR, F_DRAFT);
CREATE_FOLDER_IF_NOT_EXIST(queue, QUEUE_DIR, F_QUEUE);
CREATE_FOLDER_IF_NOT_EXIST(trash, TRASH_DIR, F_TRASH);
- /* CREATE_FOLDER_IF_NOT_EXIST(junk, JUNK_DIR, F_JUNK); */
+
+ if (!folder_get_junk(folder)) {
+ item = folder_item_new(JUNK_DIR, JUNK_DIR);
+ item->stype = F_JUNK;
+ folder_item_append(rootitem, item);
+ folder_set_junk(folder, item);
+ }
}
}
@@ -1392,10 +1474,8 @@ static gboolean folder_build_tree(GNode *node, gpointer data)
stype = F_QUEUE;
else if (!g_ascii_strcasecmp(attr->value, "trash"))
stype = F_TRASH;
-#if 0
else if (!g_ascii_strcasecmp(attr->value, "junk"))
stype = F_JUNK;
-#endif
else if (!g_ascii_strcasecmp(attr->value, "virtual"))
stype = F_VIRTUAL;
} else if (!strcmp(attr->name, "name"))
@@ -1519,7 +1599,7 @@ static gboolean folder_build_tree(GNode *node, gpointer data)
case F_DRAFT: folder->draft = item; break;
case F_QUEUE: folder->queue = item; break;
case F_TRASH: folder->trash = item; break;
- /* case F_JUNK: folder->junk = item; break; */
+ case F_JUNK: folder_set_junk(folder, item); break;
default: break;
}
item->account = account;
diff --git a/libsylph/folder.h b/libsylph/folder.h
index 7c046eb3..c3822c39 100644
--- a/libsylph/folder.h
+++ b/libsylph/folder.h
@@ -382,6 +382,11 @@ FolderItem *folder_get_default_outbox (void);
FolderItem *folder_get_default_draft (void);
FolderItem *folder_get_default_queue (void);
FolderItem *folder_get_default_trash (void);
+FolderItem *folder_get_default_junk (void);
+
+FolderItem *folder_get_junk (Folder *folder);
+void folder_set_junk (Folder *folder,
+ FolderItem *item);
void folder_set_missing_folders (void);
void folder_unref_account_all (PrefsAccount *account);
diff --git a/libsylph/mh.c b/libsylph/mh.c
index d3be1cf7..89ba6baa 100644
--- a/libsylph/mh.c
+++ b/libsylph/mh.c
@@ -1229,6 +1229,7 @@ static gint mh_create_tree(Folder *folder)
MAKE_DIR_IF_NOT_EXIST(QUEUE_DIR);
MAKE_DIR_IF_NOT_EXIST(DRAFT_DIR);
MAKE_DIR_IF_NOT_EXIST(TRASH_DIR);
+ MAKE_DIR_IF_NOT_EXIST(JUNK_DIR);
return 0;
}
@@ -1820,6 +1821,10 @@ static void mh_scan_tree_recursive(FolderItem *item)
!strcmp(dir_name, TRASH_DIR)) {
new_item->stype = F_TRASH;
folder->trash = new_item;
+ } else if (!folder_get_junk(folder) &&
+ !strcmp(dir_name, JUNK_DIR)) {
+ new_item->stype = F_JUNK;
+ folder_set_junk(folder, new_item);
}
}
diff --git a/src/foldersel.c b/src/foldersel.c
index 61c9a809..bca88d0f 100644
--- a/src/foldersel.c
+++ b/src/foldersel.c
@@ -417,6 +417,10 @@ static void foldersel_append_item(GtkTreeStore *store, FolderItem *item,
if (!strcmp2(item->name, DRAFT_DIR))
name = _("Drafts");
break;
+ case F_JUNK:
+ if (!strcmp2(item->name, JUNK_DIR))
+ name = _("Junk");
+ break;
default:
break;
}
@@ -449,7 +453,7 @@ static void foldersel_append_item(GtkTreeStore *store, FolderItem *item,
pixbuf_open = no_select ? foldernoselect_pixbuf : folderopen_pixbuf;
if (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
- item->stype == F_TRASH) {
+ item->stype == F_TRASH || item->stype == F_JUNK) {
use_color = FALSE;
} else if (item->stype == F_QUEUE) {
use_color = (item->total > 0);
diff --git a/src/folderview.c b/src/folderview.c
index 66feed77..998bbe25 100644
--- a/src/folderview.c
+++ b/src/folderview.c
@@ -111,6 +111,7 @@ static GdkPixbuf *folderopen_pixbuf;
static GdkPixbuf *foldernoselect_pixbuf;
static GdkPixbuf *draft_pixbuf;
static GdkPixbuf *trash_pixbuf;
+static GdkPixbuf *junk_pixbuf;
static GdkPixbuf *virtual_pixbuf;
static void folderview_set_columns (FolderView *folderview);
@@ -561,6 +562,7 @@ void folderview_init(FolderView *folderview)
&foldernoselect_pixbuf);
stock_pixbuf_gdk(treeview, STOCK_PIXMAP_DRAFT, &draft_pixbuf);
stock_pixbuf_gdk(treeview, STOCK_PIXMAP_TRASH, &trash_pixbuf);
+ stock_pixbuf_gdk(treeview, STOCK_PIXMAP_SPAM_SMALL, &junk_pixbuf);
stock_pixbuf_gdk(treeview, STOCK_PIXMAP_FOLDER_SEARCH, &virtual_pixbuf);
}
@@ -1266,15 +1268,13 @@ static void folderview_update_row(FolderView *folderview, GtkTreeIter *iter)
!strcmp2(item->name, DRAFT_DIR) ? _("Drafts") :
item->name);
break;
-#if 0
case F_JUNK:
- pixbuf = folder_pixbuf;
+ pixbuf = open_pixbuf = junk_pixbuf;
open_pixbuf = folderopen_pixbuf;
name = g_strdup(FOLDER_IS_LOCAL(item->folder) &&
!strcmp2(item->name, JUNK_DIR) ? _("Junk") :
item->name);
break;
-#endif
case F_VIRTUAL:
pixbuf = open_pixbuf = virtual_pixbuf;
name = g_strdup(item->name);
diff --git a/src/icons/Makefile.am b/src/icons/Makefile.am
index b69e078a..c1ad743b 100644
--- a/src/icons/Makefile.am
+++ b/src/icons/Makefile.am
@@ -20,6 +20,7 @@ BUILT_SOURCES = \
stock_person.h \
stock_book.h \
stock_spam.h \
+ stock_spam_16.h \
stock_notspam.h \
stock_sylpheed.h \
stock_sylpheed_16.h \
@@ -55,6 +56,7 @@ EXTRA_DIST = \
stock_person.png \
stock_book.png \
stock_spam.png \
+ stock_spam_16.png \
stock_notspam.png \
stock_sylpheed.png \
stock_sylpheed_16.png \
diff --git a/src/prefs_folder_item.c b/src/prefs_folder_item.c
index a6d67220..a3e725a7 100644
--- a/src/prefs_folder_item.c
+++ b/src/prefs_folder_item.c
@@ -237,6 +237,7 @@ static void prefs_folder_item_general_create(PrefsFolderItemDialog *dialog)
MENUITEM_ADD(optmenu_menu, menuitem, _("Drafts"), F_DRAFT);
MENUITEM_ADD(optmenu_menu, menuitem, _("Queue") , F_QUEUE);
MENUITEM_ADD(optmenu_menu, menuitem, _("Trash") , F_TRASH);
+ MENUITEM_ADD(optmenu_menu, menuitem, _("Junk") , F_JUNK);
gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), optmenu_menu);
@@ -562,6 +563,12 @@ static void prefs_folder_item_apply_cb(GtkWidget *widget,
prev_item = folder->trash;
folder->trash = item;
break;
+ case F_JUNK:
+ prev_item = folder_get_junk(folder);
+ if (prev_item)
+ prev_item->stype = F_NORMAL;
+ folder_set_junk(folder, item);
+ break;
default:
type = item->stype;
break;
diff --git a/src/stock_pixmap.c b/src/stock_pixmap.c
index c5497192..0da2155b 100644
--- a/src/stock_pixmap.c
+++ b/src/stock_pixmap.c
@@ -64,6 +64,7 @@
#include "icons/stock_delete.h"
#include "icons/stock_delete_16.h"
#include "icons/stock_spam.h"
+#include "icons/stock_spam_16.h"
#include "icons/stock_notspam.h"
#include "icons/stock_hand-signed.h"
#include "icons/stock_sylpheed.h"
@@ -150,6 +151,7 @@ static StockPixmapData pixmaps[] =
{NULL, NULL, NULL, NULL, sylpheed_logo, sizeof(sylpheed_logo), NULL, 0},
{NULL, NULL, NULL, NULL, stock_person, sizeof(stock_person), "stock_person", 16},
{NULL, NULL, NULL, NULL, folder_search, sizeof(folder_search), "folder-search", 0},
+ {NULL, NULL, NULL, NULL, stock_spam_16, sizeof(stock_spam_16), "stock_spam", 16},
};
diff --git a/src/stock_pixmap.h b/src/stock_pixmap.h
index f97d564a..a7c6d392 100644
--- a/src/stock_pixmap.h
+++ b/src/stock_pixmap.h
@@ -79,6 +79,7 @@ typedef enum
STOCK_PIXMAP_SYLPHEED_LOGO,
STOCK_PIXMAP_PERSON,
STOCK_PIXMAP_FOLDER_SEARCH,
+ STOCK_PIXMAP_SPAM_SMALL,
N_STOCK_PIXMAPS
} StockPixmap;