diff --git a/context.lua b/context.lua index f023461..a4e91a3 100644 --- a/context.lua +++ b/context.lua @@ -142,7 +142,7 @@ local function setup_drawable(data) end local function setup_item(data,item,args) - (data._internal.layout.setup_item or layout.vertical.setup_item)(data._internal.layout,data,item,args) + ;(data._internal.layout.setup_item or layout.vertical.setup_item)(data._internal.layout,data,item,args); end local function new(args) diff --git a/layout/horizontal.lua b/layout/horizontal.lua index 24d81ee..b0c63df 100644 --- a/layout/horizontal.lua +++ b/layout/horizontal.lua @@ -125,14 +125,15 @@ function module:setup_item(data,item,args) l:add(args.prefix_widget) end + + local icon_flex = wibox.layout.align.horizontal() + local icon = wibox.widget.imagebox() + icon.fit = function(...) return icon_fit(data,...) end if args.icon then - local icon_flex = wibox.layout.align.horizontal() - local icon = wibox.widget.imagebox() - icon.fit = function(...) return icon_fit(data,...) end icon:set_image(args.icon) - icon_flex:set_middle(icon) - l:add(icon_flex) end + icon_flex:set_middle(icon) + l:add(icon_flex) text_w:set_markup(item._private_data.text) l:add(text_w) if item._private_data.sub_menu_f or item._private_data.sub_menu_m then @@ -171,6 +172,12 @@ function module:setup_item(data,item,args) data.width = fit_w data.height = fit_h data.style(data) + item._internal.set_map.text = function (value) + text_w:set_markup(value) + end + item._internal.set_map.icon = function (value) + icon:set_image(value) + end end --Get preferred item geometry diff --git a/layout/vertical.lua b/layout/vertical.lua index bf626b1..ffb6750 100644 --- a/layout/vertical.lua +++ b/layout/vertical.lua @@ -127,11 +127,11 @@ function module:setup_item(data,item,args) l:add(args.prefix_widget) end + local icon = wibox.widget.imagebox() if args.icon then - local icon = wibox.widget.imagebox() icon:set_image(args.icon) - l:add(icon) end + l:add(icon) text_w:set_markup(item._private_data.text) l:add(text_w) if item._private_data.sub_menu_f or item._private_data.sub_menu_m then @@ -170,6 +170,12 @@ function module:setup_item(data,item,args) data.width = fit_w data.height = fit_h data.style(data) + item._internal.set_map.text = function (value) + text_w:set_markup(value) + end + item._internal.set_map.icon = function (value) + icon:set_image(value) + end end local function new(data)