item->last_num = -1;
item->no_sub = FALSE;
item->no_select = FALSE;
+ item->collapsed = FALSE; /* default is open */
item->parent = NULL;
item->folder = NULL;
item->data = NULL;
const gchar *name = NULL;
const gchar *path = NULL;
PrefsAccount *account = NULL;
- gboolean no_sub = FALSE, no_select = FALSE;
+ gboolean no_sub = FALSE, no_select = FALSE, collapsed = FALSE;
gint mtime = 0, new = 0, unread = 0, total = 0;
g_return_val_if_fail(node->data != NULL, FALSE);
no_sub = *attr->value == '1' ? TRUE : FALSE;
else if (!strcmp(attr->name, "no_select"))
no_select = *attr->value == '1' ? TRUE : FALSE;
+ else if (!strcmp(attr->name, "collapsed"))
+ collapsed = *attr->value == '1' ? TRUE : FALSE;
}
item = folder_item_new(name, path);
item->total = total;
item->no_sub = no_sub;
item->no_select = no_select;
+ item->collapsed = collapsed;
item->parent = FOLDER_ITEM(node->parent->data);
item->folder = folder;
switch (stype) {
const gchar *name = NULL;
const gchar *path = NULL;
PrefsAccount *account = NULL;
+ gboolean collapsed = FALSE;
if (g_node_depth(node) != 2) return FALSE;
g_return_val_if_fail(node->data != NULL, FALSE);
if (!account) g_warning("account_id: %s not found\n",
attr->value);
}
+ else if (!strcmp(attr->name, "collapsed")) {
+ collapsed = *(attr->value) == '1' ? 1 : 0;
+ }
}
folder = folder_new(type, name, path);
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);
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;
}
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\"");
+
} else {
fprintf(fp, "<folderitem type=\"%s\"",
folder_item_stype_str[item->stype]);
fputs(" no_sub=\"1\"", fp);
if (item->no_select)
fputs(" no_select=\"1\"", fp);
+ if (item->collapsed)
+ fputs(" collapsed=\"1\"", fp);
fprintf(fp,
" mtime=\"%ld\" new=\"%d\" unread=\"%d\" total=\"%d\"",
item->mtime, item->new, item->unread, item->total);