bumblebee-status/core/widget.py

45 lines
1.2 KiB
Python
Raw Normal View History

import core.input
import core.decorators
import util.store
class Widget(util.store.Store, core.input.Object):
2020-03-01 14:36:12 +01:00
def __init__(self, full_text='', name=None, module=None):
super(Widget, self).__init__()
self._full_text = full_text
2020-03-01 14:36:12 +01:00
self._module = module
self._name = name
def name(self):
return self._name
def full_text(self, value=None):
if value:
self._full_text = value
else:
if callable(self._full_text):
return self._full_text(self)
return self._full_text
2020-02-24 14:54:11 +01:00
def module(self, module=None):
if not module:
return self._module
self._module = module
def state(self):
rv = []
2020-03-13 13:56:08 +01:00
if self.get('state', None):
tmp = self.get('state')
if isinstance(tmp, list):
rv.extend(tmp)
else:
rv.append(tmp)
if self._module:
2020-03-13 13:56:08 +01:00
tmp = self._module.state(self)
if isinstance(tmp, list):
rv.extend(tmp)
else:
rv.append(tmp)
return rv if isinstance(rv, list) else [rv]
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4