added path settings
parent
769858fbb4
commit
1111763251
|
@ -19,8 +19,6 @@ class User : public AIconLabel {
|
|||
private:
|
||||
util::SleeperThread thread_;
|
||||
|
||||
Glib::RefPtr<Gdk::Pixbuf> pixbuf_;
|
||||
|
||||
static constexpr inline int defaultUserImageWidth_ = 20;
|
||||
static constexpr inline int defaultUserImageHeight_ = 20;
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <algorithm>
|
||||
#include <chrono>
|
||||
|
||||
#include "gdkmm/cursor.h"
|
||||
#include "gdkmm/event.h"
|
||||
#include "gdkmm/types.h"
|
||||
#include "sigc++/functors/mem_fun.h"
|
||||
|
@ -20,6 +21,8 @@
|
|||
#include <time.h>
|
||||
#endif
|
||||
|
||||
const static int LEFT_MOUSE_BUTTON_CODE = 1;
|
||||
|
||||
namespace waybar::modules {
|
||||
User::User(const std::string& id, const Json::Value& config)
|
||||
: AIconLabel(config, "user", id, "{user} {work_H}:{work_M}", 60, false, true, true) {
|
||||
|
@ -31,10 +34,18 @@ User::User(const std::string& id, const Json::Value& config)
|
|||
|
||||
bool User::handleToggle(GdkEventButton* const& e) {
|
||||
if (AIconLabel::config_["open-on-click"].isBool() &&
|
||||
AIconLabel::config_["open-on-click"].asBool()) {
|
||||
Gio::AppInfo::launch_default_for_uri("file:///" + this->get_user_home_dir());
|
||||
AIconLabel::config_["open-on-click"].asBool() && e->button == LEFT_MOUSE_BUTTON_CODE) {
|
||||
std::string openPath = this->get_user_home_dir();
|
||||
if (AIconLabel::config_["open-path"].isString()) {
|
||||
std::string customPath = AIconLabel::config_["open-path"].asString();
|
||||
if (!customPath.empty()) {
|
||||
openPath = std::move(customPath);
|
||||
}
|
||||
return ALabel::handleToggle(e);
|
||||
}
|
||||
|
||||
Gio::AppInfo::launch_default_for_uri("file:///" + openPath);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
long User::uptime_as_seconds() {
|
||||
|
@ -95,8 +106,8 @@ void User::init_default_user_avatar(int width, int height) {
|
|||
}
|
||||
|
||||
void User::init_user_avatar(const std::string& path, int width, int height) {
|
||||
this->pixbuf_ = Gdk::Pixbuf::create_from_file(path, width, height);
|
||||
AIconLabel::image_.set(this->pixbuf_);
|
||||
Glib::RefPtr<Gdk::Pixbuf> pixbuf_ = Gdk::Pixbuf::create_from_file(path, width, height);
|
||||
AIconLabel::image_.set(pixbuf_);
|
||||
}
|
||||
|
||||
auto User::update() -> void {
|
||||
|
|
Loading…
Reference in New Issue