bumblebee-status/core/widget.py
tobi-wan-kenobi 9cd9ff626d [core] make widget name an attribute
first, this fixes #607

also, i think it slightly simplifies code to make "simple" stuff like
names, etc. attributes instead of methods all the time.

so, expect this to be extended to other components, as well.
2020-04-30 12:42:34 +02:00

35 lines
1 KiB
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 module(self, module=None):
if not module:
return self.__module
self.__module = module
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