common: Re-use icon_per_state

This commit is contained in:
Emmanuel Lepage Vallee 2016-07-28 03:00:39 -04:00
parent 26a6c05d5e
commit b0f5c663e6
2 changed files with 8 additions and 8 deletions

View File

@ -26,6 +26,14 @@ function module.setup_icon(item,data) --TODO maybe create a proper widget
item.set_icon = function (_,value) icon:set_image(value) end
if data.icon_per_state == true then --TODO create an icon widget, see item/common.lua
item:connect_signal("state::changed",function(i,d,st)
if item._original_icon and data.icon_transformation then
wibox.widget.imagebox.set_image(icon,data.icon_transformation(item._original_icon,data,item))
end
end)
end
return icon
end

View File

@ -45,14 +45,6 @@ local function create_item(item,data,args)
local checkbox = common.setup_checked(item,data)
if data.icon_per_state == true then --TODO create an icon widget, see item/common.lua
item:connect_signal("state::changed",function(i,d,st)
if item._original_icon and data.icon_transformation then
wibox.widget.imagebox.set_image(icon,data.icon_transformation(item._original_icon,data,item))
end
end)
end
-- Define the item layout
item.widget = wibox.widget.base.make_widget_declarative {
-- Widgets