Skip to content

Commit

Permalink
Set default visibility setting for dedicated battery monitors
Browse files Browse the repository at this point in the history
  • Loading branch information
ReinvdZee committed Jan 3, 2025
1 parent ecdcce2 commit f3aa21d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions delegates/batterydata.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
class BatteryConfiguration(object):
""" Holds custom mapping information about a service that corresponds to a
battery. """
def __init__(self, parent, service):
def __init__(self, parent, service, default_visibility):
self.parent = parent
self.service = str(service)
self.default_visibility = default_visibility
self.name = None
self.enabled = False
self.bind_settings()
Expand All @@ -29,7 +30,7 @@ def bind_settings(self):
"", 0, 0, callback=partial(self.on_setting_change, "name", str))
self.enabled_item = self.parent._settings.addSetting(
"/Settings/SystemSetup/Batteries/Configuration/{}/Enabled".format(config_id),
0, 0, 1, callback=partial(self.on_setting_change, "enabled", bool))
self.default_visibility, 0, 1, callback=partial(self.on_setting_change, "enabled", bool))
self.service_item.set_value(self.service)
self.enabled = bool(self.enabled_item.get_value())
self.name = str(self.name_item.get_value())
Expand Down Expand Up @@ -253,7 +254,7 @@ def add_trackers(self, service, *args):
self.batteries[service].extend(args)
for t in args:
if t.service_id not in self.configured_batteries:
self.add_configured_battery(t.service_id)
self.add_configured_battery(t.service_id, type(t) is BatteryTracker)

def is_enabled(self, tracker):
return tracker.service_id in self.configured_batteries and \
Expand All @@ -269,9 +270,9 @@ def update_values(self, newvalues=None):
self.changed = any([tracker.update() for tracker in chain.from_iterable(
self.batteries.values())]) or self.changed

def add_configured_battery(self, service):
def add_configured_battery(self, service, default_visibility):
self.configured_batteries[service] = BatteryConfiguration(
self, service)
self, service, default_visibility)

def _on_timer(self):
active = self._dbusservice['/ActiveBatteryService']
Expand Down

0 comments on commit f3aa21d

Please sign in to comment.