From 6349721e5e999ef7ccdecee6c6bd565124d8aa15 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Thu, 28 Jul 2016 03:00:39 -0400 Subject: [PATCH] common: Re-use icon_per_state --- item/common.lua | 8 ++++++++ item/layout/horizontal.lua | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/item/common.lua b/item/common.lua index 6d1ced8..06ddfa7 100644 --- a/item/common.lua +++ b/item/common.lua @@ -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 diff --git a/item/layout/horizontal.lua b/item/layout/horizontal.lua index 9d78a10..2102985 100644 --- a/item/layout/horizontal.lua +++ b/item/layout/horizontal.lua @@ -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