From 0b56c55d8d953eeef3d7b36aec2c23aec6dc0e2c Mon Sep 17 00:00:00 2001 From: Viktar Lukashonak Date: Sun, 10 Mar 2024 12:19:03 +0300 Subject: [PATCH] Gtk4: Migration. Disk Signed-off-by: Viktar Lukashonak --- include/modules/disk.hpp | 6 ------ meson.build | 1 + src/factory.cpp | 4 ++-- src/modules/disk.cpp | 16 ++++++++++------ 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/include/modules/disk.hpp b/include/modules/disk.hpp index 1b4f3176..45c4ce04 100644 --- a/include/modules/disk.hpp +++ b/include/modules/disk.hpp @@ -1,12 +1,6 @@ #pragma once -#include -#include - -#include - #include "ALabel.hpp" -#include "util/format.hpp" #include "util/sleeper_thread.hpp" namespace waybar::modules { diff --git a/meson.build b/meson.build index 9ea8a75e..aab9b1f5 100644 --- a/meson.build +++ b/meson.build @@ -130,6 +130,7 @@ src_files = files( 'src/group.cpp', 'src/ASlider.cpp', 'src/modules/load.cpp', + 'src/modules/disk.cpp' ) man_files = files( diff --git a/src/factory.cpp b/src/factory.cpp index 708a82bb..5ecc0ca1 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -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]); } diff --git a/src/modules/disk.cpp b/src/modules/disk.cpp index ef257b72..c3a0545c 100644 --- a/src/modules/disk.cpp +++ b/src/modules/disk.cpp @@ -1,5 +1,9 @@ #include "modules/disk.hpp" +#include +#include +#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), @@ -112,4 +116,4 @@ float waybar::modules::Disk::calc_specific_divisor(std::string divisor) { } else { // default to Bytes if it is anything that we don't recongnise return 1.0; } -} \ No newline at end of file +}