0.9.4claws46
[claws.git] / src / plugins / spamassassin / spamassassin_gtk.c
index 6db6a94a6dc2b28ae3a294631c8f6b3523d67926..7b41f3c7dc8d2e7ab5e8642cd363b9ed3259f1a9 100644 (file)
@@ -26,6 +26,8 @@
 #include <glib.h>
 #include <gtk/gtk.h>
 
+#include "common/sylpheed.h"
+#include "common/version.h"
 #include "intl.h"
 #include "plugin.h"
 #include "common/utils.h"
@@ -62,12 +64,17 @@ static void foldersel_cb(GtkWidget *widget, gpointer data)
        }
 }
 
-static void spamassassin_create_widget_func(PrefsPage * _page, GtkWindow *window, gpointer data)
+static void spamassassin_create_widget_func(PrefsPage * _page,
+                                           GtkWindow * window,
+                                           gpointer data)
 {
        struct SpamAssassinPage *page = (struct SpamAssassinPage *) _page;
        SpamAssassinConfig *config;
 
-       /* ------------------ code made by glade -------------------- */
+       /*
+        * BEGIN GLADE CODE
+        * DO NOT EDIT
+        */
        GtkWidget *table1;
        GtkWidget *label3;
        GtkWidget *label4;
@@ -75,84 +82,50 @@ static void spamassassin_create_widget_func(PrefsPage * _page, GtkWindow *window
        GtkWidget *label8;
        GtkWidget *label9;
        GtkWidget *hbox1;
-       GtkWidget *hbox2;
        GtkWidget *hostname;
        GtkWidget *label5;
        GtkObject *port_adj;
        GtkWidget *port;
        GtkWidget *enable;
        GtkWidget *receive_spam;
-       GtkWidget *label10;
-       GtkObject *max_size_adj;
-       GtkWidget *max_size;
        GtkWidget *save_folder;
        GtkWidget *button4;
        GtkWidget *label11;
+       GtkWidget *hbox3;
+       GtkObject *max_size_adj;
+       GtkWidget *max_size;
+       GtkTooltips *tooltips;
 
-       table1 = gtk_table_new(6, 3, FALSE);
+       tooltips = gtk_tooltips_new();
+
+       table1 = gtk_table_new(5, 3, FALSE);
        gtk_widget_show(table1);
+       gtk_container_set_border_width(GTK_CONTAINER(table1), 8);
        gtk_table_set_row_spacings(GTK_TABLE(table1), 4);
        gtk_table_set_col_spacings(GTK_TABLE(table1), 8);
 
-       label3 = gtk_label_new(_("Enable SpamAssassin Filtering"));
+       label3 = gtk_label_new(_("Enable"));
        gtk_widget_show(label3);
        gtk_table_attach(GTK_TABLE(table1), label3, 0, 1, 0, 1,
                         (GtkAttachOptions) (GTK_FILL),
                         (GtkAttachOptions) (0), 0, 0);
        gtk_misc_set_alignment(GTK_MISC(label3), 0, 0.5);
 
-       label4 = gtk_label_new(_("SpamAssassin Server (spamd)"));
+       label4 = gtk_label_new(_("spamd "));
        gtk_widget_show(label4);
        gtk_table_attach(GTK_TABLE(table1), label4, 0, 1, 1, 2,
                         (GtkAttachOptions) (GTK_FILL),
                         (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"));
+       label6 = gtk_label_new(_("Maximum Size"));
        gtk_widget_show(label6);
        gtk_table_attach(GTK_TABLE(table1), label6, 0, 1, 2, 3,
                         (GtkAttachOptions) (GTK_FILL),
                         (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"));
+       label8 = gtk_label_new(_("Save Folder"));
        gtk_widget_show(label8);
        gtk_table_attach(GTK_TABLE(table1), label8, 0, 1, 4, 5,
                         (GtkAttachOptions) (GTK_FILL),
@@ -160,51 +133,103 @@ static void spamassassin_create_widget_func(PrefsPage * _page, GtkWindow *window
        gtk_label_set_justify(GTK_LABEL(label8), GTK_JUSTIFY_LEFT);
        gtk_misc_set_alignment(GTK_MISC(label8), 0, 0.5);
 
-       label9 = gtk_label_new(_("Receive Spam"));
+       label9 = gtk_label_new(_("Save Spam"));
        gtk_widget_show(label9);
        gtk_table_attach(GTK_TABLE(table1), label9, 0, 1, 3, 4,
                         (GtkAttachOptions) (GTK_FILL),
                         (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);
+       gtk_tooltips_set_tip(tooltips, hostname,
+                            _("Hostname or IP address of spamd server"),
+                            NULL);
+
+       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_end(GTK_BOX(hbox1), port, FALSE, TRUE, 0);
+       gtk_widget_set_usize(port, 64, -2);
+       gtk_tooltips_set_tip(tooltips, port, _("Port of spamd server"),
+                            NULL);
+       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,
                         (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                         (GtkAttachOptions) (0), 0, 0);
+       gtk_tooltips_set_tip(tooltips, enable,
+                            _("Enable SpamAssassin filtering"), NULL);
 
        receive_spam = gtk_check_button_new_with_label("");
        gtk_widget_show(receive_spam);
        gtk_table_attach(GTK_TABLE(table1), receive_spam, 1, 2, 3, 4,
                         (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                         (GtkAttachOptions) (0), 0, 0);
-
-       label10 =
-           gtk_label_new(_
-                         ("Leave empty to use the default trash folder"));
-       gtk_widget_show(label10);
-       gtk_table_attach(GTK_TABLE(table1), label10, 1, 2, 5, 6,
-                        (GtkAttachOptions) (GTK_FILL),
-                        (GtkAttachOptions) (0), 0, 0);
-       gtk_label_set_justify(GTK_LABEL(label10), GTK_JUSTIFY_RIGHT);
-       gtk_misc_set_alignment(GTK_MISC(label10), 1, 0.5);
+       gtk_tooltips_set_tip(tooltips, receive_spam,
+                            _
+                            ("Save mails that where identified as spam to a folder"),
+                            NULL);
 
        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);
+       gtk_tooltips_set_tip(tooltips, save_folder,
+                            _
+                            ("Folder that will be used to save spam. Leave empty to use the default trash folder"),
+                            NULL);
 
-       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);
+
+       hbox3 = gtk_hbox_new(FALSE, 0);
+       gtk_widget_show(hbox3);
+       gtk_table_attach(GTK_TABLE(table1), hbox3, 1, 2, 2, 3,
+                        (GtkAttachOptions) (GTK_EXPAND | 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_end(GTK_BOX(hbox3), max_size, FALSE, TRUE, 0);
+       gtk_widget_set_usize(max_size, 64, -2);
+       gtk_tooltips_set_tip(tooltips, max_size,
+                            _
+                            ("Maximum size a message is allowed to have to be checked"),
+                            NULL);
+       gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(max_size), TRUE);
+       /*
+        * END GLADE CODE
+        */
 
        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), config->enable);
@@ -267,10 +292,21 @@ static struct SpamAssassinPage spamassassin_page;
 
 gint plugin_init(gchar **error)
 {
-       spamassassin_page.page.path = "Filtering/SpamAssassin";
+       if ((sylpheed_get_version() > VERSION_NUMERIC)) {
+               *error = g_strdup("Your sylpheed version is newer than the version the plugin was built with");
+               return -1;
+       }
+
+       if ((sylpheed_get_version() < MAKE_NUMERIC_VERSION(0, 9, 3, 86))) {
+               *error = g_strdup("Your sylpheed version is too old");
+               return -1;
+       }
+
+       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;
+       spamassassin_page.page.weight = 35.0;
 
        prefs_gtk_register_page((PrefsPage *) &spamassassin_page);
 
@@ -287,23 +323,23 @@ void plugin_done(void)
 
 const gchar *plugin_name(void)
 {
-       return "SpamAssassin GTK";
+       return _("SpamAssassin GTK");
 }
 
 const gchar *plugin_desc(void)
 {
-       return "This plugin provides a Preferences page for the SpamAssassin "
-              "plugin.\n"
-              "\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 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";
+       return _("This plugin provides a Preferences page for the SpamAssassin "
+                "plugin.\n"
+                "\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 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(void)