mirror of
https://github.com/polybar/polybar.git
synced 2024-12-09 14:10:19 -05:00
bar: Make module separator a label
Some people use text modules instead of the `separator` key in the bar section to better configure the separator (colors, fonts). Since we disallowed the same module being used multiple times in #1534, this will now print an error message. This should help with this a bit. Ref #1913
This commit is contained in:
parent
a77923ea96
commit
587dc6c84d
7 changed files with 14 additions and 16 deletions
|
@ -10,10 +10,6 @@ POLYBAR_NS
|
|||
using std::map;
|
||||
|
||||
// fwd decl
|
||||
namespace drawtypes {
|
||||
class label;
|
||||
using label_t = shared_ptr<label>;
|
||||
} // namespace drawtypes
|
||||
using namespace drawtypes;
|
||||
|
||||
class builder {
|
||||
|
|
|
@ -12,6 +12,12 @@ POLYBAR_NS
|
|||
// fwd {{{
|
||||
struct randr_output;
|
||||
using monitor_t = shared_ptr<randr_output>;
|
||||
|
||||
namespace drawtypes {
|
||||
class label;
|
||||
}
|
||||
|
||||
using label_t = shared_ptr<drawtypes::label>;
|
||||
// }}}
|
||||
|
||||
struct enum_hash {
|
||||
|
@ -159,7 +165,7 @@ struct bar_settings {
|
|||
|
||||
struct radius radius {};
|
||||
int spacing{0};
|
||||
string separator{};
|
||||
label_t separator{};
|
||||
|
||||
string wmname{};
|
||||
string locale{};
|
||||
|
|
|
@ -18,9 +18,6 @@ namespace drawtypes {
|
|||
bool zpad{false};
|
||||
};
|
||||
|
||||
class label;
|
||||
using label_t = shared_ptr<label>;
|
||||
|
||||
class label : public non_copyable_mixin<label> {
|
||||
public:
|
||||
string m_foreground{};
|
||||
|
|
|
@ -9,10 +9,6 @@
|
|||
POLYBAR_NS
|
||||
|
||||
namespace drawtypes {
|
||||
// fwd
|
||||
class label;
|
||||
using label_t = shared_ptr<label>;
|
||||
|
||||
class progressbar : public non_copyable_mixin<progressbar> {
|
||||
public:
|
||||
explicit progressbar(const bar_settings& bar, int width, string format);
|
||||
|
|
|
@ -29,8 +29,6 @@ using std::map;
|
|||
// fwd decl {{{
|
||||
|
||||
namespace drawtypes {
|
||||
class label;
|
||||
using label_t = shared_ptr<label>;
|
||||
class ramp;
|
||||
using ramp_t = shared_ptr<ramp>;
|
||||
class progressbar;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "components/screen.hpp"
|
||||
#include "components/taskqueue.hpp"
|
||||
#include "components/types.hpp"
|
||||
#include "drawtypes/label.hpp"
|
||||
#include "events/signal.hpp"
|
||||
#include "events/signal_emitter.hpp"
|
||||
#include "utils/bspwm.hpp"
|
||||
|
@ -155,7 +156,7 @@ bar::bar(connection& conn, signal_emitter& emitter, const config& config, const
|
|||
// Load configuration values
|
||||
m_opts.origin = m_conf.get(bs, "bottom", false) ? edge::BOTTOM : edge::TOP;
|
||||
m_opts.spacing = m_conf.get(bs, "spacing", m_opts.spacing);
|
||||
m_opts.separator = m_conf.get(bs, "separator", ""s);
|
||||
m_opts.separator = drawtypes::load_optional_label(m_conf, bs, "separator", "");
|
||||
m_opts.locale = m_conf.get(bs, "locale", ""s);
|
||||
|
||||
auto radius = m_conf.get<double>(bs, "radius", 0.0);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <csignal>
|
||||
|
||||
#include "components/bar.hpp"
|
||||
#include "components/builder.hpp"
|
||||
#include "components/config.hpp"
|
||||
#include "components/ipc.hpp"
|
||||
#include "components/logger.hpp"
|
||||
|
@ -447,12 +448,15 @@ void controller::process_inputdata() {
|
|||
bool controller::process_update(bool force) {
|
||||
const bar_settings& bar{m_bar->settings()};
|
||||
string contents;
|
||||
string separator{bar.separator};
|
||||
string padding_left(bar.padding.left, ' ');
|
||||
string padding_right(bar.padding.right, ' ');
|
||||
string margin_left(bar.module_margin.left, ' ');
|
||||
string margin_right(bar.module_margin.right, ' ');
|
||||
|
||||
builder build{bar};
|
||||
build.node(bar.separator);
|
||||
string separator{build.flush()};
|
||||
|
||||
for (const auto& block : m_blocks) {
|
||||
string block_contents;
|
||||
bool is_left = false;
|
||||
|
|
Loading…
Reference in a new issue