Gtk4: Migration. Disk
Signed-off-by: Viktar Lukashonak <myxabeer@gmail.com>pull/2956/head
parent
f66e5284dd
commit
0b56c55d8d
|
@ -1,12 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <sys/statvfs.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "ALabel.hpp"
|
||||
#include "util/format.hpp"
|
||||
#include "util/sleeper_thread.hpp"
|
||||
|
||||
namespace waybar::modules {
|
||||
|
|
|
@ -130,6 +130,7 @@ src_files = files(
|
|||
'src/group.cpp',
|
||||
'src/ASlider.cpp',
|
||||
'src/modules/load.cpp',
|
||||
'src/modules/disk.cpp'
|
||||
)
|
||||
|
||||
man_files = files(
|
||||
|
|
|
@ -233,10 +233,10 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name,
|
|||
gtk4 todo
|
||||
if (ref == "user") {
|
||||
return new waybar::modules::User(id, config_[name]);
|
||||
}
|
||||
}*/
|
||||
if (ref == "disk") {
|
||||
return new waybar::modules::Disk(id, config_[name]);
|
||||
}
|
||||
}/*
|
||||
if (ref == "image") {
|
||||
return new waybar::modules::Image(id, config_[name]);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#include "modules/disk.hpp"
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <sys/statvfs.h>
|
||||
#include "util/format.hpp"
|
||||
|
||||
using namespace waybar::util;
|
||||
|
||||
waybar::modules::Disk::Disk(const std::string& id, const Json::Value& config)
|
||||
|
@ -42,7 +46,7 @@ auto waybar::modules::Disk::update() -> void {
|
|||
*/
|
||||
|
||||
if (err != 0) {
|
||||
event_box_.hide();
|
||||
Gtk::Label::hide();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -65,10 +69,10 @@ auto waybar::modules::Disk::update() -> void {
|
|||
}
|
||||
|
||||
if (format.empty()) {
|
||||
event_box_.hide();
|
||||
Gtk::Label::hide();
|
||||
} else {
|
||||
event_box_.show();
|
||||
label_.set_markup(fmt::format(
|
||||
Gtk::Label::show();
|
||||
Gtk::Label::set_markup(fmt::format(
|
||||
fmt::runtime(format), stats.f_bavail * 100 / stats.f_blocks, fmt::arg("free", free),
|
||||
fmt::arg("percentage_free", stats.f_bavail * 100 / stats.f_blocks), fmt::arg("used", used),
|
||||
fmt::arg("percentage_used", percentage_used), fmt::arg("total", total),
|
||||
|
@ -81,7 +85,7 @@ auto waybar::modules::Disk::update() -> void {
|
|||
if (config_["tooltip-format"].isString()) {
|
||||
tooltip_format = config_["tooltip-format"].asString();
|
||||
}
|
||||
label_.set_tooltip_text(fmt::format(
|
||||
Gtk::Label::set_tooltip_text(fmt::format(
|
||||
fmt::runtime(tooltip_format), stats.f_bavail * 100 / stats.f_blocks, fmt::arg("free", free),
|
||||
fmt::arg("percentage_free", stats.f_bavail * 100 / stats.f_blocks), fmt::arg("used", used),
|
||||
fmt::arg("percentage_used", percentage_used), fmt::arg("total", total),
|
||||
|
|
Loading…
Reference in New Issue