bumblebee-status/core/widget.py
tobi-wan-kenobi b27956071f [core/widget] Make module an attribute
Instead of having an artifical getter/setter method, just make module a
plain attribute.
2020-04-30 12:46:57 +02:00

30 lines
903 B
Python

import core.input
import core.decorators
import util.store
class Widget(util.store.Store, core.input.Object):
def __init__(self, full_text='', name=None, module=None):
super(Widget, self).__init__()
self.__full_text = full_text
self.module = module
self.name = 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
def state(self):
rv = []
if self.get('state', None):
tmp = self.get('state')
rv = tmp[:] if isinstance(tmp, list) else [tmp]
if self.module:
tmp = self.module.state(self)
rv.extend(tmp if isinstance(tmp, list) else [tmp])
return rv
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4