-- This file is part of Reno desktop. -- -- Reno desktop is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. -- -- Reno desktop is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License along with Reno desktop. If not, see . local awful = require("awful") local gears = require("gears") local awmtk2 = require("awmtk2") local beautiful = require("beautiful") local wibox = require("wibox") local json = require("dkjson") local try_blur = require("imagemagick_blur") local bgimagegen = function(path) return function(cont,cr,width,height) local s = gears.surface.load_uncached_silently( path ) local bg_width,bg_height = gears.surface.get_size(s) local scale = height/bg_height if width/bg_width > scale then scale = width/bg_width end cr:translate((width - (bg_width*scale))/2,(height - (bg_height*scale))/2) cr:rectangle(0,0, (bg_width*scale), (bg_height*scale)) cr:clip() cr:scale(scale,scale) cr:set_source_surface(s) cr:paint() end end local function _preload(args) local style = awmtk2.create_style("supermenu", awmtk2.generic.composite_widget,{}) local templates = awmtk2.create_template_lib("supermenu",awmtk2.templates,{}) local t = awmtk2.build_templates(templates,style,args.vertical) local wallpaper if gears.filesystem.file_readable(root_path.."/wallpaper.txt") then local wallpaper_f = io.open(root_path.."/wallpaper.txt","r") wallpaper = wallpaper_f:read("*a") wallpaper_f:close() end supermenu = awful.popup(t.popup({ { { widget = wibox.container.background }, { layout = wibox.layout.fixed.vertical, id = "contents" }, { t.container({ id = "buttonlist", layout = wibox.layout.fixed.vertical },{ bg = style.container.bg_highlight }), valign = "center", halign = "right", fill_vertical = true, fill_horizontal = false, widget = wibox.container.place }, layout = wibox.layout.align.horizontal }, widget = wibox.container.background, forced_width = args.screen.workarea.width-style.container.margins, forced_height = args.screen.workarea.height-style.container.margins, id = "supermenu_root" },{ x = args.screen.workarea.x, y = args.screen.workarea.y, visible = true })) local supermenu_root = supermenu.widget:get_children_by_id("supermenu_root")[1] supermenu_root.bgimage = bgimagegen(try_blur(wallpaper or beautiful.wallpaper, function(path) supermenu_root.bgimage = bgimagegen(path) end)) args.screen:connect_signal("property::workarea",function() supermenu.x = args.screen.workarea.x supermenu.y = args.screen.workarea.y supermenu_root.forced_width = args.screen.workarea.width-style.container.margins*2 supermenu_root.forced_height = args.screen.workarea.height-style.container.margins*2 end) supermenu:connect_signal("button::press",function(self,x,y,button) if button == 3 then supermenu.visible = false end end) local tabsfile = io.open(root_path.."/themes/"..global.theme..'/config/supermenu.json',"r") local tabs = {} if tabsfile then for k,v in pairs(json.decode(tabsfile:read("*a"))) do table.insert(tabs,require(k)(v)) end end local contents = supermenu.widget:get_children_by_id("contents")[1] if tabs[1] then contents:add(tabs[1]) end return supermenu end return function(args) for s in screen do s.lock = _preload(gears.table.join(args,{ screen = s })) end end