sync with 0.7.6cvs21
authorPaul Mangan <paul@claws-mail.org>
Mon, 3 Jun 2002 06:03:31 +0000 (06:03 +0000)
committerPaul Mangan <paul@claws-mail.org>
Mon, 3 Jun 2002 06:03:31 +0000 (06:03 +0000)
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.in
src/folder.c
src/folder.h
src/mainwindow.c
src/summaryview.c
src/summaryview.h

index cb87081..f8858fc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2002-05-31
+
+       * implemented persistent sort order.
+       * src/folder.[ch]:
+         folder_build_tree(): read 'sort_key' and 'sort_type' attributes.
+         folder_write_list_recursive(): write sorting state.
+         src/mainwindow.c
+         src/summaryview.[ch]: summary_show(): sort if required.
+         select the top node on descending sort.
+         Removed SummarySortType and sorting state variables from
+         SummaryView.
+
 2002-05-30
 
        * src/account.c
index e5c37b6..b0d502a 100644 (file)
@@ -1,3 +1,8 @@
+2002-06-03 [paul]      0.7.6claws27
+
+       * sync with 0.7.6cvs21
+               see ChangeLog 2002-05-31
+
 2002-05-31 [paul]      0.7.6claws26
 
        * sync with 0.7.6cvs20
index 0a9601c..b6dc001 100644 (file)
@@ -1,3 +1,14 @@
+2002-05-31
+
+       * ±Ê³Ū¤Ê¥½¡¼¥È½ç¤ò¼ÂÁõ¡£
+       * src/folder.[ch]:
+         folder_build_tree(): 'sort_key' ¤È 'sort_type' Â°À­¤òÆɤ߹þ¤à¡£
+         folder_write_list_recursive(): ¥½¡¼¥È¾õÂÖ¤ò½ñ¤­¹þ¤à¡£
+         src/mainwindow.c
+         src/summaryview.[ch]: summary_show(): É¬ÍפǤ¢¤ì¤Ð¥½¡¼¥È¤¹¤ë¡£
+         ¹ß½ç¥½¡¼¥È¤Î¾ì¹çÀèƬ¤Î¥Î¡¼¥É¤òÁªÂò¡£
+         SummarySortType ¤È¥½¡¼¥È¾õÂÖ¤ÎÊÑ¿ô¤ò SummaryView ¤«¤éºï½ü¡£
+
 2002-05-30
 
        * src/account.c
index 6e347b9..2f8c35a 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=7
 MICRO_VERSION=6
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws26
+EXTRA_VERSION=claws27
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 906c2e7..8b43236 100644 (file)
@@ -1144,6 +1144,8 @@ static gboolean folder_build_tree(GNode *node, gpointer data)
        PrefsAccount *account = NULL;
        gboolean no_sub = FALSE, no_select = FALSE, collapsed = FALSE, 
                 threaded = TRUE, ret_rcpt = FALSE, hidereadmsgs = FALSE;
+       FolderSortKey sort_key = SORT_BY_NONE;
+       FolderSortType sort_type = SORT_ASCENDING;
        gint mtime = 0, new = 0, unread = 0, total = 0;
 
        g_return_val_if_fail(node->data != NULL, FALSE);
@@ -1201,6 +1203,35 @@ static gboolean folder_build_tree(GNode *node, gpointer data)
                        hidereadmsgs =  *attr->value == '1' ? TRUE : FALSE;
                else if (!strcmp(attr->name, "reqretrcpt"))
                        ret_rcpt =  *attr->value == '1' ? TRUE : FALSE;
