Deprecate menubar.get()

The function seems useless and its documentation is wrong. It does not
return a wibox, but a widget. Also, the widget cannot really be used on
its own since it depends on the size of the wibox.

So menubar.get() and its wrapper through the metatable __call should
just be removed. Until then, the needed initialisation code is moved
around a bit and the function is deprecated.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2017-03-03 17:20:56 +01:00
parent edd9415df6
commit 67b12579d9
1 changed files with 13 additions and 4 deletions

View File

@ -35,7 +35,7 @@ local function get_screen(s)
end end
-- menubar -- menubar
local menubar = { mt = {}, menu_entries = {} } local menubar = { menu_entries = {} }
menubar.menu_gen = require("menubar.menu_gen") menubar.menu_gen = require("menubar.menu_gen")
menubar.utils = require("menubar.utils") menubar.utils = require("menubar.utils")
local compute_text_width = menubar.utils.compute_text_width local compute_text_width = menubar.utils.compute_text_width
@ -388,9 +388,15 @@ end
-- @param scr Screen. -- @param scr Screen.
function menubar.show(scr) function menubar.show(scr)
if not instance then if not instance then
menubar.refresh(scr)
-- Add to each category the name of its key in all_categories
for k, v in pairs(menubar.menu_gen.all_categories) do
v.key = k
end
instance = { instance = {
wibox = wibox({ ontop = true }), wibox = wibox({ ontop = true }),
widget = menubar.get(scr), widget = common_args.w,
prompt = awful.widget.prompt(), prompt = awful.widget.prompt(),
query = nil, query = nil,
count_table = nil, count_table = nil,
@ -451,7 +457,9 @@ end
--- Get a menubar wibox. --- Get a menubar wibox.
-- @tparam[opt] screen scr Screen. -- @tparam[opt] screen scr Screen.
-- @return menubar wibox. -- @return menubar wibox.
-- @deprecated If you know what this actually does, please tell us
function menubar.get(scr) function menubar.get(scr)
awful.util.deprecate("Use menubar.show() instead", { deprecated_in = 5 })
menubar.refresh(scr) menubar.refresh(scr)
-- Add to each category the name of its key in all_categories -- Add to each category the name of its key in all_categories
for k, v in pairs(menubar.menu_gen.all_categories) do for k, v in pairs(menubar.menu_gen.all_categories) do
@ -460,10 +468,11 @@ function menubar.get(scr)
return common_args.w return common_args.w
end end
function menubar.mt.__call(_, ...) local mt = {}
function mt.__call(_, ...)
return menubar.get(...) return menubar.get(...)
end end
return setmetatable(menubar, menubar.mt) return setmetatable(menubar, mt)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80