[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
This commit is contained in:
parent
86dad7436e
commit
fdcc908d83
2 changed files with 7 additions and 0 deletions
|
@ -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"):
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue