Gtk4: Migration temperature

Signed-off-by: Viktar Lukashonak <myxabeer@gmail.com>
pull/2956/head
Viktar Lukashonak 2024-03-12 09:07:58 +03:00
parent 0b56c55d8d
commit bf9325d724
No known key found for this signature in database
GPG Key ID: 08A413AA87200A6F
4 changed files with 13 additions and 13 deletions

View File

@ -1,9 +1,5 @@
#pragma once #pragma once
#include <fmt/format.h>
#include <fstream>
#include "ALabel.hpp" #include "ALabel.hpp"
#include "util/sleeper_thread.hpp" #include "util/sleeper_thread.hpp"

View File

@ -130,7 +130,8 @@ src_files = files(
'src/group.cpp', 'src/group.cpp',
'src/ASlider.cpp', 'src/ASlider.cpp',
'src/modules/load.cpp', 'src/modules/load.cpp',
'src/modules/disk.cpp' 'src/modules/disk.cpp',
'src/modules/temperature.cpp'
) )
man_files = files( man_files = files(

View File

@ -308,10 +308,10 @@ gtk4 todo
if (ref == "systemd-failed-units") { if (ref == "systemd-failed-units") {
return new waybar::modules::SystemdFailedUnits(id, config_[name]); return new waybar::modules::SystemdFailedUnits(id, config_[name]);
} }
#endif #endif*/
if (ref == "temperature") { if (ref == "temperature") {
return new waybar::modules::Temperature(id, config_[name]); return new waybar::modules::Temperature(id, config_[name]);
} }/*
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], bar_.output->name); return new waybar::modules::Custom(ref.substr(7), id, config_[name], bar_.output->name);
} }

View File

@ -1,5 +1,8 @@
#include "modules/temperature.hpp" #include "modules/temperature.hpp"
#include <fmt/format.h>
#include <fstream>
#include <filesystem> #include <filesystem>
#if defined(__FreeBSD__) #if defined(__FreeBSD__)
@ -52,20 +55,20 @@ auto waybar::modules::Temperature::update() -> void {
auto format = format_; auto format = format_;
if (critical) { if (critical) {
format = config_["format-critical"].isString() ? config_["format-critical"].asString() : format; format = config_["format-critical"].isString() ? config_["format-critical"].asString() : format;
label_.get_style_context()->add_class("critical"); Gtk::Label::get_style_context()->add_class("critical");
} else { } else {
label_.get_style_context()->remove_class("critical"); Gtk::Label::get_style_context()->remove_class("critical");
} }
if (format.empty()) { if (format.empty()) {
event_box_.hide(); Gtk::Label::hide();
return; return;
} else { } else {
event_box_.show(); Gtk::Label::show();
} }
auto max_temp = config_["critical-threshold"].isInt() ? config_["critical-threshold"].asInt() : 0; auto max_temp = config_["critical-threshold"].isInt() ? config_["critical-threshold"].asInt() : 0;
label_.set_markup(fmt::format(fmt::runtime(format), fmt::arg("temperatureC", temperature_c), Gtk::Label::set_markup(fmt::format(fmt::runtime(format), fmt::arg("temperatureC", temperature_c),
fmt::arg("temperatureF", temperature_f), fmt::arg("temperatureF", temperature_f),
fmt::arg("temperatureK", temperature_k), fmt::arg("temperatureK", temperature_k),
fmt::arg("icon", getIcon(temperature_c, "", max_temp)))); fmt::arg("icon", getIcon(temperature_c, "", max_temp))));
@ -74,7 +77,7 @@ auto waybar::modules::Temperature::update() -> void {
if (config_["tooltip-format"].isString()) { if (config_["tooltip-format"].isString()) {
tooltip_format = config_["tooltip-format"].asString(); tooltip_format = config_["tooltip-format"].asString();
} }
label_.set_tooltip_text(fmt::format( Gtk::Label::set_tooltip_text(fmt::format(
fmt::runtime(tooltip_format), fmt::arg("temperatureC", temperature_c), fmt::runtime(tooltip_format), fmt::arg("temperatureC", temperature_c),
fmt::arg("temperatureF", temperature_f), fmt::arg("temperatureK", temperature_k))); fmt::arg("temperatureF", temperature_f), fmt::arg("temperatureK", temperature_k)));
} }