From 20858991b97f58f41e5cd020a64f624a46ce8369 Mon Sep 17 00:00:00 2001 From: Tobi-wan Kenobi Date: Fri, 2 Dec 2016 22:35:28 +0100 Subject: [PATCH] [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. --- bumblebee/config.py | 4 ++++ bumblebee/theme.py | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bumblebee/config.py b/bumblebee/config.py index 57958ac..49005ad 100644 --- a/bumblebee/config.py +++ b/bumblebee/config.py @@ -78,6 +78,10 @@ class Config(object): return self._store.get(name, default) def increase(self, name, limit, default): + if not name in self._store: + self._store[name] = default + return default + self._store[name] += 1 if self._store[name] >= limit: self._store[name] = default diff --git a/bumblebee/theme.py b/bumblebee/theme.py index 2f7d5c7..42e6c01 100644 --- a/bumblebee/theme.py +++ b/bumblebee/theme.py @@ -120,9 +120,8 @@ class Theme: value = instance_state_theme.get(name, value) if type(value) is list: - key = "{}{}".format(repr(widget), value) - idx = self._config.parameter(key, 0) - self._config.increase(key, len(value), 0) + key = "{}{}".format(widget.instance(), value) + idx = self._config.increase(key, len(value), 0) value = value[idx] return value if value else default