Skip to content

Commit

Permalink
Merge pull request #286 from nwg-piotr/values
Browse files Browse the repository at this point in the history
Separate Controls display value switches
  • Loading branch information
nwg-piotr authored Feb 29, 2024
2 parents afce0ad + a490edc commit 194e8d0
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 90 deletions.
35 changes: 27 additions & 8 deletions nwg_panel/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@
"controls-settings": {
"components": ["brightness", "volume", "battery"],
"commands": {"battery": ""},
"show-values": False,
"show-brightness": False,
"show-volume": False,
"show-battery": True,
"interval": 1,
"icon-size": 16,
"hover-opens": False,
Expand Down Expand Up @@ -2769,7 +2771,9 @@ def edit_brightness_slider(self, *args):
settings = self.panel["brightness-slider"]

defaults = {
"show-values": True,
"show-brightness": False,
"show-volume": False,
"show-battery": True,
"icon-size": 16,
"interval": 10,
"hover-opens": False,
Expand Down Expand Up @@ -3551,9 +3555,11 @@ def edit_controls(self, *args):
],
"commands": {
},
"show-values": False,
"show-brightness": False,
"show-volume": False,
"show-battery": True,
"output-switcher": False,
"per-app-volume" : False,
"per-app-volume": False,
"backlight-controller": "brightnessctl",
"backlight-device": "",
"interval": 1,
Expand Down Expand Up @@ -3704,7 +3710,12 @@ def edit_controls(self, *args):
builder.get_object("lbl-interval").set_text("{}:".format(voc["refresh-interval"]))
builder.get_object("lbl-angle").set_text("{}:".format(voc["angle"]))
builder.get_object("angle").set_tooltip_text(voc["angle-tooltip"])
builder.get_object("show-values").set_label(voc["values-in-widget"])
builder.get_object("brightness-value").set_label(voc["brightness-value"])
builder.get_object("brightness-value").set_tooltip_text(voc["values-in-widget-tooltip"])
builder.get_object("volume-value").set_label(voc["volume-value"])
builder.get_object("volume-value").set_tooltip_text(voc["values-in-widget-tooltip"])
builder.get_object("battery-value").set_label(voc["battery-value"])
builder.get_object("battery-value").set_tooltip_text(voc["values-in-widget-tooltip"])
builder.get_object("hover-opens").set_label(voc["widget-hover-opens"])
builder.get_object("leave-closes").set_label(voc["window-leave-closes"])
builder.get_object("click-closes").set_label(voc["click-outside-closes"])
Expand Down Expand Up @@ -3746,8 +3757,14 @@ def edit_controls(self, *args):
self.ctrl_interval.configure(adj, 1, 0)
self.ctrl_interval.set_value(settings["interval"])

self.ctrl_show_values = builder.get_object("show-values")
self.ctrl_show_values.set_active(settings["show-values"])
self.ctrl_brightness_value = builder.get_object("brightness-value")
self.ctrl_brightness_value.set_active(settings["show-brightness"])

self.ctrl_volume_value = builder.get_object("volume-value")
self.ctrl_volume_value.set_active(settings["show-volume"])

self.ctrl_battery_value = builder.get_object("battery-value")
self.ctrl_battery_value.set_active(settings["show-battery"])

self.ctrl_hover_opens = builder.get_object("hover-opens")
self.ctrl_hover_opens.set_active(settings["hover-opens"])
Expand Down Expand Up @@ -3828,7 +3845,9 @@ def update_controls(self):
settings["window-margin-vertical"] = int(self.ctrl_window_margin_vertical.get_value())
settings["icon-size"] = int(self.ctrl_icon_size.get_value())
settings["interval"] = int(self.ctrl_interval.get_value())
settings["show-values"] = self.ctrl_show_values.get_active()
settings["show-brightness"] = self.ctrl_brightness_value.get_active()
settings["show-volume"] = self.ctrl_volume_value.get_active()
settings["show-battery"] = self.ctrl_battery_value.get_active()
settings["hover-opens"] = self.ctrl_hover_opens.get_active()
settings["leave-closes"] = self.ctrl_leave_closes.get_active()
settings["click-closes"] = self.ctrl_click_closes.get_active()
Expand Down
148 changes: 86 additions & 62 deletions nwg_panel/glade/config_controls.glade
Original file line number Diff line number Diff line change
Expand Up @@ -193,66 +193,6 @@
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="leave-closes">
<property name="label" translatable="yes">Window leave closes</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="tooltip-text" translatable="yes">Determines if to close the Controls
window when left</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">16</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="click-closes">
<property name="label" translatable="yes">Click outside closes</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="tooltip-text" translatable="yes">Determines if to close the Controls
window on mouse click outside it</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">16</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="show-values">
<property name="label" translatable="yes">Values in widget</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="tooltip-text" translatable="yes">Determines if show the Controls
values in the panel widget</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">15</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="hover-opens">
<property name="label" translatable="yes">Widget hover opens</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="tooltip-text" translatable="yes">Determines if to open the Controls window
on panel Controls widget pointed</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">15</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl-angle">
<property name="visible">True</property>
Expand Down Expand Up @@ -462,10 +402,94 @@ the horizontal, in degrees, measured counterclockwise</property>
</packing>
</child>
<child>
<placeholder/>
<object class="GtkCheckButton" id="hover-opens">
<property name="label" translatable="yes">Widget hover opens</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="tooltip-text" translatable="yes">Determines if to open the Controls window
on panel Controls widget pointed</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">15</property>
</packing>
</child>
<child>
<placeholder/>
<object class="GtkCheckButton" id="leave-closes">
<property name="label" translatable="yes">Window leave closes</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="tooltip-text" translatable="yes">Determines if to close the Controls
window when left</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">15</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="click-closes">
<property name="label" translatable="yes">Click outside closes</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="tooltip-text" translatable="yes">Determines if to close the Controls
window on mouse click outside it</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">3</property>
<property name="top-attach">15</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="brightness-value">
<property name="label" translatable="yes">Brightness value</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="tooltip-text" translatable="yes">Determines if show the Controls
values in the panel widget</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">16</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="volume-value">
<property name="label" translatable="yes">Volume value</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="tooltip-text" translatable="yes">Determines if show the Controls
values in the panel widget</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">16</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="battery-value">
<property name="label" translatable="yes">Battery value</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="tooltip-text" translatable="yes">Determines if show the Controls
values in the panel widget</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="left-attach">3</property>
<property name="top-attach">16</property>
</packing>
</child>
<child>
<placeholder/>
Expand Down
5 changes: 4 additions & 1 deletion nwg_panel/langs/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
"battery-low-check-tooltip": "Set 0 to disable.",
"battery-low-notification": "Battery low notification at [%]",
"battery-tooltip": "Depends on `python-psutil`.",
"battery-value": "Battery value",
"bottom-margin": "Bottom margin",
"brightness": "Brightness",
"brightness-slider": "Brightness slider",
"brightness-tooltip": "Depends on `light` or `brightnessctl`.",
"brightness-value": "Brightness value",
"button-css-name": "Button CSS name",
"button-name-tooltip": "Attention! Renaming an existing\nbutton will create a new one.",
"buttons": "Buttons",
Expand Down Expand Up @@ -248,11 +250,12 @@
"units": "Units",
"use-signal": "Use signal",
"user-menu": "User menu",
"values-in-widget": "Values in widget",
"values-in-widget-tooltip": "Show value in the panel widget",
"vertical-padding": "Vertical padding",
"vertical-window-margin": "Vertical window margin",
"visibility": "Visibility",
"volume": "Volume",
"volume-value": "Volume value",
"volume-tooltip": "Requires `pamixer` or `pactl` commands installed.",
"weather-icons": "Weather icons",
"weatherbit-api-key": "Weatherbit API key",
Expand Down
5 changes: 4 additions & 1 deletion nwg_panel/langs/pl_PL.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
"battery-low-check-tooltip": "Ustaw 0 by wyłączyć.",
"battery-low-notification": "Alarmuj o słabej baterii przy [%]",
"battery-tooltip": "Zależy od paczki `python-psutil`.",
"battery-value": "Wartość baterii",
"bottom-margin": "Margines dolny",
"brightness": "Jasność",
"brightness-slider": "Suwak jasności",
"brightness-tooltip": "Zależy od pakietu `light` lub `brightnessctl`.",
"brightness-value": "Wartość jasności",
"button-css-name": "Nazwa CSS przycisku",
"button-name-tooltip": "Uwaga! Zmiana nazwy przycisku\n spowoduje utworzenie nowego.",
"buttons": "Przyciski",
Expand Down Expand Up @@ -248,12 +250,13 @@
"units": "Jednostki",
"use-signal": "Używaj sygnału",
"user-menu": "Menu użytkownika",
"values-in-widget": "Wartości w widżecie",
"values-in-widget-tooltip": "Pokazuj wartość w widgecie panelu",
"vertical-padding": "Wypełnienie pionowe",
"vertical-window-margin": "Pionowy margines okna",
"visibility": "Widoczność",
"volume": "Głośność",
"volume-tooltip": "Wymaga zainstalowanego polecenia `pamixer` lub `pactl`.",
"volume-value": "Wartość głośności",
"weather-icons": "Ikonki pogody",
"weatherbit-api-key": "Klucz API Weatherbit",
"widget-css-name": "Nazwa CSS widżetu",
Expand Down
39 changes: 22 additions & 17 deletions nwg_panel/modules/controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,39 +28,44 @@ def __init__(self, settings, position, alignment, width, monitor=None, icons_pat
self.icons_path = icons_path
Gtk.EventBox.__init__(self)

check_key(settings, "show-values", True)
check_key(settings, "icon-size", 16)
check_key(settings, "interval", 1)
check_key(settings, "icon-size", 16)
check_key(settings, "hover-opens", False)
check_key(settings, "leave-closes", True)
check_key(settings, "click-closes", False)
check_key(settings, "root-css-name", "controls-overview")
check_key(settings, "components", ["brightness", "battery", "volume", "readme", "processes"])
check_key(settings, "angle", 0.0)
check_key(settings, "battery-low-level", 20)
check_key(settings, "battery-low-interval", 3)
check_key(settings, "readme-label", "README")
check_key(settings, "processes-label", "Processes")
defaults = {
"show-brightness": False,
"show-volume": False,
"show-battery": True,
"icon-size": 16,
"interval": 1,
"hover-opens": True,
"leave-closes": False,
"click-closes": True,
"root-css-name": "controls-overview",
"components": ["brightness", "battery", "volume", "readme", "processes"],
"angle": 0,
"battery-low-level": 20,
"battery-low-interval": 3,
"readme-label": "README",
"processes-label": "Processes"
}
for key in defaults:
check_key(settings, key, defaults[key])

self.set_property("name", settings["root-css-name"])

self.icon_size = settings["icon-size"]

self.bri_icon_name = "view-refresh-symbolic"
self.bri_image = Gtk.Image.new_from_icon_name(self.bri_icon_name, Gtk.IconSize.MENU)
self.bri_label = Gtk.Label() if settings["show-values"] else None
self.bri_label = Gtk.Label() if settings["show-brightness"] else None
self.bri_value = 0

self.vol_icon_name = "view-refresh-symbolic"
self.vol_image = Gtk.Image.new_from_icon_name(self.vol_icon_name, Gtk.IconSize.MENU)
self.vol_label = Gtk.Label() if settings["show-values"] else None
self.vol_label = Gtk.Label() if settings["show-volume"] else None
self.vol_value = 0
self.vol_muted = False

self.bat_icon_name = "view-refresh-symbolic"
self.bat_image = Gtk.Image.new_from_icon_name(self.bat_icon_name, Gtk.IconSize.MENU)
self.bat_label = Gtk.Label() if settings["show-values"] else None
self.bat_label = Gtk.Label() if settings["show-battery"] else None
self.bat_value = 0
self.bat_time = ""
self.bat_charging = False
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def read(f_name):

setup(
name='nwg-panel',
version='0.9.24',
version='0.9.25',
description='GTK3-based panel for sway and Hyprland Wayland compositors',
packages=find_packages(),
include_package_data=True,
Expand Down

0 comments on commit 194e8d0

Please sign in to comment.