radical/widgets/filter.lua

51 lines
1.5 KiB
Lua
Raw Permalink Normal View History

local setmetatable = setmetatable
2016-03-05 08:54:17 +01:00
local wibox = require("wibox")
local infoshapes = require( "radical.widgets.infoshapes" )
local module = {}
2016-03-05 08:54:17 +01:00
local function set_data(self, data)
local info = self:get_children_by_id("infoshapes" )[1]
local tb = self:get_children_by_id("filter_text")[1]
function self.fit(_,context,width,height)
2016-03-05 08:54:17 +01:00
return width,data.item_height
end
self:set_bg(data.bg_highlight)
tb:set_markup(" <b>".. data.filter_prefix .."</b> "..data.filter_placeholder)
info:add_infoshape {
text = data.filter_underlay ,
alpha = data.filter_underlay_alpha,
color = data.filter_underlay_color,
}
data:connect_signal("filter_string::changed",function()
local is_empty = data.filter_string == ""
tb:set_markup(" <b>".. data.filter_prefix .."</b> "..(is_empty and data.filter_placeholder or data.filter_string))
end)
self:set_widget(info) --FIXME there is a bug somewhere
end
local function new(data)
2016-03-05 08:54:17 +01:00
return wibox.widget.base.make_widget_declarative {
{
{
id = "filter_text",
widget = wibox.widget.textbox
},
id = "infoshapes",
widget = infoshapes ,
},
set_data = set_data,
widget = wibox.container.background
2016-03-05 08:54:17 +01:00
}
end
return setmetatable(module, { __call = function(_, ...) return new(...) end })
2016-03-05 08:54:17 +01:00
-- kate: space-indent on; indent-width 4; replace-tabs on;