polybar-dwm/include/drawtypes/layouticonset.hpp
dvermd 98dffc292a
feat(xkeyboard): Icon matching using variant (#2521)
* feat(string_util): add contains_nocase

* feat(xkeyboard): Enable icon by variant

* Cleanup

* string_util: add some cases to string test

* string_util: rename contains_nocase -> contains_ignore_case

* layouticonset: use contains_ignore_case

* layouticonset: apply renamings and remove dead code

* remove VARIANT_NONE and use empty string instead

* use emplace_back and add assert

* layouticonset: precompute condition

* xkeyboard: restore missing continue

* Cleanup parse_icons

* Always choose the first case-insensitive match

* Cleanup layouticonset.get

* update the changelog

Co-authored-by: patrick96 <p.ziegler96@gmail.com>
2021-10-05 12:12:47 +02:00

34 lines
785 B
C++

#pragma once
#include <tuple>
#include <vector>
#include "common.hpp"
#include "drawtypes/label.hpp"
#include "utils/mixins.hpp"
using std::tuple;
POLYBAR_NS
namespace drawtypes {
class layouticonset : public non_copyable_mixin<layouticonset> {
public:
explicit layouticonset(label_t&& default_icon);
bool add(const string& layout, const string& variant, label_t&& icon);
label_t get(const string& layout, const string& variant) const;
bool contains(const string& layout, const string& variant) const;
static constexpr const char* VARIANT_ANY = "_";
protected:
label_t m_default_icon;
vector<tuple<string, string, label_t>> m_layout_icons;
};
using layouticonset_t = shared_ptr<layouticonset>;
} // namespace drawtypes
POLYBAR_NS_END