aboutsummaryrefslogtreecommitdiffstats
path: root/modules/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-05-25 05:36:21 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2011-06-30 00:42:20 +0800
commit6e6da8a4080c4606529603ad9a90489509bea105 (patch)
treeba6161fc5b5abc0c514004ea5fafa6424a46f224 /modules/mail
parent851a872865769d1d53e495fd1d0b82f0452594c4 (diff)
downloadgsoc2013-evolution-6e6da8a4080c4606529603ad9a90489509bea105.tar
gsoc2013-evolution-6e6da8a4080c4606529603ad9a90489509bea105.tar.gz
gsoc2013-evolution-6e6da8a4080c4606529603ad9a90489509bea105.tar.bz2
gsoc2013-evolution-6e6da8a4080c4606529603ad9a90489509bea105.tar.lz
gsoc2013-evolution-6e6da8a4080c4606529603ad9a90489509bea105.tar.xz
gsoc2013-evolution-6e6da8a4080c4606529603ad9a90489509bea105.tar.zst
gsoc2013-evolution-6e6da8a4080c4606529603ad9a90489509bea105.zip
Use em_folder_tree_get_selected() in places to simplify code.
There were a few places where we were accessing the folder tree model directly to get the selected store + folder name, or were asking for the selected URI only to parse back into its store + folder name components.
Diffstat (limited to 'modules/mail')
-rw-r--r--modules/mail/e-mail-shell-backend.c31
-rw-r--r--modules/mail/e-mail-shell-view-actions.c20
-rw-r--r--modules/mail/e-mail-shell-view.c21
3 files changed, 22 insertions, 50 deletions
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index f7e9b81ae1..b95ce9db54 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -145,14 +145,14 @@ action_mail_message_new_cb (GtkAction *action,
EShellWindow *shell_window)
{
EMailShellSidebar *mail_shell_sidebar;
- EShellBackend *shell_backend;
EShellSidebar *shell_sidebar;
EShellView *shell_view;
EShell *shell;
EMFolderTree *folder_tree;
CamelFolder *folder = NULL;
+ CamelStore *store;
const gchar *view_name;
- gchar *folder_uri = NULL;
+ gchar *folder_name;
shell = e_shell_window_get_shell (shell_window);
@@ -165,36 +165,19 @@ action_mail_message_new_cb (GtkAction *action,
goto exit;
shell_view = e_shell_window_get_shell_view (shell_window, view_name);
- shell_backend = e_shell_view_get_shell_backend (shell_view);
shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
mail_shell_sidebar = E_MAIL_SHELL_SIDEBAR (shell_sidebar);
folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
- folder_uri = em_folder_tree_get_selected_uri (folder_tree);
-
- if (folder_uri != NULL) {
- EMailBackend *backend;
- EMailSession *session;
- CamelStore *store;
- gchar *folder_name;
- gboolean success;
- backend = E_MAIL_BACKEND (shell_backend);
- session = e_mail_backend_get_session (backend);
-
- success = e_mail_folder_uri_parse (
- CAMEL_SESSION (session), folder_uri,
- &store, &folder_name, NULL);
+ if (em_folder_tree_get_selected (folder_tree, &store, &folder_name)) {
/* FIXME This blocks and is not cancellable. */
- if (success) {
- folder = camel_store_get_folder_sync (
- store, folder_name, 0, NULL, NULL);
- g_object_unref (store);
- g_free (folder_name);
- }
+ folder = camel_store_get_folder_sync (
+ store, folder_name, 0, NULL, NULL);
- g_free (folder_uri);
+ g_object_unref (store);
+ g_free (folder_name);
}
exit:
diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c
index 7c55908b31..c5f155de15 100644
--- a/modules/mail/e-mail-shell-view-actions.c
+++ b/modules/mail/e-mail-shell-view-actions.c
@@ -451,24 +451,20 @@ action_mail_folder_properties_cb (GtkAction *action,
EMailShellSidebar *mail_shell_sidebar;
EMFolderTree *folder_tree;
EShellView *shell_view;
- GtkTreeSelection *selection;
- GtkTreeView *tree_view;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gchar *uri;
+ CamelStore *store;
+ gchar *folder_name;
shell_view = E_SHELL_VIEW (mail_shell_view);
mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
- tree_view = GTK_TREE_VIEW (folder_tree);
- selection = gtk_tree_view_get_selection (tree_view);
- if (!gtk_tree_selection_get_selected (selection, &model, &iter))
- return;
+ if (!em_folder_tree_get_selected (folder_tree, &store, &folder_name))
+ g_return_if_reached ();
- gtk_tree_model_get (model, &iter, COL_STRING_URI, &uri, -1);
- em_folder_properties_show (shell_view, uri);
- g_free (uri);
+ em_folder_properties_show (shell_view, store, folder_name);
+
+ g_object_unref (store);
+ g_free (folder_name);
}
static void
diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c
index f0a89e3a37..04c9d4d034 100644
--- a/modules/mail/e-mail-shell-view.c
+++ b/modules/mail/e-mail-shell-view.c
@@ -660,27 +660,18 @@ current_account:
/* Create a new search folder. */
- if (folder) {
+ if (folder != NULL) {
store = camel_folder_get_parent_store (folder);
+ if (store != NULL)
+ g_object_ref (store);
} else {
- GtkTreeView *tree_view;
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeIter iter;
-
store = 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);
+ em_folder_tree_get_selected (folder_tree, &store, NULL);
}
list = NULL; /* list of CamelFolders */
- if (store) {
+ if (store != NULL) {
CamelFolderInfo *root, *fi;
/* FIXME This call blocks the main loop. */
@@ -722,6 +713,8 @@ current_account:
if (root)
camel_store_free_folder_info_full (store, root);
+
+ g_object_unref (store);
}
list = g_list_reverse (list);