aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2003-07-10 03:54:25 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2003-07-10 03:54:25 +0800
commita5a33cf4aaa8c2700924f6cc1a9ec5cee18ff95a (patch)
treed7bf122b28b5fbb62a6a0126128680ca3cf47869
parent632b2e339f5584f86040b5e65117dc204c3f8555 (diff)
downloadgsoc2013-evolution-a5a33cf4aaa8c2700924f6cc1a9ec5cee18ff95a.tar
gsoc2013-evolution-a5a33cf4aaa8c2700924f6cc1a9ec5cee18ff95a.tar.gz
gsoc2013-evolution-a5a33cf4aaa8c2700924f6cc1a9ec5cee18ff95a.tar.bz2
gsoc2013-evolution-a5a33cf4aaa8c2700924f6cc1a9ec5cee18ff95a.tar.lz
gsoc2013-evolution-a5a33cf4aaa8c2700924f6cc1a9ec5cee18ff95a.tar.xz
gsoc2013-evolution-a5a33cf4aaa8c2700924f6cc1a9ec5cee18ff95a.tar.zst
gsoc2013-evolution-a5a33cf4aaa8c2700924f6cc1a9ec5cee18ff95a.zip
(e_shell_command_rename_folder): Do
not overwrite an existing folder. Also, cleaned up the code a bit. [#45982] svn path=/trunk/; revision=21783
-rw-r--r--shell/ChangeLog6
-rw-r--r--shell/e-shell-folder-commands.c63
2 files changed, 36 insertions, 33 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 616127ba0a..4c1d84e01e 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,9 @@
+2003-07-09 Ettore Perazzoli <ettore@ximian.com>
+
+ * e-shell-folder-commands.c (e_shell_command_rename_folder): Do
+ not overwrite an existing folder. Also, cleaned up the code a
+ bit. [#45982]
+
2003-06-25 Chris Toshok <toshok@ximian.com>
* e-config-upgrade.c: add general_map and a reference to it in
diff --git a/shell/e-shell-folder-commands.c b/shell/e-shell-folder-commands.c
index 6317b8da96..02be16cd5f 100644
--- a/shell/e-shell-folder-commands.c
+++ b/shell/e-shell-folder-commands.c
@@ -517,13 +517,9 @@ e_shell_command_rename_folder (EShell *shell,
RenameCallbackData *callback_data;
const char *old_name;
char *prompt;
- char *new_name;
- char *old_base_path;
- char *new_path;
+ gboolean done;
- g_return_if_fail (shell != NULL);
g_return_if_fail (E_IS_SHELL (shell));
- g_return_if_fail (shell_view != NULL);
g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
storage_set = e_shell_get_storage_set (shell);
@@ -537,38 +533,39 @@ e_shell_command_rename_folder (EShell *shell,
old_name = e_folder_get_name (folder);
prompt = g_strdup_printf (_("Rename the \"%s\" folder to:"), old_name);
- while (1) {
+ done = FALSE;
+ while (! done) {
const char *reason;
-
- new_name = e_request_string (shell_view != NULL ? GTK_WINDOW (shell_view) : NULL,
- _("Rename Folder"), prompt, old_name);
-
- if (new_name == NULL)
- return;
-
- if (e_shell_folder_name_is_valid (new_name, &reason))
- break;
-
- e_notice (shell_view, GTK_MESSAGE_ERROR,
- _("The specified folder name is not valid: %s"), reason);
+ char *new_name;
+
+ new_name = e_request_string (GTK_WINDOW (shell_view), _("Rename Folder"), prompt, old_name);
+
+ if (new_name == NULL || strcmp (old_name, new_name) == 0) {
+ done = TRUE;
+ } else if (! e_shell_folder_name_is_valid (new_name, &reason)) {
+ e_notice (shell_view, GTK_MESSAGE_ERROR,
+ _("The specified folder name is not valid: %s"), reason);
+ } else {
+ char *old_base_path = g_path_get_dirname (folder_path);
+ char *new_path = g_build_filename (old_base_path, new_name, NULL);
+
+ if (e_storage_set_get_folder (storage_set, new_path) != NULL) {
+ e_notice (shell_view, GTK_MESSAGE_ERROR,
+ _("A folder named \"%s\" already exists. Please use a different name."),
+ new_name);
+ } else {
+ callback_data = rename_callback_data_new (shell_view, new_path);
+ e_storage_set_async_xfer_folder (storage_set, folder_path, new_path, TRUE,
+ rename_cb, callback_data);
+ done = TRUE;
+ }
+
+ g_free (old_base_path);
+ g_free (new_path);
+ }
}
g_free (prompt);
-
- if (strcmp (old_name, new_name) == 0) {
- g_free (new_name);
- return;
- }
-
- old_base_path = g_path_get_dirname (folder_path);
- new_path = g_build_filename (old_base_path, new_name, NULL);
-
- callback_data = rename_callback_data_new (shell_view, new_path);
- e_storage_set_async_xfer_folder (storage_set, folder_path, new_path, TRUE, rename_cb, callback_data);
-
- g_free (old_base_path);
- g_free (new_path);
- g_free (new_name);
}