aboutsummaryrefslogtreecommitdiffstats
path: root/modules/mail
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2011-09-26 17:45:59 +0800
committerMilan Crha <mcrha@redhat.com>2011-09-26 17:45:59 +0800
commite0548d25707ad8c4713e2e74c622a92bf4988545 (patch)
treebe2dd1051fa169b90b959cd80b9729a1416d0393 /modules/mail
parent4046d1944855274c8a6c406392ee734943142f90 (diff)
downloadgsoc2013-evolution-e0548d25707ad8c4713e2e74c622a92bf4988545.tar
gsoc2013-evolution-e0548d25707ad8c4713e2e74c622a92bf4988545.tar.gz
gsoc2013-evolution-e0548d25707ad8c4713e2e74c622a92bf4988545.tar.bz2
gsoc2013-evolution-e0548d25707ad8c4713e2e74c622a92bf4988545.tar.lz
gsoc2013-evolution-e0548d25707ad8c4713e2e74c622a92bf4988545.tar.xz
gsoc2013-evolution-e0548d25707ad8c4713e2e74c622a92bf4988545.tar.zst
gsoc2013-evolution-e0548d25707ad8c4713e2e74c622a92bf4988545.zip
Bug #351025 - Make the order of the mail accounts configurable
Diffstat (limited to 'modules/mail')
-rw-r--r--modules/mail/e-mail-shell-settings.c8
-rw-r--r--modules/mail/e-mail-shell-view.c2
-rw-r--r--modules/mail/em-account-prefs.c95
3 files changed, 103 insertions, 2 deletions
diff --git a/modules/mail/e-mail-shell-settings.c b/modules/mail/e-mail-shell-settings.c
index 99402d5f29..b0d5f1eed8 100644
--- a/modules/mail/e-mail-shell-settings.c
+++ b/modules/mail/e-mail-shell-settings.c
@@ -142,6 +142,10 @@ e_mail_shell_settings_init (EShellBackend *shell_backend)
"/apps/evolution/mail/display/enable_vfolders");
e_shell_settings_install_property_for_key (
+ "mail-enable-local-folders",
+ "/apps/evolution/mail/display/enable_local");
+
+ e_shell_settings_install_property_for_key (
"mail-font-monospace",
"/apps/evolution/mail/display/fonts/monospace");
@@ -201,6 +205,10 @@ e_mail_shell_settings_init (EShellBackend *shell_backend)
"/apps/evolution/mail/display/show_real_date");
e_shell_settings_install_property_for_key (
+ "mail-sort-accounts-alpha",
+ "/apps/evolution/mail/display/sort_accounts_alpha");
+
+ e_shell_settings_install_property_for_key (
"mail-prompt-delete-in-vfolder",
"/apps/evolution/mail/prompts/delete_in_vfolder");
diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c
index 5759b5830f..3a92ce284b 100644
--- a/modules/mail/e-mail-shell-view.c
+++ b/modules/mail/e-mail-shell-view.c
@@ -868,7 +868,7 @@ mail_shell_view_update_actions (EShellView *shell_view)
shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
state = e_shell_sidebar_check_state (shell_sidebar);
- model = em_folder_tree_model_get_default ();
+ model = em_folder_tree_model_get_default (e_mail_reader_get_backend (reader));
folder_allows_children =
(state & E_MAIL_SIDEBAR_FOLDER_ALLOWS_CHILDREN);
diff --git a/modules/mail/em-account-prefs.c b/modules/mail/em-account-prefs.c
index b43f1fbe35..1b11b41b68 100644
--- a/modules/mail/em-account-prefs.c
+++ b/modules/mail/em-account-prefs.c
@@ -40,6 +40,8 @@
#include "e-mail-store.h"
#include "em-config.h"
#include "em-account-editor.h"
+#include "em-utils.h"
+#include "mail-vfolder.h"
#include "shell/e-shell.h"
#include "capplet/settings/mail-capplet-shell.h"
@@ -59,6 +61,36 @@ G_DEFINE_TYPE (
em_account_prefs,
E_TYPE_ACCOUNT_MANAGER)
+static gboolean
+account_prefs_toggle_enable_special (EMAccountPrefs *prefs, EAccountTreeViewSelectedType type, gboolean enabled)
+{
+ const gchar *prop = NULL;
+ EShell *shell;
+ EShellSettings *shell_settings;
+
+ g_return_val_if_fail (prefs != NULL, FALSE);
+ g_return_val_if_fail (prefs->priv != NULL, FALSE);
+
+ if (type == E_ACCOUNT_TREE_VIEW_SELECTED_LOCAL)
+ prop = "mail-enable-local-folders";
+ else if (type == E_ACCOUNT_TREE_VIEW_SELECTED_VFOLDER)
+ prop = "mail-enable-search-folders";
+
+ if (!prop)
+ return FALSE;
+
+ shell = e_shell_backend_get_shell (E_SHELL_BACKEND (prefs->priv->backend));
+ shell_settings = e_shell_get_shell_settings (shell);
+
+ e_shell_settings_set_boolean (shell_settings, prop, enabled);
+
+ /* make sure "Search Folders" are loaded when enabled */
+ if (enabled && type == E_ACCOUNT_TREE_VIEW_SELECTED_VFOLDER)
+ vfolder_load_storage (prefs->priv->backend);
+
+ return TRUE;
+}
+
static void
account_prefs_enable_account_cb (EAccountTreeView *tree_view,
EMAccountPrefs *prefs)
@@ -67,6 +99,11 @@ account_prefs_enable_account_cb (EAccountTreeView *tree_view,
EMailSession *session;
account = e_account_tree_view_get_selected (tree_view);
+ if (!account) {
+ if (account_prefs_toggle_enable_special (prefs, e_account_tree_view_get_selected_type (tree_view), TRUE))
+ return;
+ }
+
g_return_if_fail (account != NULL);
session = e_mail_backend_get_session (prefs->priv->backend);
@@ -84,6 +121,11 @@ account_prefs_disable_account_cb (EAccountTreeView *tree_view,
gint response;
account = e_account_tree_view_get_selected (tree_view);
+ if (!account) {
+ if (account_prefs_toggle_enable_special (prefs, e_account_tree_view_get_selected_type (tree_view), FALSE))
+ return;
+ }
+
g_return_if_fail (account != NULL);
account_list = e_account_tree_view_get_account_list (tree_view);
@@ -380,14 +422,35 @@ em_account_prefs_init (EMAccountPrefs *prefs)
G_CALLBACK (account_prefs_disable_account_cb), prefs);
}
+static void
+account_tree_view_sort_order_changed_cb (EAccountTreeView *tree_view, EMailBackend *backend)
+{
+ GSList *account_uids;
+
+ g_return_if_fail (tree_view != NULL);
+ g_return_if_fail (backend != NULL);
+
+ account_uids = e_account_tree_view_get_sort_order (tree_view);
+ if (!account_uids)
+ return;
+
+ em_utils_save_accounts_sort_order (backend, account_uids);
+
+ g_slist_foreach (account_uids, (GFunc) g_free, NULL);
+ g_slist_free (account_uids);
+}
+
GtkWidget *
em_account_prefs_new (EPreferencesWindow *window)
{
EShell *shell;
EShellBackend *shell_backend;
EAccountList *account_list;
+ EAccountTreeView *tree_view;
EMailSession *session;
const gchar *data_dir;
+ GtkWidget *res;
+ GSList *account_uids;
account_list = e_get_account_list ();
g_return_val_if_fail (E_IS_ACCOUNT_LIST (account_list), NULL);
@@ -402,10 +465,40 @@ em_account_prefs_new (EPreferencesWindow *window)
/* Make sure the e-mail-local is initialized. */
e_mail_local_init (session, data_dir);
- return g_object_new (
+ res = g_object_new (
EM_TYPE_ACCOUNT_PREFS,
"account-list", account_list,
"backend", shell_backend, NULL);
+
+ tree_view = e_account_manager_get_tree_view (E_ACCOUNT_MANAGER (res));
+ e_account_tree_view_set_express_mode (tree_view, e_shell_get_express_mode (shell));
+
+ g_object_bind_property (
+ e_shell_get_shell_settings (shell), "mail-sort-accounts-alpha",
+ tree_view, "sort-alpha",
+ G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+
+ g_object_bind_property (
+ e_shell_get_shell_settings (shell), "mail-enable-local-folders",
+ tree_view, "enable-local-folders",
+ G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+
+ g_object_bind_property (
+ e_shell_get_shell_settings (shell), "mail-enable-search-folders",
+ tree_view, "enable-search-folders",
+ G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+
+ account_uids = em_utils_load_accounts_sort_order (E_MAIL_BACKEND (shell_backend));
+ if (account_uids) {
+ e_account_tree_view_set_sort_order (tree_view, account_uids);
+ g_slist_foreach (account_uids, (GFunc) g_free, NULL);
+ g_slist_free (account_uids);
+ }
+
+ g_signal_connect (tree_view, "sort-order-changed",
+ G_CALLBACK (account_tree_view_sort_order_changed_cb), shell_backend);
+
+ return res;
}
EMailBackend *