From 67b12579d9386196ab6532aa99a2374de2a613a1 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Fri, 3 Mar 2017 17:20:56 +0100 Subject: [PATCH 1/2] 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 --- lib/menubar/init.lua | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/menubar/init.lua b/lib/menubar/init.lua index 1a7514cf..87dfcef0 100644 --- a/lib/menubar/init.lua +++ b/lib/menubar/init.lua @@ -35,7 +35,7 @@ local function get_screen(s) end -- menubar -local menubar = { mt = {}, menu_entries = {} } +local menubar = { menu_entries = {} } menubar.menu_gen = require("menubar.menu_gen") menubar.utils = require("menubar.utils") local compute_text_width = menubar.utils.compute_text_width @@ -388,9 +388,15 @@ end -- @param scr Screen. function menubar.show(scr) 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 = { wibox = wibox({ ontop = true }), - widget = menubar.get(scr), + widget = common_args.w, prompt = awful.widget.prompt(), query = nil, count_table = nil, @@ -451,7 +457,9 @@ end --- Get a menubar wibox. -- @tparam[opt] screen scr Screen. -- @return menubar wibox. +-- @deprecated If you know what this actually does, please tell us function menubar.get(scr) + awful.util.deprecate("Use menubar.show() instead", { deprecated_in = 5 }) 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 @@ -460,10 +468,11 @@ function menubar.get(scr) return common_args.w end -function menubar.mt.__call(_, ...) +local mt = {} +function mt.__call(_, ...) return menubar.get(...) end -return setmetatable(menubar, menubar.mt) +return setmetatable(menubar, mt) -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 From 232c5a014a81c1d9fe6ab4138e003758060d20bc Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Fri, 3 Mar 2017 17:26:15 +0100 Subject: [PATCH 2/2] menubar.show(): Remove duplicate call to menubar.refresh() This changes a line of code that was added in the previous commit. Previously, when menubar.cache_entries was set to false, menubar.refresh() was called twice. Signed-off-by: Uli Schlachter --- lib/menubar/init.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/menubar/init.lua b/lib/menubar/init.lua index 87dfcef0..ddd39fd7 100644 --- a/lib/menubar/init.lua +++ b/lib/menubar/init.lua @@ -388,12 +388,15 @@ end -- @param scr Screen. function menubar.show(scr) 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 + if menubar.cache_entries then + menubar.refresh(scr) + end + instance = { wibox = wibox({ ontop = true }), widget = common_args.w,