aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2007-11-05 19:49:53 +0800
committerMilan Crha <mcrha@src.gnome.org>2007-11-05 19:49:53 +0800
commite335802981396bacf6d20a2168853d94ba15df9c (patch)
tree84ea3d22c04f7ef58edfbb802f75ee15d3cdd25b /mail
parentaf8315fae1717faa91c26a3051b8b6f07f95062c (diff)
downloadgsoc2013-evolution-e335802981396bacf6d20a2168853d94ba15df9c.tar
gsoc2013-evolution-e335802981396bacf6d20a2168853d94ba15df9c.tar.gz
gsoc2013-evolution-e335802981396bacf6d20a2168853d94ba15df9c.tar.bz2
gsoc2013-evolution-e335802981396bacf6d20a2168853d94ba15df9c.tar.lz
gsoc2013-evolution-e335802981396bacf6d20a2168853d94ba15df9c.tar.xz
gsoc2013-evolution-e335802981396bacf6d20a2168853d94ba15df9c.tar.zst
gsoc2013-evolution-e335802981396bacf6d20a2168853d94ba15df9c.zip
** Fix for bug #343011 (restore collapse state of selected folder after
2007-11-05 Milan Crha <mcrha@redhat.com> ** Fix for bug #343011 (restore collapse state of selected folder after start) * em-folder-tree.c: (emft_maybe_expand_row): Do not expand subtree of a node, only make it visible. * em-folder-tree-model.h: (em_folder_tree_model_get_expanded_uri), (em_folder_tree_model_set_expanded_uri): * em-folder-tree-model.c: (em_folder_tree_model_get_expanded_uri), (em_folder_tree_model_set_expanded_uri): Same as ..._get/_set_expanded, but using 'uri', instead of 'key'. * em-folder-tree-model.c: (emftm_uri_to_key): New helper function. * mail-component.c: (impl_createView): Restore collapsed state after selecting last selected folder, if necessary. svn path=/trunk/; revision=34503
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog16
-rw-r--r--mail/em-folder-tree-model.c94
-rw-r--r--mail/em-folder-tree-model.h3
-rw-r--r--mail/em-folder-tree.c15
-rw-r--r--mail/mail-component.c7
5 files changed, 132 insertions, 3 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index d705da3c81..c03119a054 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,5 +1,21 @@
2007-11-05 Milan Crha <mcrha@redhat.com>
+ ** Fix for bug #343011
+ (restore collapse state of selected folder after start)
+
+ * em-folder-tree.c: (emft_maybe_expand_row): Do not expand subtree of
+ a node, only make it visible.
+ * em-folder-tree-model.h: (em_folder_tree_model_get_expanded_uri),
+ (em_folder_tree_model_set_expanded_uri):
+ * em-folder-tree-model.c: (em_folder_tree_model_get_expanded_uri),
+ (em_folder_tree_model_set_expanded_uri):
+ Same as ..._get/_set_expanded, but using 'uri', instead of 'key'.
+ * em-folder-tree-model.c: (emftm_uri_to_key): New helper function.
+ * mail-component.c: (impl_createView): Restore collapsed state after
+ selecting last selected folder, if necessary.
+
+2007-11-05 Milan Crha <mcrha@redhat.com>
+
** Fix for bug #488298
* em-folder-view.c: (EMFolderViewEnable emfv_enable_map[]):
diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c
index 66978cdae8..9048969fef 100644
--- a/mail/em-folder-tree-model.c
+++ b/mail/em-folder-tree-model.c
@@ -55,6 +55,7 @@
#include "em-utils.h"
#include <camel/camel-folder.h>
+#include <camel/camel-vee-store.h>
#include "em-marshal.h"
#include "em-folder-tree-model.h"
@@ -1021,6 +1022,99 @@ em_folder_tree_model_set_expanded (EMFolderTreeModel *model, const char *key, gb
} while (name);
}
+/**
+ * emftm_uri_to_key
+ * Converts uri to key used in functions like em_folder_tree_model_[s/g]et_expanded.
+ * @param uri Uri to be converted.
+ * @return Key of the uri or NULL, if failed. Returned value should be clear by g_free.
+ **/
+static gchar *
+emftm_uri_to_key (const char *uri)
+{
+ CamelException ex = { 0 };
+ CamelStore *store;
+ CamelURL *url;
+ gchar *key;
+
+ if (!uri)
+ return NULL;
+
+ store = (CamelStore *)camel_session_get_service (session, uri, CAMEL_PROVIDER_STORE, &ex);
+ camel_exception_clear(&ex);
+
+ url = camel_url_new (uri, NULL);
+
+ if (store == NULL || url == NULL) {
+ key = NULL;
+ } else {
+ const char *path;
+ EAccount *account;
+
+ if (((CamelService *)store)->provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH)
+ path = url->fragment;
+ else
+ path = url->path && url->path[0]=='/' ? url->path+1:url->path;
+
+ if (path == NULL)
+ path = "";
+
+ if ( (account = mail_config_get_account_by_source_url (uri)) )
+ key = g_strdup_printf ("%s/%s", account->uid, path);
+ else if (CAMEL_IS_VEE_STORE (store))
+ key = g_strdup_printf ("vfolder/%s", path);
+ else
+ key = g_strdup_printf ("local/%s", path);
+ }
+
+ if (url)
+ camel_url_free (url);
+
+ if (store)
+ camel_object_unref (store);
+
+ return key;
+}
+
+/**
+ * em_folder_tree_model_get_expanded_uri
+ * Same as @ref em_folder_tree_model_get_expanded, but here we use uri, not key for node.
+ **/
+gboolean
+em_folder_tree_model_get_expanded_uri (EMFolderTreeModel *model, const char *uri)
+{
+ gchar *key;
+ gboolean expanded;
+
+ g_return_val_if_fail (model != NULL, FALSE);
+ g_return_val_if_fail (uri != NULL, FALSE);
+
+ key = emftm_uri_to_key (uri);
+ expanded = key && em_folder_tree_model_get_expanded (model, key);
+
+ g_free (key);
+
+ return expanded;
+}
+
+/**
+ * em_folder_tree_model_set_expanded_uri
+ * Same as @ref em_folder_tree_model_set_expanded, but here we use uri, not key for node.
+ **/
+void
+em_folder_tree_model_set_expanded_uri (EMFolderTreeModel *model, const char *uri, gboolean expanded)
+{
+ gchar *key;
+
+ g_return_if_fail (model != NULL);
+ g_return_if_fail (uri != NULL);
+
+ key = emftm_uri_to_key (uri);
+ if (key)
+ em_folder_tree_model_set_expanded (model, key, expanded);
+
+ g_free (key);
+}
+
void
em_folder_tree_model_save_state (EMFolderTreeModel *model)
{
diff --git a/mail/em-folder-tree-model.h b/mail/em-folder-tree-model.h
index ba7a3d630e..9c5a4124d2 100644
--- a/mail/em-folder-tree-model.h
+++ b/mail/em-folder-tree-model.h
@@ -137,6 +137,9 @@ void em_folder_tree_model_set_selected (EMFolderTreeModel *model, const char *ur
gboolean em_folder_tree_model_get_expanded (EMFolderTreeModel *model, const char *key);
void em_folder_tree_model_set_expanded (EMFolderTreeModel *model, const char *key, gboolean expanded);
+gboolean em_folder_tree_model_get_expanded_uri (EMFolderTreeModel *model, const char *uri);
+void em_folder_tree_model_set_expanded_uri (EMFolderTreeModel *model, const char *uri, gboolean expanded);
+
void em_folder_tree_model_save_state (EMFolderTreeModel *model);
typedef void (* EMFTModelExpandFunc) (EMFolderTreeModel *model, const char *path, void *user_data);
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index be97353e42..acf317a15c 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -675,6 +675,7 @@ emft_maybe_expand_row (EMFolderTreeModel *model, GtkTreePath *tree_path, GtkTree
char *full_name;
char *key;
struct _selected_uri *u;
+ gboolean is_expanded;
gtk_tree_model_get ((GtkTreeModel *) model, iter,
COL_STRING_FULL_NAME, &full_name,
@@ -693,10 +694,18 @@ emft_maybe_expand_row (EMFolderTreeModel *model, GtkTreePath *tree_path, GtkTree
key = g_strdup_printf ("local/%s", full_name ? full_name : "");
}
+ is_expanded = em_folder_tree_model_get_expanded (model, key);
u = g_hash_table_lookup(priv->select_uris_table, key);
- if (em_folder_tree_model_get_expanded (model, key) || u) {
- gtk_tree_view_expand_to_path (priv->treeview, tree_path);
- gtk_tree_view_expand_row (priv->treeview, tree_path, FALSE);
+ if (is_expanded || u) {
+ if (is_expanded) {
+ gtk_tree_view_expand_to_path (priv->treeview, tree_path);
+ gtk_tree_view_expand_row (priv->treeview, tree_path, FALSE);
+ } else {
+ char *c = strrchr (key, '/');
+
+ *c = '\0';
+ emft_expand_node (model, key, emft);
+ }
if (u)
emft_select_uri(emft, tree_path, u);
diff --git a/mail/mail-component.c b/mail/mail-component.c
index 04198ecfb6..9237a1793d 100644
--- a/mail/mail-component.c
+++ b/mail/mail-component.c
@@ -699,8 +699,15 @@ impl_createView (PortableServer_Servant servant,
em_folder_tree_enable_drag_and_drop ((EMFolderTree *) tree_widget);
if ((uri = em_folder_tree_model_get_selected (priv->model))) {
+ gboolean expanded;
+
+ expanded = em_folder_tree_model_get_expanded_uri (priv->model, uri);
em_folder_tree_set_selected ((EMFolderTree *) tree_widget, uri, FALSE);
em_folder_view_set_folder_uri ((EMFolderView *) view_widget, uri);
+
+ if (!expanded)
+ em_folder_tree_model_set_expanded_uri (priv->model, uri, expanded);
+
g_free (uri);
}