[core/output] Move widget/module handling inside output
The core.output module now manages the list of modules and retrieves the widgets inside draw() itself. That way, details of drawing/updating widgets are not visible from the outside anymore.
This commit is contained in:
parent
96c7b762b2
commit
445c5a65f1
4 changed files with 52 additions and 11 deletions
|
@ -4,8 +4,14 @@ import time
|
|||
|
||||
class i3(object):
|
||||
def __init__(self):
|
||||
self._modules = []
|
||||
self.clear()
|
||||
|
||||
def modules(self, modules=None):
|
||||
if not modules:
|
||||
return self._modules
|
||||
self._modules = modules if isinstance(modules, list) else [ modules ]
|
||||
|
||||
def draw(self, what):
|
||||
data = getattr(self, what)()
|
||||
if 'data' in data:
|
||||
|
@ -26,15 +32,15 @@ class i3(object):
|
|||
def clear(self):
|
||||
self._statusline = []
|
||||
|
||||
def append(self, module):
|
||||
for widget in module.widgets():
|
||||
self._statusline.append({
|
||||
'full_text': widget.full_text()
|
||||
})
|
||||
|
||||
def statusline(self):
|
||||
status = []
|
||||
for module in self._modules:
|
||||
for widget in module.widgets():
|
||||
status.append({
|
||||
'full_text': widget.full_text()
|
||||
})
|
||||
return {
|
||||
'data': self._statusline,
|
||||
'data': status,
|
||||
'suffix': ','
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue