From acd1ed57687d4f0d079fa955c17b6e6ac5c8a164 Mon Sep 17 00:00:00 2001 From: o9000 Date: Mon, 20 Mar 2017 18:06:49 +0100 Subject: [PATCH] tint2conf: Do not search for icons in all icon themes (issue #563) --- src/launcher/icon-theme-common.c | 4 +++- src/launcher/icon-theme-common.h | 2 +- src/launcher/launcher.c | 4 ++-- src/tint2conf/properties.c | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/launcher/icon-theme-common.c b/src/launcher/icon-theme-common.c index 082f924..33703e1 100644 --- a/src/launcher/icon-theme-common.c +++ b/src/launcher/icon-theme-common.c @@ -740,7 +740,7 @@ void add_icon_path_to_cache(IconThemeWrapper *wrapper, const char *icon_name, in g_free(key); } -char *get_icon_path(IconThemeWrapper *wrapper, const char *icon_name, int size) +char *get_icon_path(IconThemeWrapper *wrapper, const char *icon_name, int size, gboolean use_fallbacks) { if (!wrapper) return NULL; @@ -761,6 +761,8 @@ char *get_icon_path(IconThemeWrapper *wrapper, const char *icon_name, int size) return path; } + if (!use_fallbacks) + goto notfound; fprintf(stderr, YELLOW "Icon not found in default theme: %s" RESET "\n", icon_name); load_fallbacks(wrapper); diff --git a/src/launcher/icon-theme-common.h b/src/launcher/icon-theme-common.h index e6d851f..3af39f8 100644 --- a/src/launcher/icon-theme-common.h +++ b/src/launcher/icon-theme-common.h @@ -51,7 +51,7 @@ void free_icon_theme(IconTheme *theme); // Returns the full path to an icon file (or NULL) given the list of icon themes to search and the icon name // Note: needs to be released with free(). -char *get_icon_path(IconThemeWrapper *wrapper, const char *icon_name, int size); +char *get_icon_path(IconThemeWrapper *wrapper, const char *icon_name, int size, gboolean use_fallbacks); // Returns a list of the directories used to store icons. // Do not free the result, it is cached. diff --git a/src/launcher/launcher.c b/src/launcher/launcher.c index 2699d48..8d6c23e 100644 --- a/src/launcher/launcher.c +++ b/src/launcher/launcher.c @@ -565,13 +565,13 @@ void launcher_reload_icon_image(Launcher *launcher, LauncherIcon *launcherIcon) free_icon(launcherIcon->image_pressed); launcherIcon->image = NULL; - char *new_icon_path = get_icon_path(launcher->icon_theme_wrapper, launcherIcon->icon_name, launcherIcon->icon_size); + char *new_icon_path = get_icon_path(launcher->icon_theme_wrapper, launcherIcon->icon_name, launcherIcon->icon_size, TRUE); if (new_icon_path) launcherIcon->image = load_image(new_icon_path, 1); // On loading error, fallback to default if (!launcherIcon->image) { free(new_icon_path); - new_icon_path = get_icon_path(launcher->icon_theme_wrapper, DEFAULT_ICON, launcherIcon->icon_size); + new_icon_path = get_icon_path(launcher->icon_theme_wrapper, DEFAULT_ICON, launcherIcon->icon_size, TRUE); if (new_icon_path) launcherIcon->image = imlib_load_image_immediately(new_icon_path); } diff --git a/src/tint2conf/properties.c b/src/tint2conf/properties.c index d92fdbe..ec4bba7 100644 --- a/src/tint2conf/properties.c +++ b/src/tint2conf/properties.c @@ -1640,7 +1640,7 @@ GdkPixbuf *load_icon(const gchar *name) process_events(); int size = 22; - char *path = get_icon_path(icon_theme, name, size); + char *path = get_icon_path(icon_theme, name, size, FALSE); GdkPixbuf *pixbuf = path ? gdk_pixbuf_new_from_file_at_size(path, size, size, NULL) : NULL; free(path); return pixbuf;