sync with Hiroyuki's 0.5.0cvs1
authorAlfons Hoogervorst <alfons@proteus.demon.nl>
Sat, 14 Jul 2001 17:21:51 +0000 (17:21 +0000)
committerAlfons Hoogervorst <alfons@proteus.demon.nl>
Sat, 14 Jul 2001 17:21:51 +0000 (17:21 +0000)
ChangeLog.claws
src/folder.c
src/folder.h
src/folderview.c

index f0e327ca1c4a5b0126a71fa5f98e0dc2867f441d..404f4b86113d501b16007622e447de9e614f5022 100644 (file)
@@ -3,6 +3,10 @@
        * configure.in
                0.5.1claws1
 
+       * src/folderview.c
+         src/folder.[ch]
+               sync with Hiroyuki's 0.5.0cvs1
+
        * src/summaryview.c
                more rewrite label colouring
 
index ae93c2ff3e46f53ce4b6f4d50008e0ad7e1a6171..1391dd12e2094f10506522f2ab9dc453b697e189 100644 (file)
@@ -153,7 +153,7 @@ FolderItem *folder_item_new(const gchar *name, const gchar *path)
        item->last_num = -1;
        item->no_sub = FALSE;
        item->no_select = FALSE;
-       item->collapsed = FALSE; /* default is open */
+       item->collapsed = FALSE;
        item->parent = NULL;
        item->folder = NULL;
        item->data = NULL;
@@ -578,10 +578,6 @@ gint folder_item_move_msg(FolderItem *dest, MsgInfo *msginfo)
        g_return_val_if_fail(msginfo != NULL, -1);
 
        folder = dest->folder;
-
-       g_return_val_if_fail(folder->scan != NULL, -1);
-       g_return_val_if_fail(folder->move_msg != NULL, -1);
-
        if (dest->last_num < 0) folder->scan(folder, dest);
 
        num = folder->move_msg(folder, dest, msginfo);
@@ -639,10 +635,6 @@ gint folder_item_move_msgs_with_dest(FolderItem *dest, GSList *msglist)
        g_return_val_if_fail(msglist != NULL, -1);
 
        folder = dest->folder;
-
-       g_return_val_if_fail(folder->scan != NULL, -1);
-       g_return_val_if_fail(folder->move_msgs_with_dest != NULL, -1);
-
        if (dest->last_num < 0) folder->scan(folder, dest);
 
        num = folder->move_msgs_with_dest(folder, dest, msglist);
@@ -703,10 +695,6 @@ gint folder_item_copy_msg(FolderItem *dest, MsgInfo *msginfo)
        g_return_val_if_fail(msginfo != NULL, -1);
 
        folder = dest->folder;
-
-       g_return_val_if_fail(folder->scan != NULL, -1);
-       g_return_val_if_fail(folder->copy_msg != NULL, -1);
-
        if (dest->last_num < 0) folder->scan(folder, dest);
 
        num = folder->copy_msg(folder, dest, msginfo);
@@ -753,10 +741,6 @@ gint folder_item_copy_msgs_with_dest(FolderItem *dest, GSList *msglist)
        g_return_val_if_fail(msglist != NULL, -1);
 
        folder = dest->folder;
-
-       g_return_val_if_fail(folder->scan != NULL, -1);
-       g_return_val_if_fail(folder->copy_msgs_with_dest != NULL, -1);
-
        if (dest->last_num < 0) folder->scan(folder, dest);
 
        num = folder->copy_msgs_with_dest(folder, dest, msglist);
@@ -1179,10 +1163,8 @@ static gboolean folder_read_folder_func(GNode *node, gpointer data)
                        account = account_find_from_id(atoi(attr->value));
                        if (!account) g_warning("account_id: %s not found\n",
                                                attr->value);
-               }
-               else if (!strcmp(attr->name, "collapsed")) {
-                       collapsed = *(attr->value) == '1' ? 1 : 0;
-               }
+               } else if (!strcmp(attr->name, "collapsed"))
+                       collapsed = *attr->value == '1' ? TRUE : FALSE;
        }
 
        folder = folder_new(type, name, path);
@@ -1190,23 +1172,15 @@ static gboolean folder_read_folder_func(GNode *node, gpointer data)
        folder->account = account;
        if (account && (type == F_IMAP || type == F_NEWS))
                account->folder = REMOTE_FOLDER(folder);
-               
        node->data = folder->node->data;
        g_node_destroy(folder->node);
        folder->node = node;
-
        folder_add(folder);
+       FOLDER_ITEM(node->data)->collapsed = collapsed;
 
        g_node_traverse(node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
                        folder_build_tree, folder);
 
-       /* ALFONS_NOTE: after a folder_new() the folder system also created a 
-        * FolderItem for the folder (which makes insertion in the GtkCTree
-        * easier because it deals with FolderItems only). put the collapsed
-        * state for this Folder in its associated FolderItem */
-
-       FOLDER_ITEM((folder->node->data))->collapsed = collapsed; 
-
        return FALSE;
 }
 
@@ -1254,13 +1228,8 @@ static void folder_write_list_recursive(GNode *node, gpointer data)
                if (folder->account)
                        fprintf(fp, " account_id=\"%d\"",
                                folder->account->account_id);
-                               
-               /* ALFONS_NOTE: for each Folder structure, also a FolderItem is created;
-                * this is very clever, but undocumented. (it is clever because the
-                * folderview's GtkCTree only deals with FolderItems.) */
-               if (item->collapsed )
-                       fprintf(fp, " collapsed=\"1\"");
-               
+               if (item->collapsed)
+                       fputs(" collapsed=\"1\"", fp);
        } else {
                fprintf(fp, "<folderitem type=\"%s\"",
                        folder_item_stype_str[item->stype]);
@@ -1281,7 +1250,7 @@ static void folder_write_list_recursive(GNode *node, gpointer data)
                        fputs(" no_sub=\"1\"", fp);
                if (item->no_select)
                        fputs(" no_select=\"1\"", fp);
-               if (item->collapsed) 
+               if (item->collapsed)
                        fputs(" collapsed=\"1\"", fp);
                fprintf(fp,
                        " mtime=\"%ld\" new=\"%d\" unread=\"%d\" total=\"%d\"",
index deb19dee9e75040a58538444aea2f6a264fd1bba..d6d4a63a4d0f84166bf79603ab1d81b3e1ebe913 100644 (file)
@@ -212,9 +212,9 @@ struct _FolderItem
        gint last_num;
 
        /* special flags */
-       guint no_sub    : 1; /* no childs allowed? */   
-       guint no_select : 1; /* not selectable?    */
-       guint collapsed : 1; /* collapsed item     */
+       guint no_sub    : 1; /* no child allowed? */
+       guint no_select : 1; /* not selectable?   */
+       guint collapsed : 1; /* collapsed item    */
 
        FolderItem *parent;
 
index 7ad83cbf136bf14b8f270f3270ca5b4e125f7584..d5d2826c5939b7ce4927597f73c9935cd4826e6d 100644 (file)
@@ -976,23 +976,18 @@ static gboolean folderview_gnode_func(GtkCTree *ctree, guint depth,
 static void folderview_expand_func(GtkCTree *ctree, GtkCTreeNode *node,
                                   gpointer data)
 {
-       /* NOTE: data should by FolderView pointer */
+       FolderView *folderview = (FolderView *)data;
+       FolderItem *item;
+
        if (GTK_CTREE_ROW(node)->children) {
-               FolderItem *item = gtk_ctree_node_get_row_data(ctree, node);
-               FolderView *view = (FolderView *) data;
+               item = gtk_ctree_node_get_row_data(ctree, node);
                g_return_if_fail(item != NULL);
-               g_return_if_fail(view);
-               
-               if (!item->collapsed) {
+
+               if (!item->collapsed)
                        gtk_ctree_expand(ctree, node);
-               }
-               else {
-                       /* if it is collapsed we should update the node,
-                        * in case one of the children contains unread
-                        * messages or other visible state things */
-                       folderview_update_node(view, node);                      
-               }
-       }               
+               else
+                       folderview_update_node(folderview, node);
+       }
 }
 
 #define SET_SPECIAL_FOLDER(ctree, item) \
@@ -1373,9 +1368,10 @@ static void folderview_selected(GtkCTree *ctree, GtkCTreeNode *row,
 static void folderview_tree_expanded(GtkCTree *ctree, GtkCTreeNode *node,
                                     FolderView *folderview)
 {
-       FolderItem *item = gtk_ctree_node_get_row_data(ctree, node);
+       FolderItem *item;
 
-       g_return_if_fail(item);
+       item = gtk_ctree_node_get_row_data(ctree, node);
+       g_return_if_fail(item != NULL);
        item->collapsed = FALSE;
        folderview_update_node(folderview, node);
 }
@@ -1383,10 +1379,11 @@ static void folderview_tree_expanded(GtkCTree *ctree, GtkCTreeNode *node,
 static void folderview_tree_collapsed(GtkCTree *ctree, GtkCTreeNode *node,
                                      FolderView *folderview)
 {
-       FolderItem *item = gtk_ctree_node_get_row_data(ctree, node);
+       FolderItem *item;
 
-       g_return_if_fail(item);
-       item->collapsed = TRUE;
+       item = gtk_ctree_node_get_row_data(ctree, node);
+       g_return_if_fail(item != NULL);
+       item->collapsed= TRUE;
        folderview_update_node(folderview, node);
 }