catch an inadvertent (as in *probably* at the wrong time) saving back of summary...
[claws.git] / src / summaryview.c
index aac4d2146f6aa4556a9ef5cb3b9509c9d78a69eb..2259fff03e20a24e838863925199954a118538b6 100644 (file)
@@ -46,6 +46,7 @@
 #include <ctype.h>
 #include <unistd.h>
 #include <sys/stat.h>
+#include <regex.h>
 
 #include "intl.h"
 #include "main.h"
@@ -65,6 +66,7 @@
 #include "compose.h"
 #include "utils.h"
 #include "gtkutils.h"
+#include "stock_pixmap.h"
 #include "filesel.h"
 #include "manage_window.h"
 #include "alertpanel.h"
 #include "scoring.h"
 #include "prefs_folder_item.h"
 #include "filtering.h"
-
-#include "pixmaps/dir-open.xpm"
-#include "pixmaps/mark.xpm"
-#include "pixmaps/deleted.xpm"
-#include "pixmaps/new.xpm"
-#include "pixmaps/unread.xpm"
-#include "pixmaps/replied.xpm"
-#include "pixmaps/forwarded.xpm"
-#include "pixmaps/clip.xpm"
-#include "pixmaps/ignorethread.xpm"
-#include "pixmaps/locked.xpm"
+#include "string_match.h"
 
 #define STATUSBAR_PUSH(mainwin, str) \
 { \
@@ -120,9 +112,6 @@ static GtkStyle *small_style;
 static GtkStyle *small_marked_style;
 static GtkStyle *small_deleted_style;
 
-static GdkPixmap *folderxpm;
-static GdkBitmap *folderxpmmask;
-
 static GdkPixmap *markxpm;
 static GdkBitmap *markxpmmask;
 static GdkPixmap *deletedxpm;
@@ -254,6 +243,9 @@ static void summary_unthread_for_exec_func  (GtkCTree       *ctree,
                                                 GtkCTreeNode   *node,
                                                 gpointer        data);
 
+void summary_simplify_subject(SummaryView *summaryview, gchar * rexp,
+                             GSList * mlist);
+
 void summary_processing(SummaryView *summaryview, GSList * mlist);
 static void summary_filter_func                (GtkCTree               *ctree,
                                         GtkCTreeNode           *node,
@@ -534,21 +526,24 @@ void summary_init(SummaryView *summaryview)
        GtkStyle *style;
        GtkWidget *pixmap;
 
-       PIXMAP_CREATE(summaryview->ctree, markxpm, markxpmmask, mark_xpm);
-       PIXMAP_CREATE(summaryview->ctree, deletedxpm, deletedxpmmask,
-                     deleted_xpm);
-       PIXMAP_CREATE(summaryview->ctree, newxpm, newxpmmask, new_xpm);
-       PIXMAP_CREATE(summaryview->ctree, unreadxpm, unreadxpmmask, unread_xpm);
-       PIXMAP_CREATE(summaryview->ctree, repliedxpm, repliedxpmmask,
-                     replied_xpm);
-       PIXMAP_CREATE(summaryview->ctree, forwardedxpm, forwardedxpmmask,
-                     forwarded_xpm);
-       PIXMAP_CREATE(summaryview->ctree, ignorethreadxpm, ignorethreadxpmmask,
-                     ignorethread_xpm);
-       PIXMAP_CREATE(summaryview->ctree, lockedxpm, lockedxpmmask, locked_xpm);                      
-       PIXMAP_CREATE(summaryview->ctree, clipxpm, clipxpmmask, clip_xpm);
-       PIXMAP_CREATE(summaryview->hbox, folderxpm, folderxpmmask,
-                     dir_open_xpm);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_MARK,
+                        &markxpm, &markxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_DELETED,
+                        &deletedxpm, &deletedxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_NEW,
+                        &newxpm, &newxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_UNREAD,
+                        &unreadxpm, &unreadxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_REPLIED,
+                        &repliedxpm, &repliedxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_FORWARDED,
+                        &forwardedxpm, &forwardedxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_CLIP,
+                        &clipxpm, &clipxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_LOCKED,
+                        &lockedxpm, &lockedxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_IGNORETHREAD,
+                        &ignorethreadxpm, &ignorethreadxpmmask);
 
        if (!small_style) {
                small_style = gtk_style_copy
@@ -584,7 +579,7 @@ void summary_init(SummaryView *summaryview)
        gtk_widget_set_style(summaryview->statlabel_select, style);
        gtk_widget_set_style(summaryview->statlabel_msgs, style);
 
-       pixmap = gtk_pixmap_new(folderxpm, folderxpmmask);
+       pixmap = stock_pixmap_widget(summaryview->hbox, STOCK_PIXMAP_DIR_OPEN);
        gtk_box_pack_start(GTK_BOX(summaryview->hbox), pixmap, FALSE, FALSE, 4);
        gtk_box_reorder_child(GTK_BOX(summaryview->hbox), pixmap, 0);
        gtk_widget_show(pixmap);
@@ -709,9 +704,8 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item,
                        return FALSE;
                }
                folder_update_op_count();
-       }
-        
-       summary_write_cache(summaryview);
+       } else
+               summary_write_cache(summaryview);
         
        summaryview->folderview->opened = selected_node;
 
@@ -817,6 +811,14 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item,
                mlist = not_killed;
        }
 
+       if (item->prefs->enable_simplify_subject
+           && item->prefs->simplify_subject_regexp != NULL
+           && strlen(item->prefs->simplify_subject_regexp) != 0) {
+               summary_simplify_subject(summaryview, 
+                                        item->prefs->simplify_subject_regexp,
+                                        mlist);
+       }
+
        STATUSBAR_POP(summaryview->mainwin);
 
        /* set ctree and hash table from the msginfo list
@@ -3614,6 +3616,17 @@ static void summary_unthread_for_exec_func(GtkCTree *ctree, GtkCTreeNode *node,
        }
 }
 
+void summary_simplify_subject(SummaryView *summaryview, gchar * rexp,
+                             GSList * mlist)
+{
+       GSList * cur;
+       for(cur = mlist ; cur != NULL ; cur = cur->next) {
+               MsgInfo * msginfo = (MsgInfo *) cur->data;
+               string_remove_all_matches(msginfo->subject, rexp, 
+                                         REG_EXTENDED, 0);
+       }
+}
+
 void summary_processing(SummaryView *summaryview, GSList * mlist)
 {
        GSList * processing_list;
@@ -4596,7 +4609,7 @@ static void summary_start_drag(GtkWidget *widget, gint button, GdkEvent *event,
        list = gtk_target_list_new(summary_drag_types, 1);
 
        context = gtk_drag_begin(widget, list,
-                                GDK_ACTION_MOVE, button, event);
+                                GDK_ACTION_MOVE|GDK_ACTION_COPY|GDK_ACTION_DEFAULT, button, event);
        gtk_drag_set_icon_default(context);
 }