From 396bddb946770c2d067f07db614aa2134edfc0e8 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Tue, 9 Nov 2021 23:11:58 -0800 Subject: [PATCH] layoutlist: Add a `count` property. Because it was added to the `taglist` and `tasklist` and their API somewhat mirror each other. --- lib/awful/widget/layoutlist.lua | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/awful/widget/layoutlist.lua b/lib/awful/widget/layoutlist.lua index 5fac6cd86..d61030f3e 100644 --- a/lib/awful/widget/layoutlist.lua +++ b/lib/awful/widget/layoutlist.lua @@ -281,10 +281,25 @@ local layoutlist = {} -- @property current_layout -- @param layout +--- The current number of layouts. +-- +-- @property count +-- @readonly +-- @tparam number The number of layouts. +-- @propemits true false + function layoutlist:get_layouts() local f = self.source or self._private.source or module.source.for_screen - return f(self.screen) + local ret = f(self.screen) + + if self._private.last_count ~= #ret then + self:emit_signal("property::count", ret, self._private.last_count) + + self._private.last_count = ret + end + + return ret end function layoutlist:get_current_layout() @@ -329,6 +344,14 @@ function layoutlist:set_base_layout(layout) self:emit_signal("property::base_layout", layout) end +function layoutlist:get_count() + if not self._private.last_count then + self._do_() + end + + return self._private.last_count +end + function layoutlist:set_widget_template(widget_template) self._private.widget_template = widget_template