aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2010-02-12 05:31:59 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2010-02-12 05:31:59 +0000
commit739668b38048db73994b27fc63496d42473ff08e (patch)
tree243266999341ad03124c2387899e62d01aebb0a7
parent2e693597aa60fb25b8a22b2c5c2fc0db86bad7c9 (diff)
added 'In addressbook' to the quick search menu.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2468 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog6
-rw-r--r--libsylph/folder.c7
-rw-r--r--src/addressbook.c4
-rw-r--r--src/quick_search.c37
-rw-r--r--src/quick_search.h3
5 files changed, 45 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 6e994d87..bc089f12 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2010-02-12
+ * libsylph/folder.c
+ src/quick_search.[ch]
+ src/addressbook.c: added 'In addressbook' to the quick search menu.
+
+2010-02-12
+
* src/compose.c: compose_add_new_recipients_to_addressbook():
use addressbook_has_address().
diff --git a/libsylph/folder.c b/libsylph/folder.c
index 9aaa50db..9866417c 100644
--- a/libsylph/folder.c
+++ b/libsylph/folder.c
@@ -1461,6 +1461,8 @@ static gboolean folder_build_tree(GNode *node, gpointer data)
qsearch_cond_type = 6;
else if (!strcmp(attr->value, "last7"))
qsearch_cond_type = 7;
+ else if (!strcmp(attr->value, "in-addressbook"))
+ qsearch_cond_type = 8;
} else if (!strcmp(attr->name, "account_id")) {
account = account_find_from_id(atoi(attr->value));
if (!account) g_warning("account_id: %s not found\n",
@@ -1638,7 +1640,8 @@ static void folder_write_list_recursive(GNode *node, gpointer data)
"from", "subject", "score", "label",
"mark", "unread", "mime", "to"};
static gchar *qsearch_cond_str[] = {"all", "unread", "mark", "clabel",
- "mime", "w1day", "last5", "last7"};
+ "mime", "w1day", "last5", "last7",
+ "in-addressbook"};
g_return_if_fail(node != NULL);
g_return_if_fail(fp != NULL);
@@ -1697,7 +1700,7 @@ static void folder_write_list_recursive(GNode *node, gpointer data)
fprintf(fp, " sort_type=\"descending\"");
}
if (item->qsearch_cond_type > 0 &&
- item->qsearch_cond_type < 8) {
+ item->qsearch_cond_type < 9) {
fprintf(fp, " qsearch_cond=\"%s\"",
qsearch_cond_str[item->qsearch_cond_type]);
}
diff --git a/src/addressbook.c b/src/addressbook.c
index b0ff2c13..4875e45e 100644
--- a/src/addressbook.c
+++ b/src/addressbook.c
@@ -4261,7 +4261,7 @@ gboolean addressbook_has_address(const gchar *address)
if (!address)
return FALSE;
- debug_print("addressbook_has_address: check if addressbook has address: %s\n", address);
+ /* debug_print("addressbook_has_address: check if addressbook has address: %s\n", address); */
list = address_list_append(NULL, address);
if (!list)
@@ -4279,7 +4279,7 @@ gboolean addressbook_has_address(const gchar *address)
if (g_hash_table_lookup(addr_table, addr)) {
found = TRUE;
- debug_print("'%s' is in addressbook\n", addr);
+ /* debug_print("<%s> is in addressbook\n", addr); */
} else {
found = FALSE;
g_free(addr);
diff --git a/src/quick_search.c b/src/quick_search.c
index 254672e8..81e8450e 100644
--- a/src/quick_search.c
+++ b/src/quick_search.c
@@ -34,6 +34,7 @@
#include "filter.h"
#include "procheader.h"
#include "menu.h"
+#include "addressbook.h"
static const struct {
QSearchCondType type;
@@ -46,7 +47,8 @@ static const struct {
{QS_MIME, FLT_COND_MIME},
{QS_W1DAY, -1},
{QS_LAST5, -1},
- {QS_LAST7, -1}
+ {QS_LAST7, -1},
+ {QS_IN_ADDRESSBOOK, -1}
};
static GdkColor text_color;
@@ -113,6 +115,8 @@ QuickSearch *quick_search_create(SummaryView *summaryview)
COND_MENUITEM_ADD(_("Within 1 day"), QS_W1DAY);
COND_MENUITEM_ADD(_("Last 5 days"), QS_LAST5);
COND_MENUITEM_ADD(_("Last 7 days"), QS_LAST7);
+ MENUITEM_ADD(menu, menuitem, NULL, 0);
+ COND_MENUITEM_ADD(_("In addressbook"), QS_IN_ADDRESSBOOK);
gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
#undef COND_MENUITEM_ADD
@@ -220,6 +224,9 @@ GSList *quick_search_filter(QuickSearch *qsearch, QSearchCondType type,
if (!summaryview->all_mlist)
return NULL;
+ debug_print("quick_search_filter: filtering summary (type: %d)\n",
+ type);
+
switch (type) {
case QS_UNREAD:
case QS_MARK:
@@ -252,6 +259,13 @@ GSList *quick_search_filter(QuickSearch *qsearch, QSearchCondType type,
status_rule = filter_rule_new("Status filter rule", FLT_OR,
cond_list, NULL);
break;
+ case QS_IN_ADDRESSBOOK:
+ cond = filter_cond_new(FLT_COND_HEADER, FLT_IN_ADDRESSBOOK, 0,
+ "From", NULL);
+ cond_list = g_slist_append(cond_list, cond);
+ status_rule = filter_rule_new("Status filter rule", FLT_OR,
+ cond_list, NULL);
+ break;
case QS_ALL:
default:
break;
@@ -279,28 +293,37 @@ GSList *quick_search_filter(QuickSearch *qsearch, QSearchCondType type,
for (cur = summaryview->all_mlist; cur != NULL; cur = cur->next) {
MsgInfo *msginfo = (MsgInfo *)cur->data;
- GSList *hlist;
+ GSList *hlist = NULL;
total++;
if (status_rule) {
- if (!filter_match_rule(status_rule, msginfo, NULL,
- &fltinfo))
+ if (type == QS_IN_ADDRESSBOOK)
+ hlist = procheader_get_header_list_from_msginfo
+ (msginfo);
+ if (!filter_match_rule(status_rule, msginfo, hlist,
+ &fltinfo)) {
+ if (hlist)
+ procheader_header_list_destroy(hlist);
continue;
+ }
}
if (rule) {
- hlist = procheader_get_header_list_from_msginfo
- (msginfo);
+ if (!hlist)
+ hlist = procheader_get_header_list_from_msginfo
+ (msginfo);
if (filter_match_rule(rule, msginfo, hlist, &fltinfo)) {
flt_mlist = g_slist_prepend(flt_mlist, msginfo);
count++;
}
- procheader_header_list_destroy(hlist);
} else {
flt_mlist = g_slist_prepend(flt_mlist, msginfo);
count++;
}
+
+ if (hlist)
+ procheader_header_list_destroy(hlist);
}
flt_mlist = g_slist_reverse(flt_mlist);
diff --git a/src/quick_search.h b/src/quick_search.h
index 52516499..b21b3468 100644
--- a/src/quick_search.h
+++ b/src/quick_search.h
@@ -35,7 +35,8 @@ typedef enum
QS_MIME,
QS_W1DAY,
QS_LAST5,
- QS_LAST7
+ QS_LAST7,
+ QS_IN_ADDRESSBOOK
} QSearchCondType;
struct _QuickSearch