[evolution] Bug #649939 - Cann't create new folder
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug #649939 - Cann't create new folder
- Date: Tue, 31 May 2011 09:11:31 +0000 (UTC)
commit 95ec5734c1c5fb0a513e716b6aad8ad5419c2ca2
Author: Milan Crha <mcrha redhat com>
Date: Tue May 31 11:10:38 2011 +0200
Bug #649939 - Cann't create new folder
mail/em-folder-tree.c | 36 ++++++++++++++++++++++++++++++++++++
mail/em-folder-tree.h | 3 +++
mail/em-folder-utils.c | 29 +++++++++++++++++++++++------
3 files changed, 62 insertions(+), 6 deletions(-)
---
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index 1a04599..04e544e 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -3193,6 +3193,42 @@ em_folder_tree_get_selected (EMFolderTree *folder_tree,
return TRUE;
}
+gboolean
+em_folder_tree_store_root_selected (EMFolderTree *folder_tree, CamelStore **out_store)
+{
+ GtkTreeView *tree_view;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ CamelStore *store = NULL;
+ gboolean is_store = FALSE;
+
+ g_return_val_if_fail (folder_tree != NULL, FALSE);
+ 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_BOOL_IS_STORE, &is_store, -1);
+
+ /* We should always get a valid store. */
+ g_return_val_if_fail (CAMEL_IS_STORE (store), FALSE);
+
+ if (!is_store)
+ return FALSE;
+
+ if (out_store != NULL)
+ *out_store = g_object_ref (store);
+
+ 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 17c6864..b351714 100644
--- a/mail/em-folder-tree.h
+++ b/mail/em-folder-tree.h
@@ -126,6 +126,9 @@ 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);
+gboolean em_folder_tree_store_root_selected
+ (EMFolderTree *folder_tree,
+ CamelStore **out_store);
gchar * em_folder_tree_get_selected_uri (EMFolderTree *folder_tree);
CamelFolder * em_folder_tree_get_selected_folder
(EMFolderTree *folder_tree);
diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c
index 05fcb4b..27ba1c1 100644
--- a/mail/em-folder-utils.c
+++ b/mail/em-folder-utils.c
@@ -535,7 +535,6 @@ em_folder_utils_create_folder (GtkWindow *parent,
EMFolderSelector *selector;
EMFolderTree *folder_tree;
CamelStore *store = NULL;
- const gchar *folder_uri;
gchar *folder_name = NULL;
GtkWidget *dialog;
GError *error = NULL;
@@ -559,11 +558,28 @@ em_folder_utils_create_folder (GtkWindow *parent,
if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK)
goto exit;
- folder_uri = em_folder_selector_get_selected_uri (selector);
+ if (em_folder_tree_store_root_selected (folder_tree, &store)) {
+ const gchar *folder_uri;
- e_mail_folder_uri_parse (
- CAMEL_SESSION (session), folder_uri,
- &store, &folder_name, &error);
+ folder_uri = em_folder_selector_get_selected_uri (selector);
+
+ if (!folder_uri || !strrchr (folder_uri, '/'))
+ g_set_error (
+ &error, CAMEL_FOLDER_ERROR,
+ CAMEL_FOLDER_ERROR_INVALID,
+ _("Invalid folder URI '%s'"),
+ folder_uri ? folder_uri : "null");
+ else
+ folder_name = g_strdup (strrchr (folder_uri, '/'));
+ } else {
+ const gchar *folder_uri;
+
+ folder_uri = em_folder_selector_get_selected_uri (selector);
+
+ e_mail_folder_uri_parse (
+ CAMEL_SESSION (session), folder_uri,
+ &store, &folder_name, &error);
+ }
/* XXX This is unlikely to fail since the URI comes straight from
* EMFolderSelector, but leave a breadcrumb if it does fail. */
@@ -586,7 +602,7 @@ em_folder_utils_create_folder (GtkWindow *parent,
AsyncContext *context;
context = g_slice_new0 (AsyncContext);
- context->folder_uri = g_strdup (folder_uri);
+ context->folder_uri = e_mail_folder_uri_build (store, folder_name);
if (EM_IS_FOLDER_TREE (emft))
context->folder_tree = g_object_ref (emft);
@@ -599,6 +615,7 @@ em_folder_utils_create_folder (GtkWindow *parent,
}
g_free (folder_name);
+ g_object_unref (store);
exit:
gtk_widget_destroy (dialog);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]