radical/widgets/fkey.lua

47 lines
1.5 KiB
Lua
Raw Normal View History

local setmetatable = setmetatable
local color = require( "gears.color" )
local cairo = require( "lgi" ).cairo
local pango = require( "lgi" ).Pango
local pangocairo = require( "lgi" ).PangoCairo
local wibox = require( "wibox" )
local beautiful = require( "beautiful" )
2016-06-27 08:12:48 +02:00
local constrainedtext = require("radical.widgets.constrainedtext")
local shape = require("gears.shape")
2016-06-27 08:12:48 +02:00
local function new(data,item)
local pref = wibox.widget {
{
{
{
padding = 1,
width_for_text = "F99",
text = item._internal.f_key or "F1",
widget = constrainedtext,
id = "textbox",
},
left = data.item_height / 2 - 2*2,
right = data.item_height / 2 - 2*2,
widget = wibox.container.margin
},
shape = shape.rounded_bar,
bg = color(beautiful.fg_normal),
fg = color(beautiful.bg_normal),
widget = wibox.container.background
},
margins = 2,
widget = wibox.container.margin
}
2016-06-27 08:12:48 +02:00
local tb = pref:get_children_by_id("textbox")[1]
assert(tb)
2016-06-27 08:12:48 +02:00
item:connect_signal("f_key::changed" , function()
tb:set_text("F"..item._internal.f_key)
end)
2016-06-23 06:02:30 +02:00
2016-06-27 08:12:48 +02:00
return pref
end
return setmetatable({}, { __call = function(_, ...) return new(...) end })
2016-06-27 08:12:48 +02:00
-- kate: space-indent on; indent-width 4; replace-tabs on;