+               else if (!strcmp(attr->name, "sort_key")) {
+                       if (!strcmp(attr->value, "none"))
+                               sort_key = SORT_BY_NONE;
+                       else if (!strcmp(attr->value, "number"))
+                               sort_key = SORT_BY_NUMBER;
+                       else if (!strcmp(attr->value, "size"))
+                               sort_key = SORT_BY_SIZE;
+                       else if (!strcmp(attr->value, "date"))
+                               sort_key = SORT_BY_DATE;
+                       else if (!strcmp(attr->value, "from"))
+                               sort_key = SORT_BY_FROM;
+                       else if (!strcmp(attr->value, "subject"))
+                               sort_key = SORT_BY_SUBJECT;
+                       else if (!strcmp(attr->value, "score"))
+                               sort_key = SORT_BY_SCORE;
+                       else if (!strcmp(attr->value, "label"))
+                               sort_key = SORT_BY_LABEL;
+                       else if (!strcmp(attr->value, "mark"))
+                               sort_key = SORT_BY_MARK;
+                       else if (!strcmp(attr->value, "unread"))
+                               sort_key = SORT_BY_UNREAD;
+                       else if (!strcmp(attr->value, "mime"))
+                               sort_key = SORT_BY_MIME;
+               } else if (!strcmp(attr->name, "sort_type")) {
+                       if (!strcmp(attr->value, "ascending"))
+                               sort_type = SORT_ASCENDING;
+                       else
+                               sort_type = SORT_DESCENDING;
+               }
        }
 
        item = folder_item_new(name, path);
@@ -1216,6 +1247,8 @@ static gboolean folder_build_tree(GNode *node, gpointer data)
        item->threaded  = threaded;
        item->hide_read_msgs  = hidereadmsgs;
        item->ret_rcpt  = ret_rcpt;
+       item->sort_key  = sort_key;
+       item->sort_type = sort_type;
        item->parent = FOLDER_ITEM(node->parent->data);
        item->folder = folder;
        switch (stype) {
@@ -1326,6 +1359,9 @@ static void folder_write_list_recursive(GNode *node, gpointer data)
                                           "news", "unknown"};
        static gchar *folder_item_stype_str[] = {"normal", "inbox", "outbox",
                                                 "draft", "queue", "trash"};
+       static gchar *sort_key_str[] = {"none", "number", "size", "date",
+                                       "from", "subject", "score", "label",
+                                       "mark", "unread", "mime"};
 
        g_return_if_fail(item != NULL);
 
@@ -1386,6 +1422,16 @@ static void folder_write_list_recursive(GNode *node, gpointer data)
                        fputs(" hidereadmsgs=\"0\"", fp);
                if (item->ret_rcpt)
                        fputs(" reqretrcpt=\"1\"", fp);
+
+               if (item->sort_key != SORT_BY_NONE) {
+                       fprintf(fp, " sort_key=\"%s\"",
+                               sort_key_str[item->sort_key]);
+                       if (item->sort_type == SORT_ASCENDING)
+                               fprintf(fp, " sort_type=\"ascending\"");
+                       else
+                               fprintf(fp, " sort_type=\"descending\"");
+               }
+
                fprintf(fp,
                        " mtime=\"%lu\" new=\"%d\" unread=\"%d\" total=\"%d\"",
                        item->mtime, item->new, item->unread, item->total);
index 5f8f62c..7228200 100644 (file)
@@ -73,6 +73,28 @@ typedef enum
        F_TRASH
 } SpecialFolderItemType;
 
+typedef enum
+{
+       SORT_BY_NONE,
+       SORT_BY_NUMBER,
+       SORT_BY_SIZE,
+       SORT_BY_DATE,
+       SORT_BY_FROM,
+       SORT_BY_SUBJECT,
+       SORT_BY_SCORE,
+       SORT_BY_LABEL,
+       SORT_BY_MARK,
+       SORT_BY_UNREAD,
+       SORT_BY_MIME,
+       SORT_BY_LOCKED
+} FolderSortKey;
+
+typedef enum
+{
+       SORT_ASCENDING,
+       SORT_DESCENDING
+} FolderSortType;
+
 typedef void (*FolderUIFunc)           (Folder         *folder,
                                         FolderItem     *item,
                                         gpointer        data);
@@ -203,6 +225,9 @@ struct _FolderItem
        gint op_count;
        guint opened    : 1; /* opened by summary view */
 
+       FolderSortKey sort_key;
+       FolderSortType sort_type;
+
        FolderItem *parent;
 
        Folder *folder;
