From 922575fcdac429a800cb2a0d03a73a54e291ff47 Mon Sep 17 00:00:00 2001 From: tobi-wan-kenobi Date: Mon, 18 May 2020 13:13:06 +0200 Subject: [PATCH] [core/widget] make arbitrary modules scrollable Use a boolean parameter "scrolling" that's applied generically to modules to allow arbitrary modules to scroll. see #606 TODO: Add to documentation --- bumblebee_status/core/widget.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bumblebee_status/core/widget.py b/bumblebee_status/core/widget.py index eae6f74..dd9fe1f 100644 --- a/bumblebee_status/core/widget.py +++ b/bumblebee_status/core/widget.py @@ -1,9 +1,13 @@ +import logging + import core.input import core.decorators import util.store import util.format +log = logging.getLogger(__name__) + class Widget(util.store.Store, core.input.Object): def __init__(self, full_text="", name=None): @@ -27,6 +31,13 @@ class Widget(util.store.Store, core.input.Object): custom_ids = util.format.aslist(module.parameter("id")) if len(custom_ids) > self.index(): self.id = custom_ids[self.index()] + if util.format.asbool(module.parameter("scrolling", False)) == True: + if callable(self.__full_text): + self.__full_text = core.decorators.scrollable( + self.__full_text.__func__ + ).__get__(module) + else: + log.warning("unable to make scrollable: {}".format(module.name)) def index(self): if not self.module: