2006-02-27 [cleroy] 2.0.0cvs84
authorColin Leroy <colin@colino.net>
Mon, 27 Feb 2006 17:47:53 +0000 (17:47 +0000)
committerColin Leroy <colin@colino.net>
Mon, 27 Feb 2006 17:47:53 +0000 (17:47 +0000)
* configure.ac
* src/Makefile.am
* src/mainwindow.c
* src/mainwindow.h
* src/messageview.c
* src/messageview.h
* src/prefs_toolbar.c
* src/procmsg.c
* src/stock_pixmap.c
* src/stock_pixmap.h
* src/summaryview.c
* src/toolbar.c
* src/toolbar.h
* src/pixmaps/ham_btn.xpm
* src/pixmaps/spam.xpm
* src/pixmaps/spam_btn.xpm
* src/plugins/spamassassin/spamassassin.c
Add button in toolbar for spam learning
Fix a few bugs from the last related commit
Revert 1.9.6cvs23 which messed up shift-selection

19 files changed:
ChangeLog
PATCHSETS
configure.ac
src/Makefile.am
src/mainwindow.c
src/mainwindow.h
src/messageview.c
src/messageview.h
src/pixmaps/ham_btn.xpm [new file with mode: 0644]
src/pixmaps/spam.xpm
src/pixmaps/spam_btn.xpm [new file with mode: 0644]
src/plugins/spamassassin/spamassassin.c
src/prefs_toolbar.c
src/procmsg.c
src/stock_pixmap.c
src/stock_pixmap.h
src/summaryview.c
src/toolbar.c
src/toolbar.h

index 2322722dbd070dbd9a98af13c439674d3603d2e1..533b801e3e7648fd4ce8bf5b17acf711aa1d0613 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2006-02-27 [cleroy]    2.0.0cvs84
+
+       * configure.ac
+       * src/Makefile.am
+       * src/mainwindow.c
+       * src/mainwindow.h
+       * src/messageview.c
+       * src/messageview.h
+       * src/prefs_toolbar.c
+       * src/procmsg.c
+       * src/stock_pixmap.c
+       * src/stock_pixmap.h
+       * src/summaryview.c
+       * src/toolbar.c
+       * src/toolbar.h
+       * src/pixmaps/ham_btn.xpm
+       * src/pixmaps/spam.xpm
+       * src/pixmaps/spam_btn.xpm
+       * src/plugins/spamassassin/spamassassin.c
+               Add button in toolbar for spam learning
+               Fix a few bugs from the last related commit
+               Revert 1.9.6cvs23 which messed up shift-selection
+
 2006-02-24 [colin]     2.0.0cvs83
 
        * src/procmsg.c
index aee8d9d3ec4a8c635ab125f2e524f0dcbff46fdd..576e0763f039b66bb86b1354868466da17c32663 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.382.2.246 -r 1.382.2.247 src/compose.c;  cvs diff -u -r 1.50.2.21 -r 1.50.2.22 src/compose.h;  cvs diff -u -r 1.60.2.13 -r 1.60.2.14 src/filtering.c;  ) > 2.0.0cvs81.patchset
 ( cvs diff -u -r 1.155.2.35 -r 1.155.2.36 src/Makefile.am;  cvs diff -u -r 1.274.2.99 -r 1.274.2.100 src/mainwindow.c;  cvs diff -u -r 1.39.2.12 -r 1.39.2.13 src/mainwindow.h;  cvs diff -u -r 1.150.2.51 -r 1.150.2.52 src/procmsg.c;  cvs diff -u -r 1.60.2.23 -r 1.60.2.24 src/procmsg.h;  cvs diff -u -r 1.25.2.20 -r 1.25.2.21 src/stock_pixmap.c;  cvs diff -u -r 1.18.2.14 -r 1.18.2.15 src/stock_pixmap.h;  cvs diff -u -r 1.395.2.173 -r 1.395.2.174 src/summaryview.c;  cvs diff -u -r 1.68.2.15 -r 1.68.2.16 src/summaryview.h;  cvs diff -u -r 1.1.2.6 -r 1.1.2.7 src/gtk/icon_legend.c;  diff -u /dev/null src/pixmaps/spam.xpm;  cvs diff -u -r 1.18.2.17 -r 1.18.2.18 src/plugins/spamassassin/spamassassin.c;  cvs diff -u -r 1.23.2.18 -r 1.23.2.19 src/plugins/spamassassin/spamassassin_gtk.c;  ) > 2.0.0cvs82.patchset
 ( cvs diff -u -r 1.150.2.52 -r 1.150.2.53 src/procmsg.c;  cvs diff -u -r 1.395.2.174 -r 1.395.2.175 src/summaryview.c;  cvs diff -u -r 1.68.2.16 -r 1.68.2.17 src/summaryview.h;  cvs diff -u -r 1.18.2.18 -r 1.18.2.19 src/plugins/spamassassin/spamassassin.c;  cvs diff -u -r 1.4.2.6 -r 1.4.2.7 src/plugins/spamassassin/spamassassin.h;  cvs diff -u -r 1.23.2.19 -r 1.23.2.20 src/plugins/spamassassin/spamassassin_gtk.c;  ) > 2.0.0cvs83.patchset
