commit
466988eb5a
|
@ -93,9 +93,7 @@ local current_item = 1
|
||||||
local previous_item = nil
|
local previous_item = nil
|
||||||
local current_category = nil
|
local current_category = nil
|
||||||
local shownitems = nil
|
local shownitems = nil
|
||||||
local instance = { prompt = nil,
|
local instance = nil
|
||||||
widget = nil,
|
|
||||||
wibox = nil }
|
|
||||||
|
|
||||||
local common_args = { w = wibox.layout.fixed.horizontal(),
|
local common_args = { w = wibox.layout.fixed.horizontal(),
|
||||||
data = setmetatable({}, { __mode = 'kv' }) }
|
data = setmetatable({}, { __mode = 'kv' }) }
|
||||||
|
@ -347,25 +345,14 @@ local function menulist_update(query, scr)
|
||||||
get_current_page(shownitems, query, scr))
|
get_current_page(shownitems, query, scr))
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Create the menubar wibox and widgets.
|
|
||||||
-- @tparam[opt] screen scr Screen.
|
|
||||||
local function initialize(scr)
|
|
||||||
instance.wibox = wibox({})
|
|
||||||
instance.widget = menubar.get(scr)
|
|
||||||
instance.wibox.ontop = true
|
|
||||||
instance.prompt = awful.widget.prompt()
|
|
||||||
local layout = wibox.layout.fixed.horizontal()
|
|
||||||
layout:add(instance.prompt)
|
|
||||||
layout:add(instance.widget)
|
|
||||||
instance.wibox:set_widget(layout)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Refresh menubar's cache by reloading .desktop files.
|
--- Refresh menubar's cache by reloading .desktop files.
|
||||||
-- @tparam[opt] screen scr Screen.
|
-- @tparam[opt] screen scr Screen.
|
||||||
function menubar.refresh(scr)
|
function menubar.refresh(scr)
|
||||||
menubar.menu_gen.generate(function(entries)
|
menubar.menu_gen.generate(function(entries)
|
||||||
menubar.menu_entries = entries
|
menubar.menu_entries = entries
|
||||||
|
if instance then
|
||||||
menulist_update(nil, scr)
|
menulist_update(nil, scr)
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -416,9 +403,19 @@ end
|
||||||
--- Show the menubar on the given screen.
|
--- Show the menubar on the given screen.
|
||||||
-- @param scr Screen.
|
-- @param scr Screen.
|
||||||
function menubar.show(scr)
|
function menubar.show(scr)
|
||||||
if not instance.wibox then
|
if not instance then
|
||||||
initialize(scr)
|
instance = {
|
||||||
elseif instance.wibox.visible then -- Menu already shown, exit
|
wibox = wibox({ ontop = true }),
|
||||||
|
widget = menubar.get(scr),
|
||||||
|
prompt = awful.widget.prompt(),
|
||||||
|
}
|
||||||
|
local layout = wibox.layout.fixed.horizontal()
|
||||||
|
layout:add(instance.prompt)
|
||||||
|
layout:add(instance.widget)
|
||||||
|
instance.wibox:set_widget(layout)
|
||||||
|
end
|
||||||
|
|
||||||
|
if instance.wibox.visible then -- Menu already shown, exit
|
||||||
return
|
return
|
||||||
elseif not menubar.cache_entries then
|
elseif not menubar.cache_entries then
|
||||||
menubar.refresh(scr)
|
menubar.refresh(scr)
|
||||||
|
@ -456,7 +453,9 @@ end
|
||||||
|
|
||||||
--- Hide the menubar.
|
--- Hide the menubar.
|
||||||
function menubar.hide()
|
function menubar.hide()
|
||||||
|
if instance then
|
||||||
instance.wibox.visible = false
|
instance.wibox.visible = false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get a menubar wibox.
|
--- Get a menubar wibox.
|
||||||
|
|
Loading…
Reference in New Issue