Am 02.01.2013 15:21, schrieb Jörg Thalheim:
> Am 01.01.2013 17:36, schrieb Maxim Andreev:
>> I'm tried to fix tag.move() problem which was described here in
>> maillist some days ago. Also i applied this fix to shifty module which
>> i'm porting to v3.5 right now. Please, try it and leave feedback here
>> or on github, it's only one quickly applied solution and no guaranties
>> that i didn't miss some affected code. I will published it on flyspray
>> soon.
>>
>> So, it's this test branch:
>> https://github.com/cdump/awesome-shifty/tree/tagsindex
>> Apply awful.patch first.
> I have repackaged your patch with git format-pach against awesome-git.
> Could you post it on the awesome developer mailinglist
> ([email protected])?
>

Sorry, I had a typo in the patch file.
Btw. it works fine for me.
From e728e7a37ca4e6d80e26cfafe65a22cff744ba29 Mon Sep 17 00:00:00 2001
From: cdump <[email protected]>
Date: Wed, 2 Jan 2013 15:06:45 +0100
Subject: [PATCH] awful.tag: add index property for custom tag order

---
 lib/awful/tag.lua.in            | 20 +++++++++++++++++++-
 lib/awful/widget/taglist.lua.in |  1 +
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/lib/awful/tag.lua.in b/lib/awful/tag.lua.in
index 0a5899b..9e24dd3 100644
--- a/lib/awful/tag.lua.in
+++ b/lib/awful/tag.lua.in
@@ -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")
diff --git a/lib/awful/widget/taglist.lua.in b/lib/awful/widget/taglist.lua.in
index 11bccc6..850a2a7 100644
--- a/lib/awful/widget/taglist.lua.in
+++ b/lib/awful/widget/taglist.lua.in
@@ -152,6 +152,7 @@ function taglist.new(screen, filter, buttons, style)
     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
-- 
1.8.0.3

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to