CVS: sylpheedclaws/sylpheed-claws/src/plugins/bogofilter bogofilter.c,1.1.2.19,1.1.2.20 bogofilter.h,1.1.2.6,1.1.2.7 bogofilter_gtk.c,1.1.2.11,1.1.2.12
[email protected] Fri, 15 Dec 2006 16:52:42 +0000
| Newsgroups | gmane.mail.sylpheed.claws.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /pack/anoncvs/sylpheedclaws/sylpheed-claws/src/plugins/bogofilter
In directory sunsite.dk:/tmp/cvs-serv12202/src/plugins/bogofilter
Modified Files:
Tag: gtk2
bogofilter.c bogofilter.h bogofilter_gtk.c
Log Message:
2006-12-15 [wwp] 2.6.1cvs41
* src/plugins/bogofilter/bogofilter.c
* src/plugins/bogofilter/bogofilter.h
* src/plugins/bogofilter/bogofilter_gtk.c
bogofilter's whitelist can now use a subset of
the addressbook (either a book, a subfolder of a book,
or the whole addressbook by using "Any"). Re-used there
some pref_matcher widgets and mechanisms to match a subset
of the addressbook.
Index: bogofilter.c
===================================================================
RCS file: /pack/anoncvs/sylpheedclaws/sylpheed-claws/src/plugins/bogofilter/Attic/bogofilter.c,v
retrieving revision 1.1.2.19
retrieving revision 1.1.2.20
diff -u -d -r1.1.2.19 -r1.1.2.20
--- bogofilter.c 2006/12/15 16:41:00 1.1.2.19
+++ bogofilter.c 2006/12/15 16:52:38 1.1.2.20
@@ -95,6 +95,8 @@
NULL, NULL, NULL},
{"whitelist_ab", "TRUE", &config.whitelist_ab, P_BOOL,
NULL, NULL, NULL},
+ {"whitelist_ab_folder", "Any", &config.whitelist_ab_folder, P_STRING,
+ NULL, NULL, NULL},
{NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
};
@@ -200,8 +202,20 @@
status = -1;
} else {
- if (config.whitelist_ab)
- start_address_completion(NULL);
+ if (config.whitelist_ab) {
+ gchar *ab_folderpath;
+
+ if (*config.whitelist_ab_folder == '\0' ||
+ strcasecmp(config.whitelist_ab_folder, _("Any")) == 0) {
+ /* match the whole addressbook */
+ ab_folderpath = NULL;
+ } else {
+ /* match the specific book/folder of the addressbook */
+ ab_folderpath = config.whitelist_ab_folder;
+ }
+
+ start_address_completion(ab_folderpath);
+ }
for (cur = data->msglist; cur; cur = cur->next) {
gboolean whitelisted = FALSE;
Index: bogofilter.h
===================================================================
RCS file: /pack/anoncvs/sylpheedclaws/sylpheed-claws/src/plugins/bogofilter/Attic/bogofilter.h,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -d -r1.1.2.6 -r1.1.2.7
--- bogofilter.h 2006/12/15 13:35:05 1.1.2.6
+++ bogofilter.h 2006/12/15 16:52:38 1.1.2.7
@@ -35,6 +35,7 @@
gchar *bogopath;
gboolean insert_header;
gboolean whitelist_ab;
+ gchar *whitelist_ab_folder;
};
BogofilterConfig *bogofilter_get_config (void);
Index: bogofilter_gtk.c
===================================================================
RCS file: /pack/anoncvs/sylpheedclaws/sylpheed-claws/src/plugins/bogofilter/Attic/bogofilter_gtk.c,v
retrieving revision 1.1.2.11
retrieving revision 1.1.2.12
diff -u -d -r1.1.2.11 -r1.1.2.12
--- bogofilter_gtk.c 2006/12/15 15:34:52 1.1.2.11
+++ bogofilter_gtk.c 2006/12/15 16:52:39 1.1.2.12
@@ -40,6 +40,7 @@
#include "statusbar.h"
#include "bogofilter.h"
#include "menu.h"
+#include "addressbook.h"
struct BogofilterPage
{
@@ -53,6 +54,14 @@
GtkWidget *max_size;
GtkWidget *bogopath;
GtkWidget *whitelist_ab;
+ GtkWidget *whitelist_ab_folder_combo;
+};
+
+/*!
+ *\brief Preset addressbook book/folder items
+ */
+static const gchar *whitelist_ab_folder_text [] = {
+ N_("Any")
};
static void foldersel_cb(GtkWidget *widget, gpointer data)
@@ -70,6 +79,18 @@
}
}
+static void bogofilter_whitelist_ab_select_cb(GtkWidget *widget, gpointer data)
+{
+ struct BogofilterPage *page = (struct BogofilterPage *) data;
+ gchar *folderpath = NULL;
+ gboolean ret = FALSE;
+
+ folderpath = (gchar *) gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(page->whitelist_ab_folder_combo)->entry));
+ ret = addressbook_folder_selection(&folderpath);
+ if ( ret != FALSE && folderpath != NULL)
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(page->whitelist_ab_folder_combo)->entry), folderpath);
+}
+
static void bogofilter_create_widget_func(PrefsPage * _page,
GtkWindow * window,
gpointer data)
@@ -79,7 +100,7 @@
GtkWidget *vbox1, *vbox2;
GtkWidget *hbox_max_size;
- GtkWidget *hbox_process_emails, *hbox_save_spam, *hbox_bogopath;
+ GtkWidget *hbox_process_emails, *hbox_save_spam, *hbox_bogopath, *hbox_whitelist;
GtkWidget *max_size_label;
GtkObject *max_size_spinbtn_adj;
@@ -99,6 +120,11 @@
GtkTooltips *tooltips;
+ GtkWidget *whitelist_ab_folder_combo;
+ GtkWidget *whitelist_ab_select_btn;
+ GList *combo_items;
+ gint i;
+
tooltips = gtk_tooltips_new();
vbox1 = gtk_vbox_new (FALSE, VSPACING);
@@ -167,12 +193,39 @@
_("Only done for messages in MH folders"),
NULL);
- whitelist_ab_chkbtn = gtk_check_button_new_with_label(_("Whitelist senders present in addressbook"));
+ hbox_whitelist = gtk_hbox_new(FALSE, 8);
+ gtk_widget_show(hbox_whitelist);
+ gtk_box_pack_start (GTK_BOX (vbox2), hbox_whitelist, TRUE, TRUE, 0);
+
+ whitelist_ab_chkbtn = gtk_check_button_new_with_label(_("Whitelist senders present in addressbook/folder"));
gtk_widget_show(whitelist_ab_chkbtn);
- gtk_box_pack_start(GTK_BOX(vbox2), whitelist_ab_chkbtn, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox_whitelist), whitelist_ab_chkbtn, FALSE, FALSE, 0);
gtk_tooltips_set_tip(tooltips, whitelist_ab_chkbtn,
_("Messages coming from your addressbook contacts will be received in the normal folder even if detected as spam"), NULL);
+ whitelist_ab_folder_combo = gtk_combo_new();
+ gtk_widget_show(whitelist_ab_folder_combo);
+ gtk_widget_set_size_request(whitelist_ab_folder_combo, 100, -1);
+ gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(whitelist_ab_folder_combo)->entry),
+ TRUE);
+
+ combo_items = NULL;
+ for (i = 0; i < (gint) (sizeof(whitelist_ab_folder_text) / sizeof(gchar *)); i++) {
+ combo_items = g_list_append(combo_items,
+ (gpointer) _(whitelist_ab_folder_text[i]));
+ }
+ gtk_combo_set_popdown_strings(GTK_COMBO(whitelist_ab_folder_combo), combo_items);
+ g_list_free(combo_items);
+
+ gtk_box_pack_start (GTK_BOX (hbox_whitelist), whitelist_ab_folder_combo, TRUE, TRUE, 0);
+
+ whitelist_ab_select_btn = gtk_button_new_with_label(_(" Select... "));
+ gtk_widget_show (whitelist_ab_select_btn);
+ gtk_box_pack_start (GTK_BOX (hbox_whitelist), whitelist_ab_select_btn, FALSE, FALSE, 0);
+ gtk_tooltips_set_tip(tooltips, whitelist_ab_select_btn,
+ _("Click this button to select a book or folder in the addressbook"),
+ NULL);
+
hbox_bogopath = gtk_hbox_new(FALSE, 8);
gtk_widget_show(hbox_bogopath);
gtk_box_pack_start (GTK_BOX (vbox2), hbox_bogopath, FALSE, FALSE, 0);
@@ -196,12 +249,17 @@
g_signal_connect(G_OBJECT(save_spam_folder_select), "clicked",
G_CALLBACK(foldersel_cb), page);
+ g_signal_connect(G_OBJECT (whitelist_ab_select_btn), "clicked",
+ G_CALLBACK(bogofilter_whitelist_ab_select_cb), page);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(max_size_spinbtn), (float) config->max_size);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(process_emails_checkbtn), config->process_emails);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(save_spam_checkbtn), config->receive_spam);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(insert_header_chkbtn), config->insert_header);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(whitelist_ab_chkbtn), config->whitelist_ab);
+ if (config->whitelist_ab_folder != NULL)
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(whitelist_ab_folder_combo)->entry),
+ config->whitelist_ab_folder);
if (config->save_folder != NULL)
gtk_entry_set_text(GTK_ENTRY(save_spam_folder_entry), config->save_folder);
if (config->bogopath != NULL)
@@ -212,6 +270,7 @@
page->receive_spam = save_spam_checkbtn;
page->insert_header = insert_header_chkbtn;
page->whitelist_ab = whitelist_ab_chkbtn;
+ page->whitelist_ab_folder_combo = whitelist_ab_folder_combo;
page->save_folder = save_spam_folder_entry;
page->save_folder_select = save_spam_folder_select;
page->bogopath = bogopath_entry;
@@ -248,6 +307,9 @@
/* whitelist_ab */
config->whitelist_ab = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->whitelist_ab));
+ g_free(config->whitelist_ab_folder);
+ config->whitelist_ab_folder = gtk_editable_get_chars(
+ GTK_EDITABLE(GTK_COMBO(page->whitelist_ab_folder_combo)->entry), 0, -1);
/* bogopath */
g_free(config->bogopath);