+( cvs diff -u -r 1.654.2.1313 -r 1.654.2.1314 configure.ac;  cvs diff -u -r 1.155.2.36 -r 1.155.2.37 src/Makefile.am;  cvs diff -u -r 1.274.2.100 -r 1.274.2.101 src/mainwindow.c;  cvs diff -u -r 1.39.2.13 -r 1.39.2.14 src/mainwindow.h;  cvs diff -u -r 1.94.2.77 -r 1.94.2.78 src/messageview.c;  cvs diff -u -r 1.19.2.6 -r 1.19.2.7 src/messageview.h;  cvs diff -u -r 1.30.2.25 -r 1.30.2.26 src/prefs_toolbar.c;  cvs diff -u -r 1.150.2.53 -r 1.150.2.54 src/procmsg.c;  cvs diff -u -r 1.25.2.21 -r 1.25.2.22 src/stock_pixmap.c;  cvs diff -u -r 1.18.2.15 -r 1.18.2.16 src/stock_pixmap.h;  cvs diff -u -r 1.395.2.175 -r 1.395.2.176 src/summaryview.c;  cvs diff -u -r 1.43.2.39 -r 1.43.2.40 src/toolbar.c;  cvs diff -u -r 1.19.2.8 -r 1.19.2.9 src/toolbar.h;  diff -u /dev/null src/pixmaps/ham_btn.xpm;  cvs diff -u -r 1.1.2.1 -r 1.1.2.2 src/pixmaps/spam.xpm;  diff -u /dev/null src/pixmaps/spam_btn.xpm;  cvs diff -u -r 1.18.2.19 -r 1.18.2.20 src/plugins/spamassassin/spamassassin.c;  ) > 2.0.0cvs84.patchset
index eba9703228eca6f727867e4bf949097bf667cb75..16c0daa39c1d6191ac60386f46dcf7effcf1425f 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=0
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=83
+EXTRA_VERSION=84
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
@@ -616,6 +616,7 @@ if test x"$ac_cv_enable_spamassassin_plugin" = xyes; then
        AC_MSG_RESULT(yes)
        AC_SPAMASSASSIN
        PLUGINS="spamassassin $PLUGINS"
+       AC_DEFINE(USE_SPAMASSASSIN_PLUGIN, 1, Define if spamassassin plugin is being build.)
 else
        AC_MSG_RESULT(no)
 fi
index 345d65d91c5a0728d538ea08b56442e5df0789f7..1dbb5b8cd021e337e338be0a8b77a84c8fe10d89 100644 (file)
@@ -315,6 +315,7 @@ EXTRA_DIST = \
        pixmaps/forwarded.xpm \
        pixmaps/gpg_signed.xpm \
        pixmaps/group.xpm \
+       pixmaps/ham_btn.xpm \
        pixmaps/ignorethread.xpm \
        pixmaps/inbox_hrm.xpm \
        pixmaps/inbox.xpm \
@@ -372,6 +373,7 @@ EXTRA_DIST = \
        pixmaps/replied.xpm \
        pixmaps/search.xpm \
        pixmaps/spam.xpm \
+       pixmaps/spam_btn.xpm \
        pixmaps/sylpheed_icon.xpm \
        pixmaps/sylpheed_logo.xpm \
        pixmaps/sylpheed.xpm \
index cc6ab9ede9bc04a0c89cdfcd11dcd928fa1a35fb..4e242a70c83b2378aee21ba1139063a3beb921be 100644 (file)
@@ -936,6 +936,9 @@ MainWindow *main_window_create(SeparateType type)
        mainwin->toolbar = toolbar_create(TOOLBAR_MAIN, 
                                          handlebox, 
                                          (gpointer)mainwin);
+       toolbar_set_learn_button
+               (mainwin->toolbar,
+                LEARN_SPAM);
 
        /* vbox that contains body */
        vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
@@ -3389,7 +3392,7 @@ static void sync_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
        mainwindow_check_synchronise(mainwin, FALSE);
 }
 
-/*
-* End of Source.
-*/
-
+void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
+{
+       summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
+}
index 82e7384b1714eb9326683dfebeb52609fcb4000b..3746b7667e73b29b10639c23f0c4fc12bd7d819f 100644 (file)
@@ -202,4 +202,6 @@ gboolean mainwindow_key_pressed                   (GtkWidget         *widget,
                                               GdkEventKey       *event,
                                               gpointer           data);
 MainWindow *mainwindow_get_mainwindow        (void);
+void mainwindow_learn                        (MainWindow *mainwin,
+                                              gboolean is_spam);
 #endif /* __MAINWINDOW_H__ */
