radical/widgets/filter.lua

31 lines
1.1 KiB
Lua
Raw Normal View History

local setmetatable = setmetatable
local print = print
local color = require("gears.color")
local cairo = require( "lgi" ).cairo
local wibox = require("wibox")
local beautiful = require( "beautiful" )
local module = {}
local function new(data)
local filter_tb = wibox.widget.textbox()
local bg = wibox.widget.background()
2013-07-18 06:03:19 +02:00
bg:set_bg(data.bg_highlight)
bg:set_widget(filter_tb)
2014-03-13 03:56:56 +01:00
filter_tb:set_markup(" <b>".. data.filter_prefix .."</b> "..data.filter_placeholder)
filter_tb.fit = function(tb,width,height)
return width,data.item_height
end
2014-03-13 03:56:56 +01:00
filter_tb:set_underlay(data.filter_underlay,{alpha=data.filter_underlay_alpha,color=data.filter_underlay_color})
data:connect_signal("filter_string::changed",function()
2014-03-13 03:56:56 +01:00
local is_empty = data.filter_string == ""
filter_tb:set_markup(" <b>".. data.filter_prefix .."</b> "..(is_empty and data.filter_placeholder or data.filter_string))
end)
bg.widget = filter_tb
return bg
end
return setmetatable(module, { __call = function(_, ...) return new(...) end })
-- kate: space-indent on; indent-width 2; replace-tabs on;