aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-folder-tree.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-04-28 14:39:25 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-04-28 14:39:25 +0800
commite23cf1ca36bcf886bcac15545166eff0e930a4bd (patch)
tree22462408dc2fe4da0306bb472cdd6239d739b650 /mail/em-folder-tree.c
parent9e7d28c8bc1c14cbb627f0375a60c312c5569536 (diff)
downloadgsoc2013-evolution-e23cf1ca36bcf886bcac15545166eff0e930a4bd.tar.gz
gsoc2013-evolution-e23cf1ca36bcf886bcac15545166eff0e930a4bd.tar.zst
gsoc2013-evolution-e23cf1ca36bcf886bcac15545166eff0e930a4bd.zip
** Changed error messages to use EError.
2004-04-28 Not Zed <NotZed@Ximian.com> ** Changed error messages to use EError. svn path=/trunk/; revision=25653
Diffstat (limited to 'mail/em-folder-tree.c')
-rw-r--r--mail/em-folder-tree.c108
1 files changed, 39 insertions, 69 deletions
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index 7365f6f920..56d457a725 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -49,8 +49,9 @@
#include "e-util/e-mktemp.h"
#include "e-util/e-request.h"
-#include "e-util/e-dialog-utils.h"
-#include <e-util/e-icon-factory.h>
+#include "e-util/e-icon-factory.h"
+
+#include "widgets/misc/e-error.h"
#include "filter/vfolder-rule.h"
@@ -1972,11 +1973,9 @@ emft_popup_copy_folder_selected (const char *uri, void *data)
{
struct _copy_folder_data *cfd = data;
struct _EMFolderTreePrivate *priv;
- CamelStore *fromstore, *tostore;
+ CamelStore *fromstore = NULL, *tostore = NULL;
char *tobase = NULL, *frombase;
- GtkWindow *parent;
CamelException ex;
- GtkWidget *dialog;
CamelURL *url;
if (uri == NULL) {
@@ -1989,20 +1988,24 @@ emft_popup_copy_folder_selected (const char *uri, void *data)
d(printf ("%sing folder '%s' to '%s'\n", cfd->delete ? "move" : "copy", priv->selected_path, uri));
camel_exception_init (&ex);
- if (!(fromstore = camel_session_get_store (session, priv->selected_uri, &ex)))
- goto exception;
-
frombase = priv->selected_path + 1;
- if (fromstore == mail_component_peek_local_store (NULL) && is_special_local_folder (frombase)) {
- if (cfd->delete)
- camel_exception_setv (&ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot move folder `%s': illegal operation"), frombase);
- camel_object_unref (fromstore);
- goto exception;
+
+ if (!(fromstore = camel_session_get_store (session, priv->selected_uri, &ex))) {
+ e_error_run((GtkWindow *)gtk_widget_get_ancestor ((GtkWidget *) cfd->emft, GTK_TYPE_WINDOW),
+ cfd->delete?"mail:no-move-folder-notexist":"mail:no-copy-folder-notexist", frombase, uri, ex.desc, NULL);
+ goto fail;
+ }
+
+ if (cfd->delete && fromstore == mail_component_peek_local_store (NULL) && is_special_local_folder (frombase)) {
+ e_error_run((GtkWindow *)gtk_widget_get_ancestor ((GtkWidget *) cfd->emft, GTK_TYPE_WINDOW),
+ "mail:no-rename-special-folder", frombase, NULL);
+ goto fail;
}
if (!(tostore = camel_session_get_store (session, uri, &ex))) {
- camel_object_unref (fromstore);
- goto exception;
+ e_error_run((GtkWindow *)gtk_widget_get_ancestor ((GtkWidget *) cfd->emft, GTK_TYPE_WINDOW),
+ cfd->delete?"mail:no-move-folder-to-notexist":"mail:no-move-folder-to-notexist", frombase, uri, ex.desc, NULL);
+ goto fail;
}
url = camel_url_new (uri, NULL);
@@ -2016,18 +2019,12 @@ emft_popup_copy_folder_selected (const char *uri, void *data)
emft_copy_folders (tostore, tobase, fromstore, frombase, cfd->delete);
camel_url_free (url);
- g_free (cfd);
-
- return;
-
- exception:
-
- parent = (GtkWindow *) gtk_widget_get_ancestor ((GtkWidget *) cfd->emft, GTK_TYPE_WINDOW);
- dialog = gtk_message_dialog_new (parent, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("%s"), ex.desc);
- g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
+fail:
+ if (fromstore)
+ camel_object_unref(fromstore);
+ if (tostore)
+ camel_object_unref(tostore);
camel_exception_clear (&ex);
- gtk_widget_show (dialog);
g_free (cfd);
}
@@ -2174,40 +2171,31 @@ em_folder_tree_create_folder (EMFolderTree *emft, const char *path, const char *
struct _EMFolderTreePrivate *priv = emft->priv;
struct _EMFolderTreeModelStoreInfo *si;
gboolean created = FALSE;
- GtkWindow *window;
- GtkWidget *dialog;
CamelStore *store;
CamelException ex;
d(printf ("Creating folder: %s (%s)\n", path, uri));
camel_exception_init (&ex);
- if (!(store = (CamelStore *) camel_session_get_service (session, uri, CAMEL_PROVIDER_STORE, &ex)))
- goto exception;
+ if (!(store = (CamelStore *) camel_session_get_service (session, uri, CAMEL_PROVIDER_STORE, &ex))) {
+ e_error_run((GtkWindow *)gtk_widget_get_ancestor((GtkWidget *)emft, GTK_TYPE_WINDOW),
+ "mail:no-create-folder-nostore", path, ex.desc, NULL);
+ goto fail;
+ }
if (!(si = g_hash_table_lookup (priv->model->store_hash, store))) {
abort();
camel_object_unref (store);
- goto exception;
+ goto fail;
}
camel_object_unref (store);
mail_msg_wait (emft_create_folder (si->store, path, created_cb, &created));
+fail:
+ camel_exception_clear(&ex);
return created;
-
- exception:
-
- window = (GtkWindow *) gtk_widget_get_ancestor ((GtkWidget *) emft, GTK_TYPE_WINDOW);
- dialog = gtk_message_dialog_new (window, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("%s"), ex.desc);
- g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
- camel_exception_clear (&ex);
-
- gtk_widget_show (dialog);
-
- return FALSE;
}
static void
@@ -2394,7 +2382,7 @@ emft_popup_delete_response (GtkWidget *dialog, guint response, EMFolderTree *emf
camel_exception_init (&ex);
emft_popup_delete_folders (store, path, &ex);
if (camel_exception_is_set (&ex)) {
- e_notice (NULL, GTK_MESSAGE_ERROR, _("Could not delete folder: %s"), ex.desc);
+ e_error_run(NULL, "mail:no-delete-folder", path, ex.desc, NULL);
camel_exception_clear (&ex);
}
}
@@ -2409,7 +2397,7 @@ emft_popup_delete_folder (GtkWidget *item, EMFolderTree *emft)
GtkTreeIter iter;
GtkWidget *dialog;
const char *full_name;
- char *title, *path;
+ char *path;
selection = gtk_tree_view_get_selection (priv->treeview);
if (!emft_selection_get_selected (selection, &model, &iter))
@@ -2421,26 +2409,11 @@ emft_popup_delete_folder (GtkWidget *item, EMFolderTree *emft)
full_name = path[0] == '/' ? path + 1 : path;
if (store == local && is_special_local_folder (full_name)) {
- e_notice (NULL, GTK_MESSAGE_ERROR, _("Cannot delete local %s folder."), full_name);
+ e_error_run(NULL, "mail:no-delete-spethal-folder", full_name, NULL);
return;
}
-
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
- GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
- _("Really delete folder \"%s\" and all of its subfolders?"),
- full_name);
-
- gtk_dialog_add_button ((GtkDialog *) dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
- gtk_dialog_add_button ((GtkDialog *) dialog, GTK_STOCK_DELETE, GTK_RESPONSE_OK);
-
- gtk_dialog_set_default_response ((GtkDialog *) dialog, GTK_RESPONSE_OK);
- gtk_container_set_border_width ((GtkContainer *) dialog, 6);
- gtk_box_set_spacing ((GtkBox *) ((GtkDialog *) dialog)->vbox, 6);
-
- title = g_strdup_printf (_("Delete \"%s\""), full_name);
- gtk_window_set_title ((GtkWindow *) dialog, title);
- g_free (title);
-
+
+ dialog = e_error_new(NULL, "mail:ask-delete-folder", full_name, NULL);
g_signal_connect (dialog, "response", G_CALLBACK (emft_popup_delete_response), emft);
gtk_widget_show (dialog);
}
@@ -2473,7 +2446,7 @@ emft_popup_rename_folder (GtkWidget *item, EMFolderTree *emft)
/* don't allow user to rename one of the special local folders */
if (store == local && is_special_local_folder (full_name)) {
- e_notice (NULL, GTK_MESSAGE_ERROR, _("Cannot rename local %s folder."), full_name);
+ e_error_run(NULL, "mail:no-rename-spethal-folder", full_name, NULL);
return;
}
@@ -2506,10 +2479,7 @@ emft_popup_rename_folder (GtkWidget *item, EMFolderTree *emft)
camel_exception_init (&ex);
if ((fi = camel_store_get_folder_info (store, path, CAMEL_STORE_FOLDER_INFO_FAST, &ex)) != NULL) {
camel_store_free_folder_info (store, fi);
-
- e_notice (NULL, GTK_MESSAGE_ERROR,
- _("A folder named \"%s\" already exists. Please use a different name."),
- new_name);
+ e_error_run(NULL, "mail:no-rename-folder-exists", name, new_name, NULL);
} else {
const char *oldpath, *newpath;
@@ -2521,7 +2491,7 @@ emft_popup_rename_folder (GtkWidget *item, EMFolderTree *emft)
camel_exception_clear (&ex);
camel_store_rename_folder (store, oldpath, newpath, &ex);
if (camel_exception_is_set (&ex)) {
- e_notice (NULL, GTK_MESSAGE_ERROR, _("Could not rename folder: %s"), ex.desc);
+ e_error_run(NULL, "mail:no-rename-folder", oldpath, newpath, ex.desc, NULL);
camel_exception_clear (&ex);
}