From c7d375790d10afd05fdc09961c39dc33265fdb92 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 13 Jul 2015 23:47:37 +0200 Subject: [PATCH] awful.widget.common.list_update: expose textbox to label callback This allows the "label" callback to adjust the textbox itself. `tasklist_label` is changed to make use of it and supports new style arguments: `font_focus`, `font_urgent` and `font_minimized`. Closes https://github.com/awesomeWM/awesome/pull/313. --- lib/awful/widget/common.lua | 2 +- lib/awful/widget/tasklist.lua | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/awful/widget/common.lua b/lib/awful/widget/common.lua index bbc7a50b..c7dc024b 100644 --- a/lib/awful/widget/common.lua +++ b/lib/awful/widget/common.lua @@ -91,7 +91,7 @@ function common.list_update(w, buttons, label, data, objects) } end - local text, bg, bg_image, icon = label(o) + local text, bg, bg_image, icon = label(o, tb) -- The text might be invalid, so use pcall. if text == nil or text == "" then tbm:set_margins(0) diff --git a/lib/awful/widget/tasklist.lua b/lib/awful/widget/tasklist.lua index 052959d1..401fe531 100644 --- a/lib/awful/widget/tasklist.lua +++ b/lib/awful/widget/tasklist.lua @@ -26,7 +26,7 @@ local tasklist = { mt = {} } -- Public structures tasklist.filter = {} -local function tasklist_label(c, args) +local function tasklist_label(c, args, tb) if not args then args = {} end local theme = beautiful.get() local fg_normal = util.ensure_pango_color(args.fg_normal or theme.tasklist_fg_normal or theme.fg_normal, "white") @@ -43,8 +43,11 @@ local function tasklist_label(c, args) local bg_image_minimize = args.bg_image_minimize or theme.bg_image_minimize local tasklist_disable_icon = args.tasklist_disable_icon or theme.tasklist_disable_icon or false local font = args.font or theme.tasklist_font or theme.font or "" + local font_focus = args.font_focus or theme.tasklist_font_focus or theme.font_focus or font or "" + local font_minimized = args.font_minimized or theme.tasklist_font_minimized or theme.font_minimized or font or "" + local font_urgent = args.font_urgent or theme.tasklist_font_urgent or theme.font_urgent or font or "" local bg = nil - local text = "" + local text = "" local name = "" local bg_image = nil @@ -93,20 +96,23 @@ local function tasklist_label(c, args) bg = bg_focus text = text .. ""..name.."" bg_image = bg_image_focus + font = font_focus elseif c.urgent then bg = bg_urgent text = text .. ""..name.."" bg_image = bg_image_urgent + font = font_urgent elseif c.minimized then bg = bg_minimize text = text .. ""..name.."" bg_image = bg_image_minimize + font = font_minimized else bg = bg_normal text = text .. ""..name.."" bg_image = bg_image_normal end - text = text .. "" + tb:set_font(font) return text, bg, bg_image, not tasklist_disable_icon and c.icon or nil end @@ -120,7 +126,7 @@ local function tasklist_update(s, w, buttons, filter, data, style, update_functi end end - local function label(c) return tasklist_label(c, style) end + local function label(c, tb) return tasklist_label(c, style, tb) end update_function(w, buttons, label, data, clients) end