aboutsummaryrefslogtreecommitdiff
path: root/swaybar/tray
diff options
context:
space:
mode:
authorIan Fan <ianfan0@gmail.com>2019-01-17 16:47:44 +0000
committeremersion <contact@emersion.fr>2019-03-11 14:42:58 +0100
commit5c8424c0743c36b11baabe8b316ee6daecd0cfb8 (patch)
treef29b11a1230d2dd85aba556d3c9647737808e09b /swaybar/tray
parent017a7c4da169ace601f282c87a9aaabc138a34d3 (diff)
stringop.c: remove unused functions
The only use of `join_list` in swaybar/tray/icon.c has been rewritten.
Diffstat (limited to 'swaybar/tray')
-rw-r--r--swaybar/tray/icon.c47
1 files changed, 38 insertions, 9 deletions
diff --git a/swaybar/tray/icon.c b/swaybar/tray/icon.c
index bf2736c2..c7ce20b4 100644
--- a/swaybar/tray/icon.c
+++ b/swaybar/tray/icon.c
@@ -301,6 +301,43 @@ static list_t *load_themes_in_dir(char *basedir) {
return themes;
}
+static void log_loaded_themes(list_t *themes) {
+ if (themes->length == 0) {
+ sway_log(SWAY_INFO, "Warning: no icon themes loaded");
+ return;
+ }
+
+ const char *sep = ", ";
+ size_t sep_len = strlen(sep);
+
+ size_t len = 1 - sep_len;
+ for (int i = 0; i < themes->length; ++i) {
+ struct icon_theme *theme = themes->items[i];
+ len += strlen(theme->name) + sep_len;
+ }
+
+ char *str = malloc(len);
+ if (!str) {
+ return;
+ }
+ char *p = str;
+ for (int i = 0; i < themes->length; ++i) {
+ if (i > 0) {
+ memcpy(p, sep, sep_len);
+ p += sep_len;
+ }
+
+ struct icon_theme *theme = themes->items[i];
+ size_t name_len = strlen(theme->name);
+ memcpy(p, theme->name, name_len);
+ p += name_len;
+ }
+ *p = '\0';
+
+ sway_log(SWAY_DEBUG, "Loaded icon themes: %s", str);
+ free(str);
+}
+
void init_themes(list_t **themes, list_t **basedirs) {
*basedirs = get_basedirs();
@@ -311,15 +348,7 @@ void init_themes(list_t **themes, list_t **basedirs) {
list_free(dir_themes);
}
- list_t *theme_names = create_list();
- for (int i = 0; i < (*themes)->length; ++i) {
- struct icon_theme *theme = (*themes)->items[i];
- list_add(theme_names, theme->name);
- }
- char *theme_list = join_list(theme_names, ", ");
- sway_log(SWAY_DEBUG, "Loaded themes: %s", theme_list);
- free(theme_list);
- list_free(theme_names);
+ log_loaded_themes(*themes);
}
void finish_themes(list_t *themes, list_t *basedirs) {