aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-folder-tree.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-05-25 04:14:59 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-05-25 04:14:59 +0800
commit7dbc147e266e0922e6d5c3042aeea508fc069d00 (patch)
treee70df076c51012981e83b2e56319f2fb3157c23e /mail/em-folder-tree.c
parent47c740b2ba957c1bbab7088cd77b3761f56857bc (diff)
downloadgsoc2013-evolution-7dbc147e266e0922e6d5c3042aeea508fc069d00.tar.gz
gsoc2013-evolution-7dbc147e266e0922e6d5c3042aeea508fc069d00.tar.zst
gsoc2013-evolution-7dbc147e266e0922e6d5c3042aeea508fc069d00.zip
Add em_folder_tree_get_selected().
Returns the CamelStore and folder name of the selected row.
Diffstat (limited to 'mail/em-folder-tree.c')
-rw-r--r--mail/em-folder-tree.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index 3bb5d509d5..9689c53dda 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -3149,6 +3149,42 @@ em_folder_tree_edit_selected (EMFolderTree *folder_tree)
gtk_tree_path_free (path);
}
+gboolean
+em_folder_tree_get_selected (EMFolderTree *folder_tree,
+ CamelStore **out_store,
+ gchar **out_folder_name)
+{
+ GtkTreeView *tree_view;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ CamelStore *store = NULL;
+ gchar *folder_name = NULL;
+
+ g_return_val_if_fail (EM_IS_FOLDER_TREE (folder_tree), FALSE);
+
+ 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 FALSE;
+
+ gtk_tree_model_get (
+ model, &iter,
+ COL_POINTER_CAMEL_STORE, &store,
+ COL_STRING_FULL_NAME, &folder_name, -1);
+
+ if (out_store != NULL)
+ *out_store = g_object_ref (store);
+
+ if (out_folder_name != NULL)
+ *out_folder_name = folder_name;
+ else
+ g_free (folder_name);
+
+ return TRUE;
+}
+
gchar *
em_folder_tree_get_selected_uri (EMFolderTree *folder_tree)
{