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