Clones.bjs
[gitlive] / Clones.js
index aab2925..4611de9 100644 (file)
--- a/Clones.js
+++ b/Clones.js
@@ -13,8 +13,8 @@ Clones=new XObject({
     xtype: Gtk.Dialog,
     listeners : {
         destroy_event : function (self, event) {
-             this.el.hide();
-                        return false;
+              print("DESTROY?!");
+             return true;
         },
         response : function (self, id) {
           // hide
@@ -50,7 +50,7 @@ Clones=new XObject({
         });
        // shouild set path..
         */
-     
+        this.el.set_deletable(false);
         this.el.show_all();
         // load clones..
             this.get('/reposStore').load();
@@ -84,30 +84,102 @@ Clones=new XObject({
                             xtype: Gtk.Button,
                             listeners : {
                                 clicked : function (self) {
-                                    
+                                
+                                    var rv = this.get('/reposView');
+                                    var rs = this.get('/reposStore');
+                                    if (rv.el.get_selection().count_selected_rows() != 1) {
+                                        //nothing?
+                                        // error condition.
+                                        return;
+                                    }
+                                    var Remotes =     imports.Remotes.Remotes;
                                     
                                  
+                                    var ret = {};       
+                                    var s = rv.el.get_selection();
+                                    var path = '';
+                                    s.selected_foreach(function(model,p,iter) {
+                                                                                    
+                                       path = model.get_value(iter, 6).value.get_string();
+                                     
+                                    }); 
+                                
+                                    var repo = false;
+                                    rs.repos.forEach(function(r) {
+                                        if (r.repopath == path) {
+                                            repo = r;
+                                        
+                                        }
+                                    
+                                    });
+                                    Remotes.repo = repo;
+                                    Remotes.el.set_transient_for(Clones.el);
+                                    Clones.el.set_title("Manage Clones - " + repo.repopath);
+                                    Remotes.show();
+                                    Clones.el.set_title("Manage Clones");
+                                
+                                     
+                                    
+                                    
+                                    
+                                
                                        
                                     
                                     
                                 }
                             },
-                            label : "Add Clone",
+                            label : "Remotes / Clones",
                             pack : "add"
                         },
                         {
                             xtype: Gtk.Button,
                             listeners : {
                                 clicked : function (self) {
-                                    
+                                
+                                    var rv = this.get('/reposView');
+                                    var rs = this.get('/reposStore');
+                                    if (rv.el.get_selection().count_selected_rows() != 1) {
+                                        //nothing?
+                                        // error condition.
+                                        return;
+                                    }
+                                    var Branches =     imports.Branches.Branches;
                                     
                                  
+                                    var ret = {};       
+                                    var s = rv.el.get_selection();
+                                    var path = '';
+                                    s.selected_foreach(function(model,p,iter) {
+                                                                                    
+                                       path = model.get_value(iter, 6).value.get_string();
+                                     
+                                    }); 
+                                
+                                    var repo = false;
+                                    rs.repos.forEach(function(r) {
+                                        if (r.repopath == path) {
+                                            repo = r;
+                                        
+                                        }
+                                    
+                                    });
+                                    Branches.repo = repo;
+                                    Branches.el.set_transient_for(Clones.el);
+                                    Clones.el.set_title("Manage Clones - " + repo.repopath);
+                                    Branches.show();
+                                    Clones.el.set_title("Manage Clones");
+                                
+                                     
+                                    
+                                    
+                                    
+                                
                                        
                                     
                                     
                                 }
                             },
-                            label : "Add Branch",
+                            label : "Branches",
                             pack : "add"
                         },
                         {
@@ -143,10 +215,10 @@ Clones=new XObject({
                                     
                                     });
                                     Merger.repo = repo;
-                                    //Merger.el.set_transient_for(Clones.el);
-                                
+                                    Merger.el.set_transient_for(Clones.el);
+                                    Clones.el.set_title("Manage Clones - " + repo.repopath);
                                     Merger.show();
-                                    
+                                    Clones.el.set_title("Manage Clones");
                                 
                                     
                                     
@@ -255,6 +327,11 @@ Clones=new XObject({
                                       _this, [ _this, '']
                                    );
                                          });
+                                      
+                                      
+                                      //this.el.set_tooltip_column(8); 
+                                         
+                                        
                               },
                             items : [
                                 {
@@ -263,14 +340,16 @@ Clones=new XObject({
                                     pack : "set_model",
                                     init : function() {
                                         XObject.prototype.init.call(this);
-                                        this.el.set_column_types ( 7, [
+                                        this.el.set_column_types ( 9, [
                                            GObject.TYPE_STRING, // repo  
                                           GObject.TYPE_STRING, // current branch
                                           GObject.TYPE_STRING, // all branch      
                                           GObject.TYPE_STRING, // updated
                                            GObject.TYPE_BOOLEAN, // auto-commit
                                             GObject.TYPE_BOOLEAN, // auto-push
-                                               GObject.TYPE_STRING // repopath
+                                               GObject.TYPE_STRING, // repopath
+                                               GObject.TYPE_STRING, // color highighling 
+                                               GObject.TYPE_STRING // uncommited. (tip) 
                                       ] );
                                     },
                                     load : function()
@@ -288,17 +367,40 @@ Clones=new XObject({
                                             
                                             //print(JSON.stringify(ret,null,4));
                                              tr[i].getBranches();
+                                             tr[i].getStatus();
+                                             var hi;
+                                             try {
+                                                 //tr[i].debug=1;
+                                                  hi = tr[i].history('/', 1, 'branch', tr[i].currentBranch.name );
+                                    //             print(JSON.stringify(hi,null,4));
+                                             } catch(e) { print(e);}
                                               
                                             this.el.set_value(ret.iter, 0, '' +  tr[i].repopath.split('/').pop() );
-                                            this.el.set_value(ret.iter, 1, '' + tr[i].currentBranch   );
+                                            this.el.set_value(ret.iter, 1, '' + tr[i].currentBranch.name   );
                                             this.el.set_value(ret.iter, 2, '' + tr[i].branches.map(
                                                             function(e) { return e.name; 
                                                         }).join(', ') 
                                              );
-                                            this.el.set_value(ret.iter, 3, '' + 'tbc' );        
+                                            this.el.set_value(ret.iter, 3, '' +  (!hi  ? '??' : hi[0].changed_raw));        
                                             this.el.set_value(ret.iter, 4, tr[i].autocommit() );                
                                             this.el.set_value(ret.iter, 5, tr[i].autopush() );                        
-                                            this.el.set_value(ret.iter, 6,  tr[i].repopath );      
+                                            this.el.set_value(ret.iter, 6,  tr[i].repopath );  
+                                            // highlight color.
+                                            var cb = tr[i].currentBranch;
+                                            //print(JSON.stringify(cb,null,4));
+                                            var col = '#ffffff';
+                                            if (cb.lastrev != cb.remoterev) {
+                                                col =  '#ff0000';
+                                            }
+                                            if (tr[i].hasLocalChanges) {
+                                                col =  '#0000ff';
+                                            }
+                                            if  ((cb.lastrev != cb.remoterev) && (tr[i].hasLocalChanges)) {
+                                                col =  '#ff00ff';
+                                            }
+                                            
+                                            this.el.set_value(ret.iter, 7, col  );
+                                            this.el.set_value(ret.iter, 8, tr[i].localChanges  );      
                                             
                                         }     
                                     }
@@ -368,9 +470,9 @@ Clones=new XObject({
                                 },
                                 {
                                     xtype: Gtk.TreeViewColumn,
+                                    resizable : false,
                                     min_width : 200,
                                     pack : "append_column",
-                                    resizable : true,
                                     title : "Repo",
                                     init : function() {
                                         XObject.prototype.init.call(this);
@@ -392,6 +494,7 @@ Clones=new XObject({
                                     init : function() {
                                         XObject.prototype.init.call(this);
                                         this.el.add_attribute(this.items[0].el , 'markup', 1 );
+                                         this.el.add_attribute(this.items[0].el , 'cell-background', 7 );
                                     
                                     },
                                     items : [
@@ -452,15 +555,10 @@ Clones=new XObject({
                 }
             ]
         },
-        {
-            xtype: Gtk.Button,
-            label : "Cancel",
-            pack : "add_action_widget,0"
-        },
         {
             xtype: Gtk.Button,
             id : "ok_button",
-            label : "OK",
+            label : "Close",
             pack : "add_action_widget,1"
         }
     ]