From 4e577f9fedf090609604796cb501385d67586279 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 29 Jul 2008 10:24:03 +0200 Subject: [PATCH] awful: add default taglist label function Signed-off-by: Julien Danjou --- awesomerc.lua.in | 10 +--------- lib/awful.lua | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/awesomerc.lua.in b/awesomerc.lua.in index 3eb7e0173..0c8da008e 100644 --- a/awesomerc.lua.in +++ b/awesomerc.lua.in @@ -84,15 +84,7 @@ mytaglist:mouse_add(mouse({}, 3, function (object, tag) tag.selected = not tag.s mytaglist:mouse_add(mouse({ modkey }, 3, function (object, tag) awful.client.toggletag(tag) end)) mytaglist:mouse_add(mouse({ }, 4, awful.tag.viewnext)) mytaglist:mouse_add(mouse({ }, 5, awful.tag.viewprev)) -function mytaglist.label(t) - local text = "" - if t.selected then - text = " "..t.name.." " - else - text = " "..t.name.." " - end - return text -end +function mytaglist.label(t) return awful.widget.taglist.label(t, bg_focus, fg_focus) end -- Create a tasklist widget mytasklist = widget({ type = "tasklist", name = "mytasklist" }) diff --git a/lib/awful.lua b/lib/awful.lua index 414286d62..0c9a5b204 100644 --- a/lib/awful.lua +++ b/lib/awful.lua @@ -43,6 +43,8 @@ P.screen = {} P.layout = {} P.client = {} P.tag = {} +P.widget = {} +P.widget.taglist = {} --- Create a new userhook (for external libs). -- @param name Hook name. @@ -754,4 +756,21 @@ function P.unescape(text) return text end +--- Return labels for a taglist widget. +-- It returns the tag name and set a special +-- foreground and background color for selected tags. +-- @param t The tag. +-- @param bg_focus The background color for selected tag. +-- @param fg_focus The foreground color for selected tag. +-- @return A string to print. +function P.widget.taglist.label(t, bg_focus, fg_focus) + local text = "" + if t.selected then + text = " "..t.name.." " + else + text = " "..t.name.." " + end + return text +end + return P