filter: Rewrite the filter widget

This commit is contained in:
Emmanuel Lepage Vallee 2016-03-05 02:54:17 -05:00
parent 9ea34d4003
commit 0be013f1f7
2 changed files with 44 additions and 25 deletions

View File

@ -99,7 +99,8 @@ local function new(data)
data._internal.scroll_w and data._internal.scroll_w["down"] or nil,
data.show_filter and {
id = "filter_widget",
widget = filter(data) --FIXME for some reason it doesn't show up
data = data,
widget = filter
} or nil,
-- Attributes
@ -120,7 +121,6 @@ local function new(data)
data._internal.content_layout = real_l:get_children_by_id( "content_layout" )[1]
data._internal.suf_l = real_l:get_children_by_id( "suffix_layout" )[1]
data._internal.pref_l = real_l:get_children_by_id( "prefix_layout" )[1]
data._internal.filter_tb = real_l:get_children_by_id( "filter_widget" )[1]
-- Set the overloaded methods
real_l.fit = real_fit

View File

@ -1,31 +1,50 @@
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 infoshapes = require( "radical.widgets.infoshapes" )
local module = {}
--TODO broken
local function new(data)
local filter_tb = wibox.widget.textbox()
local bg = wibox.widget.background()
bg:set_bg(data.bg_highlight)
bg:set_widget(filter_tb)
filter_tb:set_markup(" <b>".. data.filter_prefix .."</b> "..data.filter_placeholder)
filter_tb.fit = function(tb,context,width,height)
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)
return width,data.item_height
end
-- filter_tb:set_underlay(data.filter_underlay,{alpha=data.filter_underlay_alpha,color=data.filter_underlay_color})
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 == ""
filter_tb:set_markup(" <b>".. data.filter_prefix .."</b> "..(is_empty and data.filter_placeholder or data.filter_string))
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
self:set_widget(info) --FIXME there is a bug somewhere
end
local function new(data)
return wibox.widget.base.make_widget_declarative {
{
{
id = "filter_text",
widget = wibox.widget.textbox
},
id = "infoshapes",
widget = infoshapes ,
},
set_data = set_data,
widget = wibox.widget.background
}
end
return setmetatable(module, { __call = function(_, ...) return new(...) end })
-- kate: space-indent on; indent-width 2; replace-tabs on;
-- kate: space-indent on; indent-width 4; replace-tabs on;