From fb6be007e590a48fbcb8ef623943118323b56ddf Mon Sep 17 00:00:00 2001 From: tobi-wan-kenobi Date: Tue, 27 Apr 2021 17:17:28 +0200 Subject: [PATCH] [core/output] fix minimum width with padding when calculating the minimum width of a widget, also take the padding into consideration. see #785 --- bumblebee_status/core/output.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/bumblebee_status/core/output.py b/bumblebee_status/core/output.py index 1760309..9c032d6 100644 --- a/bumblebee_status/core/output.py +++ b/bumblebee_status/core/output.py @@ -57,6 +57,9 @@ class block(object): def set(self, key, value): self.__attributes[key] = value + def get(self, key, default=None): + return self.__attributes.get(key, default) + def is_pango(self, attr): if isinstance(attr, dict) and "pango" in attr: return True @@ -91,9 +94,17 @@ class block(object): assign(self.__attributes, result, "background", "bg") if "full_text" in self.__attributes: + 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", self.get("full_text")) result["full_text"] = self.pangoize(result["full_text"]) result["full_text"] = self.__format(self.__attributes["full_text"]) + if "min-width" in self.__attributes and "padding" in self.__attributes: + self.set("min-width", self.__format(self.get("min-width"))) + for k in [ "name", "instance", @@ -123,11 +134,8 @@ class block(object): def __format(self, text): if text is None: return None - 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) + prefix = self.get("_prefix") + suffix = self.get("_suffix") return "{}{}{}".format(prefix, text, suffix)