index d4e84a36e7445856252f6e86a4b4ef2a48622394..92dfcaa36158eaf8db9daa63f4730cada23bb240 100644 (file)
@@ -747,6 +747,25 @@ gint messageview_show(MessageView *messageview, MsgInfo *msginfo,
        gchar *subject = NULL;
        g_return_val_if_fail(msginfo != NULL, -1);
 
+       if (messageview->toolbar)
+               toolbar_set_learn_button
+                       (messageview->toolbar,
+                        MSG_IS_SPAM(msginfo->flags)?LEARN_HAM:LEARN_SPAM);
+       else
+               toolbar_set_learn_button
+                       (messageview->mainwin->toolbar,
+                        MSG_IS_SPAM(msginfo->flags)?LEARN_HAM:LEARN_SPAM);
+
+       if (messageview->toolbar) {
+               if (messageview->toolbar->learn_ham_btn)
+                       gtk_widget_set_sensitive(
+                               messageview->toolbar->learn_ham_btn, 
+                               procmsg_spam_can_learn());
+               if (messageview->toolbar->learn_spam_btn)
+                       gtk_widget_set_sensitive(
+                               messageview->toolbar->learn_spam_btn, 
+                               procmsg_spam_can_learn());
+       }
        mimeinfo = procmime_scan_message(msginfo);
        if (!mimeinfo) {
                textview_show_error(messageview->mimeview->textview);
@@ -1592,3 +1611,22 @@ void messageview_set_menu_sensitive(MessageView *messageview)
                         messageview->mimeview->textview->show_all_headers);
        }
 }
+
+void messageview_learn (MessageView *msgview, gboolean is_spam)
+{
+       if (is_spam) {
+               procmsg_msginfo_set_flags(msgview->msginfo, MSG_SPAM, 0);
+               procmsg_spam_learner_learn(msgview->msginfo, NULL, TRUE);
+       } else {
+               procmsg_msginfo_unset_flags(msgview->msginfo, MSG_SPAM, 0);
+               procmsg_spam_learner_learn(msgview->msginfo, NULL, FALSE);
+       }
+       if (msgview->toolbar)
+               toolbar_set_learn_button
+                       (msgview->toolbar,
+                        MSG_IS_SPAM(msgview->msginfo->flags)?LEARN_HAM:LEARN_SPAM);
+       else
+               toolbar_set_learn_button
+                       (msgview->mainwin->toolbar,
+                        MSG_IS_SPAM(msgview->msginfo->flags)?LEARN_HAM:LEARN_SPAM);
+}
index 1e7a03027dc0dda65231c2eb0473f74f47188856..ebf7a27458e04de91a4f047d462949a37a17adbe 100644 (file)
@@ -109,5 +109,7 @@ void messageview_reflect_prefs_pixmap_theme (void);
 gchar *messageview_get_selection               (MessageView    *msgview);
 
 void messageview_set_menu_sensitive            (MessageView    *msgview);
+void messageview_learn                         (MessageView    *msgview,
+                                                gboolean is_spam);
 
 #endif /* __MESSAGEVIEW_H__ */
diff --git a/src/pixmaps/ham_btn.xpm b/src/pixmaps/ham_btn.xpm
new file mode 100644 (file)
index 0000000..75242f2
--- /dev/null
@@ -0,0 +1,74 @@
+/* XPM */
+static char * ham_btn_xpm[] = {
+"24 24 47 1",
+"      c None",
+".     c #999999",
+"+     c #000000",
+"@     c #929292",
+"#     c #535353",
+"$     c #FFFFFF",
+"%     c #FEFEFE",
+"&     c #FDFDFD",
+"*     c #FCFCFC",
+"=     c #FBFBFB",
+"-     c #F9F9F9",
+";     c #F8F8F8",
+">     c #F7F7F7",
+",     c #F6F6F6",
+"'     c #F5F5F5",
+")     c #F4F4F4",
+"!     c #E3E3E3",
+"~     c #EEEEEE",
+"{     c #4F4F4F",
+"]     c #F3F3F3",
+"^     c #F2F2F2",
+"/     c #F1F1F1",
+"(     c #F0F0F0",
+"_     c #EFEFEF",
+":     c #EDEDED",
+"<     c #AEAEAE",
+"[     c #E4E4E4",
+"}     c #434343",
+"|     c #ACACAC",
+"1     c #C8C8C8",
+"2     c #A0A0A0",
+"3     c #D4D4D4",
+"4     c #ECECEC",
+"5     c #959595",
+"6     c #3E3E3E",
+"7     c #4D4D4D",
+"8     c #818181",
+"9     c #C6C6C6",
+"0     c #6A6A6A",
+"a     c #A7A7A7",
+"b     c #636363",
+"c     c #B9B9B9",
+"d     c #606060",
+"e     c #FFD10D",
+"f     c #737373",
+"g     c #7C7C7C",
+"h     c #BCBCBC",
+"                        ",
+"                        ",
+"                        ",
+"                        ",
+"                        ",
+"  .+++++++++++++++++@   ",
+"  +#$$$$%&*=-;>,')!#+   ",
+"  +~{$')]^^/((_~:!{<+   ",
+"  +$[}&]^^/(_~~:!{|1+   ",
+"  +$'[{=/((_~::!}231+   ",
+"  +$='[};(_~:4!{53[1+   ",
+"  +$'''[6'~:4!789[[1+   ",
+"  +$=''[0}]447a++++++   ",
+"  +$''[b$c{(7ddeeeeedd  ",
+"  +$=[b$'[3{adeeeeeeeda ",
+"  +$[f$'''''+ee+eee+ee+ ",
+"  +$g$[[[[[[+eeeeeeeee+ ",
+"  +fhhhhhhhh+eeeeeeeee+ ",
+"  @++++++++++eeeeeeeee+ ",
+"            +ee+eee+ee+ ",
+"            adee+++eeda ",
+"             ddeeeeedd  ",
+"              a+++++a   ",
+"                        "};
index ba147e606ba338bd2dc14ab4626e086e75888810..c5915de6aeeadc0cbfccb475edf876b39d8ae68a 100644 (file)
@@ -1,17 +1,20 @@
 /* XPM */
 static char * spam_xpm[] = {
-"10 10 4 1",
+"10 10 7 1",
 "      c None",
-".     c #DF0B18",
-"+     c #CC0000",
-"@     c #D5050C",
+".     c #606060",
+"+     c #130303",
+"@     c #454343",
+"#     c #000000",
+"$     c #0A0A0A",
+"%     c #FFD10D",
 "  .++++.  ",
-" ++....+@ ",
-".+.   .++.",
-"+.   .+..+",
-"+.  .+. .+",
-"+. .+.  .+",
-"+..+.   .+",
-".++.   .+.",
-" ++....++ ",
+" @#####$@ ",
+".########.",
+"+##%##%##+",
+"+########+",
+"+########+",
+"+###%%###+",
+".##%##%##.",
+" @######@ ",
 "  .++++.  "};
diff --git a/src/pixmaps/spam_btn.xpm b/src/pixmaps/spam_btn.xpm
new file mode 100644 (file)
index 0000000..bb4b846
--- /dev/null
@@ -0,0 +1,75 @@
+/* XPM */
+static char * spam_btn_xpm[] = {
+"24 24 48 1",
+"      c None",
+".     c #999999",
+"+     c #000000",
+"@     c #929292",
+"#     c #535353",
+"$     c #FFFFFF",
+"%     c #FEFEFE",
+"&     c #FDFDFD",
+"*     c #FCFCFC",
+"=     c #FBFBFB",
+"-     c #F9F9F9",
+";     c #F8F8F8",
+">     c #F7F7F7",
+",     c #F6F6F6",
+"'     c #F5F5F5",
+")     c #F4F4F4",
+"!     c #E3E3E3",
+"~     c #EEEEEE",
+"{     c #4F4F4F",
+"]     c #F3F3F3",
+"^     c #F2F2F2",
+"/     c #F1F1F1",
+"(     c #F0F0F0",
+"_     c #EFEFEF",
+":     c #EDEDED",
+"<     c #AEAEAE",
+"[     c #E4E4E4",
+"}     c #434343",
+"|     c #ACACAC",
+"1     c #C8C8C8",
+"2     c #A0A0A0",
+"3     c #D4D4D4",
+"4     c #ECECEC",
+"5     c #959595",
+"6     c #3E3E3E",
+"7     c #4D4D4D",
+"8     c #818181",
+"9     c #C6C6C6",
+"0     c #6A6A6A",
+"a     c #868686",
+"b     c #1E1E1E",
+"c     c #636363",
+"d     c #B9B9B9",
+"e     c #333333",
+"f     c #737373",
+"g     c #FFD10D",
+"h     c #7C7C7C",
+"i     c #BCBCBC",
+"                        ",
+"                        ",
+"                        ",
+"                        ",
+"                        ",
+"  .+++++++++++++++++@   ",
+"  +#$$$$%&*=-;>,')!#+   ",
+"  +~{$')]^^/((_~:!{<+   ",
+"  +$[}&]^^/(_~~:!{|1+   ",
+"  +$'[{=/((_~::!}231+   ",
+"  +$='[};(_~:4!{53[1+   ",
+"  +$'''[6'~:4!789[[1+   ",
+"  +$=''[0}]447a++++b+   ",
+"  +$''[c$d{(7ee+++++ee  ",
+"  +$=[c$'[3{ae+++++++ea ",
+"  +$[f$'''''+++g+++g+++ ",
+"  +$h$[[[[[[+++++++++++ ",
+"  +fiiiiiiii+++++++++++ ",
+"  @+++++++++++++ggg++++ ",
+"            +++g+++g+++ ",
+"            ae+++++++ea ",
+"             ee+++++ee  ",
+"              a+++++a   ",
+"                        "};
index ed48d70bea0fc0949df90cfe66a1d1d0582caaf6..6dd257e49f3115b60026e8d444c7c75b5f135016 100644 (file)
@@ -45,6 +45,8 @@
 
 #include "libspamc.h"
 #include "spamassassin.h"
+#include "log.h"
+#include "prefs_common.h"
 
 #ifdef HAVE_SYSEXITS_H
 #include <sysexits.h>
@@ -266,7 +268,8 @@ void spamassassin_learn(MsgInfo *msginfo, GSList *msglist, gboolean spam)
                file = procmsg_get_message_file(msginfo);
                if (file == NULL)
                        return;
-               cmd = g_strdup_printf("sa-learn %s %s", 
+               cmd = g_strdup_printf("sa-learn %s %s %s", 
+                       prefs_common.work_offline?"-L":"",
                        spam?"--spam":"--ham", file);
        }
        if (msglist) {
index 5f22dbb02c499b989f7ad00243b64efcf87a82d7..73298d90f3d57c0c874fbad38ab2a16c86daf428 100644 (file)
@@ -293,8 +293,10 @@ static void prefs_toolbar_populate(ToolbarPage *prefs_toolbar)
                g_list_free(syl_actions);
        }
 
-       for (i = 0; i < STOCK_PIXMAP_SYLPHEED_LOGO; i++) {
+       for (i = 0; i < STOCK_PIXMAP_EMPTY; i++) {
                GdkPixbuf *pixbuf;
+               if (i == STOCK_PIXMAP_SYLPHEED_LOGO)
+                       continue;/* that's too big */
 
                stock_pixbuf_gdk(prefs_toolbar->window, i, &pixbuf);
                
index c1c877fcd236d893a3f8b3b56f2d954620e476b3..8f89d8563b316083ce148a6c54b8f4f0a3fe06a9 100644 (file)
@@ -2079,6 +2079,7 @@ void procmsg_register_spam_learner (void (*learn_func)(MsgInfo *info, GSList *li
                main_window_set_menu_sensitive(mainwindow_get_mainwindow());
                summary_set_menu_sensitive(
                        mainwindow_get_mainwindow()->summaryview);
+               toolbar_main_set_sensitive(mainwindow_get_mainwindow());
        }
 }
 
@@ -2089,6 +2090,7 @@ void procmsg_unregister_spam_learner (void (*learn_func)(MsgInfo *info, GSList *
                main_window_set_menu_sensitive(mainwindow_get_mainwindow());
                summary_set_menu_sensitive(
                        mainwindow_get_mainwindow()->summaryview);
+               toolbar_main_set_sensitive(mainwindow_get_mainwindow());
        }
 }
 
index 90b3400f66c42daf3f0400ef6cbdab43d76b0fc4..f6bbe602a4e0cee8100fb51e90c2faeee100c9fd 100644 (file)
 #include "pixmaps/drafts_open_mark.xpm"
 #include "pixmaps/dir_noselect.xpm"
 #include "pixmaps/spam.xpm"
+#include "pixmaps/spam_btn.xpm"
+#include "pixmaps/ham_btn.xpm"
 #include "pixmaps/empty.xpm"
 
 typedef struct _StockPixmapData        StockPixmapData;
@@ -296,6 +298,8 @@ static StockPixmapData pixmaps[] =
        {sylpheed_logo_xpm                      , NULL, NULL, "sylpheed_logo", NULL},
         {dir_noselect_xpm                       , NULL, NULL, "dir_noselect" , NULL},
         {spam_xpm                               , NULL, NULL, "spam" , NULL},
+        {spam_btn_xpm                           , NULL, NULL, "spam_btn" , NULL},
+        {ham_btn_xpm                            , NULL, NULL, "ham_btn" , NULL},
         {empty_xpm                              , NULL, NULL, "empty" , NULL}
 };
 
index 8da74f74b5edbb25ceb4056b172d7ae153aec51d..dc05fb1cfa94fba6e76ded61ae4c78cf1ea97e5c 100644 (file)
@@ -153,6 +153,8 @@ typedef enum
        STOCK_PIXMAP_SYLPHEED_LOGO,
        STOCK_PIXMAP_DIR_NOSELECT, 
        STOCK_PIXMAP_SPAM,
+       STOCK_PIXMAP_SPAM_BTN,
+       STOCK_PIXMAP_HAM_BTN,
        STOCK_PIXMAP_EMPTY,              /* last entry */
        N_STOCK_PIXMAPS
 } StockPixmap;
