Fixed not visible when only battery is plugged in
parent
d7a030daf3
commit
2b2ac311d5
|
@ -171,10 +171,6 @@ void UPower::resetDevices() {
|
||||||
|
|
||||||
auto UPower::update() -> void {
|
auto UPower::update() -> void {
|
||||||
std::lock_guard<std::mutex> guard(m_Mutex);
|
std::lock_guard<std::mutex> guard(m_Mutex);
|
||||||
if (devices.size() == 0 && hideIfEmpty) {
|
|
||||||
event_box_.set_visible(false);
|
|
||||||
} else {
|
|
||||||
event_box_.set_visible(true);
|
|
||||||
|
|
||||||
UpDeviceKind kind;
|
UpDeviceKind kind;
|
||||||
UpDeviceState state;
|
UpDeviceState state;
|
||||||
|
@ -201,20 +197,32 @@ auto UPower::update() -> void {
|
||||||
bool displayDeviceValid =
|
bool displayDeviceValid =
|
||||||
kind == UpDeviceKind::UP_DEVICE_KIND_BATTERY || kind == UpDeviceKind::UP_DEVICE_KIND_UPS;
|
kind == UpDeviceKind::UP_DEVICE_KIND_BATTERY || kind == UpDeviceKind::UP_DEVICE_KIND_UPS;
|
||||||
|
|
||||||
|
std::string percentString = "";
|
||||||
|
|
||||||
|
std::string tooltip = "";
|
||||||
|
|
||||||
|
if (devices.size() == 0 && !displayDeviceValid && hideIfEmpty) {
|
||||||
|
event_box_.set_visible(false);
|
||||||
|
goto update;
|
||||||
|
}
|
||||||
|
|
||||||
|
event_box_.set_visible(true);
|
||||||
|
|
||||||
// TODO: Tooltip
|
// TODO: Tooltip
|
||||||
|
|
||||||
// Set percentage
|
// Set percentage
|
||||||
std::string percent_string =
|
if (displayDeviceValid) {
|
||||||
displayDeviceValid ? std::to_string(int(percentage + 0.5)) + "%" : "";
|
percentString = std::to_string(int(percentage + 0.5)) + "%";
|
||||||
label_.set_text(percent_string);
|
}
|
||||||
|
label_.set_text(percentString);
|
||||||
|
|
||||||
// Set icon
|
// Set icon
|
||||||
if (!Gtk::IconTheme::get_default()->has_icon(icon_name)) {
|
if (!Gtk::IconTheme::get_default()->has_icon(icon_name)) {
|
||||||
icon_name = (char*)"battery-missing-symbolic";
|
icon_name = (char*)"battery-missing-symbolic";
|
||||||
}
|
}
|
||||||
icon_.set_from_icon_name(icon_name, Gtk::ICON_SIZE_INVALID);
|
icon_.set_from_icon_name(icon_name, Gtk::ICON_SIZE_INVALID);
|
||||||
}
|
|
||||||
|
|
||||||
|
update:
|
||||||
// Call parent update
|
// Call parent update
|
||||||
AModule::update();
|
AModule::update();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue