diff --git a/core/output.py b/core/output.py index 6237f1d..af1a5b8 100644 --- a/core/output.py +++ b/core/output.py @@ -84,7 +84,7 @@ class block(object): for k in [ 'name', 'instance', 'separator_block_width', 'border', 'border_top', 'border_bottom', 'border_left', 'border_right', 'markup', - '_raw', '_suffix', '_prefix' + '_raw', '_suffix', '_prefix', 'min_width' ]: assign(self.__attributes, result, k) @@ -153,7 +153,12 @@ class i3(object): def __content_block(self, module, widget): blk = block(self.__theme, module, widget) - blk.set('min_width', widget.get('theme.minwidth')) + minwidth = widget.theme('minwidth') + if minwidth is not None: + try: + blk.set('min-width', '-'*int(minwidth)) + except: + blk.set('min-width', minwidth) blk.set('full_text', self.__content[widget]) if widget.get('pango', False): blk.set('markup', 'pango') diff --git a/core/widget.py b/core/widget.py index 0c12e99..2d1ad17 100644 --- a/core/widget.py +++ b/core/widget.py @@ -1,6 +1,8 @@ import core.input import core.decorators + import util.store +import util.format class Widget(util.store.Store, core.input.Object): def __init__(self, full_text='', name=None, module=None): @@ -9,6 +11,24 @@ class Widget(util.store.Store, core.input.Object): self.module = module self.name = name + def index(self): + if not self.module: return 0 + + idx = 0 + for w in self.module.widgets(): + if w.id == self.id: + return idx + idx = idx + 1 + return -1 # not found + + def theme(self, attribute): + attr = 'theme.{}'.format(attribute) + if self.module: + param = util.format.aslist(self.module.parameter(attr)) + if param and len(param) > self.index(): + return param[self.index()] + return self.get(attr) + def full_text(self, value=None): if value: self.__full_text = value