[core] Each module can now access theme data
Add a method "theme()" to the generic module to have access to the theme information. Specifically, "theme().get(widget, attribute, default_value)" can be used to retrieve theming for a widget with an arbitrary attribute. This is in response to #412 - thanks to @bbernhard for the suggestion!
This commit is contained in:
parent
93606315e3
commit
eb72d59ed1
2 changed files with 10 additions and 0 deletions
|
@ -41,6 +41,7 @@ class Module(object):
|
||||||
self.error = None
|
self.error = None
|
||||||
self._next = int(time.time())
|
self._next = int(time.time())
|
||||||
self._default_interval = 0
|
self._default_interval = 0
|
||||||
|
self._engine = engine
|
||||||
|
|
||||||
self._configFile = None
|
self._configFile = None
|
||||||
for cfg in [os.path.expanduser("~/.bumblebee-status.conf"), os.path.expanduser("~/.config/bumblebee-status.conf")]:
|
for cfg in [os.path.expanduser("~/.bumblebee-status.conf"), os.path.expanduser("~/.config/bumblebee-status.conf")]:
|
||||||
|
@ -56,6 +57,9 @@ class Module(object):
|
||||||
if widgets:
|
if widgets:
|
||||||
self._widgets = widgets if isinstance(widgets, list) else [widgets]
|
self._widgets = widgets if isinstance(widgets, list) else [widgets]
|
||||||
|
|
||||||
|
def theme(self):
|
||||||
|
return self._engine.theme()
|
||||||
|
|
||||||
def widgets(self, widgets=None):
|
def widgets(self, widgets=None):
|
||||||
"""Return the widgets to draw for this module"""
|
"""Return the widgets to draw for this module"""
|
||||||
if widgets:
|
if widgets:
|
||||||
|
@ -160,6 +164,9 @@ class Engine(object):
|
||||||
|
|
||||||
self.input.start()
|
self.input.start()
|
||||||
|
|
||||||
|
def theme(self):
|
||||||
|
return self._theme
|
||||||
|
|
||||||
def _toggle_minimize(self, event):
|
def _toggle_minimize(self, event):
|
||||||
for module in self._modules:
|
for module in self._modules:
|
||||||
widget = module.widget_by_id(event["instance"])
|
widget = module.widget_by_id(event["instance"])
|
||||||
|
|
|
@ -105,6 +105,9 @@ class Theme(object):
|
||||||
if icon is None:
|
if icon is None:
|
||||||
return self._get(widget, "prefix", None)
|
return self._get(widget, "prefix", None)
|
||||||
|
|
||||||
|
def get(self, widget, attribute, default_value=""):
|
||||||
|
return self._get(widget, attribute, default_value)
|
||||||
|
|
||||||
def padding(self, widget):
|
def padding(self, widget):
|
||||||
"""Return padding for widget"""
|
"""Return padding for widget"""
|
||||||
return self._get(widget, "padding", "")
|
return self._get(widget, "padding", "")
|
||||||
|
|
Loading…
Reference in a new issue