[core] Make error widget scrollable

Restrict error module to 15 characters and make it scrollable.
This commit is contained in:
Tobias Witek 2020-02-23 14:47:47 +01:00
parent a69e058dd1
commit 65186baea6
4 changed files with 8 additions and 4 deletions

View file

@ -3,6 +3,7 @@ import logging
import core.input import core.input
import core.widget import core.widget
import core.decorators
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -47,7 +48,10 @@ class Error(Module):
self._module = module self._module = module
self._error = error self._error = error
def full_text(self): self.widgets()[0].set('theme.width', 15)
@core.decorators.scrollable
def full_text(self, widget):
return '{}: {}'.format(self._module, self._error) return '{}: {}'.format(self._module, self._error)
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

View file

@ -11,7 +11,7 @@ class Widget(util.store.Store, core.input.Object):
self._full_text = value self._full_text = value
else: else:
if callable(self._full_text): if callable(self._full_text):
return self._full_text() return self._full_text(self)
return self._full_text return self._full_text
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

View file

@ -113,7 +113,7 @@ class Module(core.module.Module):
logging.error('no pulseaudio device found') logging.error('no pulseaudio device found')
return 'n/a' return 'n/a'
def volume(self): def volume(self, widget):
if self._failed == True: if self._failed == True:
return 'n/a' return 'n/a'
if int(self._mono) > 0: if int(self._mono) > 0:

View file

@ -33,7 +33,7 @@ class Module(core.module.Module):
def default_format(self): def default_format(self):
return '%x %X' return '%x %X'
def full_text(self): def full_text(self, widget):
enc = locale.getpreferredencoding() enc = locale.getpreferredencoding()
retval = datetime.datetime.now().strftime(self._fmt) retval = datetime.datetime.now().strftime(self._fmt)
if hasattr(retval, 'decode'): if hasattr(retval, 'decode'):