mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Merge pull request #1975 from bd-g/fix-image
This commit is contained in:
commit
0ecfce9c61
@ -7,6 +7,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "ALabel.hpp"
|
#include "ALabel.hpp"
|
||||||
|
#include "gtkmm/box.h"
|
||||||
#include "util/command.hpp"
|
#include "util/command.hpp"
|
||||||
#include "util/json.hpp"
|
#include "util/json.hpp"
|
||||||
#include "util/sleeper_thread.hpp"
|
#include "util/sleeper_thread.hpp"
|
||||||
@ -15,7 +16,7 @@ namespace waybar::modules {
|
|||||||
|
|
||||||
class Image : public AModule {
|
class Image : public AModule {
|
||||||
public:
|
public:
|
||||||
Image(const std::string&, const std::string&, const Json::Value&);
|
Image(const std::string&, const Json::Value&);
|
||||||
auto update() -> void;
|
auto update() -> void;
|
||||||
void refresh(int /*signal*/);
|
void refresh(int /*signal*/);
|
||||||
|
|
||||||
@ -23,6 +24,7 @@ class Image : public AModule {
|
|||||||
void delayWorker();
|
void delayWorker();
|
||||||
void handleEvent();
|
void handleEvent();
|
||||||
|
|
||||||
|
Gtk::Box box_;
|
||||||
Gtk::Image image_;
|
Gtk::Image image_;
|
||||||
std::string path_;
|
std::string path_;
|
||||||
int size_;
|
int size_;
|
||||||
|
@ -10,8 +10,6 @@ The *image* module displays an image from a path.
|
|||||||
|
|
||||||
# CONFIGURATION
|
# CONFIGURATION
|
||||||
|
|
||||||
Addressed by *custom/<name>*
|
|
||||||
|
|
||||||
*path*: ++
|
*path*: ++
|
||||||
typeof: string ++
|
typeof: string ++
|
||||||
The path to the image.
|
The path to the image.
|
||||||
@ -58,15 +56,15 @@ Addressed by *custom/<name>*
|
|||||||
|
|
||||||
# EXAMPLES
|
# EXAMPLES
|
||||||
|
|
||||||
## Spotify:
|
|
||||||
|
|
||||||
## mpd:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
"image/album-art": {
|
"image#album-art": {
|
||||||
"path": "/tmp/mpd_art",
|
"path": "/tmp/mpd_art",
|
||||||
"size": 32,
|
"size": 32,
|
||||||
"interval": 5,
|
"interval": 5,
|
||||||
"on-click": "mpc toggle"
|
"on-click": "mpc toggle"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# STYLE
|
||||||
|
|
||||||
|
- *#image*
|
||||||
|
@ -98,6 +98,9 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name) const {
|
|||||||
if (ref == "disk") {
|
if (ref == "disk") {
|
||||||
return new waybar::modules::Disk(id, config_[name]);
|
return new waybar::modules::Disk(id, config_[name]);
|
||||||
}
|
}
|
||||||
|
if (ref == "image") {
|
||||||
|
return new waybar::modules::Image(id, config_[name]);
|
||||||
|
}
|
||||||
#ifdef HAVE_DBUSMENU
|
#ifdef HAVE_DBUSMENU
|
||||||
if (ref == "tray") {
|
if (ref == "tray") {
|
||||||
return new waybar::modules::SNI::Tray(id, bar_, config_[name]);
|
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) {
|
if (ref.compare(0, 7, "custom/") == 0 && ref.size() > 7) {
|
||||||
return new waybar::modules::Custom(ref.substr(7), id, config_[name]);
|
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) {
|
} catch (const std::exception& e) {
|
||||||
auto err = fmt::format("Disabling module \"{}\", {}", name, e.what());
|
auto err = fmt::format("Disabling module \"{}\", {}", name, e.what());
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
#include "modules/image.hpp"
|
#include "modules/image.hpp"
|
||||||
|
|
||||||
#include <spdlog/spdlog.h>
|
waybar::modules::Image::Image(const std::string& id, const Json::Value& config)
|
||||||
|
: AModule(config, "image", id), box_(Gtk::ORIENTATION_HORIZONTAL, 0) {
|
||||||
waybar::modules::Image::Image(const std::string& name, const std::string& id,
|
box_.pack_start(image_);
|
||||||
const Json::Value& config)
|
box_.set_name("image");
|
||||||
: AModule(config, "image-" + name, id, "{}") {
|
if (!id.empty()) {
|
||||||
event_box_.add(image_);
|
box_.get_style_context()->add_class(id);
|
||||||
|
}
|
||||||
|
event_box_.add(box_);
|
||||||
|
|
||||||
dp.emit();
|
dp.emit();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user