index 23afd53..473b4b1 100644 (file)
@@ -2993,7 +2993,7 @@ static void set_display_item_cb(MainWindow *mainwin, guint action,
 static void sort_summary_cb(MainWindow *mainwin, guint action,
                            GtkWidget *widget)
 {
-       summary_sort(mainwin->summaryview, (SummarySortType)action);
+       summary_sort(mainwin->summaryview, (FolderSortKey)action);
 }
 
 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
index e553acd..10bb6a3 100644 (file)
@@ -545,8 +545,6 @@ SummaryView *summary_create(void)
        summaryview->popupfactory = popupfactory;
        summaryview->msg_is_toggled_on = TRUE;
        summaryview->lock_count = 0;
-       summaryview->sort_mode = SORT_BY_NONE;
-       summaryview->sort_type = GTK_SORT_ASCENDING;
 
        gtk_widget_show_all(vbox);
 
@@ -871,26 +869,20 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item,
 
        g_slist_free(mlist);
 
+       if (item->sort_key != SORT_BY_NONE) {
+               if (item->sort_type == SORT_DESCENDING)
+                       item->sort_type = SORT_ASCENDING;
+               else
+                       item->sort_type = SORT_DESCENDING;
+               summary_sort(summaryview, item->sort_key);
+       }
+
        summary_write_cache(summaryview);
 
        gtk_signal_handler_unblock_by_data(GTK_OBJECT(ctree), summaryview);
 
        gtk_clist_thaw(GTK_CLIST(ctree));
 
-       /* sort before */
-       sort_mode = prefs_folder_item_get_sort_mode(item);
-       sort_type = prefs_folder_item_get_sort_type(item);
-
-       if (sort_mode != SORT_BY_NONE) {
-               summaryview->sort_mode = sort_mode;
-               if (sort_type == GTK_SORT_DESCENDING)
-                       summaryview->sort_type = GTK_SORT_ASCENDING;
-               else
-                       summaryview->sort_type = GTK_SORT_DESCENDING;
-
-               summary_sort(summaryview, sort_mode);
-       }
-
        if (is_refresh) {
                summaryview->displayed =
                        summary_find_msg_by_msgnum(summaryview,
@@ -904,9 +896,9 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item,
                        node = summary_find_next_unread_msg(summaryview, NULL);
                        if (node == NULL && GTK_CLIST(ctree)->row_list != NULL)
                                node = gtk_ctree_node_nth
-                                       (ctree, sort_type == 
-                                        GTK_SORT_DESCENDING ? 0 : 
-                                        GTK_CLIST(ctree)->rows - 1);
+                                       (ctree,
+                                        item->sort_type == SORT_DESCENDING
+                                        ? 0 : GTK_CLIST(ctree)->rows - 1);
                        summary_select_node(summaryview, node, FALSE, TRUE);
                }
        } else {
@@ -918,12 +910,11 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item,
                        node = summary_find_next_unread_msg(summaryview, NULL);
 
                if (node == NULL && GTK_CLIST(ctree)->row_list != NULL) {
-                       /* Get the last visible node on screen */
-                       /* FIXME: huh, what happens if node is null? that allowed?? */
-                       node = gtk_ctree_node_nth(ctree, sort_type == 
-                                                 GTK_SORT_DESCENDING ? 0 : 
-                                                 GTK_CLIST(ctree)->rows - 1);
-               }       
+                       node = gtk_ctree_node_nth
+                               (ctree,
+                                item->sort_type == SORT_DESCENDING
+                                ? 0 : GTK_CLIST(ctree)->rows - 1);
+               }
                if (prefs_common.open_unread_on_enter) {
                        summary_unlock(summaryview);
                        summary_select_node(summaryview, node, TRUE, TRUE);
@@ -992,8 +983,6 @@ void summary_clear_list(SummaryView *summaryview)
                g_hash_table_destroy(summaryview->folder_table);
                summaryview->folder_table = NULL;
        }
-       summaryview->sort_mode = SORT_BY_NONE;
-       summaryview->sort_type = GTK_SORT_ASCENDING;
 
        gtk_clist_clear(clist);
        if (summaryview->col_pos[S_COL_SUBJECT] == N_SUMMARY_COLS - 1) {
@@ -1799,8 +1788,9 @@ static void summary_set_column_titles(SummaryView *summaryview)
        SummaryColumnType type;
        gboolean single_char;
        GtkJustification justify;
+       FolderItem *item = summaryview->folder_item;
 
-       static SummarySortType sort_by[N_SUMMARY_COLS] = {
+       static FolderSortKey sort_by[N_SUMMARY_COLS] = {
                SORT_BY_MARK,
                SORT_BY_UNREAD,
                SORT_BY_MIME,
@@ -1869,9 +1859,9 @@ static void summary_set_column_titles(SummaryView *summaryview)
                        gtk_box_pack_start(GTK_BOX(hbox), label,
                                           FALSE, FALSE, 0);
 
-               if (summaryview->sort_mode == sort_by[type]) {
+               if (item && item->sort_key == sort_by[type]) {
                        arrow = gtk_arrow_new
-                               (summaryview->sort_type == GTK_SORT_ASCENDING
+                               (item->sort_type == SORT_ASCENDING
                                 ? GTK_ARROW_DOWN : GTK_ARROW_UP,
                                 GTK_SHADOW_IN);
                        if (justify == GTK_JUSTIFY_RIGHT)
@@ -1887,16 +1877,16 @@ static void summary_set_column_titles(SummaryView *summaryview)
        }
 }
 
-void summary_sort(SummaryView *summaryview, SummarySortType type)
+void summary_sort(SummaryView *summaryview, FolderSortKey sort_key)
 {
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
        GtkCList *clist = GTK_CLIST(summaryview->ctree);
        GtkCListCompareFunc cmp_func;
+       FolderItem *item = summaryview->folder_item;
 
-       if (!summaryview->folder_item)
-               return;
+       if (!item) return;
 
-       switch (type) {
+       switch (sort_key) {
        case SORT_BY_MARK:
                cmp_func = (GtkCListCompareFunc)summary_cmp_by_mark;
                break;
@@ -1942,24 +1932,20 @@ void summary_sort(SummaryView *summaryview, SummarySortType type)
        gtk_clist_set_compare_func(clist, cmp_func);
 
        /* toggle sort type if the same column is selected */
-       if (summaryview->sort_mode == type)
-               summaryview->sort_type =
-                       summaryview->sort_type == GTK_SORT_ASCENDING
-                       ? GTK_SORT_DESCENDING : GTK_SORT_ASCENDING;
+       if (item->sort_key == sort_key)
+               item->sort_type =
+                       item->sort_type == SORT_ASCENDING
+                       ? SORT_DESCENDING : SORT_ASCENDING;
        else
-               summaryview->sort_type = GTK_SORT_ASCENDING;
-       gtk_clist_set_sort_type(clist, summaryview->sort_type);
-       summaryview->sort_mode = type;
+               item->sort_type = SORT_ASCENDING;
+       gtk_clist_set_sort_type(clist, (GtkSortType)item->sort_type);
+       item->sort_key = sort_key;
 
        summary_set_column_titles(summaryview);
 
        gtk_ctree_sort_recursive(ctree, NULL);
 
        gtk_ctree_node_moveto(ctree, summaryview->selected, -1, 0.5, 0);
-       prefs_folder_item_set_config(summaryview->folder_item,
-                                    summaryview->sort_type,
-                                    summaryview->sort_mode);
-       prefs_folder_item_save_config(summaryview->folder_item);
 
        debug_print(_("done.\n"));
        STATUSBAR_POP(summaryview->mainwin);
index 71bbcf1..3cf1628 100644 (file)
@@ -55,22 +55,6 @@ typedef enum
 
 #define N_SUMMARY_COLS 10
 
-typedef enum
-{
-       SORT_BY_NONE,
-       SORT_BY_NUMBER,
-       SORT_BY_SIZE,
-       SORT_BY_DATE,
-       SORT_BY_FROM,
-       SORT_BY_SUBJECT,
-       SORT_BY_SCORE,
-       SORT_BY_LOCKED,
-       SORT_BY_LABEL,
-       SORT_BY_MARK,
-       SORT_BY_UNREAD,
-       SORT_BY_MIME
-} SummarySortType;
-
 typedef enum
 {
        SUMMARY_NONE,
@@ -158,11 +142,6 @@ private:
        GSList *mlist;
        /* table for updating folder tree */
        GHashTable *folder_table;
-
-       /* current sorting state */
-       SummarySortType sort_mode;
-       GtkSortType sort_type;
-
 };
 
 SummaryView    *summary_create(void);
@@ -205,7 +184,7 @@ void summary_filter_open      (SummaryView          *summaryview,
                                   PrefsFilterType       type);
 
 void summary_sort                (SummaryView          *summaryview,
-                                  SummarySortType       type);
+                                  FolderSortKey         sort_key);
 
 void summary_delete              (SummaryView          *summaryview);
 void summary_delete_duplicated   (SummaryView          *summaryview);