aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2011-05-31 17:10:38 +0800
committerMilan Crha <mcrha@redhat.com>2011-05-31 17:10:38 +0800
commit95ec5734c1c5fb0a513e716b6aad8ad5419c2ca2 (patch)
treec70d4e90180343985ef534ee0a42bd0a28048250
parent420ac55791b7b481b5b734cf0d5ca709bd829117 (diff)
downloadgsoc2013-evolution-95ec5734c1c5fb0a513e716b6aad8ad5419c2ca2.tar
gsoc2013-evolution-95ec5734c1c5fb0a513e716b6aad8ad5419c2ca2.tar.gz
gsoc2013-evolution-95ec5734c1c5fb0a513e716b6aad8ad5419c2ca2.tar.bz2
gsoc2013-evolution-95ec5734c1c5fb0a513e716b6aad8ad5419c2ca2.tar.lz
gsoc2013-evolution-95ec5734c1c5fb0a513e716b6aad8ad5419c2ca2.tar.xz
gsoc2013-evolution-95ec5734c1c5fb0a513e716b6aad8ad5419c2ca2.tar.zst
gsoc2013-evolution-95ec5734c1c5fb0a513e716b6aad8ad5419c2ca2.zip
Bug #649939 - Cann't create new folder
-rw-r--r--mail/em-folder-tree.c36
-rw-r--r--mail/em-folder-tree.h3
-rw-r--r--mail/em-folder-utils.c29
3 files changed, 62 insertions, 6 deletions
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index 1a045991ed..04e544e47b 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 17c68648a9..b35171468a 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 05fcb4b064..27ba1c17e8 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);