layoutlist: Add a `count` property.

Because it was added to the `taglist` and `tasklist` and their API
somewhat mirror each other.
This commit is contained in:
Emmanuel Lepage Vallee 2021-11-09 23:11:58 -08:00
parent 798d31881d
commit 396bddb946
1 changed files with 24 additions and 1 deletions

View File

@ -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