diff options
Diffstat (limited to 'shell/e-shell-utils.c')
-rw-r--r-- | shell/e-shell-utils.c | 37 |
1 files changed, 37 insertions, 0 deletions
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; +} + |