aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-folder-tree-model.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@novell.com>2004-06-11 06:08:41 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2004-06-11 06:08:41 +0800
commitcb21428ef8f23891a4870886ed1f9dfec3969a61 (patch)
tree048652d03889e5dbf1ee916c3e36131dd9833a12 /mail/em-folder-tree-model.c
parent0678d00b52c75cc685dd64a82c77c5adb4b5be71 (diff)
downloadgsoc2013-evolution-cb21428ef8f23891a4870886ed1f9dfec3969a61.tar.gz
gsoc2013-evolution-cb21428ef8f23891a4870886ed1f9dfec3969a61.tar.zst
gsoc2013-evolution-cb21428ef8f23891a4870886ed1f9dfec3969a61.zip
Fixes bug #58825. Ugh. Really Gross Hack (tm).
2004-06-10 Jeffrey Stedfast <fejj@novell.com> Fixes bug #58825. Ugh. Really Gross Hack (tm). * em-folder-tree.c (emft_tree_row_expanded): If the store that we are expanding matches the uri that we've been requested to select (e.g. from before the store was added to the tree), then give the uri to the get_folder_info_op. (em_folder_tree_set_selected): If the store for the uri isn't in the tree yet, save the uri for later. * mail-component.c (folder_selected_cb): Set the selected state of the folder-tree and save it. (impl_createControls): Restore the selected state on the folder-tree. * em-folder-tree-model.c (em_folder_tree_model_set_selected): New function to set the selected-uri saved state. (em_folder_tree_model_get_selected): New function to get the selected uri saved state. (em_folder_tree_model_save_state): Renamed. * em-folder-tree.c (emft_update_model_expanded_state): Don't let path be NULL if the node is a store node (path == NULL for any other case is a bug). (emft_maybe_expand_row): Same. svn path=/trunk/; revision=26294
Diffstat (limited to 'mail/em-folder-tree-model.c')
-rw-r--r--mail/em-folder-tree-model.c99
1 files changed, 78 insertions, 21 deletions
diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c
index 0ea5ced173..aa32044b6f 100644
--- a/mail/em-folder-tree-model.c
+++ b/mail/em-folder-tree-model.c
@@ -281,8 +281,8 @@ em_folder_tree_model_finalize (GObject *obj)
EMFolderTreeModel *model = (EMFolderTreeModel *) obj;
g_free (model->filename);
- if (model->expanded)
- xmlFreeDoc (model->expanded);
+ if (model->state)
+ xmlFreeDoc (model->state);
g_hash_table_foreach (model->store_hash, store_hash_free, NULL);
g_hash_table_destroy (model->store_hash);
@@ -317,16 +317,16 @@ em_folder_tree_model_load_state (EMFolderTreeModel *model, const char *filename)
xmlNodePtr root, node;
struct stat st;
- if (model->expanded)
- xmlFreeDoc (model->expanded);
+ if (model->state)
+ xmlFreeDoc (model->state);
- if (stat (filename, &st) == 0 && (model->expanded = xmlParseFile (filename)))
+ if (stat (filename, &st) == 0 && (model->state = xmlParseFile (filename)))
return;
/* setup some defaults - expand "Local Folders" and "VFolders" */
- model->expanded = xmlNewDoc ("1.0");
- root = xmlNewDocNode (model->expanded, NULL, "tree-state", NULL);
- xmlDocSetRootElement (model->expanded, root);
+ model->state = xmlNewDoc ("1.0");
+ root = xmlNewDocNode (model->state, NULL, "tree-state", NULL);
+ xmlDocSetRootElement (model->state, root);
node = xmlNewChild (root, NULL, "node", NULL);
xmlSetProp (node, "name", "local");
@@ -915,7 +915,7 @@ em_folder_tree_model_get_expanded (EMFolderTreeModel *model, const char *key)
const char *name;
char *buf, *p;
- node = model->expanded ? model->expanded->children : NULL;
+ node = model->state ? model->state->children : NULL;
if (!node || strcmp (node->name, "tree-state") != 0)
return FALSE;
@@ -924,7 +924,7 @@ em_folder_tree_model_get_expanded (EMFolderTreeModel *model, const char *key)
if (p[-1] == '/')
p[-1] = '\0';
p = NULL;
-
+
do {
if ((p = strchr (name, '/')))
*p = '\0';
@@ -942,7 +942,7 @@ em_folder_tree_model_get_expanded (EMFolderTreeModel *model, const char *key)
name = p ? p + 1 : NULL;
} while (name && node);
-
+
return FALSE;
}
@@ -954,14 +954,14 @@ em_folder_tree_model_set_expanded (EMFolderTreeModel *model, const char *key, gb
const char *name;
char *buf, *p;
- if (model->expanded == NULL)
- model->expanded = xmlNewDoc ("1.0");
+ if (model->state == NULL)
+ model->state = xmlNewDoc ("1.0");
- if (!model->expanded->children) {
- node = xmlNewDocNode (model->expanded, NULL, "tree-state", NULL);
- xmlDocSetRootElement (model->expanded, node);
+ if (!model->state->children) {
+ node = xmlNewDocNode (model->state, NULL, "tree-state", NULL);
+ xmlDocSetRootElement (model->state, node);
} else {
- node = model->expanded->children;
+ node = model->state->children;
}
name = buf = g_alloca (strlen (key) + 1);
@@ -993,11 +993,11 @@ em_folder_tree_model_set_expanded (EMFolderTreeModel *model, const char *key, gb
}
void
-em_folder_tree_model_save_expanded (EMFolderTreeModel *model)
+em_folder_tree_model_save_state (EMFolderTreeModel *model)
{
char *dirname;
- if (model->expanded == NULL)
+ if (model->state == NULL)
return;
dirname = g_path_get_dirname (model->filename);
@@ -1008,7 +1008,7 @@ em_folder_tree_model_save_expanded (EMFolderTreeModel *model)
g_free (dirname);
- e_xml_save_file (model->filename, model->expanded);
+ e_xml_save_file (model->filename, model->state);
}
@@ -1048,7 +1048,7 @@ em_folder_tree_model_expand_foreach (EMFolderTreeModel *model, EMFTModelExpandFu
{
xmlNodePtr root;
- root = model->expanded ? model->expanded->children : NULL;
+ root = model->state ? model->state->children : NULL;
if (!root || !root->children || strcmp (root->name, "tree-state") != 0)
return;
@@ -1092,3 +1092,60 @@ em_folder_tree_model_set_unread_count (EMFolderTreeModel *model, CamelStore *sto
gtk_tree_store_set ((GtkTreeStore *) model, &iter, COL_UINT_UNREAD, unread, -1);
}
+
+
+char *
+em_folder_tree_model_get_selected (EMFolderTreeModel *model)
+{
+ xmlNodePtr node;
+ char *buf, *uri;
+
+ node = model->state ? model->state->children : NULL;
+ if (!node || strcmp (node->name, "tree-state") != 0)
+ return FALSE;
+
+ node = node->children;
+ while (node != NULL) {
+ if (!strcmp (node->name, "selected"))
+ break;
+ node = node->next;
+ }
+
+ if (node == NULL)
+ return NULL;
+
+ buf = xmlGetProp (node, "uri");
+ uri = g_strdup (buf);
+ xmlFree (buf);
+
+ return uri;
+}
+
+
+void
+em_folder_tree_model_set_selected (EMFolderTreeModel *model, const char *uri)
+{
+ xmlNodePtr root, node;
+
+ if (model->state == NULL)
+ model->state = xmlNewDoc ("1.0");
+
+ if (!model->state->children) {
+ root = xmlNewDocNode (model->state, NULL, "tree-state", NULL);
+ xmlDocSetRootElement (model->state, node);
+ } else {
+ root = model->state->children;
+ }
+
+ node = root->children;
+ while (node != NULL) {
+ if (!strcmp (node->name, "selected"))
+ break;
+ node = node->next;
+ }
+
+ if (node == NULL)
+ node = xmlNewChild (root, NULL, "selected", NULL);
+
+ xmlSetProp (node, "uri", uri);
+}