diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-05-03 07:07:06 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2011-05-03 07:07:06 +0800 |
commit | 52844f40f158be11749f5d8dcdf52454e776c9bd (patch) | |
tree | 63c20593c805bec00dfdcf9491882ab41700d03c | |
parent | 305c62f1e07d1987b93fa7f4fe22b1eb891ebbd4 (diff) | |
download | gsoc2013-evolution-52844f40f158be11749f5d8dcdf52454e776c9bd.tar gsoc2013-evolution-52844f40f158be11749f5d8dcdf52454e776c9bd.tar.gz gsoc2013-evolution-52844f40f158be11749f5d8dcdf52454e776c9bd.tar.bz2 gsoc2013-evolution-52844f40f158be11749f5d8dcdf52454e776c9bd.tar.lz gsoc2013-evolution-52844f40f158be11749f5d8dcdf52454e776c9bd.tar.xz gsoc2013-evolution-52844f40f158be11749f5d8dcdf52454e776c9bd.tar.zst gsoc2013-evolution-52844f40f158be11749f5d8dcdf52454e776c9bd.zip |
Add em_folder_tree_get_selected_account().
Comes in handy for a few EMailShellView actions.
-rw-r--r-- | mail/em-folder-tree.c | 26 | ||||
-rw-r--r-- | mail/em-folder-tree.h | 2 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view-actions.c | 19 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view.c | 6 |
4 files changed, 35 insertions, 18 deletions
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index da845fbac6..e0ce87b89c 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -3157,6 +3157,32 @@ done: return fi; } +EAccount * +em_folder_tree_get_selected_account (EMFolderTree *folder_tree) +{ + GtkTreeView *tree_view; + GtkTreeSelection *selection; + GtkTreeModel *model; + GtkTreeIter iter; + CamelStore *store = NULL; + const gchar *uid = NULL; + + g_return_val_if_fail (EM_IS_FOLDER_TREE (folder_tree), NULL); + + tree_view = GTK_TREE_VIEW (folder_tree); + selection = gtk_tree_view_get_selection (tree_view); + + if (gtk_tree_selection_get_selected (selection, &model, &iter)) + gtk_tree_model_get ( + model, &iter, + COL_POINTER_CAMEL_STORE, &store, -1); + + if (CAMEL_IS_STORE (store)) + uid = camel_service_get_uid (CAMEL_SERVICE (store)); + + return (uid != NULL) ? e_get_account_by_uid (uid) : NULL; +} + void em_folder_tree_set_skip_double_click (EMFolderTree *folder_tree, gboolean skip) { diff --git a/mail/em-folder-tree.h b/mail/em-folder-tree.h index ecf0ddd29c..c824e86ed2 100644 --- a/mail/em-folder-tree.h +++ b/mail/em-folder-tree.h @@ -123,6 +123,8 @@ CamelFolder * em_folder_tree_get_selected_folder CamelFolderInfo * em_folder_tree_get_selected_folder_info (EMFolderTree *folder_tree); +EAccount * em_folder_tree_get_selected_account + (EMFolderTree *folder_tree); gboolean em_folder_tree_create_folder (EMFolderTree *folder_tree, const gchar *full_name, const gchar *uri); diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c index aa48ed0788..a5e6e9d40e 100644 --- a/modules/mail/e-mail-shell-view-actions.c +++ b/modules/mail/e-mail-shell-view-actions.c @@ -86,7 +86,6 @@ action_mail_account_disable_cb (GtkAction *action, EMFolderTree *folder_tree; EAccountList *account_list; EAccount *account; - gchar *folder_uri; mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar; @@ -97,12 +96,10 @@ action_mail_account_disable_cb (GtkAction *action, session = e_mail_backend_get_session (backend); folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); - folder_uri = em_folder_tree_get_selected_uri (folder_tree); - g_return_if_fail (folder_uri != NULL); + account = em_folder_tree_get_selected_account (folder_tree); + g_return_if_fail (account != NULL); account_list = e_get_account_list (); - account = e_get_account_by_source_url (folder_uri); - g_return_if_fail (account != NULL); if (e_account_list_account_has_proxies (account_list, account)) e_account_list_remove_account_proxies (account_list, account); @@ -115,8 +112,6 @@ action_mail_account_disable_cb (GtkAction *action, e_account_list_remove (account_list, account); e_account_list_save (account_list); - - g_free (folder_uri); } static void @@ -1004,9 +999,8 @@ action_mail_tools_subscriptions_cb (GtkAction *action, EMailBackend *backend; EMailSession *session; EMFolderTree *folder_tree; - EAccount *account = NULL; + EAccount *account; GtkWidget *dialog; - gchar *uri; shell_view = E_SHELL_VIEW (mail_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); @@ -1014,16 +1008,11 @@ action_mail_tools_subscriptions_cb (GtkAction *action, mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar; folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); + account = em_folder_tree_get_selected_account (folder_tree); backend = E_MAIL_BACKEND (shell_backend); session = e_mail_backend_get_session (backend); - uri = em_folder_tree_get_selected_uri (folder_tree); - if (uri != NULL) { - account = e_get_account_by_source_url (uri); - g_free (uri); - } - dialog = em_subscription_editor_new ( GTK_WINDOW (shell_window), CAMEL_SESSION (session), account); diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c index 7655fba835..4af7de5a1b 100644 --- a/modules/mail/e-mail-shell-view.c +++ b/modules/mail/e-mail-shell-view.c @@ -844,7 +844,7 @@ mail_shell_view_update_actions (EShellView *shell_view) EMailBackend *backend; EMailSession *session; EMailView *mail_view; - EAccount *account = NULL; + EAccount *account; GtkAction *action; GList *list; const gchar *label; @@ -902,6 +902,8 @@ mail_shell_view_update_actions (EShellView *shell_view) (state & E_MAIL_SIDEBAR_STORE_SUPPORTS_SUBSCRIPTIONS); uri = em_folder_tree_get_selected_uri (folder_tree); + account = em_folder_tree_get_selected_account (folder_tree); + if (uri != NULL) { GtkTreeRowReference *reference; EMFolderTreeModel *model; @@ -919,8 +921,6 @@ mail_shell_view_update_actions (EShellView *shell_view) folder_tree_and_message_list_agree = (g_strcmp0 (uri, folder_uri) == 0); - account = e_get_account_by_source_url (uri); - /* FIXME This belongs in a GroupWise plugin. */ account_is_groupwise = (g_strrstr (uri, "groupwise://") != NULL) && |