mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
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.
|
The format, how information should be displayed.
|
||||||
|
|
||||||
*icon-theme*: ++
|
*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.
|
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*: ++
|
*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 */
|
/* Get the configured icon theme if specified */
|
||||||
if (config_["icon-theme"].isString()) {
|
if (config_["icon-theme"].isArray()) {
|
||||||
auto icon_theme_config = config_["icon-theme"].asString();
|
for (auto& c : config_["icon-theme"]) {
|
||||||
size_t start = 0, end = 0;
|
auto it_name = c.asString();
|
||||||
|
|
||||||
do {
|
|
||||||
end = icon_theme_config.find(',', start);
|
|
||||||
auto it_name = trim(icon_theme_config.substr(start, end-start));
|
|
||||||
|
|
||||||
auto it = Gtk::IconTheme::create();
|
auto it = Gtk::IconTheme::create();
|
||||||
it->set_custom_theme(it_name);
|
it->set_custom_theme(it_name);
|
||||||
spdlog::debug("Use custom icon theme: {}", it_name);
|
spdlog::debug("Use custom icon theme: {}", it_name);
|
||||||
|
|
||||||
icon_themes_.push_back(it);
|
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;
|
auto it = Gtk::IconTheme::create();
|
||||||
} while(end != std::string::npos);
|
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());
|
icon_themes_.push_back(Gtk::IconTheme::get_default());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user