awful.tag: add index property for custom tag order

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
cdump 2013-01-02 15:06:45 +01:00 committed by Uli Schlachter
parent d0ab8dc0c1
commit d8a93dafa3
2 changed files with 20 additions and 1 deletions

View file

@ -55,7 +55,8 @@ function tag.move(new_index, target_tag)
table.insert(tmp_tags, new_index, target_tag)
for _, tmp_tag in ipairs(tmp_tags) do
for i, tmp_tag in ipairs(tmp_tags) do
tag.setproperty(tmp_tag, "index", i)
tag.setscreen(tmp_tag, scr)
end
end
@ -244,6 +245,22 @@ function tag.gettags(s)
table.insert(tags, t)
end
end
local without_index = 0
for _, t in ipairs(tags) do
if not tag.getproperty(t, "index") then
without_index = without_index + 1
end
end
if without_index > 0 then
for _, t in ipairs(tags) do
if not tag.getproperty(t, "index") then
tag.setproperty(t, "index", (#tags - without_index + 1))
end
end
end
table.sort(tags, function(a, b) return tag.getproperty(a, "index") < tag.getproperty(b, "index") end)
return tags
end
@ -563,6 +580,7 @@ capi.tag.add_signal("property::ncol")
capi.tag.add_signal("property::nmaster")
capi.tag.add_signal("property::windowfact")
capi.tag.add_signal("property::screen")
capi.tag.add_signal("property::index")
for s = 1, capi.screen.count() do
capi.screen[s]:add_signal("tag::history::update")

View file

@ -162,6 +162,7 @@ function taglist.new(screen, filter, buttons, style, update_function, base_widge
tag.attached_connect_signal(screen, "property::name", ut)
tag.attached_connect_signal(screen, "property::activated", ut)
tag.attached_connect_signal(screen, "property::screen", ut)
tag.attached_connect_signal(screen, "property::index", ut)
capi.client.connect_signal("property::urgent", uc)
capi.client.connect_signal("property::screen", function(c)
-- If client change screen, refresh it anyway since we don't from