/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2002 Hiroyuki Yamamoto and the Sylpheed-Claws Team
+ * Copyright (C) 1999-2003 Hiroyuki Yamamoto and the Sylpheed-Claws Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "common/utils.h"
#include "prefs.h"
#include "folder.h"
-#include "prefswindow.h"
+#include "prefs_gtk.h"
#include "foldersel.h"
#include "spamassassin.h"
}
}
-static void spamassassin_create_widget_func(PrefsPage * _page)
+static void spamassassin_create_widget_func(PrefsPage * _page, GtkWindow *window, gpointer data)
{
struct SpamAssassinPage *page = (struct SpamAssassinPage *) _page;
+ SpamAssassinConfig *config;
/* ------------------ code made by glade -------------------- */
GtkWidget *table1;
GtkWidget *label8;
GtkWidget *label9;
GtkWidget *hbox1;
+ GtkWidget *hbox2;
GtkWidget *hostname;
GtkWidget *label5;
GtkObject *port_adj;
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label4), 0, 0.5);
+ hbox1 = gtk_hbox_new(FALSE, 0);
+ gtk_widget_show(hbox1);
+ gtk_table_attach(GTK_TABLE(table1), hbox1, 1, 2, 1, 2,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (GTK_FILL), 0, 0);
+
+ hostname = gtk_entry_new();
+ gtk_widget_show(hostname);
+ gtk_box_pack_start(GTK_BOX(hbox1), hostname, TRUE, TRUE, 0);
+
+ label5 = gtk_label_new(":");
+ gtk_widget_show(label5);
+ gtk_box_pack_start(GTK_BOX(hbox1), label5, FALSE, FALSE, 0);
+ gtk_misc_set_padding(GTK_MISC(label5), 8, 0);
+
+ port_adj = gtk_adjustment_new(783, 1, 65535, 1, 10, 10);
+ port =
+ gtk_spin_button_new(GTK_ADJUSTMENT(port_adj), 1, 0);
+ gtk_widget_show(port);
+ gtk_box_pack_start(GTK_BOX(hbox1), port, FALSE, TRUE, 0);
+ gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(port), TRUE);
+
label6 = gtk_label_new(_("Maximum Message Size"));
gtk_widget_show(label6);
gtk_table_attach(GTK_TABLE(table1), label6, 0, 1, 2, 3,
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label6), 0, 0.5);
+ hbox2 = gtk_hbox_new (FALSE, 0);
+ gtk_widget_show (hbox2);
+ gtk_table_attach (GTK_TABLE (table1), hbox2, 1, 2, 2, 3,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (GTK_FILL), 0, 0);
+
+ max_size_adj = gtk_adjustment_new (250, 0, 10000, 10, 10, 10);
+ max_size = gtk_spin_button_new (GTK_ADJUSTMENT (max_size_adj), 1, 0);
+ gtk_widget_show (max_size);
+ gtk_box_pack_start (GTK_BOX (hbox2), max_size, FALSE, FALSE, 0);
+
+ label11 = gtk_label_new ("kB");
+ gtk_widget_show (label11);
+ gtk_box_pack_start (GTK_BOX (hbox2), label11, FALSE, FALSE, 0);
+
label8 = gtk_label_new(_("Folder for saved Spam"));
gtk_widget_show(label8);
gtk_table_attach(GTK_TABLE(table1), label8, 0, 1, 4, 5,
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label9), 0, 0.5);
- hbox1 = gtk_hbox_new(FALSE, 0);
- gtk_widget_show(hbox1);
- gtk_table_attach(GTK_TABLE(table1), hbox1, 1, 2, 1, 2,
- (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions) (GTK_FILL), 0, 0);
-
- hostname = gtk_entry_new();
- gtk_widget_show(hostname);
- gtk_box_pack_start(GTK_BOX(hbox1), hostname, TRUE, TRUE, 0);
-
- label5 = gtk_label_new(_(":"));
- gtk_widget_show(label5);
- gtk_box_pack_start(GTK_BOX(hbox1), label5, FALSE, FALSE, 0);
- gtk_misc_set_padding(GTK_MISC(label5), 8, 0);
-
- port_adj = gtk_adjustment_new(783, 1, 65535, 1, 10, 10);
- port =
- gtk_spin_button_new(GTK_ADJUSTMENT(port_adj), 1, 0);
- gtk_widget_show(port);
- gtk_box_pack_start(GTK_BOX(hbox1), port, FALSE, TRUE, 0);
- gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(port), TRUE);
-
enable = gtk_check_button_new_with_label("");
gtk_widget_show(enable);
gtk_table_attach(GTK_TABLE(table1), enable, 1, 2, 0, 1,
gtk_label_set_justify(GTK_LABEL(label10), GTK_JUSTIFY_RIGHT);
gtk_misc_set_alignment(GTK_MISC(label10), 1, 0.5);
- max_size_adj = gtk_adjustment_new(250, 0, 10000, 10, 10, 10);
- max_size = gtk_spin_button_new(GTK_ADJUSTMENT(max_size_adj), 1, 0);
- gtk_widget_show(max_size);
- gtk_table_attach(GTK_TABLE(table1), max_size, 1, 2, 2, 3,
- (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
-
save_folder = gtk_entry_new();
gtk_widget_show(save_folder);
gtk_table_attach(GTK_TABLE(table1), save_folder, 1, 2, 4, 5,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
- button4 = gtk_button_new_with_label(_("..."));
+ button4 = gtk_button_new_with_label("...");
gtk_widget_show(button4);
gtk_table_attach(GTK_TABLE(table1), button4, 2, 3, 4, 5,
(GtkAttachOptions) (GTK_SHRINK | GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
-
- label11 = gtk_label_new(_("kB"));
- gtk_widget_show(label11);
- gtk_table_attach(GTK_TABLE(table1), label11, 2, 3, 2, 3,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_misc_set_alignment(GTK_MISC(label11), 0, 0.5);
/* --------------------------------------------------------- */
+ config = spamassassin_get_config();
+
gtk_widget_set_usize(GTK_WIDGET(port), 64, -1);
gtk_signal_connect(GTK_OBJECT(button4), "released", GTK_SIGNAL_FUNC(foldersel_cb), page);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(enable), spamassassin_enable);
- gtk_entry_set_text(GTK_ENTRY(hostname), spamassassin_hostname);
- gtk_spin_button_set_value(GTK_SPIN_BUTTON(port), (float) spamassassin_port);
- gtk_spin_button_set_value(GTK_SPIN_BUTTON(max_size), (float) spamassassin_max_size);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(receive_spam), spamassassin_receive_spam);
- gtk_entry_set_text(GTK_ENTRY(save_folder), spamassassin_save_folder);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(enable), config->enable);
+ if (config->hostname != NULL)
+ gtk_entry_set_text(GTK_ENTRY(hostname), config->hostname);
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(port), (float) config->port);
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(max_size), (float) config->max_size);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(receive_spam), config->receive_spam);
+ if (config->save_folder != NULL)
+ gtk_entry_set_text(GTK_ENTRY(save_folder), config->save_folder);
page->enable = enable;
page->hostname = hostname;
static void spamassassin_save_func(PrefsPage *_page)
{
struct SpamAssassinPage *page = (struct SpamAssassinPage *) _page;
- gchar *tmp;
+ SpamAssassinConfig *config;
debug_print("Saving SpamAssassin Page\n");
- spamassassin_enable = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->enable));
- if (spamassassin_hostname)
- g_free(spamassassin_hostname);
- spamassassin_hostname = gtk_editable_get_chars(GTK_EDITABLE(page->hostname), 0, -1);
- tmp = gtk_editable_get_chars(GTK_EDITABLE(page->port), 0, -1);
- spamassassin_port = atoi(tmp);
- g_free(tmp);
- spamassassin_max_size = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(page->max_size));
- spamassassin_receive_spam = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->receive_spam));
- if (spamassassin_save_folder)
- g_free(spamassassin_save_folder);
- spamassassin_save_folder = gtk_editable_get_chars(GTK_EDITABLE(page->save_folder), 0, -1);
+ config = spamassassin_get_config();
- spamassassin_save_config();
-}
+ /* enable */
+ config->enable = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->enable));
-static void spamassassin_destroy_func(PrefsPage *_page)
-{
- debug_print("Destroying SpamAssassin Page\n");
- g_free(_page);
+ /* hostname */
+ g_free(config->hostname);
+ config->hostname = gtk_editable_get_chars(GTK_EDITABLE(page->hostname), 0, -1);
+
+ /* port */
+ config->port = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(page->port));
+
+ /* maxsize */
+ config->max_size = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(page->max_size));
+
+ /* receive_spam */
+ config->receive_spam = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->receive_spam));
+
+ /* save_folder */
+ g_free(config->save_folder);
+ config->save_folder = gtk_editable_get_chars(GTK_EDITABLE(page->save_folder), 0, -1);
+
+ spamassassin_save_config();
}
-static struct SpamAssassinPage *spamassassin_page;
+static struct SpamAssassinPage spamassassin_page;
gint plugin_init(gchar **error)
{
- struct SpamAssassinPage *page;
+ spamassassin_page.page.path = "Filtering/SpamAssassin";
+ spamassassin_page.page.create_widget = spamassassin_create_widget_func;
+ spamassassin_page.page.destroy_widget = spamassassin_destroy_widget_func;
+ spamassassin_page.page.save_page = spamassassin_save_func;
- page = g_new0(struct SpamAssassinPage, 1);
- page->page.path = _("Filtering/SpamAssassin");
- page->page.create_widget = spamassassin_create_widget_func;
- page->page.destroy_widget = spamassassin_destroy_widget_func;
- page->page.save_page = spamassassin_save_func;
- page->page.destroy_page = spamassassin_destroy_func;
- prefswindow_register_page((PrefsPage *) page);
-
- spamassassin_page = page;
+ prefs_gtk_register_page((PrefsPage *) &spamassassin_page);
debug_print("SpamAssassin GTK plugin loaded\n");
return 0;
void plugin_done()
{
- prefswindow_unregister_page((PrefsPage *) spamassassin_page);
- g_free(spamassassin_page);
+ prefs_gtk_unregister_page((PrefsPage *) &spamassassin_page);
debug_print("SpamAssassin GTK plugin unloaded\n");
}
return "This plugin provides a Preferences page for the SpamAssassin "
"plugin.\n"
"\n"
- "You will find the options in the Preferences window under "
- "Filtering/SpamAssassin.\n"
+ "You will find the options in the Other Preferences window "
+ "under Filtering/SpamAssassin.\n"
"\n"
"With this plugin you can enable the filtering, change the "
- "SpamAssassin server's host and port, the maximum size that "
- "a message is allowed to have (if the message is larger it "
- "will not be checked), set the option if spam mails "
- "should be received at all (default) and select the folder "
- "where spam mails will be saved.\n";
+ "SpamAssassin server host and port, set the maximum size of "
+ "messages to be checked, (if the message is larger it will "
+ "not be checked), configure whether spam mail should be received "
+ "(default: Yes) and select the folder where spam mail will be "
+ "saved.\n";
+}
+
+const gchar *plugin_type()
+{
+ return "GTK";
}