awful.menu: use bg_image instead of an imagebox
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
4379b19eb9
commit
653fa0fadb
|
@ -17,6 +17,7 @@ local capi = { screen = screen, mouse = mouse, client = client }
|
||||||
local util = require("awful.util")
|
local util = require("awful.util")
|
||||||
local tags = require("awful.tag")
|
local tags = require("awful.tag")
|
||||||
local awbeautiful = require("beautiful")
|
local awbeautiful = require("beautiful")
|
||||||
|
local tonumber = tonumber
|
||||||
|
|
||||||
--- Menu module for awful
|
--- Menu module for awful
|
||||||
module("awful.menu")
|
module("awful.menu")
|
||||||
|
@ -113,31 +114,25 @@ local function add_item(data, num, item_info)
|
||||||
button({}, 3, function () hide(data) end)
|
button({}, 3, function () hide(data) end)
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Create the item icon widget
|
-- Create the item label widget
|
||||||
local icon
|
local label = widget({ type = "textbox", align = "left" })
|
||||||
|
label.text = item_info[1]
|
||||||
|
label:margin({ left = data.h + 2 })
|
||||||
|
-- Set icon if needed
|
||||||
if item_info[3] then
|
if item_info[3] then
|
||||||
icon = widget({ type = "imagebox", align = "left" })
|
local icon = type(item_info[3]) == "string" and image(item_info[3]) or item_info[3]
|
||||||
if type(item_info[3]) == "string" then
|
if icon.width > tonumber(data.h) or icon.height > tonumber(data.h) then
|
||||||
icon.image = image(item_info[3])
|
local width, height
|
||||||
else
|
if ((data.h/icon.height) * icon.width) > tonumber(data.h) then
|
||||||
icon.image = item_info[3]
|
width, height = data.h, (tonumber(data.h) / icon.width) * icon.height
|
||||||
|
else
|
||||||
|
width, height = (tonumber(data.h) / icon.height) * icon.width, data.h
|
||||||
|
end
|
||||||
|
icon = icon:crop_and_scale(0, 0, icon.width, icon.height, width, height)
|
||||||
end
|
end
|
||||||
else
|
label.bg_image = icon
|
||||||
icon = widget({type = "textbox", align = "left" })
|
|
||||||
icon.width = data.h
|
|
||||||
end
|
end
|
||||||
|
|
||||||
icon:buttons(bindings)
|
|
||||||
|
|
||||||
function icon.mouse_enter() mouse_enter(item, data.theme) end
|
|
||||||
function icon.mouse_leave() mouse_leave(item, data.theme) end
|
|
||||||
|
|
||||||
-- Create the item label widget
|
|
||||||
local label = widget({
|
|
||||||
type = "textbox",
|
|
||||||
align = "flex"
|
|
||||||
})
|
|
||||||
label.text = " " .. item_info[1]
|
|
||||||
label:buttons(bindings)
|
label:buttons(bindings)
|
||||||
|
|
||||||
function label.mouse_enter() mouse_enter(item, data.theme) end
|
function label.mouse_enter() mouse_enter(item, data.theme) end
|
||||||
|
@ -155,7 +150,7 @@ local function add_item(data, num, item_info)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add widgets to the wibox
|
-- Add widgets to the wibox
|
||||||
item.widgets = { icon, label, submenu }
|
item.widgets = { label, submenu }
|
||||||
|
|
||||||
item.ontop = true
|
item.ontop = true
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue