Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions data/css/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@
padding-left: 5px;
}

.wf-panel .battery overlay label {
--bcol: rgb(from currentcolor calc(255 - r) calc(255 - g) calc(255 - b) );
text-shadow: 1px 1px 0 var(--bcol),
-1px -1px 0 var(--bcol),
-1px 1px 0 var(--bcol),
1px -1px 0 var(--bcol),
0px 1px 0 var(--bcol),
0px -1px 0 var(--bcol),
-1px 0px 0 var(--bcol),
1px 0px 0 var(--bcol);
font-weight:bold;
}

.wf-panel .notification .time {
padding-left: 5px;
padding-right: 5px;
Expand Down
4 changes: 4 additions & 0 deletions metadata/panel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@
<value>full</value>
<_name>Full Information</_name>
</desc>
<desc>
<value>percentage_overlay</value>
<_name>Percentage over Icon</_name>
</desc>
</option>
<option name="battery_icon_size" type="int">
<_short>Battery Icon Size</_short>
Expand Down
12 changes: 11 additions & 1 deletion src/panel/widgets/battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,18 @@ void WayfireBatteryInfo::update_details()
if (status_opt.value() == BATTERY_STATUS_PERCENT)
{
label.set_text(percentage_string);
overlay.remove_overlay(label);
button_box.append(label);
} else if (status_opt.value() == BATTERY_STATUS_FULL)
{
label.set_text(description);
overlay.remove_overlay(label);
button_box.append(label);
} else if (status_opt.value() == BATTERY_STATUS_OVERLAY)
{
label.set_text(percentage_string);
button_box.remove(label);
overlay.add_overlay(label);
}

if (status_opt.value() == BATTERY_STATUS_ICON)
Expand Down Expand Up @@ -215,7 +224,8 @@ void WayfireBatteryInfo::init(Gtk::Box *container)
return;
}

button_box.append(icon);
button_box.append(overlay);
overlay.set_child(icon);
icon.add_css_class("widget-icon");
button.add_css_class("battery");
button.add_css_class("flat");
Expand Down
3 changes: 3 additions & 0 deletions src/panel/widgets/battery.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <gtkmm/image.h>
#include <gtkmm/box.h>
#include <gtkmm/label.h>
#include <gtkmm/overlay.h>

#include <giomm/dbusproxy.h>
#include <giomm/dbusconnection.h>
Expand All @@ -18,6 +19,7 @@ using DBusProxy = Glib::RefPtr<Gio::DBus::Proxy>;
static const std::string BATTERY_STATUS_ICON = "icon"; // icon
static const std::string BATTERY_STATUS_PERCENT = "percentage"; // icon + percentage
static const std::string BATTERY_STATUS_FULL = "full"; // icon + percentage + TimeToFull/TimeToEmpty
static const std::string BATTERY_STATUS_OVERLAY = "percentage_overlay";

class wayfire_config;
class WayfireBatteryInfo : public WayfireWidget
Expand All @@ -29,6 +31,7 @@ class WayfireBatteryInfo : public WayfireWidget
Gtk::Button button;
Gtk::Label label;
Gtk::Box button_box;
Gtk::Overlay overlay;

Gtk::Image icon;

Expand Down