re-implement per folder threading setting (now stored in folderlist.xml)
authorAlfons Hoogervorst <alfons@proteus.demon.nl>
Sat, 22 Sep 2001 13:24:51 +0000 (13:24 +0000)
committerAlfons Hoogervorst <alfons@proteus.demon.nl>
Sat, 22 Sep 2001 13:24:51 +0000 (13:24 +0000)
ChangeLog.claws
src/folder.c
src/folder.h
src/mainwindow.c
src/mainwindow.h
src/summaryview.c

index 20cfce5c9c848191aecc256c5d38f6f864e126ac..f4ef04a769c59004209ff665d27e57cb83760a8c 100644 (file)
@@ -1,3 +1,13 @@
+2001-09-22 [alfons]
+
+       * README.claws **NEW**
+               (add things of interest for users of main branch 
+               and claws here)
+
+       * src/folder.[ch], src/mainwindow.c, src/summaryview.c
+               re-implement threading per folder option, but store 
+               the setting in folderlist.xml (where it belongs)
+
 2001-09-21 [melvin]
 
        * src/gtkspell.[ch]
@@ -9,6 +19,7 @@
                dropped PSPELL_PATH macro
        * po/fr.po
                updated translations
+
 2001-09-21 [christoph]
 
        * src/compose.c
index 3f4775448972757134a1f4cd03a6697101641412..c1f95d6b727125ee677ab46677b87ac61bd73a8c 100644 (file)
@@ -156,6 +156,7 @@ FolderItem *folder_item_new(const gchar *name, const gchar *path)
        item->no_sub = FALSE;
        item->no_select = FALSE;
        item->collapsed = FALSE;
+       item->threaded  = FALSE;
        item->parent = NULL;
        item->folder = NULL;
        item->data = NULL;
@@ -1039,7 +1040,7 @@ static gboolean folder_build_tree(GNode *node, gpointer data)
        const gchar *name = NULL;
        const gchar *path = NULL;
        PrefsAccount *account = NULL;
-       gboolean no_sub = FALSE, no_select = FALSE, collapsed = FALSE;
+       gboolean no_sub = FALSE, no_select = FALSE, collapsed = FALSE, threaded = FALSE;
        gint mtime = 0, new = 0, unread = 0, total = 0;
 
        g_return_val_if_fail(node->data != NULL, FALSE);
@@ -1091,6 +1092,8 @@ static gboolean folder_build_tree(GNode *node, gpointer data)
                        no_select = *attr->value == '1' ? TRUE : FALSE;
                else if (!strcmp(attr->name, "collapsed"))
                        collapsed = *attr->value == '1' ? TRUE : FALSE;
+               else if (!strcmp(attr->name, "threaded"))
+                       threaded =  *attr->value == '1' ? TRUE : FALSE;
        }
 
        item = folder_item_new(name, path);
@@ -1103,6 +1106,7 @@ static gboolean folder_build_tree(GNode *node, gpointer data)
        item->no_sub = no_sub;
        item->no_select = no_select;
        item->collapsed = collapsed;
+       item->threaded  = threaded;
        item->parent = FOLDER_ITEM(node->parent->data);
        item->folder = folder;
        switch (stype) {
@@ -1132,7 +1136,7 @@ static gboolean folder_read_folder_func(GNode *node, gpointer data)
        const gchar *name = NULL;
        const gchar *path = NULL;
        PrefsAccount *account = NULL;
-       gboolean collapsed = FALSE;
+       gboolean collapsed = FALSE, threaded = FALSE;
 
        if (g_node_depth(node) != 2) return FALSE;
        g_return_val_if_fail(node->data != NULL, FALSE);
@@ -1169,6 +1173,8 @@ static gboolean folder_read_folder_func(GNode *node, gpointer data)
                                                attr->value);
                } else if (!strcmp(attr->name, "collapsed"))
                        collapsed = *attr->value == '1' ? TRUE : FALSE;
+               else if (!strcmp(attr->name, "threaded"))
+                       threaded = *attr->value == '1' ? TRUE : FALSE;
        }
 
        folder = folder_new(type, name, path);
@@ -1181,6 +1187,7 @@ static gboolean folder_read_folder_func(GNode *node, gpointer data)
        folder->node = node;
        folder_add(folder);
        FOLDER_ITEM(node->data)->collapsed = collapsed;
+       FOLDER_ITEM(node->data)->threaded  = threaded;
 
        g_node_traverse(node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
                        folder_build_tree, folder);
@@ -1234,6 +1241,8 @@ static void folder_write_list_recursive(GNode *node, gpointer data)
                                folder->account->account_id);
                if (item->collapsed && node->children)
                        fputs(" collapsed=\"1\"", fp);
