clienticon: add a client setter (#2018)

It's required to work with the declarative syntax and be used
in the tasklist due to its limitations.
This commit is contained in:
Emmanuel Lepage Vallée 2017-08-27 08:23:06 -04:00 committed by Daniel Hahler
parent 78686166b2
commit ec08af4e76
1 changed files with 18 additions and 2 deletions

View File

@ -31,7 +31,7 @@ end
function clienticon:draw(_, cr, width, height)
local c = self._private.client
if not c.valid then
if not c or not c.valid then
return
end
@ -52,7 +52,7 @@ end
function clienticon:fit(_, width, height)
local c = self._private.client
if not c.valid then
if not c or not c.valid then
return 0, 0
end
@ -80,6 +80,22 @@ function clienticon:fit(_, width, height)
return w * aspect, h * aspect
end
--- The widget's @{client}.
--
-- @property client
-- @param client
function clienticon:get_client()
return self._private.client
end
function clienticon:set_client(c)
if self._private.client == c then return end
self._private.client = c
self:emit_signal("widget::layout_changed")
self:emit_signal("widget::redraw_needed")
end
--- Returns a new clienticon.
-- @tparam client c The client whose icon should be displayed.
-- @treturn widget A new `widget`