2013-07-07 06:39:17 +02:00
|
|
|
local setmetatable = setmetatable
|
2016-03-05 08:54:17 +01:00
|
|
|
local wibox = require("wibox")
|
|
|
|
local infoshapes = require( "radical.widgets.infoshapes" )
|
2013-07-07 06:39:17 +02:00
|
|
|
|
|
|
|
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]
|
|
|
|
|
2016-06-24 22:53:47 +02:00
|
|
|
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
|
|
|
|
|
2013-07-07 06:39:17 +02:00
|
|
|
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,
|
2016-06-24 06:46:41 +02:00
|
|
|
widget = wibox.container.background
|
2016-03-05 08:54:17 +01:00
|
|
|
}
|
2013-07-07 06:39:17 +02: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;
|