Merge pull request #1620 from psychon/menubar-remove-get2

Deprecate menubar.get()
This commit is contained in:
Emmanuel Lepage Vallée 2017-03-16 16:40:23 -04:00 committed by GitHub
commit 2c30991579
1 changed files with 16 additions and 4 deletions

View File

@ -39,7 +39,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
@ -395,9 +395,18 @@ end
-- @param scr Screen. -- @param scr Screen.
function menubar.show(scr) function menubar.show(scr)
if not instance then if not instance then
-- 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
if menubar.cache_entries then
menubar.refresh(scr)
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,
@ -458,7 +467,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
@ -467,10 +478,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