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

View File

@ -1,31 +1,50 @@
local setmetatable = setmetatable local setmetatable = setmetatable
local print = print local wibox = require("wibox")
local color = require("gears.color") local infoshapes = require( "radical.widgets.infoshapes" )
local cairo = require( "lgi" ).cairo
local wibox = require("wibox")
local beautiful = require( "beautiful" )
local module = {} local module = {}
--TODO broken 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
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) local function new(data)
local filter_tb = wibox.widget.textbox() return wibox.widget.base.make_widget_declarative {
local bg = wibox.widget.background() {
bg:set_bg(data.bg_highlight) {
bg:set_widget(filter_tb) id = "filter_text",
filter_tb:set_markup(" <b>".. data.filter_prefix .."</b> "..data.filter_placeholder) widget = wibox.widget.textbox
filter_tb.fit = function(tb,context,width,height) },
return width,data.item_height id = "infoshapes",
end widget = infoshapes ,
-- filter_tb:set_underlay(data.filter_underlay,{alpha=data.filter_underlay_alpha,color=data.filter_underlay_color}) },
data:connect_signal("filter_string::changed",function() set_data = set_data,
local is_empty = data.filter_string == "" widget = wibox.widget.background
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 end
return setmetatable(module, { __call = function(_, ...) return new(...) 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;