Git.vala
[gitlive] / Git.vala
index 8d7451d..95b4743 100644 (file)
--- a/Git.vala
+++ b/Git.vala
@@ -19,6 +19,12 @@ void main()
 
        Ggit.init();
        
+       
+       GLib.Timeout.add (500, () => {
+      GLib.debug("Meanwhile");
+      return false;
+    }, GLib.Priority.DEFAULT);
+       
        var loop = new MainLoop();
        
        var a = new GitLive.Repo("/home/alan/gitlive/gitlive");
@@ -296,29 +302,38 @@ namespace  GitLive {
         
                }
                
-               public void loadRemoteHeads(bool force = false)
+               public async void loadRemoteHeads(bool force = false)
                {
+                   SourceFunc callback = loadRemoteHeads.callback;
                        
-                       if (!force && this.remote_heads != null) {
-                               return;
-                       }
-                       var r = this.repo.lookup_remote("origin");
-                       r.connect(Ggit.Direction.FETCH, this.callbacks, null, null);
-                       this.remote_heads = r.list();
-                       
-                       foreach(var br in this.remote_heads) {
-                               if (!br.get_name().has_prefix("refs/heads/")) {
-                                       continue;
+                       ThreadFunc<bool> run = () => {
+                               
+                               if (!force && this.remote_heads != null) {
+                                       return true;;
                                }
+                               var r = this.repo.lookup_remote("origin");
+                               r.connect(Ggit.Direction.FETCH, this.callbacks, null, null);
+                               this.remote_heads = r.list();
                                
-                               GLib.debug("Remote: name=%s  oid=%s local_oid=%s is_local=%s",
-                                       br.get_name().substring(11),
-                                       br.get_oid().to_string(),
-                                       br.get_local_oid().to_string(),
-                                       br.is_local() ? "Y" : "n"
-                                       );
+                               foreach(var br in this.remote_heads) {
+                                       if (!br.get_name().has_prefix("refs/heads/")) {
+                                               continue;
                                        }
+                                       
+                                       GLib.debug("Remote: name=%s  oid=%s local_oid=%s is_local=%s",
+                                               br.get_name().substring(11),
+                                               br.get_oid().to_string(),
+                                               br.get_local_oid().to_string(),
+                                               br.is_local() ? "Y" : "n"
+                                               );
+                               }
+                               Idle.add((owned) callback);
+                               return true;;
+                       };
+                       new Thread<bool>("thread-example", run);
+                       yield;
                        
+
                }