mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
refactor(client): extract config handling into a new class
This commit is contained in:
@ -3,11 +3,10 @@
|
||||
#include <fmt/format.h>
|
||||
#include <gdk/gdk.h>
|
||||
#include <gdk/gdkwayland.h>
|
||||
#include <unistd.h>
|
||||
#include <wayland-client.h>
|
||||
#include <wordexp.h>
|
||||
|
||||
#include "bar.hpp"
|
||||
#include "config.hpp"
|
||||
|
||||
struct zwlr_layer_shell_v1;
|
||||
struct zwp_idle_inhibitor_v1;
|
||||
@ -32,15 +31,8 @@ class Client {
|
||||
|
||||
private:
|
||||
Client() = default;
|
||||
std::tuple<const std::string, const std::string> getConfigs(const std::string &config,
|
||||
const std::string &style) const;
|
||||
void bindInterfaces();
|
||||
const std::string getValidPath(const std::vector<std::string> &paths) const;
|
||||
void bindInterfaces();
|
||||
void handleOutput(struct waybar_output &output);
|
||||
bool isValidOutput(const Json::Value &config, struct waybar_output &output);
|
||||
auto setupConfig(const std::string &config_file, int depth) -> void;
|
||||
auto resolveConfigIncludes(Json::Value &config, int depth) -> void;
|
||||
auto mergeConfig(Json::Value &a_config_, Json::Value &b_config_) -> void;
|
||||
auto setupCss(const std::string &css_file) -> void;
|
||||
struct waybar_output & getOutput(void *);
|
||||
std::vector<Json::Value> getOutputConfigs(struct waybar_output &output);
|
||||
@ -55,7 +47,7 @@ class Client {
|
||||
void handleMonitorRemoved(Glib::RefPtr<Gdk::Monitor> monitor);
|
||||
void handleDeferredMonitorRemoval(Glib::RefPtr<Gdk::Monitor> monitor);
|
||||
|
||||
Json::Value config_;
|
||||
Config config_;
|
||||
Glib::RefPtr<Gtk::StyleContext> style_context_;
|
||||
Glib::RefPtr<Gtk::CssProvider> css_provider_;
|
||||
std::list<struct waybar_output> outputs_;
|
||||
|
31
include/config.hpp
Normal file
31
include/config.hpp
Normal file
@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <json/json.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace waybar {
|
||||
|
||||
class Config {
|
||||
public:
|
||||
Config() = default;
|
||||
|
||||
void load(const std::string &config, const std::string &style);
|
||||
|
||||
const std::string &getStyle() { return css_file_; }
|
||||
|
||||
Json::Value &getConfig() { return config_; }
|
||||
|
||||
std::vector<Json::Value> getOutputConfigs(const std::string &name, const std::string &identifier);
|
||||
|
||||
private:
|
||||
void setupConfig(const std::string &config_file, int depth);
|
||||
void resolveConfigIncludes(Json::Value &config, int depth);
|
||||
void mergeConfig(Json::Value &a_config_, Json::Value &b_config_);
|
||||
|
||||
std::string config_file_;
|
||||
std::string css_file_;
|
||||
|
||||
Json::Value config_;
|
||||
};
|
||||
} // namespace waybar
|
Reference in New Issue
Block a user