From cb21428ef8f23891a4870886ed1f9dfec3969a61 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Thu, 10 Jun 2004 22:08:41 +0000 Subject: Fixes bug #58825. Ugh. Really Gross Hack (tm). 2004-06-10 Jeffrey Stedfast 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 --- mail/em-folder-tree.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'mail/em-folder-tree.c') diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index 101e593b96..96d5677073 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -76,6 +76,8 @@ struct _EMFolderTreePrivate { GtkTreeView *treeview; EMFolderTreeModel *model; + char *select_uri; /* uri to load when the proper store/etc have been populated */ + char *selected_uri; char *selected_path; @@ -372,6 +374,7 @@ em_folder_tree_finalize (GObject *obj) emft->priv->lost_folders = NULL; } + g_free (emft->priv->select_uri); g_free (emft->priv->selected_uri); g_free (emft->priv->selected_path); g_free (emft->priv); @@ -560,6 +563,7 @@ static void emft_maybe_expand_row (EMFolderTreeModel *model, GtkTreePath *tree_path, GtkTreeIter *iter, EMFolderTree *emft) { struct _EMFolderTreeModelStoreInfo *si; + gboolean is_store; CamelStore *store; EAccount *account; char *path, *key; @@ -567,8 +571,12 @@ emft_maybe_expand_row (EMFolderTreeModel *model, GtkTreePath *tree_path, GtkTree gtk_tree_model_get ((GtkTreeModel *) model, iter, COL_STRING_FULL_NAME, &path, COL_POINTER_CAMEL_STORE, &store, + COL_BOOL_IS_STORE, &is_store, -1); + if (is_store) + path = ""; + si = g_hash_table_lookup (model->store_hash, store); if ((account = mail_config_get_account_by_name (si->display_name))) { key = g_strdup_printf ("%s/%s", account->uid, path); @@ -1685,6 +1693,7 @@ static void emft_update_model_expanded_state (struct _EMFolderTreePrivate *priv, GtkTreeIter *iter, gboolean expanded) { struct _EMFolderTreeModelStoreInfo *si; + gboolean is_store; CamelStore *store; EAccount *account; char *path, *key; @@ -1692,8 +1701,12 @@ emft_update_model_expanded_state (struct _EMFolderTreePrivate *priv, GtkTreeIter gtk_tree_model_get ((GtkTreeModel *) priv->model, iter, COL_STRING_FULL_NAME, &path, COL_POINTER_CAMEL_STORE, &store, + COL_BOOL_IS_STORE, &is_store, -1); + if (is_store && path == NULL) + path = ""; + si = g_hash_table_lookup (priv->model->store_hash, store); if ((account = mail_config_get_account_by_name (si->display_name))) { key = g_strdup_printf ("%s/%s", account->uid, path); @@ -1714,8 +1727,10 @@ emft_tree_row_expanded (GtkTreeView *treeview, GtkTreeIter *root, GtkTreePath *t { struct _EMFolderTreePrivate *priv = emft->priv; struct _EMFolderTreeGetFolderInfo *m; + CamelStore *store, *store2; + char *select_uri = NULL; GtkTreeModel *model; - CamelStore *store; + CamelException ex; gboolean load; char *path; @@ -1734,6 +1749,17 @@ emft_tree_row_expanded (GtkTreeView *treeview, GtkTreeIter *root, GtkTreePath *t return; } + camel_exception_init (&ex); + if (priv->select_uri && + (store2 = (CamelStore *) camel_session_get_service (session, priv->select_uri, CAMEL_PROVIDER_STORE, &ex))) { + if (store2 == store) { + select_uri = priv->select_uri; + priv->select_uri = NULL; + } + camel_object_unref (store2); + } + camel_exception_clear (&ex); + m = mail_msg_new (&get_folder_info_op, NULL, sizeof (struct _EMFolderTreeGetFolderInfo)); m->root = gtk_tree_row_reference_new (model, tree_path); camel_object_ref (store); @@ -1742,7 +1768,7 @@ emft_tree_row_expanded (GtkTreeView *treeview, GtkTreeIter *root, GtkTreePath *t g_object_ref(emft); m->top = g_strdup (path); m->flags = CAMEL_STORE_FOLDER_INFO_RECURSIVE; - m->select_uri = NULL; + m->select_uri = select_uri; e_thread_put (mail_thread_new, (EMsg *) m); } @@ -2703,6 +2729,7 @@ em_folder_tree_set_selected (EMFolderTree *emft, const char *uri) } if (!(si = g_hash_table_lookup (priv->model->store_hash, store))) { + priv->select_uri = g_strdup (uri); camel_object_unref (store); return; } @@ -2802,7 +2829,7 @@ emft_save_state (EMFolderTree *emft) { struct _EMFolderTreePrivate *priv = emft->priv; - em_folder_tree_model_save_expanded (priv->model); + em_folder_tree_model_save_state (priv->model); priv->save_state_id = 0; return FALSE; -- cgit