Made it possible to mix multimenus and regular menus
This commit is contained in:
parent
c6ca21f73a
commit
a3cfb76c48
|
@ -3,7 +3,7 @@
|
|||
terminal = "$HOME/.local/bin/st"
|
||||
browser = "prime-run librewolf"
|
||||
modkey = "Mod4"
|
||||
theme = "serenity"
|
||||
theme = "unity"
|
||||
shell = "zsh"
|
||||
|
||||
# Keybindings
|
||||
|
|
|
@ -40,8 +40,7 @@ end
|
|||
|
||||
asckey.custom_binds = function()
|
||||
local custom_keys = {}
|
||||
|
||||
for comm,bind in pairs(asckey.keymap) do
|
||||
for comm,_ in pairs(asckey.keymap) do
|
||||
if not comm:match("^:.*") then
|
||||
table.insert(custom_keys,asckey.k(comm,function()
|
||||
awful.spawn(comm)
|
||||
|
|
|
@ -50,10 +50,11 @@ return function(description,opts)
|
|||
if not test then
|
||||
error("Builder failure: "..err)
|
||||
end
|
||||
local function inner_builder(struct,vertical)
|
||||
local function inner_builder(struct,options,vertical)
|
||||
if struct.widget then -- External widget descriptions
|
||||
local args = gears.table.join({
|
||||
layout = (struct.layout and inner_builder(struct.layout)), client = (struct.client and c),
|
||||
layout = (struct.layout and inner_builder(struct.layout,options)),
|
||||
client = (struct.client and c),
|
||||
screen = (struct.screen and s),
|
||||
vertical = (function()
|
||||
if type(struct.vertical) ~= "nil" then
|
||||
|
@ -61,7 +62,7 @@ return function(description,opts)
|
|||
end
|
||||
return vertical
|
||||
end)()
|
||||
},struct.options or {},opts.passthrough or {})
|
||||
},struct.options or {},options.passthrough or {})
|
||||
return require(struct.widget)(args)
|
||||
elseif struct.list then -- List descriptions
|
||||
local list = {
|
||||
|
@ -75,7 +76,7 @@ return function(description,opts)
|
|||
if v.draggable then
|
||||
list.buttons = buttons
|
||||
else
|
||||
local new_obj = inner_builder(v,struct.vertical)
|
||||
local new_obj = inner_builder(v,options,struct.vertical)
|
||||
if new_obj then
|
||||
table.insert(list,new_obj)
|
||||
end
|
||||
|
@ -108,7 +109,7 @@ return function(description,opts)
|
|||
if obj.draggable then
|
||||
list[k].buttons = buttons
|
||||
else
|
||||
local new_obj = inner_builder(obj,struct.vertical)
|
||||
local new_obj = inner_builder(obj,options,struct.vertical)
|
||||
if new_obj then
|
||||
table.insert(list[k],new_obj)
|
||||
end
|
||||
|
@ -127,14 +128,17 @@ return function(description,opts)
|
|||
return builtins[struct.builtin](gears.table.join({
|
||||
client = (struct.client and c)
|
||||
},struct.options or {}))
|
||||
elseif struct.multimenu then
|
||||
elseif struct.multimenu then -- Multimenus, or otherwise "Context menu mergers".
|
||||
-- These merge multiple menus into one using the menu_parent argument.
|
||||
local multimenu = menu({items={}})
|
||||
if not opts.passthrough then
|
||||
opts.passthrough = {}
|
||||
local newopts = {}
|
||||
for k,v in pairs(options) do
|
||||
newopts[k] = v
|
||||
end
|
||||
opts.passthrough.menu_parent = multimenu
|
||||
newopts.passthrough = options.passthrough or {}
|
||||
newopts.passthrough.menu_parent = multimenu
|
||||
for _,v in pairs(struct.multimenu) do
|
||||
inner_builder(v,struct.vertical)
|
||||
inner_builder(v,newopts,struct.vertical)
|
||||
end
|
||||
return multimenu
|
||||
end
|
||||
|
@ -144,5 +148,5 @@ return function(description,opts)
|
|||
gears.debug.dump(struct)
|
||||
error("Builder error: invalid object description")
|
||||
end
|
||||
return inner_builder(test),test.context_options
|
||||
return inner_builder(test,opts),test.context_options
|
||||
end
|
||||
|
|
|
@ -46,6 +46,7 @@ if not context_menu then
|
|||
local menus = digger(context_menu.widget,"menu_root")
|
||||
local context_menu_size = context_menu.width * context_menu.height
|
||||
context_menu.widget:connect_signal("widget::size_changed",function()
|
||||
-- Attach callbacks to close context_menu to new buttons
|
||||
local already_managed = {}
|
||||
for _,v in pairs(menus) do
|
||||
already_managed[v] = true
|
||||
|
|
|
@ -50,6 +50,7 @@ return function(args)
|
|||
local menus = digger(root_menu.widget,"menu_root")
|
||||
local root_menu_size = root_menu.width * root_menu.height
|
||||
root_menu:connect_signal("widget::size_changed",function()
|
||||
-- Attach callbacks to close the root_menu when new buttons appear
|
||||
local already_managed = {}
|
||||
for _,v in pairs(menus) do
|
||||
already_managed[v] = true
|
||||
|
|
Loading…
Reference in New Issue