2016-11-02 19:22:45 +00:00
|
|
|
#include "drawtypes/iconset.hpp"
|
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS
|
2016-11-02 19:22:45 +00:00
|
|
|
|
|
|
|
namespace drawtypes {
|
|
|
|
void iconset::add(string id, icon_t&& icon) {
|
|
|
|
m_icons.emplace(id, forward<decltype(icon)>(icon));
|
|
|
|
}
|
|
|
|
|
2016-11-25 12:55:15 +00:00
|
|
|
bool iconset::has(const string& id) {
|
2016-11-02 19:22:45 +00:00
|
|
|
return m_icons.find(id) != m_icons.end();
|
|
|
|
}
|
|
|
|
|
2016-11-25 12:55:15 +00:00
|
|
|
icon_t iconset::get(const string& id, const string& fallback_id) {
|
2016-11-02 19:22:45 +00:00
|
|
|
auto icon = m_icons.find(id);
|
2016-11-25 12:55:15 +00:00
|
|
|
if (icon == m_icons.end()) {
|
2016-11-02 19:22:45 +00:00
|
|
|
return m_icons.find(fallback_id)->second;
|
2016-11-25 12:55:15 +00:00
|
|
|
}
|
2016-11-02 19:22:45 +00:00
|
|
|
return icon->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
iconset::operator bool() {
|
2016-11-25 12:55:15 +00:00
|
|
|
return !m_icons.empty();
|
2016-11-02 19:22:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS_END
|