aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/ChangeLog15
-rw-r--r--shell/e-component-registry.c4
-rw-r--r--shell/e-shell-folder-commands.c22
-rw-r--r--shell/e-shell-folder-creation-dialog.c42
-rw-r--r--shell/e-shell-utils.c37
-rw-r--r--shell/e-shell-utils.h7
6 files changed, 81 insertions, 46 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 1ce5763004..64c6f9beeb 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,18 @@
+2001-10-26 Ettore Perazzoli <ettore@ximian.com>
+
+ * e-shell-folder-commands.c (e_shell_command_rename_folder): Don't
+ allow invalid folder names. [#12027]
+
+ * e-shell-folder-creation-dialog.c (entry_name_is_valid): Removed.
+ (dialog_clicked_cb): Use `e_shell_folder_name_is_valid()' instead.
+
+ * e-shell-utils.c (e_shell_folder_name_is_valid): New. Sorry I18N
+ people, it breaks the string freeze slighty.
+
+ * e-component-registry.c (component_free): Add a cast.
+ (e_component_registry_restart_component): Argh, use the
+ corba_objref properly in calling `wait_for_corba_object_to_die()'.
+
2001-10-25 Ettore Perazzoli <ettore@ximian.com>
* e-shell-view-menu.c (update_offline_menu_item): Add accelerators
diff --git a/shell/e-component-registry.c b/shell/e-component-registry.c
index 7448e1b4a8..a1f86b71e4 100644
--- a/shell/e-component-registry.c
+++ b/shell/e-component-registry.c
@@ -120,7 +120,7 @@ component_free (Component *component)
bonobo_object_unref (BONOBO_OBJECT (component->client));
- wait_for_corba_object_to_die (corba_shell_component, component->id);
+ wait_for_corba_object_to_die ((Bonobo_Unknown) corba_shell_component, component->id);
CORBA_Object_release (corba_shell_component, &ev);
e_free_string_list (component->folder_type_names);
@@ -464,7 +464,7 @@ e_component_registry_restart_component (EComponentRegistry *component_registry,
component_free (component);
- wait_for_corba_object_to_die (component, id);
+ wait_for_corba_object_to_die (corba_objref, id);
CORBA_exception_free (&ev);
diff --git a/shell/e-shell-folder-commands.c b/shell/e-shell-folder-commands.c
index 38b934057e..4aa6e43055 100644
--- a/shell/e-shell-folder-commands.c
+++ b/shell/e-shell-folder-commands.c
@@ -44,6 +44,7 @@
#include "e-shell-constants.h"
#include "e-shell-folder-creation-dialog.h"
#include "e-shell-folder-selection-dialog.h"
+#include "e-shell-utils.h"
/* Utility functions. */
@@ -535,13 +536,24 @@ e_shell_command_rename_folder (EShell *shell,
prompt = g_strdup_printf (_("Rename the \"%s\" folder to:"), old_name);
- new_name = e_request_string (shell_view != NULL ? GTK_WINDOW (shell_view) : NULL,
- _("Rename folder"), prompt, old_name);
+ while (1) {
+ const char *reason;
- g_free (prompt);
+ new_name = e_request_string (shell_view != NULL ? GTK_WINDOW (shell_view) : NULL,
+ _("Rename folder"), prompt, old_name);
- if (new_name == NULL)
- return;
+ if (new_name == NULL)
+ return;
+
+ if (e_shell_folder_name_is_valid (new_name, &reason))
+ break;
+
+ e_notice (shell_view != NULL ? GTK_WINDOW (shell_view) : NULL,
+ GNOME_MESSAGE_BOX_ERROR,
+ _("The specified folder name is not valid: %s"), reason);
+ }
+
+ g_free (prompt);
if (strcmp (old_name, new_name) == 0) {
g_free (new_name);
diff --git a/shell/e-shell-folder-creation-dialog.c b/shell/e-shell-folder-creation-dialog.c
index d46002a410..04487d5560 100644
--- a/shell/e-shell-folder-creation-dialog.c
+++ b/shell/e-shell-folder-creation-dialog.c
@@ -39,6 +39,7 @@
#include "e-storage-set.h"
#include "e-storage-set-view.h"
+#include "e-shell-utils.h"
#include "e-shell-folder-creation-dialog.h"
@@ -112,40 +113,6 @@ async_create_cb (EStorageSet *storage_set,
e_storage_result_to_string (result));
}
-
-/* Sanity check for the user-specified folder name. */
-/* FIXME in the future we would like not to have the `G_DIR_SEPARATOR' limitation. */
-static gboolean
-entry_name_is_valid (GtkEntry *entry, char **reason)
-{
- const char *name;
-
- name = gtk_entry_get_text (entry);
-
- if (name == NULL || *name == '\0') {
- *reason = _("No folder name specified.");
- return FALSE;
- }
-
- /* GtkEntry is broken - if you hit KP_ENTER you get a \r inserted... */
- if (strchr (name, '\r')) {
- *reason = _("Folder name cannot contain the Return character.");
- return FALSE;
- }
-
- if (strchr (name, G_DIR_SEPARATOR) != NULL) {
- *reason = _("Folder cannot contain the directory separator.");
- return FALSE;
- }
-
- if (strcmp (name, ".") == 0 || strcmp (name, "..") == 0) {
- *reason = _("'.' and '..' are reserved folder names.");
- return FALSE;
- }
-
- return TRUE;
-}
-
/* Dialog signal callbacks. */
@@ -159,8 +126,8 @@ dialog_clicked_cb (GnomeDialog *dialog,
GtkWidget *folder_type_menu_item;
const char *folder_type;
const char *parent_path;
+ const char *reason;
char *folder_name;
- char *reason;
char *path;
dialog_data = (DialogData *) data;
@@ -175,7 +142,9 @@ dialog_clicked_cb (GnomeDialog *dialog,
return;
}
- if (!entry_name_is_valid (GTK_ENTRY (dialog_data->folder_name_entry), &reason)) {
+ folder_name = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog_data->folder_name_entry));
+
+ if (! e_shell_folder_name_is_valid (folder_name, &reason)) {
e_notice (GTK_WINDOW (dialog), GNOME_MESSAGE_BOX_ERROR,
_("The specified folder name is not valid: %s"), reason);
return;
@@ -193,7 +162,6 @@ dialog_clicked_cb (GnomeDialog *dialog,
return;
}
- folder_name = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog_data->folder_name_entry));
path = g_concat_dir_and_file (parent_path, folder_name);
g_free (folder_name);
diff --git a/shell/e-shell-utils.c b/shell/e-shell-utils.c
index f5f63c5a91..e916cbe1dc 100644
--- a/shell/e-shell-utils.c
+++ b/shell/e-shell-utils.c
@@ -30,6 +30,7 @@
#include <glib.h>
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-util.h>
+#include <libgnome/gnome-i18n.h>
#include "e-shell-constants.h"
#include "e-shell-utils.h"
@@ -103,3 +104,39 @@ e_shell_get_icon_path (const char *icon_name,
return get_icon_path (icon_name);
}
+
+
+gboolean
+e_shell_folder_name_is_valid (const char *name,
+ const char **reason_return)
+{
+ if (name == NULL || *name == '\0') {
+ if (reason_return != NULL)
+ *reason_return = _("No folder name specified.");
+ return FALSE;
+ }
+
+ /* GtkEntry is broken - if you hit KP_ENTER you get a \r inserted... */
+ if (strchr (name, '\r')) {
+ if (reason_return != NULL)
+ *reason_return = _("Folder name cannot contain the Return character.");
+ return FALSE;
+ }
+
+ if (strchr (name, G_DIR_SEPARATOR) != NULL) {
+ if (reason_return != NULL)
+ *reason_return = _("Folder name cannot contain slashes.");
+ return FALSE;
+ }
+
+ if (strcmp (name, ".") == 0 || strcmp (name, "..") == 0) {
+ if (reason_return != NULL)
+ *reason_return = _("'.' and '..' are reserved folder names.");
+ return FALSE;
+ }
+
+ *reason_return = NULL;
+
+ return TRUE;
+}
+
diff --git a/shell/e-shell-utils.h b/shell/e-shell-utils.h
index 3d86ac0081..0dc86919a9 100644
--- a/shell/e-shell-utils.h
+++ b/shell/e-shell-utils.h
@@ -26,7 +26,10 @@
#include <glib.h>
-char *e_shell_get_icon_path (const char *icon_name,
- gboolean try_mini);
+char *e_shell_get_icon_path (const char *icon_name,
+ gboolean try_mini);
+
+gboolean e_shell_folder_name_is_valid (const char *name,
+ const char **reason_return);
#endif