[evolution/webkit] Add em_folder_tree_get_selected().



commit d4bc760b6da8cbb38a29b45bfdee9b6b76dde7d9
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue May 24 16:14:59 2011 -0400

    Add em_folder_tree_get_selected().
    
    Returns the CamelStore and folder name of the selected row.

 mail/em-folder-tree.c |   36 ++++++++++++++++++++++++++++++++++++
 mail/em-folder-tree.h |    3 +++
 2 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index 3bb5d50..9689c53 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)
 {
diff --git a/mail/em-folder-tree.h b/mail/em-folder-tree.h
index 0e6eba4..3a28d5c 100644
--- a/mail/em-folder-tree.h
+++ b/mail/em-folder-tree.h
@@ -123,6 +123,9 @@ void		em_folder_tree_select_next_path	(EMFolderTree *folder_tree,
 void		em_folder_tree_select_prev_path	(EMFolderTree *folder_tree,
 						 gboolean skip_read_folders);
 void		em_folder_tree_edit_selected	(EMFolderTree *folder_tree);
+gboolean	em_folder_tree_get_selected	(EMFolderTree *folder_tree,
+						 CamelStore **out_store,
+						 gchar **out_folder_name);
 gchar *		em_folder_tree_get_selected_uri	(EMFolderTree *folder_tree);
 gchar *		em_folder_tree_get_selected_path
 						(EMFolderTree *folder_tree);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]