[core/theme] Add prefix/postfix methods

Add a way to specify prefix and postfix strings to the full text of a
widget's text. Currently, the theme does not fill those yet.

see #23
This commit is contained in:
Tobi-wan Kenobi 2016-12-08 11:31:20 +01:00
parent e6666becb3
commit 64f5fc100e
6 changed files with 73 additions and 6 deletions

View file

@ -19,8 +19,8 @@ class Widget(object):
class I3BarOutput(object):
"""Manage output according to the i3bar protocol"""
def __init__(self):
pass
def __init__(self, theme):
self._theme = theme
def start(self):
"""Print start preamble for i3bar protocol"""
@ -32,8 +32,13 @@ class I3BarOutput(object):
def draw_widget(self, result, widget):
"""Draw a single widget"""
full_text = widget.full_text()
if self._theme.prefix():
full_text = "{}{}".format(self._theme.prefix(), full_text)
if self._theme.suffix():
full_text = "{}{}".format(full_text, self._theme.suffix())
result.append({
u"full_text": widget.full_text()
u"full_text": "{}".format(full_text)
})
def draw(self, widgets, engine=None):