Archive/unarchive entries
authorEnrico Zini <enrico@enricozini.org>
Sat, 27 Mar 2010 23:59:17 +0000 (23:59 +0000)
committerEnrico Zini <enrico@enricozini.org>
Sat, 27 Mar 2010 23:59:17 +0000 (23:59 +0000)
src/app_log.vala
src/log.vala

index fa247b4ea34e77dceab14e30a05eb7358f9fabbd..6092a773c256eca36b6e0d64eb14958dc3bffc5d 100644 (file)
@@ -125,6 +125,10 @@ public class Log : Applet
         model.set(cur_iter, 2, cur_log.acked, -1);
 
         update_read_unread(cur_log.acked);
+
+        Value vname;
+        model.get_value(cur_iter, 1, out vname);
+        zavai.log.log.set_acknowledged(vname.get_string(), cur_log.acked);
     }
 
     private void update_read_unread(bool acked)
index 2bbb5d40c3651d95e3af922896acdc0cd459be78..6b9c06978237611e597cd6cb6a29609a209c651a 100644 (file)
@@ -370,8 +370,27 @@ public class Logger : Resource, Object
         return parser.result;
     }
 
-    public delegate bool EntriesVisitor(string dir, string name);
+    public void set_acknowledged(string name, bool acked)
+    {
+        string from, to;
+        if (acked)
+        {
+            from = config.homedir + "/log/" + name;
+            to = config.homedir + "/archive/" + name;
+            DirUtils.create(config.homedir + "/archive", 0777);
+        } else {
+            from = config.homedir + "/archive/" + name;
+            to = config.homedir + "/log/" + name;
+            DirUtils.create(config.homedir + "/log", 0777);
+        }
+        if (FileUtils.test(from, FileTest.EXISTS))
+        {
+            FileUtils.rename(from, to);
+            entries_changed();
+        }
+    }
 
+    public delegate bool EntriesVisitor(string dir, string name);
 
     protected void list_dir(string dir, EntriesVisitor visitor)
     {