Merge pull request #1975 from bd-g/fix-image

This commit is contained in:
Alex
2023-01-27 14:38:26 +01:00
committed by GitHub
4 changed files with 19 additions and 16 deletions

View File

@ -98,6 +98,9 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name) const {
if (ref == "disk") {
return new waybar::modules::Disk(id, config_[name]);
}
if (ref == "image") {
return new waybar::modules::Image(id, config_[name]);
}
#ifdef HAVE_DBUSMENU
if (ref == "tray") {
return new waybar::modules::SNI::Tray(id, bar_, config_[name]);
@ -156,8 +159,6 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name) const {
}
if (ref.compare(0, 7, "custom/") == 0 && ref.size() > 7) {
return new waybar::modules::Custom(ref.substr(7), id, config_[name]);
} else if (ref.compare(0, 6, "image/") == 0 && ref.size() > 6) {
return new waybar::modules::Image(ref.substr(6), id, config_[name]);
}
} catch (const std::exception& e) {
auto err = fmt::format("Disabling module \"{}\", {}", name, e.what());

View File

@ -1,11 +1,13 @@
#include "modules/image.hpp"
#include <spdlog/spdlog.h>
waybar::modules::Image::Image(const std::string& name, const std::string& id,
const Json::Value& config)
: AModule(config, "image-" + name, id, "{}") {
event_box_.add(image_);
waybar::modules::Image::Image(const std::string& id, const Json::Value& config)
: AModule(config, "image", id), box_(Gtk::ORIENTATION_HORIZONTAL, 0) {
box_.pack_start(image_);
box_.set_name("image");
if (!id.empty()) {
box_.get_style_context()->add_class(id);
}
event_box_.add(box_);
dp.emit();