cleanup and text placement tweak

This commit is contained in:
Izaya 2022-08-26 13:53:43 +10:00
parent d155461729
commit d081f4fb44

View File

@ -3,7 +3,6 @@ local wibox = require("wibox")
local gears = require("gears")
local beautiful = require("beautiful")
local menubar = require("menubar")
local naughty = require "naughty"
local cairo = require("lgi").cairo
local Rsvg = require("lgi").Rsvg
local longpress = require("awesome-longpress")
@ -12,40 +11,21 @@ local launcherpopup = {
spacing = 5,
iconPath = gears.filesystem.get_configuration_dir() .. "/awesome-launcherpopup/",
updateOnSpawn = true,
font = "sans",
fontSize = 15,
applications = {},
allInstances = {}
}
function launcherpopup.update()
naughty.notify({text="started update"})
menubar.menu_gen.generate(function(rv)
launcherpopup.applications = rv
for k,v in pairs(launcherpopup.allInstances) do
if k and v then
w,e = pcall(v.populateMenu)
if not w then naughty.notify{text=e} end
end
end
end)
end
local function tryLoadIcon(icon)
local img = icon
if dentry.icon:match("%.([^%.]+)$") == "svg" then
naughty.notify{text="is svg"}
img = cairo.ImageSurface(cairo.Format.ARGB32,launcherpopup.buttonsize,launcherpopup.buttonsize)
local cr = cairo.Context(img)
Rsvg.Handle.new_from_file(dentry.icon):render_cairo(cr)
end
return img
end
local function getFont(scale)
return string.format("%s %d",launcherpopup.font,launcherpopup.fontSize * (scale or 1))
end
function launcherpopup.new(s)
local menuStart = 1
local launcherWidget = wibox.widget{
@ -113,9 +93,8 @@ function launcherpopup.new(s)
mwidget:add(mwicon)
local mwtext = wibox.container.constraint(wibox.widget{
widget = wibox.widget.textbox,
valign = center,
align = center,
font = getFont(),
valign = "top",
align = "center",
text = dentry.name
},"exact",launcherpopup.buttonsize,launcherpopup.buttonsize * 0.5)
mwidget:add(mwtext)