[core] Add ability to "hide" a module with all its widgets

* A module can override the method "hidden" to specify when all it's
widgets should be hidden.
* Implement hidden for cmus and spotify
* Fix problem that cmus widgets were not displayed correctly

fixes #157
This commit is contained in:
Tobias Witek 2017-08-12 17:03:04 +02:00
parent 8376e406e5
commit 9f69cc6ae9
4 changed files with 15 additions and 2 deletions

View file

@ -49,6 +49,9 @@ class Module(bumblebee.engine.Module):
self._repeat = False
self._tags = defaultdict(lambda: '')
def hidden(self):
return self._status == None
@scrollable
def description(self, widget):
return string.Formatter().vformat(self._fmt, (), self._tags)
@ -72,6 +75,7 @@ class Module(bumblebee.engine.Module):
try:
info = bumblebee.util.execute("cmus-remote -Q")
except RuntimeError:
self._status = None
pass
self._tags = defaultdict(lambda: '')
for line in info.split("\n"):