From 59d245cf5bb90f6041b9d2601d222b5dd5a7c2c1 Mon Sep 17 00:00:00 2001 From: Felix Weilbach Date: Sat, 1 May 2021 11:38:20 +0200 Subject: [PATCH] Cleanup icon theme code Signed-off-by: Felix Weilbach --- include/swaybar/icon.h | 2 +- swaybar/icon.c | 2 +- swaybar/ipc.c | 4 ++-- swaybar/render.c | 7 +------ 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/include/swaybar/icon.h b/include/swaybar/icon.h index 51f6aecdc..224e63ba2 100644 --- a/include/swaybar/icon.h +++ b/include/swaybar/icon.h @@ -27,7 +27,7 @@ struct icon_theme { char *dir; list_t *subdirs; // struct icon_theme_subdir * }; -list_t *get_basedirs(void); + void init_themes(list_t **themes, list_t **basedirs); void finish_themes(list_t *themes, list_t *basedirs); diff --git a/swaybar/icon.c b/swaybar/icon.c index fee46dc8f..2d9c72af5 100644 --- a/swaybar/icon.c +++ b/swaybar/icon.c @@ -42,7 +42,7 @@ char* append_path_safe(const char * base_path, const char * append_path) { return path; } -list_t *get_basedirs(void) { +static list_t *get_basedirs(void) { list_t *basedirs = create_list(); list_add(basedirs, strdup("$HOME/.icons")); // deprecated diff --git a/swaybar/ipc.c b/swaybar/ipc.c index 55278998e..0364b3190 100644 --- a/swaybar/ipc.c +++ b/swaybar/ipc.c @@ -335,11 +335,11 @@ static bool ipc_parse_config( wl_list_insert(&config->tray_bindings, &binding->link); } } - +#endif + json_object *icon_theme; if ((json_object_object_get_ex(bar_config, "icon_theme", &icon_theme))) { config->icon_theme = strdup(json_object_get_string(icon_theme)); } -#endif json_object_put(bar_config); return true; diff --git a/swaybar/render.c b/swaybar/render.c index 5f11b8e64..4aa4b50d3 100644 --- a/swaybar/render.c +++ b/swaybar/render.c @@ -758,18 +758,13 @@ uint32_t render_focused_window_icon(cairo_t *cairo, cairo_surface_t *icon = NULL; if (icon_name) { char *icon_theme = output->bar->config->icon_theme; - list_t *basedirs = get_basedirs(); int min_size = 0; int max_size = 0; - list_t *themes = create_list(); - // TODO: Load correct theme - list_add(themes, "Adwaita"); - assert(output->bar); assert(output->bar->themes); char *icon_path = find_icon(output->bar->themes, - basedirs, + output->bar->basedirs, icon_name, target_size, icon_theme,