mirror of
https://github.com/powerline/powerline.git
synced 2025-07-23 13:55:45 +02:00
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):
|
class PowerlineTextBox(TextBox):
|
||||||
def __init__(self, timeout=2, text=' ', width=CALCULATED, side='right', **config):
|
def __init__(self, timeout=2, text=' ', width=CALCULATED, side='right', **config):
|
||||||
super(PowerlineTextBox, self).__init__(text, width, **config)
|
super(PowerlineTextBox, self).__init__(text, width, **config)
|
||||||
self.timeout_add(timeout, self.update)
|
|
||||||
self.side = side
|
self.side = side
|
||||||
|
self.update_interval = timeout
|
||||||
|
self.did_run_timer_setup = False
|
||||||
powerline = QTilePowerline(ext='wm', renderer_module='pango_markup')
|
powerline = QTilePowerline(ext='wm', renderer_module='pango_markup')
|
||||||
powerline.setup(self)
|
powerline.setup(self)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
if not self.configured:
|
if not self.configured:
|
||||||
return True
|
return True
|
||||||
self.text = self.powerline.render(side=self.side)
|
self.text = self.powerline.render(side=self.side).encode('utf-8')
|
||||||
self.bar.draw()
|
self.bar.draw()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -33,6 +34,11 @@ class PowerlineTextBox(TextBox):
|
|||||||
def cmd_get(self):
|
def cmd_get(self):
|
||||||
return self.text
|
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):
|
def _configure(self, qtile, bar):
|
||||||
super(PowerlineTextBox, self)._configure(qtile, bar)
|
super(PowerlineTextBox, self)._configure(qtile, bar)
|
||||||
self.layout = self.drawer.textlayout(
|
self.layout = self.drawer.textlayout(
|
||||||
@ -43,6 +49,7 @@ class PowerlineTextBox(TextBox):
|
|||||||
self.fontshadow,
|
self.fontshadow,
|
||||||
markup=True,
|
markup=True,
|
||||||
)
|
)
|
||||||
|
self.timer_setup()
|
||||||
|
|
||||||
|
|
||||||
# TODO: Remove this at next major release
|
# TODO: Remove this at next major release
|
||||||
|
Loading…
x
Reference in New Issue
Block a user