diff --git a/metadata/panel.xml b/metadata/panel.xml index ca7241b..986c230 100644 --- a/metadata/panel.xml +++ b/metadata/panel.xml @@ -133,6 +133,14 @@ <_short>Battery Font default + + <_short>Network diff --git a/src/panel/widgets/battery.cpp b/src/panel/widgets/battery.cpp index 409bcd0..3cb437c 100644 --- a/src/panel/widgets/battery.cpp +++ b/src/panel/widgets/battery.cpp @@ -174,6 +174,23 @@ void WayfireBatteryInfo::update_details() } } +void WayfireBatteryInfo::on_battery_scroll(GdkEventScroll *event) +{ + if (scroll_counter <= 0) { + if (event->delta_y < 0) + { + std::system(battery_scrollup_command.value().c_str()); + } else if (0 < event->delta_y) + { + std::system(battery_scrolldown_command.value().c_str()); + } + + scroll_counter = 3; + } + + scroll_counter--; +} + void WayfireBatteryInfo::update_state() { std::cout << "unimplemented reached, in battery.cpp: " @@ -222,10 +239,11 @@ bool WayfireBatteryInfo::setup_dbus() } // TODO: simplify config loading - static const std::string default_font = "default"; void WayfireBatteryInfo::init(Gtk::HBox *container) { + scroll_counter = 0; + if (!setup_dbus()) { return; @@ -234,6 +252,10 @@ void WayfireBatteryInfo::init(Gtk::HBox *container) button_box.add(icon); button.get_style_context()->add_class("flat"); + button.set_events(Gdk::SCROLL_MASK | Gdk::SMOOTH_SCROLL_MASK); + button.signal_scroll_event().connect_notify( + sigc::mem_fun(this, &WayfireBatteryInfo::on_battery_scroll)); + status_opt.set_callback([=] () { update_details(); }); font_opt.set_callback([=] () { update_font(); }); size_opt.set_callback([=] () { update_icon(); }); diff --git a/src/panel/widgets/battery.hpp b/src/panel/widgets/battery.hpp index b2a5d98..15428e8 100644 --- a/src/panel/widgets/battery.hpp +++ b/src/panel/widgets/battery.hpp @@ -23,6 +23,8 @@ class WayfireBatteryInfo : public WayfireWidget { WfOption status_opt{"panel/battery_status"}; WfOption font_opt{"panel/battery_font"}; + WfOption battery_scrollup_command{"panel/battery_scrollup_command"}; + WfOption battery_scrolldown_command{"panel/battery_scrolldown_command"}; WfOption size_opt{"panel/battery_icon_size"}; WfOption invert_opt{"panel/battery_icon_invert"}; @@ -30,6 +32,8 @@ class WayfireBatteryInfo : public WayfireWidget Gtk::Label label; Gtk::HBox button_box; + int scroll_counter; + Gtk::Image icon; DBusConnection connection; @@ -41,6 +45,7 @@ class WayfireBatteryInfo : public WayfireWidget void update_icon(); void update_details(); void update_state(); + void on_battery_scroll(GdkEventScroll *event); void on_properties_changed( const Gio::DBus::Proxy::MapChangedProperties& properties,