From c10a94c0cb1112c342211721add488e540fcd410 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 16 Mar 2014 23:46:23 -0400 Subject: [PATCH] Use 'state::changed' instead of hardcoded calls to refresh (issue #18) --- item/init.lua | 6 ++++++ item/layout/horizontal.lua | 1 + theme/init.lua | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/item/init.lua b/item/init.lua index 4b4854d..e93ba0e 100644 --- a/item/init.lua +++ b/item/init.lua @@ -160,6 +160,12 @@ local function new_item(data,args) data.item_style(item,{}) data._current_item = item end + + -- Listen to signals + item:connect_signal("state::changed",function() + item:style() + end) + return item end diff --git a/item/layout/horizontal.lua b/item/layout/horizontal.lua index b1d2e41..1f9e80a 100644 --- a/item/layout/horizontal.lua +++ b/item/layout/horizontal.lua @@ -40,6 +40,7 @@ end -- Apply icon transformation function module.set_icon(self,image) if self._data.icon_transformation then + self._item._original_icon = image image = self._data.icon_transformation(image,self._data,self._item) end wibox.widget.imagebox.set_image(self,image) diff --git a/theme/init.lua b/theme/init.lua index 8323b0b..2b6a264 100644 --- a/theme/init.lua +++ b/theme/init.lua @@ -23,13 +23,13 @@ local function change_data(tab, key,value) if tab._item._internal.text_w and tab._item._internal.text_w.cache then tab._item._internal.text_w.cache = {} end - tab._item:style() + tab._item:emit_signal("state::changed") elseif value and (rawget(tab,"_current_key") or math.huge) > key then rawset(tab,"_current_key",key) if tab._item._internal.text_w and tab._item._internal.text_w.cache then tab._item._internal.text_w.cache = {} end - tab._item:style() + tab._item:emit_signal("state::changed") end tab._real_table[key] = value end