index 606f25586203f939920fd13b3fcfc0f645f68445..39642a26611d9dba07eeb7d81a30a426f78e22eb 100644 (file)
@@ -3221,7 +3221,7 @@ void summary_mark_as_spam(SummaryView *summaryview, guint action, GtkWidget *wid
        gboolean is_spam = action;
        GSList *msgs = NULL;
        gboolean immediate_exec = prefs_common.immediate_exec;
-       
+       gboolean moved = FALSE;
        prefs_common.immediate_exec = FALSE;
 
        START_LONG_OPERATION(summaryview);
@@ -3231,7 +3231,10 @@ void summary_mark_as_spam(SummaryView *summaryview, guint action, GtkWidget *wid
                MsgInfo *msginfo = gtk_ctree_node_get_row_data(ctree, row);
                if (is_spam) {
                        summary_msginfo_change_flags(msginfo, MSG_SPAM, 0, MSG_NEW|MSG_UNREAD, 0);
-                       summary_move_row_to(summaryview, row, procmsg_spam_get_folder());
+                       if (procmsg_spam_get_folder() != summaryview->folder_item) {
+                               summary_move_row_to(summaryview, row, procmsg_spam_get_folder());
+                               moved = TRUE;
+                       }
                } else {
                        summary_msginfo_unset_flags(msginfo, MSG_SPAM, 0);
                }
@@ -3245,7 +3248,7 @@ void summary_mark_as_spam(SummaryView *summaryview, guint action, GtkWidget *wid
 
        END_LONG_OPERATION(summaryview);
 
-       if (prefs_common.immediate_exec) {
+       if (prefs_common.immediate_exec && moved) {
                summary_execute(summaryview);
        }
 
@@ -4876,6 +4879,27 @@ static gboolean summary_key_pressed(GtkWidget *widget, GdkEventKey *event,
        case GDK_Escape:
                gtk_widget_grab_focus(summaryview->folderview->ctree);
                return TRUE;
+       case GDK_Up:
+       case GDK_Down:
+               if ((node = summaryview->selected) != NULL) {
+                       GtkCTreeNode *next = NULL;
+                       do {
+                               next = (event->keyval == GDK_Down)
+                                       ? gtkut_ctree_node_next(ctree, next ? next:node)
+                                       : gtkut_ctree_node_prev(ctree, next ? next:node);
+                       } while (next && !gtk_ctree_is_viewable(ctree, next));
+
+                       if (next) {
+                               gtk_sctree_select_with_state
+                                       (GTK_SCTREE(ctree), next, event->state);
+                               
+                               /* Deprecated - what are the non-deprecated equivalents? */
+                               if (gtk_ctree_node_is_visible(GTK_CTREE(ctree), next) != GTK_VISIBILITY_FULL)
+                                       gtk_ctree_node_moveto(GTK_CTREE(ctree), next, 0, 0, 0);
+                               summaryview->selected = next;
+                       }
+               }
+               return TRUE;
        case GDK_Home:
        case GDK_End:
                if ((node = summaryview->selected) != NULL) {
@@ -5061,6 +5085,10 @@ static void summary_selected(GtkCTree *ctree, GtkCTreeNode *row,
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
        g_return_if_fail(msginfo != NULL);
 
+       toolbar_set_learn_button
+               (summaryview->mainwin->toolbar,
+                MSG_IS_SPAM(msginfo->flags)?LEARN_HAM:LEARN_SPAM);
+
        switch (column < 0 ? column : summaryview->col_state[column].type) {
        case S_COL_MARK:
                if (!MSG_IS_DELETED(msginfo->flags) &&
index 954d973aa2ed7338c05b1f36a4955943c440c868..90c460450a07ac324ed5f961fe588b2f448d52ad 100644 (file)
@@ -97,6 +97,9 @@ static void toolbar_trash_cb                  (GtkWidget      *widget,
 static void toolbar_compose_cb                 (GtkWidget      *widget,
                                                 gpointer        data);
 
+static void toolbar_learn_cb                   (GtkWidget      *widget,
+                                                gpointer        data);
+
 static void toolbar_reply_cb                   (GtkWidget      *widget,
                                                 gpointer        data);
 
@@ -173,6 +176,8 @@ struct {
        { "A_GOTO_NEXT",        N_("Go to Next Unread Message")            },
        { "A_IGNORE_THREAD",    N_("Ignore thread")                        },
        { "A_PRINT",            N_("Print")                                },
+       { "A_LEARN_SPAM",       N_("Learn Spam")                           },
+       { "A_LEARN_HAM",        N_("Learn Ham")                            },
 
        { "A_SEND",             N_("Send Message")                         },
        { "A_SENDL",            N_("Put into queue folder and send later") },
@@ -302,7 +307,7 @@ GList *toolbar_get_action_items(ToolbarType source)
                                        A_REPLY_ALL,     A_REPLY_ML,      A_FORWARD, 
                                        A_TRASH , A_DELETE_REAL,       A_EXECUTE,       A_GOTO_PREV, 
                                        A_GOTO_NEXT,    A_IGNORE_THREAD,  A_PRINT,
-                                       A_ADDRBOOK,      A_SYL_ACTIONS };
+                                       A_ADDRBOOK,     A_LEARN_SPAM, A_SYL_ACTIONS };
 
                for (i = 0; i < sizeof main_items / sizeof main_items[0]; i++)  {
                        items = g_list_append(items, gettext(toolbar_text[main_items[i]].descr));
@@ -325,7 +330,7 @@ GList *toolbar_get_action_items(ToolbarType source)
                gint msgv_items[] =   { A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
                                        A_REPLY_ALL,     A_REPLY_ML,      A_FORWARD,
                                        A_TRASH, A_DELETE_REAL,       A_GOTO_PREV,        A_GOTO_NEXT,
-                                       A_ADDRBOOK,      A_SYL_ACTIONS };       
+                                       A_ADDRBOOK,      A_LEARN_SPAM, A_SYL_ACTIONS }; 
 
                for (i = 0; i < sizeof msgv_items / sizeof msgv_items[0]; i++) 
                        items = g_list_append(items, gettext(toolbar_text[msgv_items[i]].descr));
@@ -393,6 +398,9 @@ static void toolbar_set_default_main(void)
                { A_FORWARD,       STOCK_PIXMAP_MAIL_FORWARD,         _("Forward") },
                { A_SEPARATOR,     0,                                 ("")         },
                { A_TRASH,         STOCK_PIXMAP_TRASH,                _("Trash")   },
+#ifdef USE_SPAMASSASSIN_PLUGIN
+               { A_LEARN_SPAM,    STOCK_PIXMAP_SPAM_BTN,             _("Spam")    },
+#endif
                { A_SEPARATOR,     0,                                 ("")         },
                { A_GOTO_NEXT,     STOCK_PIXMAP_DOWN_ARROW,           _("Next")    }
        };
@@ -481,6 +489,9 @@ static void toolbar_set_default_msgview(void)
                { A_FORWARD,       STOCK_PIXMAP_MAIL_FORWARD,         _("Forward") },
                { A_SEPARATOR,     0,                                 ("")         },
                { A_TRASH,         STOCK_PIXMAP_TRASH,                _("Trash")   },
+#ifdef USE_SPAMASSASSIN_PLUGIN
+               { A_LEARN_SPAM,    STOCK_PIXMAP_SPAM_BTN,             _("Spam")    },
+#endif
                { A_GOTO_NEXT,     STOCK_PIXMAP_DOWN_ARROW,           _("Next")    }
        };
        
@@ -741,6 +752,29 @@ void toolbar_set_compose_button(Toolbar            *toolbar,
                                        compose_btn_type);
 }
 
+static void activate_learn_button (Toolbar           *toolbar,
+                                    ToolbarStyle      style,
+                                    LearnButtonType type)
+{
+       if ((!toolbar->learn_spam_btn) || (!toolbar->learn_ham_btn))
+               return;
+
+       gtk_widget_hide(type == LEARN_SPAM ? toolbar->learn_ham_btn 
+                       : toolbar->learn_spam_btn);
+       gtk_widget_show(type == LEARN_SPAM ? toolbar->learn_spam_btn
+                       : toolbar->learn_ham_btn);
+       toolbar->learn_btn_type = type; 
+}
+
+void toolbar_set_learn_button(Toolbar            *toolbar, 
+                               LearnButtonType  learn_btn_type)
+{
+       if (toolbar->learn_btn_type != learn_btn_type)
+               activate_learn_button(toolbar, 
+                                       prefs_common.toolbar_style,
+                                       learn_btn_type);
+}
+
 void toolbar_toggle(guint action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow*)data;
@@ -972,6 +1006,34 @@ static void toolbar_compose_cb(GtkWidget *widget, gpointer data)
        }
 }
 
+static void toolbar_learn_cb(GtkWidget *widget, gpointer data)
+{
+       ToolbarItem *toolbar_item = (ToolbarItem*)data;
+       MainWindow *mainwin;
+       MessageView *msgview;
+
+       g_return_if_fail(toolbar_item != NULL);
+
+       switch (toolbar_item->type) {
+       case TOOLBAR_MAIN:
+               mainwin = (MainWindow*)toolbar_item->parent;
+               if (mainwin->toolbar->learn_btn_type == LEARN_SPAM) 
+                       mainwindow_learn(mainwin, TRUE);
+               else
+                       mainwindow_learn(mainwin, FALSE);
+               break;
+       case TOOLBAR_MSGVIEW:
+               msgview = (MessageView*)toolbar_item->parent;
+               if (msgview->toolbar->learn_btn_type == LEARN_SPAM) 
+                       messageview_learn(msgview, TRUE);
+               else
+                       messageview_learn(msgview, FALSE);
+               break;
+       default:
+               debug_print("toolbar event not supported\n");
+       }
+}
+
 
 /*
  * Reply Message
@@ -1304,6 +1366,8 @@ static void toolbar_buttons_cb(GtkWidget   *widget,
                { A_GOTO_NEXT,          toolbar_next_unread_cb          },
                { A_IGNORE_THREAD,      toolbar_ignore_thread_cb        },
                { A_PRINT,              toolbar_print_cb                },
+               { A_LEARN_SPAM,         toolbar_learn_cb                },
+               { A_LEARN_HAM,          toolbar_learn_cb                },
 
                { A_SEND,               toolbar_send_cb                 },
                { A_SENDL,              toolbar_send_later_cb           },
@@ -1345,9 +1409,10 @@ Toolbar *toolbar_create(ToolbarType       type,
        GtkWidget *toolbar;
        GtkWidget *icon_wid = NULL;
        GtkWidget *icon_news;
+       GtkWidget *icon_ham;
        GtkWidget *item;
        GtkWidget *item_news;
-
+       GtkWidget *item_ham;
        guint n_menu_entries;
        ComboButton *getall_combo;
        ComboButton *reply_combo;
@@ -1394,7 +1459,6 @@ Toolbar *toolbar_create(ToolbarType        type,
                toolbar_data->item_list = 
                        g_slist_append(toolbar_data->item_list, 
                                       toolbar_item);
-
                icon_wid = stock_pixmap_widget(container, stock_pixmap_get_icon(toolbar_item->file));
                item  = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
                                                toolbar_item->text,
@@ -1448,6 +1512,23 @@ Toolbar *toolbar_create(ToolbarType       type,
                                             toolbar_data->compose_news_btn,
                                           _("Compose News"), NULL);
                        break;
+               case A_LEARN_SPAM:
+                       icon_ham = stock_pixmap_widget(container, STOCK_PIXMAP_HAM_BTN);
+                       item_ham = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
+                                                           _("Ham"),
+                                                           (""),
+                                                           (""),
+                                                           icon_ham, G_CALLBACK(toolbar_buttons_cb), 
+                                                           toolbar_item);
+                       toolbar_data->learn_spam_btn = item; 
+                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
+                                            toolbar_data->learn_spam_btn,
+                                          _("Learn Spam"), NULL);
+                       toolbar_data->learn_ham_btn = item_ham;
+                       gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
+                                            toolbar_data->learn_ham_btn,
+                                          _("Learn Ham"), NULL);                       
+                       break;
                case A_REPLY_MESSAGE:
                        toolbar_data->reply_btn = item;
                        gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips), 
@@ -1667,6 +1748,9 @@ Toolbar *toolbar_create(ToolbarType        type,
                activate_compose_button(toolbar_data, 
                                        prefs_common.toolbar_style, 
                                        toolbar_data->compose_btn_type);
+       if (type != TOOLBAR_COMPOSE)
+               activate_learn_button(toolbar_data, prefs_common.toolbar_style,
+                               LEARN_SPAM);
        
        gtk_widget_show_all(toolbar);
        
@@ -1796,12 +1880,20 @@ void toolbar_main_set_sensitive(gpointer data)
        } else {
                SET_WIDGET_COND(toolbar->next_btn, 0);
        }
-
-       SET_WIDGET_COND(toolbar->trash_btn,
+       
+       if (toolbar->trash_btn)
+               SET_WIDGET_COND(toolbar->trash_btn,
                        M_TARGET_EXIST|M_ALLOW_DELETE);
-       SET_WIDGET_COND(toolbar->delete_btn,
+       if (toolbar->delete_btn)
+               SET_WIDGET_COND(toolbar->delete_btn,
                        M_TARGET_EXIST|M_ALLOW_DELETE);
-       SET_WIDGET_COND(toolbar->exec_btn, M_DELAY_EXEC);
+       if (toolbar->exec_btn)
+               SET_WIDGET_COND(toolbar->exec_btn, M_DELAY_EXEC);
+       
+       if (toolbar->learn_ham_btn)
+               SET_WIDGET_COND(toolbar->learn_ham_btn, M_TARGET_EXIST|M_CAN_LEARN_SPAM);
+       if (toolbar->learn_spam_btn)
+               SET_WIDGET_COND(toolbar->learn_spam_btn, M_TARGET_EXIST|M_CAN_LEARN_SPAM);
 
        for (cur = toolbar->action_list; cur != NULL;  cur = cur->next) {
                ToolbarSylpheedActions *act = (ToolbarSylpheedActions*)cur->data;
index eb36004c1746592a59b5d0aca865faa9213aca70..4e64bde5a5d6019281a5d353cc5e41723553e2d4 100644 (file)
@@ -40,6 +40,12 @@ typedef enum
        COMPOSEBUTTON_NEWS
 } ComposeButtonType;
 
+typedef enum 
+{
+       LEARN_SPAM,
+       LEARN_HAM
+} LearnButtonType;
+
 struct _Toolbar {
        GtkWidget *toolbar;
 
@@ -70,9 +76,11 @@ struct _Toolbar {
        GtkWidget *exec_btn;
 
        GtkWidget *separator;
+       GtkWidget *learn_spam_btn;
+       GtkWidget *learn_ham_btn;
 
-       
        ComposeButtonType compose_btn_type;
+       LearnButtonType learn_btn_type;
 
        /* compose buttons */
        GtkWidget *sendl_btn;
@@ -155,6 +163,8 @@ enum {
        A_GOTO_NEXT,
        A_IGNORE_THREAD,
        A_PRINT,
+       A_LEARN_SPAM,
+       A_LEARN_HAM,
 
        /* compose toolbar */
        A_SEND,
@@ -241,5 +251,7 @@ void        toolbar_set_style               (GtkWidget      *toolbar_wid,
                                         guint           action);
 void   toolbar_destroy                 (Toolbar        *toolbar);
 void   toolbar_init                    (Toolbar        *toolbar);
+void toolbar_set_learn_button          (Toolbar        *toolbar, 
+                                        LearnButtonType  learn_btn_type);
 
 #endif /* __CUSTOM_TOOLBAR_H__ */