From fdcc908d833e4f0f237e699a477ef03a580d1cf9 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Wed, 10 May 2017 20:01:29 +0200 Subject: [PATCH] [core] Use class theme, if no specific module theme matches For modules that use aliases, until now, *only* the alias theme was considered. This is typically a bad idea (tm), as the "generic" case is that of a module theme (e.g. "disk", not that of a theme per instance of the module (i.e. "home", "root", etc.)). Therefore, introduce the concept of a "class" theme that can be optionall overridden by a specific module theme. As a pleasant side-effect, this should bring back the disk icons for all instances of the disk module :) fixes #79 --- bumblebee/output.py | 5 +++++ bumblebee/theme.py | 2 ++ 2 files changed, 7 insertions(+) diff --git a/bumblebee/output.py b/bumblebee/output.py index ee11037..992eec6 100644 --- a/bumblebee/output.py +++ b/bumblebee/output.py @@ -47,6 +47,11 @@ class Widget(bumblebee.store.Store): self.module = module.name self._module = module + def cls(self): + if not self._module: + return None + return self._module.__module__.replace("bumblebee.modules.", "") + def state(self): """Return the widget's state""" if self._module and hasattr(self._module, "state"): diff --git a/bumblebee/theme.py b/bumblebee/theme.py index 0b2a724..eed2ea7 100644 --- a/bumblebee/theme.py +++ b/bumblebee/theme.py @@ -130,6 +130,7 @@ class Theme(object): self._cycle = self._cycles[self._cycle_idx] module_theme = self._theme.get(widget.module, {}) + class_theme = self._theme.get(widget.cls(), {}) state_themes = [] # avoid infinite recursion @@ -141,6 +142,7 @@ class Theme(object): value = self._defaults.get(name, default) value = widget.get("theme.{}".format(name), value) value = self._cycle.get(name, value) + value = class_theme.get(name, value) value = module_theme.get(name, value) for theme in state_themes: