[core] do not scroll errors
to make errors easier to diagnose, do not scroll them, but instead fully show them. also, re-introduce the supplementary fields for the dwm bridge, kudos to @somospocos
This commit is contained in:
parent
4daae88a7c
commit
2ab575d190
5 changed files with 14 additions and 20 deletions
|
@ -19,7 +19,6 @@ def every(hours=0, minutes=0, seconds=0):
|
|||
def scrollable(func):
|
||||
def wrapper(module, widget):
|
||||
text = func(module, widget)
|
||||
widget.set('_raw', text)
|
||||
if not text:
|
||||
return text
|
||||
width = widget.get('theme.width', util.format.asint(module.parameter('width', 30)))
|
||||
|
|
|
@ -101,11 +101,6 @@ class Error(Module):
|
|||
self.__module = module
|
||||
self.__error = error
|
||||
|
||||
self.set('scrolling.bounce', False)
|
||||
self.set('scrolling.speed', 2)
|
||||
self.set('width', 15)
|
||||
|
||||
@core.decorators.scrollable
|
||||
def full_text(self, widget):
|
||||
return '{}: {}'.format(self.__module, self.__error)
|
||||
|
||||
|
|
|
@ -12,7 +12,10 @@ def dump_json(obj):
|
|||
|
||||
def assign(src, dst, key, src_key=None, default=None):
|
||||
if not src_key:
|
||||
src_key = key.replace('_', '-') # automagically replace - with _
|
||||
if key.startswith('_'):
|
||||
src_key = key
|
||||
else:
|
||||
src_key = key.replace('_', '-') # automagically replace _ with -
|
||||
|
||||
for k in src_key if isinstance(src_key, list) else [src_key]:
|
||||
if k in src:
|
||||
|
@ -80,7 +83,8 @@ class block(object):
|
|||
|
||||
for k in [
|
||||
'name', 'instance', 'separator_block_width', 'border', 'border_top',
|
||||
'border_bottom', 'border_left', 'border_right', 'markup'
|
||||
'border_bottom', 'border_left', 'border_right', 'markup',
|
||||
'_raw', '_suffix', '_prefix'
|
||||
]:
|
||||
assign(self.__attributes, result, k)
|
||||
|
||||
|
@ -93,13 +97,12 @@ class block(object):
|
|||
|
||||
def __format(self, text):
|
||||
if text is None: return None
|
||||
prefix = self.pangoize(self.__attributes.get('prefix'))
|
||||
suffix = self.pangoize(self.__attributes.get('suffix'))
|
||||
return '{}{}{}'.format(
|
||||
self.__pad(prefix),
|
||||
text,
|
||||
self.__pad(suffix)
|
||||
)
|
||||
prefix = self.__pad(self.pangoize(self.__attributes.get('prefix')))
|
||||
suffix = self.__pad(self.pangoize(self.__attributes.get('suffix')))
|
||||
self.set('_prefix', prefix)
|
||||
self.set('_suffix', suffix)
|
||||
self.set('_raw', text)
|
||||
return '{}{}{}'.format(prefix, text, suffix)
|
||||
|
||||
class i3(object):
|
||||
def __init__(self, theme=core.theme.Theme(), config=core.config.Config([])):
|
||||
|
|
|
@ -26,7 +26,4 @@
|
|||
- theme.exclude (battery)
|
||||
- help output
|
||||
- configuration files
|
||||
- custom fields __ in output for dwm bridge
|
||||
- default separators
|
||||
- make a create_widget call in module
|
||||
- do not scroll errors?
|
||||
- use add_widget() instead of core.widget.Widget()
|
||||
|
|
|
@ -36,7 +36,7 @@ class module(unittest.TestCase):
|
|||
module = core.module.load(module_name=self.validModuleName, config=config)
|
||||
module.widget().full_text()
|
||||
self.assertEqual('Error', module.__class__.__name__, 'an invalid module must be a core.module.Error')
|
||||
self.assertEqual(module.widget().get('_raw'), 'test: some-error')
|
||||
self.assertEqual(module.widget().full_text(), 'test: some-error')
|
||||
|
||||
def test_loadvalid_module(self):
|
||||
module = core.module.load(module_name=self.validModuleName)
|
||||
|
|
Loading…
Reference in a new issue