1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
4 * Copyright (C) 2000 Ximian, Inc.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of version 2 of the GNU General Public
8 * License as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: Ettore Perazzoli
31 #include <libgnome/gnome-util.h>
32 #include <libgnome/gnome-i18n.h>
34 #include "e-shell-constants.h"
35 #include "e-shell-utils.h"
39 get_icon_path (const char *icon_name
)
43 if (g_path_is_absolute (icon_name
))
44 icon_path
= g_strdup (icon_name
);
46 icon_path
= g_build_filename (EVOLUTION_IMAGES
, icon_name
, NULL
);
48 if (g_file_test (icon_path
, G_FILE_TEST_EXISTS
)) {
57 get_mini_name (const char *icon_name
)
61 char *name_without_extension
;
64 basename
= g_path_get_basename (icon_name
);
68 dot_ptr
= strrchr (basename
, '.');
70 if (dot_ptr
== NULL
) {
73 return g_strconcat (icon_name
, E_SHELL_MINI_ICON_SUFFIX
, NULL
);
76 name_without_extension
= g_strndup (icon_name
, dot_ptr
- basename
);
77 mini_name
= g_strconcat (name_without_extension
, E_SHELL_MINI_ICON_SUFFIX
,
79 g_free (name_without_extension
);
87 e_shell_get_icon_path (const char *icon_name
,
94 mini_name
= get_mini_name (icon_name
);
95 if (mini_name
== NULL
) {
98 path
= get_icon_path (mini_name
);
106 return get_icon_path (icon_name
);
111 e_shell_folder_name_is_valid (const char *name
,
112 const char **reason_return
)
114 if (name
== NULL
|| *name
== '\0') {
115 if (reason_return
!= NULL
)
116 *reason_return
= _("No folder name specified.");
120 /* GtkEntry is broken - if you hit KP_ENTER you get a \r inserted... */
121 if (strchr (name
, '\r')) {
122 if (reason_return
!= NULL
)
123 *reason_return
= _("Folder name cannot contain the Return character.");
127 if (strchr (name
, E_PATH_SEPARATOR
) != NULL
) {
128 if (reason_return
!= NULL
)
129 *reason_return
= _("Folder name cannot contain the character \"/\".");
133 if (strchr (name
, '#') != NULL
) {
134 if (reason_return
!= NULL
)
135 *reason_return
= _("Folder name cannot contain the character \"#\".");
139 if (strcmp (name
, ".") == 0 || strcmp (name
, "..") == 0) {
140 if (reason_return
!= NULL
)
141 *reason_return
= _("'.' and '..' are reserved folder names.");
145 *reason_return
= NULL
;