+               if (item->threaded)
+                       fputs(" threaded=\"1\"", fp);
        } else {
                fprintf(fp, "<folderitem type=\"%s\"",
                        folder_item_stype_str[item->stype]);
@@ -1256,6 +1265,8 @@ static void folder_write_list_recursive(GNode *node, gpointer data)
                        fputs(" no_select=\"1\"", fp);
                if (item->collapsed && node->children)
                        fputs(" collapsed=\"1\"", fp);
+               if (item->threaded)
+                       fputs(" threaded=\"1\"", fp);
                fprintf(fp,
                        " mtime=\"%ld\" new=\"%d\" unread=\"%d\" total=\"%d\"",
                        item->mtime, item->new, item->unread, item->total);
index 7ebfdbc3de4f7a333277997124a5f5a88f279217..c23d8dae5f065ba78355ae0cc78a6cde520f104e 100644 (file)
@@ -219,6 +219,7 @@ struct _FolderItem
        guint no_sub    : 1; /* no child allowed? */
        guint no_select : 1; /* not selectable?   */
        guint collapsed : 1; /* collapsed item    */
+       guint threaded  : 1; /* threaded folder view */
 
        gint op_count;
 
index 884b59828c3d1e5e3d96529904a4615e28f02ab5..826ade80bbc4beef0f18ce7de4e71942e9457370 100644 (file)
@@ -1215,7 +1215,9 @@ typedef enum
        M_SINGLE_TARGET_EXIST = 1 << 3,
        M_EXEC                = 1 << 4,
        M_ALLOW_REEDIT        = 1 << 5,
-       M_HAVE_ACCOUNT        = 1 << 6
+       M_HAVE_ACCOUNT        = 1 << 6,
+       M_THREADED            = 1 << 7,
+       M_UNTHREADED          = 1 << 8
 } SensitiveCond;
 
 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
@@ -1229,6 +1231,11 @@ static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
                state |= M_UNLOCKED;
        if (selection != SUMMARY_NONE)
                state |= M_MSG_EXIST;
+       if (mainwin->summaryview->folder_item) {
+               if (mainwin->summaryview->folder_item->threaded)
+                       state |= M_THREADED;
+               else state |= M_UNTHREADED;     
+       }               
        if (selection == SUMMARY_SELECTED_SINGLE ||
            selection == SUMMARY_SELECTED_MULTIPLE)
                state |= M_TARGET_EXIST;
@@ -1336,6 +1343,8 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
                {"/Summary/Go to/Prev labeled message", M_MSG_EXIST},
                {"/Summary/Go to/Next labeled message", M_MSG_EXIST},
                {"/Summary/Sort"                      , M_MSG_EXIST},
+               {"/Summary/Thread view"               , M_UNTHREADED | M_UNLOCKED},
+               {"/Summary/Unthread view"             , M_THREADED | M_UNLOCKED},
 
                {"/Configuration", M_UNLOCKED},
 
@@ -2517,63 +2526,25 @@ static void set_charset_cb(MainWindow *mainwin, guint action,
        debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
 }
 
