Changed MergeBranch.bjsMergeBranch.vala
[gitlive] / WindowLog.vala
index d41d3be..d63516c 100644 (file)
@@ -24,9 +24,7 @@ public class WindowLog : Object  {
             return this.getStatus();
         } );
         //Roo.log("Windowlog start");
-        this.screen.active_window_changed.connect((pr_win) => {
-            this.windowChanged();
-        });
+        this.screen.active_window_changed.connect( this.windowChanged );
     }
     
     
@@ -44,7 +42,7 @@ public class WindowLog : Object  {
                  try {
                         this.write("", "IDLE");
                 } catch (Error e) {
-                    print(e.message + "\n");
+                    GLib.debug("%s",e.message);
                 }
             }
             this.win = "";
@@ -53,7 +51,7 @@ public class WindowLog : Object  {
         return true;
     }
 
-    public void windowChanged()
+    public void windowChanged(Wnck.Window? pr_win)
     {
         this.screen.force_update();
        // print("window changeD");
@@ -68,16 +66,19 @@ public class WindowLog : Object  {
             //print("PID " + pid);
                     //var cmd = File.realpath('/proc/'+ pid + '/exe');
             string cmd = "";
-            size_t len = 0;
-            print("/proc/%u/cmdline".printf(pid) + "\n");
+             
+           // print("/proc/%u/cmdline".printf(pid) + "\n");
 
             if (pid > 0 ) { 
-                FileUtils.get_contents("/proc/%u/cmdline".printf(pid), out cmd, out len);
+                var cf = File.new_for_path("/proc/%u/cmdline".printf(pid));
+                var dis = new DataInputStream (cf.read ());
+                cmd = dis.read_line (null);
             }  else {
                 cmd = "UNKNOWN";
             } 
             //  has it changed?
-            print(this.win +"\n" + cmd + "\n");
+            //print(this.win +"\n" + cmd + "\n");
             if (this.win.length < 1 || (win != this.win)) { 
         
                 //print((xDate.newDate()).format("Y-m-d H:i:s") + " " + win + ' - '+ cmd );
@@ -85,7 +86,7 @@ public class WindowLog : Object  {
                 this.win=win;
             }
         } catch (Error e) {
-            print(e.message + "\n");
+            GLib.debug("%s",e.message);
         }
         
         
@@ -99,6 +100,8 @@ public class WindowLog : Object  {
         var now = new DateTime.now(new TimeZone.local()); 
 
         var dir =  this.outdir + now.format("/%Y/%m");
+        //print(dir + "\n");
+
 
         if (this.lastdir.length < 1 || this.lastdir != dir) {
             if (!FileUtils.test(dir, FileTest.IS_DIR)) {
@@ -110,16 +113,17 @@ public class WindowLog : Object  {
           
             this.lastdir = dir;
         }
-        
+         
         var fname = now.format("/%d") + ".log";
         var path  = dir + "/" + fname;
-        var time  = now.format("%H:%i:%s ");
+        var time  = now.format("%H:%M:%S ");
+        //print("time: " + time + "\n");
         var f = File.new_for_path(path);
-       FileOutputStream ios = f.append_to (FileCreateFlags.NONE);
+       var ios = f.append_to (FileCreateFlags.NONE);
                var data_out = new DataOutputStream (ios);
 
         data_out.put_string("\n" +time + str + " "  + cmd, null);
-        print(time + str + " "  + cmd + "\n");
+        GLib.debug("%s%s %s",time , str , cmd);
         data_out.close(null);