parent
90d1fff4e2
commit
100c64a20c
@ -23,7 +23,7 @@ class config {
|
|||||||
using make_type = const config&;
|
using make_type = const config&;
|
||||||
static make_type make(string path = "", string bar = "");
|
static make_type make(string path = "", string bar = "");
|
||||||
|
|
||||||
explicit config(const logger& logger, unique_ptr<xresource_manager>&& xrm, string&& path = "", string&& bar = "");
|
explicit config(const logger& logger, const xresource_manager& xrm, string&& path = "", string&& bar = "");
|
||||||
|
|
||||||
string filepath() const;
|
string filepath() const;
|
||||||
string section() const;
|
string section() const;
|
||||||
@ -285,10 +285,10 @@ class config {
|
|||||||
size_t pos;
|
size_t pos;
|
||||||
|
|
||||||
if ((pos = var.find(":")) != string::npos) {
|
if ((pos = var.find(":")) != string::npos) {
|
||||||
return convert<T>(m_xrm->get_string(var.substr(0, pos), var.substr(pos + 1)));
|
return convert<T>(m_xrm.get_string(var.substr(0, pos), var.substr(pos + 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
string str{m_xrm->get_string(var, "")};
|
string str{m_xrm.get_string(var, "")};
|
||||||
return str.empty() ? fallback : convert<T>(move(str));
|
return str.empty() ? fallback : convert<T>(move(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,7 +310,7 @@ class config {
|
|||||||
private:
|
private:
|
||||||
static constexpr const char* KEY_INHERIT{"inherit"};
|
static constexpr const char* KEY_INHERIT{"inherit"};
|
||||||
const logger& m_log;
|
const logger& m_log;
|
||||||
unique_ptr<xresource_manager> m_xrm;
|
const xresource_manager& m_xrm;
|
||||||
string m_file;
|
string m_file;
|
||||||
string m_barname;
|
string m_barname;
|
||||||
sectionmap_t m_sections{};
|
sectionmap_t m_sections{};
|
||||||
|
@ -9,7 +9,7 @@ POLYBAR_NS
|
|||||||
|
|
||||||
class xresource_manager {
|
class xresource_manager {
|
||||||
public:
|
public:
|
||||||
using make_type = unique_ptr<xresource_manager>;
|
using make_type = const xresource_manager&;
|
||||||
static make_type make();
|
static make_type make();
|
||||||
|
|
||||||
explicit xresource_manager(Display*);
|
explicit xresource_manager(Display*);
|
||||||
|
@ -22,7 +22,7 @@ config::make_type config::make(string path, string bar) {
|
|||||||
/**
|
/**
|
||||||
* Construct config object
|
* Construct config object
|
||||||
*/
|
*/
|
||||||
config::config(const logger& logger, unique_ptr<xresource_manager>&& xrm, string&& path, string&& bar)
|
config::config(const logger& logger, const xresource_manager& xrm, string&& path, string&& bar)
|
||||||
: m_log(logger)
|
: m_log(logger)
|
||||||
, m_xrm(forward<decltype(xrm)>(xrm))
|
, m_xrm(forward<decltype(xrm)>(xrm))
|
||||||
, m_file(forward<string>(path))
|
, m_file(forward<string>(path))
|
||||||
|
@ -63,7 +63,7 @@ tray_manager::~tray_manager() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void tray_manager::setup(const bar_settings& bar_opts) {
|
void tray_manager::setup(const bar_settings& bar_opts) {
|
||||||
auto& conf = config::make();
|
const config& conf = config::make();
|
||||||
auto bs = conf.section();
|
auto bs = conf.section();
|
||||||
string position;
|
string position;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ POLYBAR_NS
|
|||||||
* Create instance
|
* Create instance
|
||||||
*/
|
*/
|
||||||
xresource_manager::make_type xresource_manager::make() {
|
xresource_manager::make_type xresource_manager::make() {
|
||||||
return factory_util::unique<xresource_manager>(static_cast<Display*>(connection::make()));
|
return *factory_util::singleton<xresource_manager>(static_cast<Display*>(connection::make()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,7 +30,7 @@ xresource_manager::xresource_manager(Display* dsp) {
|
|||||||
* Deconstruct instance
|
* Deconstruct instance
|
||||||
*/
|
*/
|
||||||
xresource_manager::~xresource_manager() {
|
xresource_manager::~xresource_manager() {
|
||||||
if (m_db != nullptr) {
|
if (m_manager != nullptr) {
|
||||||
XrmDestroyDatabase(m_db);
|
XrmDestroyDatabase(m_db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ int xresource_manager::get_int(string name, int fallback) const {
|
|||||||
* Query the database for given key
|
* Query the database for given key
|
||||||
*/
|
*/
|
||||||
string xresource_manager::load_value(const string& key, const string& res_type, size_t n) const {
|
string xresource_manager::load_value(const string& key, const string& res_type, size_t n) const {
|
||||||
if (m_manager != nullptr && m_db != nullptr) {
|
if (m_manager != nullptr) {
|
||||||
char* type = nullptr;
|
char* type = nullptr;
|
||||||
XrmValue ret{};
|
XrmValue ret{};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user