Convert icon-theme option to array|string
Use the config support of using arrays in its options instead of the complicated and error-prone parsing of the string.
This commit is contained in:
parent
70e368a1c6
commit
bc112eaae1
|
@ -24,7 +24,7 @@ Addressed by *wlr/taskbar*
|
|||
The format, how information should be displayed.
|
||||
|
||||
*icon-theme*: ++
|
||||
typeof: string ++
|
||||
typeof: array|string ++
|
||||
The names of the icon-themes that should be used to find an icon. The list will be traversed from left to right. If omitted, the system default will be used.
|
||||
|
||||
*icon-size*: ++
|
||||
|
|
|
@ -579,22 +579,24 @@ Taskbar::Taskbar(const std::string &id, const waybar::Bar &bar, const Json::Valu
|
|||
}
|
||||
|
||||
/* Get the configured icon theme if specified */
|
||||
if (config_["icon-theme"].isString()) {
|
||||
auto icon_theme_config = config_["icon-theme"].asString();
|
||||
size_t start = 0, end = 0;
|
||||
|
||||
do {
|
||||
end = icon_theme_config.find(',', start);
|
||||
auto it_name = trim(icon_theme_config.substr(start, end-start));
|
||||
if (config_["icon-theme"].isArray()) {
|
||||
for (auto& c : config_["icon-theme"]) {
|
||||
auto it_name = c.asString();
|
||||
|
||||
auto it = Gtk::IconTheme::create();
|
||||
it->set_custom_theme(it_name);
|
||||
spdlog::debug("Use custom icon theme: {}", it_name);
|
||||
|
||||
icon_themes_.push_back(it);
|
||||
}
|
||||
} else if (config_["icon-theme"].isString()) {
|
||||
auto it_name = config_["icon-theme"].asString();
|
||||
|
||||
start = end == std::string::npos ? end : end + 1;
|
||||
} while(end != std::string::npos);
|
||||
auto it = Gtk::IconTheme::create();
|
||||
it->set_custom_theme(it_name);
|
||||
spdlog::debug("Use custom icon theme: {}", it_name);
|
||||
|
||||
icon_themes_.push_back(it);
|
||||
}
|
||||
icon_themes_.push_back(Gtk::IconTheme::get_default());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue