diff --git a/bumblebee/output.py b/bumblebee/output.py index ace407f..de80d90 100644 --- a/bumblebee/output.py +++ b/bumblebee/output.py @@ -42,8 +42,9 @@ class I3BarOutput(object): def draw(self, widget, engine=None): """Draw a single widget""" full_text = widget.full_text() - prefix = self._theme.prefix(widget) - suffix = self._theme.suffix(widget) + padding = self._theme.padding(widget) + prefix = self._theme.prefix(widget, padding) + suffix = self._theme.suffix(widget, padding) if prefix: full_text = u"{}{}".format(prefix, full_text) if suffix: diff --git a/bumblebee/theme.py b/bumblebee/theme.py index 6e328e0..196a574 100644 --- a/bumblebee/theme.py +++ b/bumblebee/theme.py @@ -38,17 +38,21 @@ class Theme(object): self._widget = None self._prevbg = None - def prefix(self, widget): - """Return the theme prefix for a widget's full text""" - padding = self._get(widget, "padding", "") - pre = self._get(widget, "prefix", None) - return u"{}{}{}".format(padding, pre, padding) if pre else None + def padding(self, widget): + """Return padding for widget""" + return self._get(widget, "padding", "") - def suffix(self, widget): + def prefix(self, widget, default=None): + """Return the theme prefix for a widget's full text""" + padding = self.padding(widget) + pre = self._get(widget, "prefix", None) + return u"{}{}{}".format(padding, pre, padding) if pre else default + + def suffix(self, widget, default=None): """Return the theme suffix for a widget's full text""" padding = self._get(widget, "padding", "") suf = self._get(widget, "suffix", None) - return u"{}{}{}".format(padding, suf, padding) if suf else None + return u"{}{}{}".format(padding, suf, padding) if suf else default def fg(self, widget): """Return the foreground color for this widget""" diff --git a/tests/util.py b/tests/util.py index 0d78aef..314cfa0 100644 --- a/tests/util.py +++ b/tests/util.py @@ -48,6 +48,9 @@ class MockTheme(object): self.attr_separator = None self.attr_separator_block_width = 0 + def padding(self, widget): + return "" + def reset(self): pass @@ -57,10 +60,10 @@ class MockTheme(object): def separator(self, widget): return self.attr_separator - def prefix(self, widget): + def prefix(self, widget, default=None): return self.attr_prefix - def suffix(self, widget): + def suffix(self, widget, default=None): return self.attr_suffix def fg(self, widget):