You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.3 KiB
71 lines
2.3 KiB
local awmtk2 = require("awmtk2")
|
|
local wibox = require("wibox")
|
|
local gears = require("gears")
|
|
local awful = require("awful")
|
|
local beautiful = require("beautiful")
|
|
local builder = require("builder")
|
|
|
|
return function(args)
|
|
local style = awmtk2.create_style("root_menu",awmtk2.default,{})
|
|
local templates = awmtk2.create_template_lib("root_menu",awmtk2.templates,{})
|
|
local t = awmtk2.build_templates(templates,style)
|
|
local config_file = io.open(root_path.."/themes/"..global.theme.."/config/root_menu.json","r")
|
|
local config
|
|
if config_file then
|
|
config = config_file:read("*a")
|
|
config_file:close()
|
|
else
|
|
config = [[{"list": [{"widget": "widgets.rootcontrols"}],"vertical": true}]]
|
|
end
|
|
-- TODO: Refactor this whole mess
|
|
root_menu = awful.popup(t.popup({
|
|
markup = "brainhurt the game",
|
|
widget = wibox.widget.textbox
|
|
}))
|
|
root_menu:connect_signal("button::press",function(self,x,y,b)
|
|
if b == 3 then
|
|
root_menu.visible = false
|
|
end
|
|
end)
|
|
root_menu._menu_private = {}
|
|
root_menu.widget = wibox.widget(t.popup(builder(
|
|
config,
|
|
{
|
|
style = style.base,
|
|
screen = mouse.screen,
|
|
passthrough = {
|
|
parent = root_menu,
|
|
_tracking_layer = root_menu._menu_private
|
|
}
|
|
}
|
|
)).widget)
|
|
for _,layout in pairs(root_menu.widget:get_children_by_id("menu_root")) do
|
|
print(layout)
|
|
for _,button in pairs(layout.children) do
|
|
button:connect_signal("cascade::kill",function()
|
|
root_menu.visible = false
|
|
end)
|
|
end
|
|
end
|
|
root_menu:connect_signal("property::visible",function()
|
|
local roots = root_menu.widget:get_children_by_id("menu_root")
|
|
for k,v in pairs(roots) do
|
|
for _,w in ipairs(v.children) do
|
|
w:emit_signal("cascade::close")
|
|
end
|
|
end
|
|
end)
|
|
local buttons = root.buttons()
|
|
root.buttons(gears.table.join(buttons,
|
|
awful.button({}, 3, function()
|
|
root_menu.visible = (not root_menu.visible)
|
|
if root_menu.visible then
|
|
root_menu:move_next_to(gears.table.join(mouse.coords(),{
|
|
width = 0,
|
|
height = 0
|
|
}))
|
|
end
|
|
end)
|
|
))
|
|
return root_menu
|
|
end
|