[theme] Fix cycling through widget styles
Cycled widget styles (such as the battery charging style) were broken until now. The reason for this: They maintain state that represents the current cycle position (i.e. what is the current icon that is being displayed), but that is done in a way that uses repr() on the widget object. Since the widget objects are re-created each time the bar is drawn, this is a deeply flawed design. Instead, use the instance() of the widget for now.
This commit is contained in:
parent
31067159d6
commit
20858991b9
2 changed files with 6 additions and 3 deletions
|
@ -78,6 +78,10 @@ class Config(object):
|
||||||
return self._store.get(name, default)
|
return self._store.get(name, default)
|
||||||
|
|
||||||
def increase(self, name, limit, default):
|
def increase(self, name, limit, default):
|
||||||
|
if not name in self._store:
|
||||||
|
self._store[name] = default
|
||||||
|
return default
|
||||||
|
|
||||||
self._store[name] += 1
|
self._store[name] += 1
|
||||||
if self._store[name] >= limit:
|
if self._store[name] >= limit:
|
||||||
self._store[name] = default
|
self._store[name] = default
|
||||||
|
|
|
@ -120,9 +120,8 @@ class Theme:
|
||||||
value = instance_state_theme.get(name, value)
|
value = instance_state_theme.get(name, value)
|
||||||
|
|
||||||
if type(value) is list:
|
if type(value) is list:
|
||||||
key = "{}{}".format(repr(widget), value)
|
key = "{}{}".format(widget.instance(), value)
|
||||||
idx = self._config.parameter(key, 0)
|
idx = self._config.increase(key, len(value), 0)
|
||||||
self._config.increase(key, len(value), 0)
|
|
||||||
value = value[idx]
|
value = value[idx]
|
||||||
|
|
||||||
return value if value else default
|
return value if value else default
|
||||||
|
|
Loading…
Reference in a new issue