taglist: Add a `count` property.

This is mostly for its signal handler. It will allow to replace the
template or layout based on the number of tags.
This commit is contained in:
Emmanuel Lepage Vallee 2021-11-09 23:11:24 -08:00
parent b11a8fb52c
commit 798d31881d
1 changed files with 20 additions and 0 deletions

View File

@ -403,6 +403,11 @@ local function taglist_update(s, self, buttons, filter, data, style, update_func
end
end
if self._private.last_count ~= #tags then
self:emit_signal("property::count", #tags, self._private.last_count)
self._private.last_count = #tags
end
local function label(c) return taglist.taglist_label(c, style) end
update_function(self._private.base_layout, buttons, label, data, tags, {
@ -422,6 +427,13 @@ end
-- @tparam[opt=wibox.layout.fixed.horizontal] wibox.layout base_layout
-- @see wibox.layout.fixed.horizontal
--- The current number of tags.
--
-- @property count
-- @readonly
-- @tparam number The number of tags.
-- @propemits true false
function taglist:set_base_layout(layout)
self._private.base_layout = base.make_widget_from_value(
layout or fixed.horizontal
@ -442,6 +454,14 @@ function taglist:set_base_layout(layout)
self:emit_signal("property::base_layout", layout)
end
function taglist:get_count()
if not self._private.last_count then
self._do_taglist_update_now()
end
return self._private.last_count
end
function taglist:layout(_, width, height)
if self._private.base_layout then
return { base.place_widget_at(self._private.base_layout, 0, 0, width, height) }