awful: add default taglist label function

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-07-29 10:24:03 +02:00
parent 6329a9801a
commit 4e577f9fed
2 changed files with 20 additions and 9 deletions

View File

@ -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({ modkey }, 3, function (object, tag) awful.client.toggletag(tag) end))
mytaglist:mouse_add(mouse({ }, 4, awful.tag.viewnext)) mytaglist:mouse_add(mouse({ }, 4, awful.tag.viewnext))
mytaglist:mouse_add(mouse({ }, 5, awful.tag.viewprev)) mytaglist:mouse_add(mouse({ }, 5, awful.tag.viewprev))
function mytaglist.label(t) function mytaglist.label(t) return awful.widget.taglist.label(t, bg_focus, fg_focus) end
local text = ""
if t.selected then
text = "<bg color='"..bg_focus.."'/> <span color='"..fg_focus.."'>"..t.name.."</span> "
else
text = " "..t.name.." "
end
return text
end
-- Create a tasklist widget -- Create a tasklist widget
mytasklist = widget({ type = "tasklist", name = "mytasklist" }) mytasklist = widget({ type = "tasklist", name = "mytasklist" })

View File

@ -43,6 +43,8 @@ P.screen = {}
P.layout = {} P.layout = {}
P.client = {} P.client = {}
P.tag = {} P.tag = {}
P.widget = {}
P.widget.taglist = {}
--- Create a new userhook (for external libs). --- Create a new userhook (for external libs).
-- @param name Hook name. -- @param name Hook name.
@ -754,4 +756,21 @@ function P.unescape(text)
return text return text
end 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 = "<bg color='"..bg_focus.."'/> <span color='"..fg_focus.."'>"..t.name.."</span> "
else
text = " "..t.name.." "
end
return text
end
return P return P