* src/folderview.c
authorChristoph Hohmann <reboot@gmx.ch>
Mon, 19 Aug 2002 17:55:14 +0000 (17:55 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Mon, 19 Aug 2002 17:55:14 +0000 (17:55 +0000)
* src/prefs_folder_item.h
* src/summaryview.[ch]
        o add summary_set_prefs_from_folderitem to set
          summaryview prefs (first step to remove all
          references to the folderitem in summaryview)
        o moved compiled regex stuff from folderitem prefs
          to summaryview code

ChangeLog.claws
configure.in
src/folderview.c
src/prefs_folder_item.h
src/summaryview.c
src/summaryview.h

index 6d9e3f8..a93dd42 100644 (file)
@@ -1,3 +1,14 @@
+2002-08-19 [christoph] 0.8.1claws78
+
+       * src/folderview.c
+       * src/prefs_folder_item.h
+       * src/summaryview.[ch]
+               o add summary_set_prefs_from_folderitem to set
+                 summaryview prefs (first step to remove all
+                 references to the folderitem in summaryview)
+               o moved compiled regex stuff from folderitem prefs
+                 to summaryview code
+
 2002-08-19 [paul]      0.8.1claws77
 
        * src/compose.c
index 4e3a35d..45dbed3 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=8
 MICRO_VERSION=1
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws77
+EXTRA_VERSION=claws78
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 352122f..ee13550 100644 (file)
@@ -1702,6 +1702,7 @@ static void folderview_selected(GtkCTree *ctree, GtkCTreeNode *row,
        }
                
        /* Show messages */
+       summary_set_prefs_from_folderitem(folderview->summaryview, item);
        opened = summary_show(folderview->summaryview, item);
 
        folder_clean_cache_memory();
index a39fc48..3e42dce 100644 (file)
@@ -24,7 +24,6 @@
 #include "folder.h"
 #include <glib.h>
 #include <sys/types.h>
-#include <regex.h>
 
 struct _PrefsFolderItem {
        gchar * directory;
@@ -51,7 +50,6 @@ struct _PrefsFolderItem {
        gchar *default_to;
        gboolean enable_simplify_subject;
        gchar *simplify_subject_regexp;
-       regex_t *simplify_subject_preg;
        gboolean enable_folder_chmod;
        gint folder_chmod;
        gboolean enable_default_account;
index d2c8d98..27aee33 100644 (file)
@@ -180,7 +180,6 @@ static void summary_display_msg_full        (SummaryView            *summaryview,
                                         gboolean                all_headers);
 static void summary_set_row_marks      (SummaryView            *summaryview,
                                         GtkCTreeNode           *row);
-static void summaryview_subject_filter_init (PrefsFolderItem    *prefs);
 
 /* message handling */
 static void summary_mark_row           (SummaryView            *summaryview,
@@ -604,6 +603,9 @@ void summary_init(SummaryView *summaryview)
        gtk_widget_show(pixmap);
        summaryview->folder_pixmap = pixmap;
 
+       /* Init Summaryview prefs */
+       summaryview->simplify_subject_preg = NULL;
+
        summary_clear_list(summaryview);
        summary_set_column_titles(summaryview);
        summary_colorlabel_menu_create(summaryview);
@@ -1830,7 +1832,7 @@ void summary_sort(SummaryView *summaryview,
 {
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
        GtkCList *clist = GTK_CLIST(summaryview->ctree);
-       GtkCListCompareFunc cmp_func;
+       GtkCListCompareFunc cmp_func = NULL;
        FolderItem *item = summaryview->folder_item;
 
        if (!item || !item->path || !item->parent || item->no_select) return;
@@ -1858,15 +1860,10 @@ void summary_sort(SummaryView *summaryview,
                cmp_func = (GtkCListCompareFunc)summary_cmp_by_from;
                break;
        case SORT_BY_SUBJECT:
-               {
-                       PrefsFolderItem *prefs = summaryview->folder_item->prefs;
-
-                       if (prefs && prefs->enable_simplify_subject
-                       &&  prefs->simplify_subject_regexp && prefs->simplify_subject_regexp[0])
-                               cmp_func = (GtkCListCompareFunc)summary_cmp_by_simplified_subject;
-                       else
-                               cmp_func = (GtkCListCompareFunc)summary_cmp_by_subject;
-               }                               
+               if (summaryview->simplify_subject_preg)
+                       cmp_func = (GtkCListCompareFunc)summary_cmp_by_simplified_subject;
+               else
+                       cmp_func = (GtkCListCompareFunc)summary_cmp_by_subject;
                break;
        case SORT_BY_SCORE:
                cmp_func = (GtkCListCompareFunc)summary_cmp_by_score;
@@ -1878,37 +1875,36 @@ void summary_sort(SummaryView *summaryview,
                cmp_func = (GtkCListCompareFunc)summary_cmp_by_label;
                break;
        case SORT_BY_NONE:
-               item->sort_key = sort_key;
-               item->sort_type = SORT_ASCENDING;
-               summary_set_column_titles(summaryview);
-               summary_set_menu_sensitive(summaryview);
+               cmp_func = NULL;
                return;
        default:
                return;
        }
 
-       debug_print("Sorting summary...");
-       STATUSBAR_PUSH(summaryview->mainwin, _("Sorting summary..."));
-
-       main_window_cursor_wait(summaryview->mainwin);
-
-       gtk_clist_set_compare_func(clist, cmp_func);
-
-       gtk_clist_set_sort_type(clist, (GtkSortType)sort_type);
        item->sort_key = sort_key;
        item->sort_type = sort_type;
 
        summary_set_column_titles(summaryview);
        summary_set_menu_sensitive(summaryview);
+       if(cmp_func != NULL) {
+               debug_print("Sorting summary...");
+               STATUSBAR_PUSH(summaryview->mainwin, _("Sorting summary..."));
 
-       gtk_sctree_sort_recursive(ctree, NULL);
+               main_window_cursor_wait(summaryview->mainwin);
 
-       gtk_ctree_node_moveto(ctree, summaryview->selected, -1, 0.5, 0);
+               gtk_clist_set_compare_func(clist, cmp_func);
 
-       debug_print("done.\n");
-       STATUSBAR_POP(summaryview->mainwin);
+               gtk_clist_set_sort_type(clist, (GtkSortType)sort_type);
 
-       main_window_cursor_normal(summaryview->mainwin);
+               gtk_sctree_sort_recursive(ctree, NULL);
+
+               gtk_ctree_node_moveto(ctree, summaryview->selected, -1, 0.5, 0);
+
+               main_window_cursor_normal(summaryview->mainwin);
+
+               debug_print("done.\n");
+               STATUSBAR_POP(summaryview->mainwin);
+       }
 }
 
 gboolean summary_insert_gnode_func(GtkCTree *ctree, guint depth, GNode *gnode,
@@ -1986,8 +1982,6 @@ static void summary_set_ctree_from_list(SummaryView *summaryview,
                                summaryview->folder_item->prefs->important_score;
        }
 
-       summaryview_subject_filter_init(summaryview->folder_item->prefs);
-       
        if (summaryview->folder_item->threaded) {
                GNode *root, *gnode;
 
@@ -2082,7 +2076,6 @@ static void summary_set_header(SummaryView *summaryview, gchar *text[],
        static gchar *to = NULL;
        static gchar col_score[11];
        static gchar buf[BUFFSIZE];
-       PrefsFolderItem *prefs = summaryview->folder_item->prefs;
        gint *col_pos = summaryview->col_pos;
 
        text[col_pos[S_COL_MARK]]   = NULL;
@@ -2146,12 +2139,10 @@ static void summary_set_header(SummaryView *summaryview, gchar *text[],
                }       
        }
 
-       if (prefs->enable_simplify_subject 
-           && prefs->simplify_subject_preg != NULL )
+       if (summaryview->simplify_subject_preg != NULL)
                text[col_pos[S_COL_SUBJECT]] = msginfo->subject ? 
                        string_remove_match(buf, BUFFSIZE, msginfo->subject, 
-                                       prefs->simplify_subject_preg) : 
-                       
+                                       summaryview->simplify_subject_preg) : 
                        _("(No Subject)");
        else 
                text[col_pos[S_COL_SUBJECT]] = msginfo->subject ? msginfo->subject :
@@ -4981,36 +4972,6 @@ static void summary_set_hide_read_msgs_menu (SummaryView *summaryview,
        gtk_object_set_data(GTK_OBJECT(widget), "dont_toggle",
                            GINT_TO_POINTER(0));
 }
-static void summaryview_subject_filter_init(PrefsFolderItem *prefs)
-{
-       int err;
-       gchar buf[BUFFSIZE];
-       if (prefs->enable_simplify_subject) {
-               if (prefs->simplify_subject_regexp && 
-                               *prefs->simplify_subject_regexp != 0x00) {
-
-                       if (!prefs->simplify_subject_preg) 
-                               prefs->simplify_subject_preg = g_new(regex_t, 1);
-                       else
-                               regfree(prefs->simplify_subject_preg);
-
-                       err = string_match_precompile(prefs->simplify_subject_regexp, 
-                                       prefs->simplify_subject_preg, REG_EXTENDED);
-                       if (err) {
-                               regerror(err, prefs->simplify_subject_preg, buf, BUFFSIZE);
-                               alertpanel_error(_("Regular expression (regexp) error:\n%s"), buf);
-                               g_free(prefs->simplify_subject_preg);
-                               prefs->simplify_subject_preg = NULL;
-                       }
-               } else {
-                       if (prefs->simplify_subject_preg) {
-                               regfree(prefs->simplify_subject_preg);
-                               g_free(prefs->simplify_subject_preg);
-                               prefs->simplify_subject_preg = NULL;
-                       }
-               }
-       }
-}
 
 void summary_reflect_prefs_pixmap_theme(SummaryView *summaryview)
 {
@@ -5044,7 +5005,8 @@ void summary_reflect_prefs_pixmap_theme(SummaryView *summaryview)
 /*
  * Harvest addresses for selected messages in summary view.
  */
-void summary_harvest_address( SummaryView *summaryview ) {
+void summary_harvest_address(SummaryView *summaryview)
+{
        GtkCTree *ctree = GTK_CTREE( summaryview->ctree );
        GList *cur;
        GList *msgList;
@@ -5059,7 +5021,42 @@ void summary_harvest_address( SummaryView *summaryview ) {
        g_list_free( msgList );
 }
 
+static regex_t *summary_compile_simplify_regexp(gchar *simplify_subject_regexp)
+{
+       int err;
+       gchar buf[BUFFSIZE];
+       regex_t *preg = NULL;
+       
+       preg = g_new0(regex_t, 1);
+
+       err = string_match_precompile(simplify_subject_regexp, 
+                                     preg, REG_EXTENDED);
+       if (err) {
+               regerror(err, preg, buf, BUFFSIZE);
+               alertpanel_error(_("Regular expression (regexp) error:\n%s"), buf);
+               g_free(preg);
+               preg = NULL;
+       }
+       
+       return preg;
+}
+
+void summary_set_prefs_from_folderitem(SummaryView *summaryview, FolderItem *item)
+{
+       g_return_if_fail(summaryview != NULL);
+       g_return_if_fail(item != NULL);
+
+       /* Subject simplification */
+       if(summaryview->simplify_subject_preg) {
+               regfree(summaryview->simplify_subject_preg);
+               g_free(summaryview->simplify_subject_preg);
+               summaryview->simplify_subject_preg = NULL;
+       }
+       if(item->prefs && item->prefs->simplify_subject_regexp && 
+          item->prefs->simplify_subject_regexp[0] && item->prefs->enable_simplify_subject)
+               summaryview->simplify_subject_preg = summary_compile_simplify_regexp(item->prefs->simplify_subject_regexp);
+}
+
 /*
  * End of Source.
  */
-
index 1a10403..4f96bc8 100644 (file)
@@ -20,6 +20,8 @@
 #ifndef __SUMMARY_H__
 #define __SUMMARY_H__
 
+#include <regex.h>
+
 #include <glib.h>
 #include <gdk/gdk.h>
 #include <gtk/gtkwidget.h>
@@ -118,8 +120,12 @@ struct _SummaryView
 
        FolderItem *folder_item;
 
+       /* summaryview prefs */
        gint important_score;
 
+       /* Extra data for summaryview */
+       regex_t *simplify_subject_preg;
+
        /* current message status */
        gint   newmsgs;
        gint   unread;
@@ -248,6 +254,7 @@ void summary_toggle_view_real       (SummaryView    *summaryview);
 
 void summary_reflect_prefs_pixmap_theme(SummaryView *summaryview);
 
-void summary_harvest_address   ( SummaryView *summaryview );
+void summary_harvest_address(SummaryView *summaryview);
+void summary_set_prefs_from_folderitem(SummaryView *summaryview, FolderItem *item);
 
 #endif /* __SUMMARY_H__ */