From 92be7d3020389b92da9b57b70984b6f7f30f2404 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Sat, 22 Apr 2017 08:24:52 +0200 Subject: [PATCH] [core] Added min-width and alignment themeing Added theme-options ("minwidth" and "align") for setting the minimum width and the alignment of a widget. Also, allow widget to provide defaults for the theme options by setting an attribute in their store called "theme-". For example, a widget can now define a default alignment by using: widget.set("theme-align", "default-value"). --- bumblebee/output.py | 2 ++ bumblebee/theme.py | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/bumblebee/output.py b/bumblebee/output.py index 578fb30..bf6a689 100644 --- a/bumblebee/output.py +++ b/bumblebee/output.py @@ -89,6 +89,8 @@ class I3BarOutput(object): "background": self._theme.bg(widget), "separator_block_width": self._theme.separator_block_width(widget), "separator": True if separator is None else False, + "min_width": self._theme.minwidth(widget), + "align": self._theme.align(widget), "instance": widget.id, "name": module.id, }) diff --git a/bumblebee/theme.py b/bumblebee/theme.py index 08584c7..a424f4a 100644 --- a/bumblebee/theme.py +++ b/bumblebee/theme.py @@ -74,6 +74,14 @@ class Theme(object): """Return the background color for this widget""" return self._get(widget, "bg", None) + def align(self, widget): + """Return the widget alignment""" + return self._get(widget, "align", None) + + def minwidth(self, widget): + """Return the minimum width string for this widget""" + return self._get(widget, "minwidth", "") + def separator(self, widget): """Return the separator between widgets""" return self._get(widget, "separator", None) @@ -131,6 +139,7 @@ class Theme(object): state_themes.append(self._get(widget, state, {})) value = self._defaults.get(name, default) + value = widget.get("theme-{}".format(name), value) value = self._cycle.get(name, value) value = module_theme.get(name, value)