Use .timer_setup() to setup timer, fix error from cffi markup renderer
1. In qtile-0.9.1 .timeout_add() must be run after ._configure(). In qtile-0.8.0 .timer_setup() is not run automatically. 2. New pango markup renderer (qtile-0.9.1) is not accepting unicode() objects, only str() ones as it converts them to cffi `char *`. Fixes #1313
This commit is contained in:
parent
86bb1616b4
commit
1742571b63
|
@ -15,15 +15,16 @@ class QTilePowerline(Powerline):
|
|||
class PowerlineTextBox(TextBox):
|
||||
def __init__(self, timeout=2, text=' ', width=CALCULATED, side='right', **config):
|
||||
super(PowerlineTextBox, self).__init__(text, width, **config)
|
||||
self.timeout_add(timeout, self.update)
|
||||
self.side = side
|
||||
self.update_interval = timeout
|
||||
self.did_run_timer_setup = False
|
||||
powerline = QTilePowerline(ext='wm', renderer_module='pango_markup')
|
||||
powerline.setup(self)
|
||||
|
||||
def update(self):
|
||||
if not self.configured:
|
||||
return True
|
||||
self.text = self.powerline.render(side=self.side)
|
||||
self.text = self.powerline.render(side=self.side).encode('utf-8')
|
||||
self.bar.draw()
|
||||
return True
|
||||
|
||||
|
@ -33,6 +34,11 @@ class PowerlineTextBox(TextBox):
|
|||
def cmd_get(self):
|
||||
return self.text
|
||||
|
||||
def timer_setup(self):
|
||||
if not self.did_run_timer_setup:
|
||||
self.did_run_timer_setup = True
|
||||
self.timeout_add(self.update_interval, self.update)
|
||||
|
||||
def _configure(self, qtile, bar):
|
||||
super(PowerlineTextBox, self)._configure(qtile, bar)
|
||||
self.layout = self.drawer.textlayout(
|
||||
|
@ -43,6 +49,7 @@ class PowerlineTextBox(TextBox):
|
|||
self.fontshadow,
|
||||
markup=True,
|
||||
)
|
||||
self.timer_setup()
|
||||
|
||||
|
||||
# TODO: Remove this at next major release
|
||||
|
|
Loading…
Reference in New Issue