titlebar/wibox: Support widget definition in set_widget.
So now it is mostly identical to `:setup()` beside some legacy difference in how the get_children_by_id is implemented.
This commit is contained in:
parent
249f11ec82
commit
349b75994f
|
@ -492,6 +492,18 @@ local function load_titlebars(c, hide_all, keep)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function get_children_by_id(self, name)
|
||||||
|
--TODO v5: Move the ID management to the hierarchy.
|
||||||
|
if self._drawable._widget
|
||||||
|
and self._drawable._widget._private
|
||||||
|
and self._drawable._widget._private.by_id then
|
||||||
|
return self._drawable.widget._private.by_id[name]
|
||||||
|
end
|
||||||
|
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get a client's titlebar.
|
--- Get a client's titlebar.
|
||||||
-- @tparam client c The client for which a titlebar is wanted.
|
-- @tparam client c The client for which a titlebar is wanted.
|
||||||
-- @tparam[opt={}] table args A table with extra arguments for the titlebar.
|
-- @tparam[opt={}] table args A table with extra arguments for the titlebar.
|
||||||
|
@ -556,6 +568,7 @@ local function new(c, args)
|
||||||
|
|
||||||
-- Handle declarative/recursive widget container
|
-- Handle declarative/recursive widget container
|
||||||
ret.setup = base.widget.setup
|
ret.setup = base.widget.setup
|
||||||
|
ret.get_children_by_id = get_children_by_id
|
||||||
|
|
||||||
c._private = c._private or {}
|
c._private = c._private or {}
|
||||||
c._private.titlebars = bars
|
c._private.titlebars = bars
|
||||||
|
|
|
@ -13,6 +13,7 @@ local capi = {
|
||||||
screen = screen
|
screen = screen
|
||||||
}
|
}
|
||||||
local beautiful = require("beautiful")
|
local beautiful = require("beautiful")
|
||||||
|
local base = require("wibox.widget.base")
|
||||||
local cairo = require("lgi").cairo
|
local cairo = require("lgi").cairo
|
||||||
local color = require("gears.color")
|
local color = require("gears.color")
|
||||||
local object = require("gears.object")
|
local object = require("gears.object")
|
||||||
|
@ -226,7 +227,7 @@ end
|
||||||
|
|
||||||
--- Set the widget that the drawable displays
|
--- Set the widget that the drawable displays
|
||||||
function drawable:set_widget(widget)
|
function drawable:set_widget(widget)
|
||||||
self._widget = widget
|
self._widget = base.make_widget_from_value(widget)
|
||||||
|
|
||||||
-- Make sure the widget gets drawn
|
-- Make sure the widget gets drawn
|
||||||
self._need_relayout = true
|
self._need_relayout = true
|
||||||
|
|
|
@ -39,7 +39,8 @@ local force_forward = {
|
||||||
--@DOC_wibox_COMMON@
|
--@DOC_wibox_COMMON@
|
||||||
|
|
||||||
function wibox:set_widget(widget)
|
function wibox:set_widget(widget)
|
||||||
self._drawable:set_widget(widget)
|
local w = base.make_widget_from_value(widget)
|
||||||
|
self._drawable:set_widget(w)
|
||||||
end
|
end
|
||||||
|
|
||||||
function wibox:get_widget()
|
function wibox:get_widget()
|
||||||
|
@ -202,6 +203,7 @@ end
|
||||||
function wibox:get_children_by_id(name)
|
function wibox:get_children_by_id(name)
|
||||||
--TODO v5: Move the ID management to the hierarchy.
|
--TODO v5: Move the ID management to the hierarchy.
|
||||||
if rawget(self, "_by_id") then
|
if rawget(self, "_by_id") then
|
||||||
|
--TODO v5: Remove this, it's `if` nearly dead code, keep the `elseif`
|
||||||
return rawget(self, "_by_id")[name]
|
return rawget(self, "_by_id")[name]
|
||||||
elseif self._drawable.widget
|
elseif self._drawable.widget
|
||||||
and self._drawable.widget._private
|
and self._drawable.widget._private
|
||||||
|
|
Loading…
Reference in New Issue