From eb72d59ed1858209bec9d68f4da844da525e6b54 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Thu, 1 Aug 2019 20:41:13 +0200 Subject: [PATCH] [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! --- bumblebee/engine.py | 7 +++++++ bumblebee/theme.py | 3 +++ 2 files changed, 10 insertions(+) diff --git a/bumblebee/engine.py b/bumblebee/engine.py index 2efa2d4..b6b52b9 100644 --- a/bumblebee/engine.py +++ b/bumblebee/engine.py @@ -41,6 +41,7 @@ class Module(object): self.error = None self._next = int(time.time()) self._default_interval = 0 + self._engine = engine self._configFile = None 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: self._widgets = widgets if isinstance(widgets, list) else [widgets] + def theme(self): + return self._engine.theme() + def widgets(self, widgets=None): """Return the widgets to draw for this module""" if widgets: @@ -160,6 +164,9 @@ class Engine(object): self.input.start() + def theme(self): + return self._theme + def _toggle_minimize(self, event): for module in self._modules: widget = module.widget_by_id(event["instance"]) diff --git a/bumblebee/theme.py b/bumblebee/theme.py index 7e6a8c5..d7e8471 100644 --- a/bumblebee/theme.py +++ b/bumblebee/theme.py @@ -105,6 +105,9 @@ class Theme(object): if icon is 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): """Return padding for widget""" return self._get(widget, "padding", "")