[evolution] Bug 795567 - Do not expand archive folder in Copy/Move message to folder dialog
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug 795567 - Do not expand archive folder in Copy/Move message to folder dialog
- Date: Thu, 26 Apr 2018 09:49:49 +0000 (UTC)
commit dd4cd78c96c7e91d17f7cd9c1d7d220ac8504f3e
Author: Milan Crha <mcrha redhat com>
Date: Thu Apr 26 11:48:47 2018 +0200
Bug 795567 - Do not expand archive folder in Copy/Move message to folder dialog
data/org.gnome.evolution.mail.gschema.xml.in | 4 +
src/mail/e-mail-reader.c | 1 +
src/mail/em-folder-selector.c | 98 ++++++++++++++++++++++++++
src/mail/em-folder-selector.h | 2 +
src/modules/mail/e-mail-shell-view-actions.c | 1 +
5 files changed, 106 insertions(+), 0 deletions(-)
---
diff --git a/data/org.gnome.evolution.mail.gschema.xml.in b/data/org.gnome.evolution.mail.gschema.xml.in
index 02f8e2d..9564c94 100644
--- a/data/org.gnome.evolution.mail.gschema.xml.in
+++ b/data/org.gnome.evolution.mail.gschema.xml.in
@@ -783,6 +783,10 @@
<default>false</default>
<_summary>Close the message browser window when the selected message is deleted or marked as
Junk.</_summary>
</key>
+ <key name="collapse-archive-folders-in-selectors" type="b">
+ <default>false</default>
+ <_summary>Collapse archive folders in Move/Copy message to Folder and Go to Folder
selectors.</_summary>
+ </key>
<!-- The following keys are deprecated. -->
<key name="forward-style" type="i">
diff --git a/src/mail/e-mail-reader.c b/src/mail/e-mail-reader.c
index aa372ab..3500656 100644
--- a/src/mail/e-mail-reader.c
+++ b/src/mail/e-mail-reader.c
@@ -363,6 +363,7 @@ mail_reader_copy_or_move_selected_messages (EMailReader *reader,
EMFT_EXCLUDE_VIRTUAL |
EMFT_EXCLUDE_VTRASH);
gtk_tree_view_expand_all (GTK_TREE_VIEW (folder_tree));
+ em_folder_selector_maybe_collapse_archive_folders (selector);
if (default_xfer_messages_uri != NULL) {
em_folder_tree_set_selected (
diff --git a/src/mail/em-folder-selector.c b/src/mail/em-folder-selector.c
index 12daad1..edd4399 100644
--- a/src/mail/em-folder-selector.c
+++ b/src/mail/em-folder-selector.c
@@ -825,3 +825,101 @@ em_folder_selector_new_activity (EMFolderSelector *selector)
return activity;
}
+void
+em_folder_selector_maybe_collapse_archive_folders (EMFolderSelector *selector)
+{
+ EMFolderTreeModel *model;
+ EMailSession *mail_session;
+ ESourceRegistry *registry;
+ CamelSession *session;
+ GSettings *settings;
+ GList *services, *link;
+ GHashTable *archives;
+ gchar *local_archive_folder;
+
+ g_return_if_fail (EM_IS_FOLDER_SELECTOR (selector));
+
+ settings = e_util_ref_settings ("org.gnome.evolution.mail");
+ if (!g_settings_get_boolean (settings, "collapse-archive-folders-in-selectors")) {
+ g_object_unref (settings);
+ return;
+ }
+ local_archive_folder = g_settings_get_string (settings, "local-archive-folder");
+ g_object_unref (settings);
+
+ model = em_folder_selector_get_model (selector);
+ mail_session = em_folder_tree_model_get_session (model);
+ registry = e_mail_session_get_registry (mail_session);
+ session = CAMEL_SESSION (mail_session);
+
+ archives = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+ if (local_archive_folder && *local_archive_folder) {
+ g_hash_table_insert (archives, local_archive_folder, NULL);
+ } else {
+ g_free (local_archive_folder);
+ }
+
+ services = camel_session_list_services (session);
+ for (link = services; link; link = g_list_next (link)) {
+ CamelService *service = link->data;
+
+ if (CAMEL_IS_STORE (service)) {
+ ESource *source;
+
+ source = e_source_registry_ref_source (registry, camel_service_get_uid (service));
+ if (source && e_source_has_extension (source, E_SOURCE_EXTENSION_MAIL_ACCOUNT)) {
+ ESourceMailAccount *account_ext;
+ gchar *archive_folder;
+
+ account_ext = e_source_get_extension (source,
E_SOURCE_EXTENSION_MAIL_ACCOUNT);
+
+ archive_folder = e_source_mail_account_dup_archive_folder (account_ext);
+ if (archive_folder && *archive_folder) {
+ g_hash_table_insert (archives, archive_folder, NULL);
+ } else {
+ g_free (archive_folder);
+ }
+ }
+
+ g_clear_object (&source);
+ }
+ }
+
+ g_list_free_full (services, g_object_unref);
+
+ if (g_hash_table_size (archives)) {
+ GtkTreeView *tree_view;
+ GHashTableIter iter;
+ gpointer key;
+
+ tree_view = GTK_TREE_VIEW (em_folder_selector_get_folder_tree (selector));
+
+ g_hash_table_iter_init (&iter, archives);
+
+ while (g_hash_table_iter_next (&iter, &key, NULL)) {
+ const gchar *folder_uri = key;
+ CamelStore *store = NULL;
+ gchar *folder_name = NULL;
+
+ if (folder_uri && *folder_uri &&
+ e_mail_folder_uri_parse (session, folder_uri, &store, &folder_name, NULL)) {
+ GtkTreeRowReference *row;
+
+ row = em_folder_tree_model_get_row_reference (model, store, folder_name);
+ if (row) {
+ GtkTreePath *path;
+
+ path = gtk_tree_row_reference_get_path (row);
+ gtk_tree_view_collapse_row (tree_view, path);
+ gtk_tree_path_free (path);
+ }
+
+ g_clear_object (&store);
+ g_free (folder_name);
+ }
+ }
+ }
+
+ g_hash_table_destroy (archives);
+}
diff --git a/src/mail/em-folder-selector.h b/src/mail/em-folder-selector.h
index 8093d71..6a5787f 100644
--- a/src/mail/em-folder-selector.h
+++ b/src/mail/em-folder-selector.h
@@ -96,6 +96,8 @@ void em_folder_selector_set_selected (EMFolderSelector *selector,
const gchar * em_folder_selector_get_selected_uri
(EMFolderSelector *selector);
EActivity * em_folder_selector_new_activity (EMFolderSelector *selector);
+void em_folder_selector_maybe_collapse_archive_folders
+ (EMFolderSelector *selector);
G_END_DECLS
diff --git a/src/modules/mail/e-mail-shell-view-actions.c b/src/modules/mail/e-mail-shell-view-actions.c
index 0c1fe14..d1da9fb 100644
--- a/src/modules/mail/e-mail-shell-view-actions.c
+++ b/src/modules/mail/e-mail-shell-view-actions.c
@@ -1145,6 +1145,7 @@ action_mail_goto_folder_cb (GtkAction *action,
folder_tree = em_folder_selector_get_folder_tree (selector);
gtk_tree_view_expand_all (GTK_TREE_VIEW (folder_tree));
+ em_folder_selector_maybe_collapse_archive_folders (selector);
if (folder) {
gchar *uri = e_mail_folder_uri_from_folder (folder);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]