aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-shell-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/e-shell-utils.c')
-rw-r--r--shell/e-shell-utils.c66
1 files changed, 61 insertions, 5 deletions
diff --git a/shell/e-shell-utils.c b/shell/e-shell-utils.c
index 746f985874..9065fc224c 100644
--- a/shell/e-shell-utils.c
+++ b/shell/e-shell-utils.c
@@ -27,16 +27,16 @@
#include <gnome.h>
+#include "e-shell-constants.h"
+
#include "e-shell-utils.h"
-char *
-e_shell_get_icon_path (const char *icon_name)
+static char *
+get_icon_path (const char *icon_name)
{
char *icon_path;
- g_return_val_if_fail (icon_name != NULL, NULL);
-
if (g_path_is_absolute (icon_name)) {
icon_path = g_strdup (icon_name);
} else {
@@ -47,5 +47,61 @@ e_shell_get_icon_path (const char *icon_name)
icon_name);
}
- return icon_path;
+ if (g_file_exists (icon_path)) {
+ return icon_path;
+ } else {
+ g_free (icon_path);
+ return NULL;
+ }
+}
+
+static char *
+get_mini_name (const char *icon_name)
+{
+ const char *dot_ptr;
+ const char *basename;
+ char *name_without_extension;
+ char *mini_name;
+
+ basename = g_basename (icon_name);
+ if (basename == NULL)
+ return NULL;
+
+ dot_ptr = strrchr (basename, '.');
+
+ if (dot_ptr == NULL) {
+ /* No extension. */
+ return g_strconcat (icon_name, E_SHELL_MINI_ICON_SUFFIX, NULL);
+ }
+
+ name_without_extension = g_strndup (icon_name, dot_ptr - icon_name);
+ mini_name = g_strconcat (name_without_extension, E_SHELL_MINI_ICON_SUFFIX,
+ dot_ptr, NULL);
+ g_free (name_without_extension);
+
+ return mini_name;
+}
+
+
+char *
+e_shell_get_icon_path (const char *icon_name,
+ gboolean try_mini)
+{
+ if (try_mini) {
+ char *path;
+ char *mini_name;
+
+ mini_name = get_mini_name (icon_name);
+ if (mini_name == NULL) {
+ path = NULL;
+ } else {
+ path = get_icon_path (mini_name);
+ g_free (mini_name);
+ }
+
+ if (path != NULL)
+ return path;
+ }
+
+ return get_icon_path (icon_name);
}