-/*void main_window_set_thread_option(MainWindow *mainwin)
+static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
 {
        GtkItemFactory *ifactory;
-       gboolean no_item = FALSE;
 
-       ifactory = gtk_item_factory_from_widget(mainwin->menubar);
-
-       if (mainwin->summaryview == NULL)
-               no_item = TRUE;
-       else if (mainwin->summaryview->folder_item == NULL)
-               no_item = TRUE;
+       ifactory = gtk_item_factory_from_widget(widget);
 
-       if (no_item) {
-               menu_set_sensitive(ifactory, "/Summary/Thread view",   FALSE);
-               menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
-       }
-       else {
-               if (mainwin->summaryview->folder_item->prefs->enable_thread) {
-                       menu_set_sensitive(ifactory,
-                                          "/Summary/Thread view",   FALSE);
-                       menu_set_sensitive(ifactory,
-                                          "/Summary/Unthread view", TRUE);
-                       summary_thread_build(mainwin->summaryview, TRUE);
-               }
-               else {
-                       menu_set_sensitive(ifactory,
-                                          "/Summary/Thread view",   TRUE);
-                       menu_set_sensitive(ifactory,
-                                          "/Summary/Unthread view", FALSE);
+       if (mainwin->summaryview->folder_item) {
+               if (0 == action) {
+                       summary_thread_build(mainwin->summaryview, FALSE);
+                       mainwin->summaryview->folder_item->threaded = TRUE;
+                       menu_set_sensitive(ifactory, "/Summary/Thread view",   FALSE);
+                       menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
+               } else {
                        summary_unthread(mainwin->summaryview);
+                       mainwin->summaryview->folder_item->threaded = FALSE;
+                       menu_set_sensitive(ifactory, "/Summary/Thread view",   TRUE);
+                       menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
                }
-               prefs_folder_item_save_config(mainwin->summaryview->folder_item);
-       }
-}*/
-
-static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
-{
-       /*mainwin->summaryview->folder_item->prefs->enable_thread =
-               !mainwin->summaryview->folder_item->prefs->enable_thread;
-       main_window_set_thread_option(mainwin);
-        */
-
-        GtkItemFactory *ifactory;
-
-       ifactory = gtk_item_factory_from_widget(widget);
-
-       if (0 == action) {
-               summary_thread_build(mainwin->summaryview, FALSE);
-               prefs_common.enable_thread = TRUE;
-               menu_set_sensitive(ifactory, "/Summary/Thread view",   FALSE);
-               menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
-       } else {
-               summary_unthread(mainwin->summaryview);
-               prefs_common.enable_thread = FALSE;
-               menu_set_sensitive(ifactory, "/Summary/Thread view",   TRUE);
-               menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
-       }
+       }               
 }
 
 static void set_display_item_cb(MainWindow *mainwin, guint action,
index 5315d105b88ffce3fdc3b5ba75b61c90ad26bbea..8182b05c5e297e2ffd118a9b3fc91932e374e19f 100644 (file)
@@ -158,6 +158,5 @@ void main_window_set_toolbar_sensitive      (MainWindow     *mainwin);
 void main_window_set_menu_sensitive    (MainWindow     *mainwin);
 
 void main_window_popup                 (MainWindow     *mainwin);
-/*void main_window_set_thread_option      (MainWindow *mainwin);*/
 
 #endif /* __MAINWINDOW_H__ */
index ba3c52bac616d77ec6e77bf9e4a1ad7dd0c0ba92..9263320d5fdf690f4db32509506fe1bf159f06d1 100644 (file)
@@ -1819,8 +1819,6 @@ static void summary_set_ctree_from_list(SummaryView *summaryview,
        if (prefs_common.use_addr_book)
                start_address_completion();
        
-       /*main_window_set_thread_option(summaryview->mainwin)*/;
-
        for (cur = mlist ; cur != NULL; cur = cur->next) {
                msginfo = (MsgInfo *)cur->data;
                msginfo->threadscore = msginfo->score;
@@ -1834,8 +1832,7 @@ static void summary_set_ctree_from_list(SummaryView *summaryview,
                                summaryview->folder_item->prefs->important_score;
        }
        
-               if (prefs_common.enable_thread) {
-       /*if (summaryview->folder_item->prefs->enable_thread) { */
+       if (summaryview->folder_item->threaded) {
                for (; mlist != NULL; mlist = mlist->next) {
                        msginfo = (MsgInfo *)mlist->data;
                        parent = NULL;
@@ -3032,8 +3029,7 @@ void summary_execute(SummaryView *summaryview)
 
        gtk_clist_freeze(clist);
 
-       /*if (summaryview->folder_item->prefs->enable_thread) */
-                       if (prefs_common.enable_thread)
+       if (summaryview->folder_item->threaded)
                summary_unthread_for_exec(summaryview);
 
        summary_execute_move(summaryview);
@@ -3056,8 +3052,7 @@ void summary_execute(SummaryView *summaryview)
                node = next;
        }
 
-       /*if (summaryview->folder_item->prefs->enable_thread) */
-       if (prefs_common.enable_thread) 
+       if (summaryview->folder_item->threaded)
                summary_thread_build(summaryview, FALSE);
 
        summaryview->selected = clist->selection ?
@@ -3261,6 +3256,10 @@ void summary_thread_build(SummaryView *summaryview, gboolean init)
                next = GTK_CTREE_ROW(node)->sibling;
 
                msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
+
+               /* alfons - claws seems to prefer subject threading before
+                * inreplyto threading. we should look more deeply in this,
+                * because inreplyto should have precedence... */
                if (msginfo && msginfo->inreplyto) {
                        parent = g_hash_table_lookup(summaryview->msgid_table,
                                                     msginfo->inreplyto);
@@ -3269,6 +3268,14 @@ void summary_thread_build(SummaryView *summaryview, gboolean init)
                                gtk_ctree_expand(ctree, node);
                        }
                }
+               else if (msginfo && msginfo->subject) {
+                       parent = g_hash_table_lookup
+                                       (summaryview->subject_table, msginfo->subject);
+                       if (parent && parent != node) {
+                               gtk_ctree_move(ctree, node, parent, NULL);
+                               gtk_ctree_expand(ctree, node);
+                       }
+               }
 
                node = next;
        }