diff options
author | Milan Crha <mcrha@redhat.com> | 2011-09-26 17:45:59 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-09-26 18:56:08 +0800 |
commit | d230dd72bb6aff738974ccaa91bfad5d321e9c0c (patch) | |
tree | 1c4f343340ad4a613e0016e93301fce83d2ef130 /modules/mail/em-account-prefs.c | |
parent | 3262bdb1c49d65c5fa7d2fc3b931784bfcdb57da (diff) | |
download | gsoc2013-evolution-d230dd72bb6aff738974ccaa91bfad5d321e9c0c.tar gsoc2013-evolution-d230dd72bb6aff738974ccaa91bfad5d321e9c0c.tar.gz gsoc2013-evolution-d230dd72bb6aff738974ccaa91bfad5d321e9c0c.tar.bz2 gsoc2013-evolution-d230dd72bb6aff738974ccaa91bfad5d321e9c0c.tar.lz gsoc2013-evolution-d230dd72bb6aff738974ccaa91bfad5d321e9c0c.tar.xz gsoc2013-evolution-d230dd72bb6aff738974ccaa91bfad5d321e9c0c.tar.zst gsoc2013-evolution-d230dd72bb6aff738974ccaa91bfad5d321e9c0c.zip |
Bug #351025 - Make the order of the mail accounts configurable
Diffstat (limited to 'modules/mail/em-account-prefs.c')
-rw-r--r-- | modules/mail/em-account-prefs.c | 95 |
1 files changed, 94 insertions, 1 deletions
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 * |