tint2conf: Do not search for icons in all icon themes (issue #563)

This commit is contained in:
o9000 2017-03-20 18:06:49 +01:00
parent b6a4fe03df
commit acd1ed5768
4 changed files with 7 additions and 5 deletions

View file

@ -740,7 +740,7 @@ void add_icon_path_to_cache(IconThemeWrapper *wrapper, const char *icon_name, in
g_free(key); 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) if (!wrapper)
return NULL; return NULL;
@ -761,6 +761,8 @@ char *get_icon_path(IconThemeWrapper *wrapper, const char *icon_name, int size)
return path; return path;
} }
if (!use_fallbacks)
goto notfound;
fprintf(stderr, YELLOW "Icon not found in default theme: %s" RESET "\n", icon_name); fprintf(stderr, YELLOW "Icon not found in default theme: %s" RESET "\n", icon_name);
load_fallbacks(wrapper); load_fallbacks(wrapper);

View file

@ -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 // 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(). // 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. // Returns a list of the directories used to store icons.
// Do not free the result, it is cached. // Do not free the result, it is cached.

View file

@ -565,13 +565,13 @@ void launcher_reload_icon_image(Launcher *launcher, LauncherIcon *launcherIcon)
free_icon(launcherIcon->image_pressed); free_icon(launcherIcon->image_pressed);
launcherIcon->image = NULL; 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) if (new_icon_path)
launcherIcon->image = load_image(new_icon_path, 1); launcherIcon->image = load_image(new_icon_path, 1);
// On loading error, fallback to default // On loading error, fallback to default
if (!launcherIcon->image) { if (!launcherIcon->image) {
free(new_icon_path); 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) if (new_icon_path)
launcherIcon->image = imlib_load_image_immediately(new_icon_path); launcherIcon->image = imlib_load_image_immediately(new_icon_path);
} }

View file

@ -1640,7 +1640,7 @@ GdkPixbuf *load_icon(const gchar *name)
process_events(); process_events();
int size = 22; 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; GdkPixbuf *pixbuf = path ? gdk_pixbuf_new_from_file_at_size(path, size, size, NULL) : NULL;
free(path); free(path);
return pixbuf; return pixbuf;