Add Interface for Repository Management and Merger tool
authorAlan Knowles <alan@akbkhome.com>
Tue, 20 Sep 2011 14:19:42 +0000 (22:19 +0800)
committerAlan Knowles <alan@akbkhome.com>
Tue, 20 Sep 2011 14:19:42 +0000 (22:19 +0800)
12 files changed:
Branches.bjs [new file with mode: 0644]
Branches.js [new file with mode: 0644]
Clones.bjs [new file with mode: 0644]
Clones.js [new file with mode: 0644]
Commit.bjs [new file with mode: 0644]
Commit.js [new file with mode: 0644]
Merger.bjs [new file with mode: 0644]
Merger.js [new file with mode: 0644]
RemoteEdit.bjs [new file with mode: 0644]
RemoteEdit.js [new file with mode: 0644]
Remotes.bjs [new file with mode: 0644]
Remotes.js [new file with mode: 0644]

diff --git a/Branches.bjs b/Branches.bjs
new file mode 100644 (file)
index 0000000..1e8bd44
--- /dev/null
@@ -0,0 +1,152 @@
+{
+    "id": "file-gtk-6",
+    "name": "Branches",
+    "parent": "",
+    "title": false,
+    "path": "/home/alan/gitlive/gitlive/Branches.bjs",
+    "items": [
+        {
+            "listeners": {
+                "destroy_event": "function (self, event) {\n     this.el.hide();\n                return false;\n}",
+                "response": "function (self, id) {\n  // hide\n     //if (id < 1) {\n        this.el.hide();\n        return;\n    //}\n    if (typeof(this.get('bug').getValue()) != 'object') {\n        print(\"ERROR\");\n        return;\n    }\n \n    this.el.hide();\n        \n    //var val = this.get('bug').getValue();\n     //   Seed.print(val);\n}"
+            },
+            " modal": true,
+            "border_width": 3,
+            "default_height": 300,
+            "default_width": 500,
+            "title": "Branches",
+            "xtype": "Dialog",
+            "|deletable": true,
+            "|modal": true,
+            "|show": "function(c) {\n    \n    if (!this.el) {\n        this.init();\n    }\n    var _this = this;\n    this.get('/branchStore').load();\n    this.el.show_all();\n    \n    var run_ret = this.el.run();\n    if (run_ret < 1 ) {\n        return  \"DONE\";\n    }\n    print(\"RUN RETURN : \" + run_ret);\n    return \"DONE\";\n    \n}\n",
+            "|xns": "Gtk",
+            "items": [
+                {
+                    "xtype": "VBox",
+                    "|pack": " function(p,e) {\n        p.el.get_content_area().pack_start(e.el,true,true,0)\n    }\n",
+                    "|xns": "Gtk",
+                    "items": [
+                        {
+                            "pack": "pack_start,false,true",
+                            "xtype": "HBox",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "listeners": {
+                                        "clicked": "function (self) {\n\n     return;\n    var RemoteEdit=    imports.RemoteEdit.RemoteEdit\n     RemoteEdit.repo = Remotes.repo;\n    RemoteEdit.el.set_transient_for(Remotes.el);\n\n    var res =  RemoteEdit.show();\n    \n    if (res != false) {\n        Remotes.repo.remotes(res);\n    }\n    \n    this.get('/remotesStore').load();\n\n    \n}"
+                                    },
+                                    "label": "Pull",
+                                    "pack": "add",
+                                    "xtype": "Button",
+                                    "|xns": "Gtk"
+                                }
+                            ]
+                        },
+                        {
+                            "xtype": "ScrolledWindow",
+                            "|init": "function() {\n    XObject.prototype.init.call(this);\n      this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "listeners": {
+                                        "cursor_changed": "function (self)\n{\n\n   return;\n  // SEE SELECTION.CHANGED\n    if (this.el.get_selection().count_selected_rows() < 1) {\n        //nothing? - clea it?\n        return;\n    }\n        var ret = {};         \n    var model = this.get('/changedFilesStore');\n\n     var s = this.el.get_selection();\n     var files = [];\n    s.selected_foreach(function(model,p,iter) {\n    \n       files.push( model.get_value(iter, 0).value.get_string());\n     \n    });\n    this.get('/patchview').showDiff(files); \n    //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();\n     //print(\"OUT?\" + value);// id..\n    // load the list in the right grid..\n     \n    return true;\n\n}"
+                                    },
+                                    "id": "branchView",
+                                    "pack": "add",
+                                    "xtype": "TreeView",
+                                    "|init": "function() {\n    XObject.prototype.init.call(this);\n        var description = new Pango.FontDescription.c_new();\n   description.set_size(8000);\n     this.el.modify_font(description);\n\n     this.selection = this.el.get_selection();\n      this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);\n    var _this = this;\n  this.selection.signal['changed'].connect(function() {\n     _this.listeners.cursor_changed.apply(\n          _this, [ _this, '']\n       );\n             });\n  }\n",
+                                    "|xns": "Gtk",
+                                    "items": [
+                                        {
+                                            "id": "branchStore",
+                                            "pack": "set_model",
+                                            "xtype": "ListStore",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.set_column_types ( 3, [\n       GObject.TYPE_STRING, // file  \n      GObject.TYPE_STRING, // added\n      GObject.TYPE_STRING, // removed\n  ] );\n}\n",
+                                            "|load": "function(tr)\n{\n    //this.insert(citer,iter,0);\n    this.el.clear();\n    \n    var tr = Branches.repo.getBranches();\n    \n    \n    for(var i =0 ; i < tr.length; i++) {\n        var ret = {  };\n       \n        this.el.append(ret);\n        \n        //print(JSON.stringify(ret,null,4));\n        var lastrev = tr[i].lastrev;\n        var remoterev = tr[i].remoterev;\n        \n        var lastrev = lastrev.length ? lastrev : remoterev;\n        \n        if (lastrev != remoterev) {\n            lastrev = \"Out of sync: remote=\" + remoterev + \", local=\" + lastrev;\n        }\n        \n \n          \n        this.el.set_value(ret.iter, 0, ''  +  tr[i].name );\n        this.el.set_value(ret.iter, 1, '' + tr[i].remote );\n        this.el.set_value(ret.iter, 2, '' + lastrev );\n \n        \n    }     \n}",
+                                            "|xns": "Gtk"
+                                        },
+                                        {
+                                            "min_width": 70,
+                                            "pack": "append_column",
+                                            "resizable": true,
+                                            "title": "Local",
+                                            "xtype": "TreeViewColumn",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 0 );\n\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "pack": "pack_start",
+                                                    "xtype": "CellRendererText",
+                                                    "|xns": "Gtk"
+                                                }
+                                            ]
+                                        },
+                                        {
+                                            "min_width": 70,
+                                            "pack": "append_column",
+                                            "resizable": true,
+                                            "title": "Remote",
+                                            "xtype": "TreeViewColumn",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 1 );\n\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "pack": "pack_start",
+                                                    "xtype": "CellRendererText",
+                                                    "|xns": "Gtk"
+                                                }
+                                            ]
+                                        },
+                                        {
+                                            "min_width": 200,
+                                            "pack": "append_column",
+                                            "title": "Status",
+                                            "xtype": "TreeViewColumn",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 2 );\n\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "pack": "pack_start",
+                                                    "xtype": "CellRendererText",
+                                                    "|xns": "Gtk"
+                                                }
+                                            ]
+                                        }
+                                    ]
+                                },
+                                {
+                                    "|xns": "Gtk",
+                                    "xtype": "TreeView",
+                                    "pack": false,
+                                    "items": [
+                                        {
+                                            "|xns": "Gtk",
+                                            "xtype": "ListStore",
+                                            "pack": false
+                                        }
+                                    ]
+                                }
+                            ]
+                        }
+                    ]
+                },
+                {
+                    "label": "Cancel",
+                    "pack": "add_action_widget,0",
+                    "xtype": "Button",
+                    "|xns": "Gtk",
+                    "listeners": {}
+                },
+                {
+                    "id": "ok_button",
+                    "label": "OK",
+                    "pack": "add_action_widget,1",
+                    "xtype": "Button",
+                    "|xns": "Gtk"
+                }
+            ]
+        }
+    ],
+    "permname": "",
+    "modOrder": "0"
+}
\ No newline at end of file
diff --git a/Branches.js b/Branches.js
new file mode 100644 (file)
index 0000000..5e617c7
--- /dev/null
@@ -0,0 +1,281 @@
+Gtk = imports.gi.Gtk;
+Gdk = imports.gi.Gdk;
+Pango = imports.gi.Pango;
+GLib = imports.gi.GLib;
+Gio = imports.gi.Gio;
+GObject = imports.gi.GObject;
+GtkSource = imports.gi.GtkSource;
+WebKit = imports.gi.WebKit;
+Vte = imports.gi.Vte;
+console = imports.console;
+XObject = imports.XObject.XObject;
+Branches=new XObject({
+    xtype: Gtk.Dialog,
+    listeners : {
+        destroy_event : function (self, event) {
+             this.el.hide();
+                        return false;
+        },
+        response : function (self, id) {
+          // hide
+             //if (id < 1) {
+                this.el.hide();
+                return;
+            //}
+            if (typeof(this.get('bug').getValue()) != 'object') {
+                print("ERROR");
+                return;
+            }
+         
+            this.el.hide();
+                
+            //var val = this.get('bug').getValue();
+             //   Seed.print(val);
+        }
+    },
+    ' modal' : true,
+    border_width : 3,
+    default_height : 300,
+    default_width : 500,
+    title : "Branches",
+    deletable : true,
+    modal : true,
+    show : function(c) {
+        
+        if (!this.el) {
+            this.init();
+        }
+        var _this = this;
+        this.get('/branchStore').load();
+        this.el.show_all();
+        
+        var run_ret = this.el.run();
+        if (run_ret < 1 ) {
+            return  "DONE";
+        }
+        print("RUN RETURN : " + run_ret);
+        return "DONE";
+        
+    },
+    items : [
+        {
+            xtype: Gtk.VBox,
+            pack : function(p,e) {
+                    p.el.get_content_area().pack_start(e.el,true,true,0)
+                },
+            items : [
+                {
+                    xtype: Gtk.HBox,
+                    pack : "pack_start,false,true",
+                    items : [
+                        {
+                            xtype: Gtk.Button,
+                            listeners : {
+                                clicked : function (self) {
+                                
+                                     return;
+                                    var RemoteEdit=    imports.RemoteEdit.RemoteEdit
+                                     RemoteEdit.repo = Remotes.repo;
+                                    RemoteEdit.el.set_transient_for(Remotes.el);
+                                
+                                    var res =  RemoteEdit.show();
+                                    
+                                    if (res != false) {
+                                        Remotes.repo.remotes(res);
+                                    }
+                                    
+                                    this.get('/remotesStore').load();
+                                
+                                    
+                                }
+                            },
+                            label : "Pull",
+                            pack : "add"
+                        }
+                    ]
+                },
+                {
+                    xtype: Gtk.ScrolledWindow,
+                    init : function() {
+                        XObject.prototype.init.call(this);
+                          this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+                    },
+                    items : [
+                        {
+                            xtype: Gtk.TreeView,
+                            listeners : {
+                                cursor_changed : function (self)
+                                {
+                                
+                                   return;
+                                  // SEE SELECTION.CHANGED
+                                    if (this.el.get_selection().count_selected_rows() < 1) {
+                                        //nothing? - clea it?
+                                        return;
+                                    }
+                                        var ret = {};         
+                                    var model = this.get('/changedFilesStore');
+                                
+                                     var s = this.el.get_selection();
+                                     var files = [];
+                                    s.selected_foreach(function(model,p,iter) {
+                                    
+                                       files.push( model.get_value(iter, 0).value.get_string());
+                                     
+                                    });
+                                    this.get('/patchview').showDiff(files); 
+                                    //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
+                                     //print("OUT?" + value);// id..
+                                    // load the list in the right grid..
+                                     
+                                    return true;
+                                
+                                }
+                            },
+                            id : "branchView",
+                            pack : "add",
+                            init : function() {
+                                XObject.prototype.init.call(this);
+                                    var description = new Pango.FontDescription.c_new();
+                               description.set_size(8000);
+                                 this.el.modify_font(description);
+                            
+                                 this.selection = this.el.get_selection();
+                                  this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);
+                                var _this = this;
+                              this.selection.signal['changed'].connect(function() {
+                                 _this.listeners.cursor_changed.apply(
+                                      _this, [ _this, '']
+                                   );
+                                         });
+                              },
+                            items : [
+                                {
+                                    xtype: Gtk.ListStore,
+                                    id : "branchStore",
+                                    pack : "set_model",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                        this.el.set_column_types ( 3, [
+                                           GObject.TYPE_STRING, // file  
+                                          GObject.TYPE_STRING, // added
+                                          GObject.TYPE_STRING, // removed
+                                      ] );
+                                    },
+                                    load : function(tr)
+                                    {
+                                        //this.insert(citer,iter,0);
+                                        this.el.clear();
+                                        
+                                        var tr = Branches.repo.getBranches();
+                                        
+                                        
+                                        for(var i =0 ; i < tr.length; i++) {
+                                            var ret = {  };
+                                           
+                                            this.el.append(ret);
+                                            
+                                            //print(JSON.stringify(ret,null,4));
+                                            var lastrev = tr[i].lastrev;
+                                            var remoterev = tr[i].remoterev;
+                                            
+                                            var lastrev = lastrev.length ? lastrev : remoterev;
+                                            
+                                            if (lastrev != remoterev) {
+                                                lastrev = "Out of sync: remote=" + remoterev + ", local=" + lastrev;
+                                            }
+                                            
+                                     
+                                              
+                                            this.el.set_value(ret.iter, 0, ''  +  tr[i].name );
+                                            this.el.set_value(ret.iter, 1, '' + tr[i].remote );
+                                            this.el.set_value(ret.iter, 2, '' + lastrev );
+                                     
+                                            
+                                        }     
+                                    }
+                                },
+                                {
+                                    xtype: Gtk.TreeViewColumn,
+                                    min_width : 70,
+                                    pack : "append_column",
+                                    resizable : true,
+                                    title : "Local",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                        this.el.add_attribute(this.items[0].el , 'markup', 0 );
+                                    
+                                    },
+                                    items : [
+                                        {
+                                            xtype: Gtk.CellRendererText,
+                                            pack : "pack_start"
+                                        }
+                                    ]
+                                },
+                                {
+                                    xtype: Gtk.TreeViewColumn,
+                                    min_width : 70,
+                                    pack : "append_column",
+                                    resizable : true,
+                                    title : "Remote",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                        this.el.add_attribute(this.items[0].el , 'markup', 1 );
+                                    
+                                    },
+                                    items : [
+                                        {
+                                            xtype: Gtk.CellRendererText,
+                                            pack : "pack_start"
+                                        }
+                                    ]
+                                },
+                                {
+                                    xtype: Gtk.TreeViewColumn,
+                                    min_width : 200,
+                                    pack : "append_column",
+                                    title : "Status",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                        this.el.add_attribute(this.items[0].el , 'markup', 2 );
+                                    
+                                    },
+                                    items : [
+                                        {
+                                            xtype: Gtk.CellRendererText,
+                                            pack : "pack_start"
+                                        }
+                                    ]
+                                }
+                            ]
+                        },
+                        {
+                            xtype: Gtk.TreeView,
+                            pack : false,
+                            items : [
+                                {
+                                    xtype: Gtk.ListStore,
+                                    pack : false
+                                }
+                            ]
+                        }
+                    ]
+                }
+            ]
+        },
+        {
+            xtype: Gtk.Button,
+            label : "Cancel",
+            pack : "add_action_widget,0"
+        },
+        {
+            xtype: Gtk.Button,
+            id : "ok_button",
+            label : "OK",
+            pack : "add_action_widget,1"
+        }
+    ]
+});
+Branches.init();
+XObject.cache['/Branches'] = Branches;
diff --git a/Clones.bjs b/Clones.bjs
new file mode 100644 (file)
index 0000000..1f08553
--- /dev/null
@@ -0,0 +1,234 @@
+{
+    "id": "file-gtk-2",
+    "name": "Clones",
+    "parent": "",
+    "title": false,
+    "path": "/home/alan/gitlive/gitlive/Clones.bjs",
+    "items": [
+        {
+            "listeners": {
+                "destroy_event": "function (self, event) {\n      print(\"DESTROY?!\");\n     return true;\n}",
+                "response": "function (self, id) {\n  // hide\n     //if (id < 1) {\n        this.el.hide();\n        return;\n    //}\n    if (typeof(this.get('bug').getValue()) != 'object') {\n        print(\"ERROR\");\n        return;\n    }\n \n    this.el.hide();\n        \n    //var val = this.get('bug').getValue();\n     //   Seed.print(val);\n}"
+            },
+            "border_width": 3,
+            "default_height": 500,
+            "default_width": 600,
+            "title": "Manage Clones",
+            "xtype": "Dialog",
+            "|deletable": "true",
+            "|modal": "true",
+            "|show": "function(c) {\n    \n    if (!this.el) {\n        this.init();\n    }\n    var _this = this;\n    /*[ 'xtype'  ].forEach(function(k) {\n        _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]);\n    });\n\t// shouild set path..\n    */\n    this.el.set_deletable(false);\n    this.el.show_all();\n    // load clones..\n        this.get('/reposStore').load();\n    \n    //this.get('/ok_button').el.set_sensitive(false);\n    \n    // block until we return.\n    var run_ret = this.el.run();\n    if (run_ret < 1 ) {\n        return  \"DONE\";\n    }\n    print(\"RUN RETURN : \" + run_ret);\n    return \"DONE\";\n    //print(JSON.stringify(this.get('bug').getValue()));\n   // return this.get('bug').getValue();\n    //this.success = c.success;\n}\n",
+            "|xns": "Gtk",
+            "items": [
+                {
+                    "id": "Clones",
+                    "xtype": "VBox",
+                    "|pack": " function(p,e) {\n        p.el.get_content_area().pack_start(e.el,true,true,0)\n    }\n",
+                    "|xns": "Gtk",
+                    "items": [
+                        {
+                            "pack": "pack_start,false,true",
+                            "xtype": "HBox",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "listeners": {
+                                        "clicked": "function (self) {\n\n    var rv = this.get('/reposView');\n    var rs = this.get('/reposStore');\n    if (rv.el.get_selection().count_selected_rows() != 1) {\n        //nothing?\n        // error condition.\n        return;\n    }\n    var Remotes =     imports.Remotes.Remotes;\n    \n \n    var ret = {};       \n    var s = rv.el.get_selection();\n    var path = '';\n    s.selected_foreach(function(model,p,iter) {\n                                                    \n       path = model.get_value(iter, 6).value.get_string();\n     \n    }); \n\n    var repo = false;\n    rs.repos.forEach(function(r) {\n        if (r.repopath == path) {\n            repo = r;\n        \n        }\n    \n    });\n    Remotes.repo = repo;\n    Remotes.el.set_transient_for(Clones.el);\n    Clones.el.set_title(\"Manage Clones - \" + repo.repopath);\n    Remotes.show();\n    Clones.el.set_title(\"Manage Clones\");\n\n     \n    \n    \n    \n\n       \n    \n    \n}"
+                                    },
+                                    "label": "Remotes / Clones",
+                                    "pack": "add",
+                                    "xtype": "Button",
+                                    "|xns": "Gtk"
+                                },
+                                {
+                                    "listeners": {
+                                        "clicked": "function (self) {\n\n    var rv = this.get('/reposView');\n    var rs = this.get('/reposStore');\n    if (rv.el.get_selection().count_selected_rows() != 1) {\n        //nothing?\n        // error condition.\n        return;\n    }\n    var Branches =     imports.Branches.Branches;\n    \n \n    var ret = {};       \n    var s = rv.el.get_selection();\n    var path = '';\n    s.selected_foreach(function(model,p,iter) {\n                                                    \n       path = model.get_value(iter, 6).value.get_string();\n     \n    }); \n\n    var repo = false;\n    rs.repos.forEach(function(r) {\n        if (r.repopath == path) {\n            repo = r;\n        \n        }\n    \n    });\n    Branches.repo = repo;\n    Branches.el.set_transient_for(Clones.el);\n    Clones.el.set_title(\"Manage Clones - \" + repo.repopath);\n    Branches.show();\n    Clones.el.set_title(\"Manage Clones\");\n\n     \n    \n    \n    \n\n       \n    \n    \n}"
+                                    },
+                                    "label": "Branches",
+                                    "pack": "add",
+                                    "xtype": "Button",
+                                    "|xns": "Gtk"
+                                },
+                                {
+                                    "listeners": {
+                                        "clicked": "function (self) {\n\n    var rv = this.get('/reposView');\n    var rs = this.get('/reposStore');\n    if (rv.el.get_selection().count_selected_rows() != 1) {\n        //nothing?\n        // error condition.\n        return;\n    }\n    var Merger =     imports.Merger.Merger;\n    \n \n    var ret = {};       \n    var s = rv.el.get_selection();\n    var path = '';\n    s.selected_foreach(function(model,p,iter) {\n                                                    \n       path = model.get_value(iter, 6).value.get_string();\n     \n    }); \n\n    var repo = false;\n    rs.repos.forEach(function(r) {\n        if (r.repopath == path) {\n            repo = r;\n        \n        }\n    \n    });\n    Merger.repo = repo;\n    Merger.el.set_transient_for(Clones.el);\n    Clones.el.set_title(\"Manage Clones - \" + repo.repopath);\n    Merger.show();\n    Clones.el.set_title(\"Manage Clones\");\n\n    \n    \n\n    \n\n    \n    \n    \n    \n\n       \n    \n    \n}"
+                                    },
+                                    "label": "Run Merger",
+                                    "pack": "add",
+                                    "xtype": "Button",
+                                    "|xns": "Gtk"
+                                },
+                                {
+                                    "listeners": {
+                                        "clicked": "function (self) {\n    \n    \n \n       \n    \n    \n}"
+                                    },
+                                    "label": "Switch Branch",
+                                    "pack": "add",
+                                    "xtype": "Button",
+                                    "|xns": "Gtk"
+                                },
+                                {
+                                    "listeners": {
+                                        "clicked": "function (self) {\n    \n    \n \n       \n    \n    \n}"
+                                    },
+                                    "label": "Pull",
+                                    "pack": "add",
+                                    "xtype": "Button",
+                                    "|xns": "Gtk"
+                                }
+                            ]
+                        },
+                        {
+                            "xtype": "ScrolledWindow",
+                            "|init": "function() {\n    XObject.prototype.init.call(this);\n      this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "listeners": {
+                                        "cursor_changed": "function (self) {\n  // SEE SELECTION.CHANGED\n  \n  \n  return;\n  \n    if (this.el.get_selection().count_selected_rows() < 1) {\n        //nothing? - clea it?\n        return;\n    }\n        var ret = {};         \n    var model = this.get('/changedFilesStore');\n\n     var s = this.el.get_selection();\n     var files = [];\n    s.selected_foreach(function(model,p,iter) {\n    \n       files.push( model.get_value(iter, 0).value.get_string());\n     \n    });\n    this.get('/patchview').showDiff(files); \n    //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();\n     //print(\"OUT?\" + value);// id..\n    // load the list in the right grid..\n     \n    return true;\n\n}"
+                                    },
+                                    "id": "reposView",
+                                    "pack": "add",
+                                    "xtype": "TreeView",
+                                    "|init": "function() {\n    XObject.prototype.init.call(this);\n        var description = new Pango.FontDescription.c_new();\n   description.set_size(10000);\n     this.el.modify_font(description);\n\n     this.selection = this.el.get_selection();\n      this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);\n    var _this = this;\n    \n    \n  this.selection.signal['changed'].connect(function() {\n     _this.listeners.cursor_changed.apply(\n          _this, [ _this, '']\n       );\n             });\n  }\n",
+                                    "|xns": "Gtk",
+                                    "items": [
+                                        {
+                                            "id": "reposStore",
+                                            "pack": "set_model",
+                                            "xtype": "ListStore",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.set_column_types ( 8, [\n       GObject.TYPE_STRING, // repo  \n      GObject.TYPE_STRING, // current branch\n      GObject.TYPE_STRING, // all branch      \n      GObject.TYPE_STRING, // updated\n       GObject.TYPE_BOOLEAN, // auto-commit\n        GObject.TYPE_BOOLEAN, // auto-push\n           GObject.TYPE_STRING, // repopath\n           GObject.TYPE_STRING // color highighling \n  ] );\n}\n",
+                                            "|load": "function()\n{\n    //this.insert(citer,iter,0);\n    print(\"getting list\");\n    this.repos = imports.Scm.Repo.Repo.list();\n    var tr= this.repos;\n    this.el.clear();\n    \n    for(var i =0 ; i < tr.length; i++) {\n        var ret = {  };\n       \n        this.el.append(ret);\n        \n        //print(JSON.stringify(ret,null,4));\n         tr[i].getBranches();\n         var hi;\n         try {\n             //tr[i].debug=1;\n              hi = tr[i].history('/', 1, 'branch', tr[i].currentBranch.name );\n//             print(JSON.stringify(hi,null,4));\n         } catch(e) { print(e);}\n          \n        this.el.set_value(ret.iter, 0, '' +  tr[i].repopath.split('/').pop() );\n        this.el.set_value(ret.iter, 1, '' + tr[i].currentBranch.name   );\n        this.el.set_value(ret.iter, 2, '' + tr[i].branches.map(\n                        function(e) { return e.name; \n                    }).join(', ') \n         );\n        this.el.set_value(ret.iter, 3, '' +  (!hi  ? '??' : hi[0].changed_raw));        \n        this.el.set_value(ret.iter, 4, tr[i].autocommit() );                \n        this.el.set_value(ret.iter, 5, tr[i].autopush() );                        \n        this.el.set_value(ret.iter, 6,  tr[i].repopath );  \n        // highlight color.\n        var cb = tr[i].currentBranch;\n        //print(JSON.stringify(cb,null,4));\n        var col = cb.lastrev == cb.remoterev ? '#ffffff' : '#ff0000';\n        this.el.set_value(ret.iter, 7, col  );      \n        \n    }     \n}",
+                                            "|xns": "Gtk"
+                                        },
+                                        {
+                                            "min_width": 50,
+                                            "pack": "append_column",
+                                            "title": "Auto Commit",
+                                            "xtype": "TreeViewColumn",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'active', 4 );\n    this.items[0].el.set_activatable(true);\n\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "listeners": {
+                                                        "toggled": "function (self, path) {\n    var ret ={} ;\n    var store = this.get('/reposStore');\n    store.el.get_iter_from_string(ret, path);\n                                                                 \n    var value =   store.el.get_value(ret.iter,4).value.get_boolean();\n                                                                 \n    //print(JSON.stringify(value));\n    store.el.set_value(ret.iter,4, !value);\n    \n}"
+                                                    },
+                                                    "pack": "pack_start",
+                                                    "xtype": "CellRendererToggle",
+                                                    "|mode": "Gtk.CellRendererMode.ACTIVATABLE",
+                                                    "|xns": "Gtk"
+                                                }
+                                            ]
+                                        },
+                                        {
+                                            "min_width": 50,
+                                            "pack": "append_column",
+                                            "title": "Auto Push",
+                                            "xtype": "TreeViewColumn",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'active', 5 );\n      this.items[0].el.set_activatable(true);\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "listeners": {
+                                                        "toggled": "function (self, path) {\n    var ret ={} ;\n    var store = this.get('/reposStore');\n    store.el.get_iter_from_string(ret, path);\n                                                                 \n    var value =   store.el.get_value(ret.iter,5).value.get_boolean();\n                                                                 \n    //print(JSON.stringify(value));\n    store.el.set_value(ret.iter,5, !value);\n    \n}"
+                                                    },
+                                                    "pack": "pack_start",
+                                                    "xtype": "CellRendererToggle",
+                                                    "|mode": "Gtk.CellRendererMode.ACTIVATABLE",
+                                                    "|xns": "Gtk"
+                                                }
+                                            ]
+                                        },
+                                        {
+                                            "min_width": 200,
+                                            "pack": "append_column",
+                                            "resizable": true,
+                                            "title": "Repo",
+                                            "xtype": "TreeViewColumn",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 0 );\n\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "pack": "pack_start",
+                                                    "xtype": "CellRendererText",
+                                                    "|xns": "Gtk"
+                                                }
+                                            ]
+                                        },
+                                        {
+                                            "min_width": 50,
+                                            "pack": "append_column",
+                                            "title": "Current Branch",
+                                            "xtype": "TreeViewColumn",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 1 );\n     this.el.add_attribute(this.items[0].el , 'cell-background', 7 );\n\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "pack": "pack_start",
+                                                    "xtype": "CellRendererText",
+                                                    "|xns": "Gtk"
+                                                }
+                                            ]
+                                        },
+                                        {
+                                            "min_width": 50,
+                                            "pack": "append_column",
+                                            "title": "Last updated",
+                                            "xtype": "TreeViewColumn",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 3 );\n\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "pack": "pack_start",
+                                                    "xtype": "CellRendererText",
+                                                    "|xns": "Gtk"
+                                                }
+                                            ]
+                                        },
+                                        {
+                                            "min_width": 50,
+                                            "pack": "append_column",
+                                            "resizable": false,
+                                            "title": "All Branches",
+                                            "xtype": "TreeViewColumn",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 2 );\n\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "pack": "pack_start",
+                                                    "xtype": "CellRendererText",
+                                                    "|xns": "Gtk"
+                                                }
+                                            ]
+                                        }
+                                    ]
+                                },
+                                {
+                                    "|xns": "Gtk",
+                                    "xtype": "TreeView",
+                                    "pack": false,
+                                    "items": [
+                                        {
+                                            "|xns": "Gtk",
+                                            "xtype": "ListStore",
+                                            "pack": false
+                                        }
+                                    ]
+                                }
+                            ]
+                        }
+                    ]
+                },
+                {
+                    "id": "ok_button",
+                    "label": "Close",
+                    "pack": "add_action_widget,1",
+                    "xtype": "Button",
+                    "|xns": "Gtk"
+                }
+            ]
+        }
+    ],
+    "permname": "",
+    "modOrder": ""
+}
\ No newline at end of file
diff --git a/Clones.js b/Clones.js
new file mode 100644 (file)
index 0000000..553a8ad
--- /dev/null
+++ b/Clones.js
@@ -0,0 +1,549 @@
+Gtk = imports.gi.Gtk;
+Gdk = imports.gi.Gdk;
+Pango = imports.gi.Pango;
+GLib = imports.gi.GLib;
+Gio = imports.gi.Gio;
+GObject = imports.gi.GObject;
+GtkSource = imports.gi.GtkSource;
+WebKit = imports.gi.WebKit;
+Vte = imports.gi.Vte;
+console = imports.console;
+XObject = imports.XObject.XObject;
+Clones=new XObject({
+    xtype: Gtk.Dialog,
+    listeners : {
+        destroy_event : function (self, event) {
+              print("DESTROY?!");
+             return true;
+        },
+        response : function (self, id) {
+          // hide
+             //if (id < 1) {
+                this.el.hide();
+                return;
+            //}
+            if (typeof(this.get('bug').getValue()) != 'object') {
+                print("ERROR");
+                return;
+            }
+         
+            this.el.hide();
+                
+            //var val = this.get('bug').getValue();
+             //   Seed.print(val);
+        }
+    },
+    border_width : 3,
+    default_height : 500,
+    default_width : 600,
+    title : "Manage Clones",
+    deletable : true,
+    modal : true,
+    show : function(c) {
+        
+        if (!this.el) {
+            this.init();
+        }
+        var _this = this;
+        /*[ 'xtype'  ].forEach(function(k) {
+            _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]);
+        });
+       // shouild set path..
+        */
+        this.el.set_deletable(false);
+        this.el.show_all();
+        // load clones..
+            this.get('/reposStore').load();
+        
+        //this.get('/ok_button').el.set_sensitive(false);
+        
+        // block until we return.
+        var run_ret = this.el.run();
+        if (run_ret < 1 ) {
+            return  "DONE";
+        }
+        print("RUN RETURN : " + run_ret);
+        return "DONE";
+        //print(JSON.stringify(this.get('bug').getValue()));
+       // return this.get('bug').getValue();
+        //this.success = c.success;
+    },
+    items : [
+        {
+            xtype: Gtk.VBox,
+            id : "Clones",
+            pack : function(p,e) {
+                    p.el.get_content_area().pack_start(e.el,true,true,0)
+                },
+            items : [
+                {
+                    xtype: Gtk.HBox,
+                    pack : "pack_start,false,true",
+                    items : [
+                        {
+                            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 : "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 : "Branches",
+                            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 Merger =     imports.Merger.Merger;
+                                    
+                                 
+                                    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;
+                                        
+                                        }
+                                    
+                                    });
+                                    Merger.repo = repo;
+                                    Merger.el.set_transient_for(Clones.el);
+                                    Clones.el.set_title("Manage Clones - " + repo.repopath);
+                                    Merger.show();
+                                    Clones.el.set_title("Manage Clones");
+                                
+                                    
+                                    
+                                
+                                    
+                                
+                                    
+                                    
+                                    
+                                    
+                                
+                                       
+                                    
+                                    
+                                }
+                            },
+                            label : "Run Merger",
+                            pack : "add"
+                        },
+                        {
+                            xtype: Gtk.Button,
+                            listeners : {
+                                clicked : function (self) {
+                                    
+                                    
+                                 
+                                       
+                                    
+                                    
+                                }
+                            },
+                            label : "Switch Branch",
+                            pack : "add"
+                        },
+                        {
+                            xtype: Gtk.Button,
+                            listeners : {
+                                clicked : function (self) {
+                                    
+                                    
+                                 
+                                       
+                                    
+                                    
+                                }
+                            },
+                            label : "Pull",
+                            pack : "add"
+                        }
+                    ]
+                },
+                {
+                    xtype: Gtk.ScrolledWindow,
+                    init : function() {
+                        XObject.prototype.init.call(this);
+                          this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+                    },
+                    items : [
+                        {
+                            xtype: Gtk.TreeView,
+                            listeners : {
+                                cursor_changed : function (self) {
+                                  // SEE SELECTION.CHANGED
+                                  
+                                  
+                                  return;
+                                  
+                                    if (this.el.get_selection().count_selected_rows() < 1) {
+                                        //nothing? - clea it?
+                                        return;
+                                    }
+                                        var ret = {};         
+                                    var model = this.get('/changedFilesStore');
+                                
+                                     var s = this.el.get_selection();
+                                     var files = [];
+                                    s.selected_foreach(function(model,p,iter) {
+                                    
+                                       files.push( model.get_value(iter, 0).value.get_string());
+                                     
+                                    });
+                                    this.get('/patchview').showDiff(files); 
+                                    //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
+                                     //print("OUT?" + value);// id..
+                                    // load the list in the right grid..
+                                     
+                                    return true;
+                                
+                                }
+                            },
+                            id : "reposView",
+                            pack : "add",
+                            init : function() {
+                                XObject.prototype.init.call(this);
+                                    var description = new Pango.FontDescription.c_new();
+                               description.set_size(10000);
+                                 this.el.modify_font(description);
+                            
+                                 this.selection = this.el.get_selection();
+                                  this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);
+                                var _this = this;
+                                
+                                
+                              this.selection.signal['changed'].connect(function() {
+                                 _this.listeners.cursor_changed.apply(
+                                      _this, [ _this, '']
+                                   );
+                                         });
+                              },
+                            items : [
+                                {
+                                    xtype: Gtk.ListStore,
+                                    id : "reposStore",
+                                    pack : "set_model",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                        this.el.set_column_types ( 8, [
+                                           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 // color highighling 
+                                      ] );
+                                    },
+                                    load : function()
+                                    {
+                                        //this.insert(citer,iter,0);
+                                        print("getting list");
+                                        this.repos = imports.Scm.Repo.Repo.list();
+                                        var tr= this.repos;
+                                        this.el.clear();
+                                        
+                                        for(var i =0 ; i < tr.length; i++) {
+                                            var ret = {  };
+                                           
+                                            this.el.append(ret);
+                                            
+                                            //print(JSON.stringify(ret,null,4));
+                                             tr[i].getBranches();
+                                             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.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, '' +  (!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 );  
+                                            // highlight color.
+                                            var cb = tr[i].currentBranch;
+                                            //print(JSON.stringify(cb,null,4));
+                                            var col = cb.lastrev == cb.remoterev ? '#ffffff' : '#ff0000';
+                                            this.el.set_value(ret.iter, 7, col  );      
+                                            
+                                        }     
+                                    }
+                                },
+                                {
+                                    xtype: Gtk.TreeViewColumn,
+                                    min_width : 50,
+                                    pack : "append_column",
+                                    title : "Auto Commit",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                        this.el.add_attribute(this.items[0].el , 'active', 4 );
+                                        this.items[0].el.set_activatable(true);
+                                    
+                                    },
+                                    items : [
+                                        {
+                                            xtype: Gtk.CellRendererToggle,
+                                            listeners : {
+                                                toggled : function (self, path) {
+                                                    var ret ={} ;
+                                                    var store = this.get('/reposStore');
+                                                    store.el.get_iter_from_string(ret, path);
+                                                                                                                 
+                                                    var value =   store.el.get_value(ret.iter,4).value.get_boolean();
+                                                                                                                 
+                                                    //print(JSON.stringify(value));
+                                                    store.el.set_value(ret.iter,4, !value);
+                                                    
+                                                }
+                                            },
+                                            pack : "pack_start",
+                                            mode : Gtk.CellRendererMode.ACTIVATABLE
+                                        }
+                                    ]
+                                },
+                                {
+                                    xtype: Gtk.TreeViewColumn,
+                                    min_width : 50,
+                                    pack : "append_column",
+                                    title : "Auto Push",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                        this.el.add_attribute(this.items[0].el , 'active', 5 );
+                                          this.items[0].el.set_activatable(true);
+                                    },
+                                    items : [
+                                        {
+                                            xtype: Gtk.CellRendererToggle,
+                                            listeners : {
+                                                toggled : function (self, path) {
+                                                    var ret ={} ;
+                                                    var store = this.get('/reposStore');
+                                                    store.el.get_iter_from_string(ret, path);
+                                                                                                                 
+                                                    var value =   store.el.get_value(ret.iter,5).value.get_boolean();
+                                                                                                                 
+                                                    //print(JSON.stringify(value));
+                                                    store.el.set_value(ret.iter,5, !value);
+                                                    
+                                                }
+                                            },
+                                            pack : "pack_start",
+                                            mode : Gtk.CellRendererMode.ACTIVATABLE
+                                        }
+                                    ]
+                                },
+                                {
+                                    xtype: Gtk.TreeViewColumn,
+                                    min_width : 200,
+                                    pack : "append_column",
+                                    resizable : true,
+                                    title : "Repo",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                        this.el.add_attribute(this.items[0].el , 'markup', 0 );
+                                    
+                                    },
+                                    items : [
+                                        {
+                                            xtype: Gtk.CellRendererText,
+                                            pack : "pack_start"
+                                        }
+                                    ]
+                                },
+                                {
+                                    xtype: Gtk.TreeViewColumn,
+                                    min_width : 50,
+                                    pack : "append_column",
+                                    title : "Current Branch",
+                                    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 : [
+                                        {
+                                            xtype: Gtk.CellRendererText,
+                                            pack : "pack_start"
+                                        }
+                                    ]
+                                },
+                                {
+                                    xtype: Gtk.TreeViewColumn,
+                                    min_width : 50,
+                                    pack : "append_column",
+                                    title : "Last updated",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                        this.el.add_attribute(this.items[0].el , 'markup', 3 );
+                                    
+                                    },
+                                    items : [
+                                        {
+                                            xtype: Gtk.CellRendererText,
+                                            pack : "pack_start"
+                                        }
+                                    ]
+                                },
+                                {
+                                    xtype: Gtk.TreeViewColumn,
+                                    min_width : 50,
+                                    pack : "append_column",
+                                    resizable : false,
+                                    title : "All Branches",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                        this.el.add_attribute(this.items[0].el , 'markup', 2 );
+                                    
+                                    },
+                                    items : [
+                                        {
+                                            xtype: Gtk.CellRendererText,
+                                            pack : "pack_start"
+                                        }
+                                    ]
+                                }
+                            ]
+                        },
+                        {
+                            xtype: Gtk.TreeView,
+                            pack : false,
+                            items : [
+                                {
+                                    xtype: Gtk.ListStore,
+                                    pack : false
+                                }
+                            ]
+                        }
+                    ]
+                }
+            ]
+        },
+        {
+            xtype: Gtk.Button,
+            id : "ok_button",
+            label : "Close",
+            pack : "add_action_widget,1"
+        }
+    ]
+});
+Clones.init();
+XObject.cache['/Clones'] = Clones;
diff --git a/Commit.bjs b/Commit.bjs
new file mode 100644 (file)
index 0000000..b24740e
--- /dev/null
@@ -0,0 +1,161 @@
+{
+    "id": "file-gtk-3",
+    "name": "Commit",
+    "parent": "",
+    "title": false,
+    "path": "/home/alan/gitlive/gitlive/Commit.bjs",
+    "items": [
+        {
+            "listeners": {
+                "destroy_event": "function (self, event) {\n     this.el.hide();\n                return false;\n}",
+                "response": "function (self, id) {\n  // hide\n     //if (id < 1) {\n        this.el.hide();\n        return;\n    //}\n    if (typeof(this.get('bug').getValue()) != 'object') {\n        print(\"ERROR\");\n        return;\n    }\n \n    this.el.hide();\n        \n    //var val = this.get('bug').getValue();\n     //   Seed.print(val);\n}"
+            },
+            " modal": true,
+            "border_width": 3,
+            "default_height": 500,
+            "default_width": 800,
+            "title": "Commit",
+            "xtype": "Dialog",
+            "|deletable": "true",
+            "|modal": "true",
+            "|show": "function(c) {\n    \n    if (!this.el) {\n        this.init();\n    }\n    var _this = this;\n    \n    \n    this.files = c.files;\n    this.release = c.release;\n    this.rev = c.rev;\n    \n    this.repo = c.repo;\n\n    this.get('/commitDate').el.set_text(c.changed);\n    this.get('/commitAuthor').el.set_text(c.author);\n    this.get('/commitMsg').el.get_buffer().set_text('');\n    this.get('/commitPatch').showDiff(c.files);\n    \n    this.el.show_all();\n    \n    var run_ret = this.el.run();\n    if (run_ret < 1 ) {\n        return false;\n    }\n    var buf = this.get('/commitMsg').el.get_buffer();\n    var e = {};\n    var s = {};\n    buf.get_start_iter(s);\n    buf.get_end_iter(e);\n    \n    var ret=  {\n        date :  this.get('/commitDate').el.get_text(),\n        author :  this.get('/commitAuthor').el.get_text(),\n        message : buf.get_text(s.value, e.value, false)\n    };\n \n    return ret;\n    \n    \n    \n}\n",
+            "|xns": "Gtk",
+            "items": [
+                {
+                    "xtype": "VBox",
+                    "|pack": " function(p,e) {\n        p.el.get_content_area().pack_start(e.el,true,true,10);\n    }\n",
+                    "|xns": "Gtk",
+                    "items": [
+                        {
+                            "pack": "pack_start,false,true,2",
+                            "xtype": "HBox",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "label": "Fixes",
+                                    "pack": "pack_start,false,false,10",
+                                    "width_request": 50,
+                                    "xtype": "Label",
+                                    "|xns": "Gtk"
+                                },
+                                {
+                                    "listeners": {
+                                        "changed": "function (self) {\n   var val = this.el.get_child().get_text();\n   print(JSON.stringify(val));\n   if (!val.length) {\n       return;\n   }\n   \n   var name = this.get('/remoteName').el.get_text();\n   if (name.length) {\n       return;\n   }\n   // fill in name\n   var val = imports.Scm.Git.Repo.Repo.parseURL(val);\n   if ((typeof(val.host) != 'undefined') && val.host.length) {\n       var host = val.host;\n       // need to add github owner...\n        if (host.match(/github.com$/)) {\n          host += '.' + val.path.split('/').shift();\n        }\n   \n   \n        this.get('/remoteName').el.set_text(host);\n   }\n    \n   \n}"
+                                    },
+                                    "id": "commitFixes",
+                                    "xtype": "ComboBox",
+                                    "|init": "function() {\n    this.el = new Gtk.ComboBox.with_entry();\n    \n    \n    this.model  = new XObject(this.model);\n    this.model.init();\n    this.el.set_model(this.model.el);\n    this.el.set_entry_text_column (0);\n     XObject.prototype.init.call(this);\n    \n}\n",
+                                    "|load": "function(tr)\n{\n    //this.insert(citer,iter,0);\n    this.model.el.clear();\n    \n    var master = false;\n    var working = false;\n    \n    for(var i =0 ; i < tr.length; i++) {\n        var ret = {  };\n        this.model.el.append(ret);\n        //print(JSON.stringify(ret,null,4));\n        if (tr[i].name == 'master') {\n            master = i;\n        }\n        if (tr[i].name == 'working') {\n            working = i;\n        }          \n        this.model.el.set_value(ret.iter, 0, '' + tr[i].name );\n        this.model.el.set_value(ret.iter, 1, '' + tr[i].rev  );\n \n        \n    }     \n    if (master !== false) {\n        this.el.set_active(master);\n    }\n    if (working !== false) {\n        this.el.set_active(working);\n    }\n    \n}",
+                                    "|xns": "Gtk",
+                                    "items": [
+                                        {
+                                            "*prop": "model",
+                                            "xtype": "ListStore",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.set_column_types ( 3, [\n           GObject.TYPE_STRING, // file  \n          GObject.TYPE_STRING, // added\n          GObject.TYPE_STRING, // removed\n      ] );\n}\n",
+                                            "|xns": "Gtk"
+                                        }
+                                    ]
+                                }
+                            ]
+                        },
+                        {
+                            "pack": "pack_start,false,true,2",
+                            "xtype": "HBox",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "label": "Date",
+                                    "pack": "pack_start,false,false,10",
+                                    "width_request": 50,
+                                    "xalign": 1,
+                                    "xtype": "Label",
+                                    "|xns": "Gtk"
+                                },
+                                {
+                                    "id": "commitDate",
+                                    "xtype": "Entry",
+                                    "|xns": "Gtk"
+                                }
+                            ]
+                        },
+                        {
+                            "pack": "pack_start,false,true,2",
+                            "xtype": "HBox",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "label": "Author",
+                                    "pack": "pack_start,false,false,10",
+                                    "width_request": 50,
+                                    "xalign": 1,
+                                    "xtype": "Label",
+                                    "|xns": "Gtk"
+                                },
+                                {
+                                    "id": "commitAuthor",
+                                    "xtype": "Entry",
+                                    "|xns": "Gtk"
+                                }
+                            ]
+                        },
+                        {
+                            "pack": "pack_start,false,false,2",
+                            "xtype": "HBox",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "label": "Message",
+                                    "pack": "pack_start,false,false,10",
+                                    "width_request": 50,
+                                    "xalign": 1,
+                                    "xtype": "Label",
+                                    "|xns": "Gtk"
+                                },
+                                {
+                                    "height_request": 100,
+                                    "id": "commitMsg",
+                                    "pack": "add",
+                                    "xtype": "TextView",
+                                    "|xns": "Gtk"
+                                }
+                            ]
+                        },
+                        {
+                            "height_request": 200,
+                            "pack": "pack_end,true,true,0",
+                            "xtype": "ScrolledWindow",
+                            "|init": "function() {\n    XObject.prototype.init.call(this);\n      this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "id": "commitPatch",
+                                    "pack": "add",
+                                    "xtype": "WebView",
+                                    "|clear": "function() {\n    \n    \n    \n     \n   // remove..\n    var s  = \"document.body.textContent='';\"\n        \n    this.el.execute_script(s);\n        \n        \n    \n    \n    \n}\n",
+                                    "|showDiff": "function(files) {\n    this.clear();\n    \n    \n    \n    if (Commit.release === false) {\n        return;\n    }\n    \n    var diff = Commit.repo.diff(files, Commit.release, Commit.rev);\n    \n   // remove..\n    var s  = \"var pre  = document.createElement('pre'); document.body.appendChild(pre);\";\n    s += \"pre.textContent =  \" +\n             JSON.stringify(Commit.repo.lastCmd + \"\\n\") + '+  ' + \n             JSON.stringify(diff) + \";\";\n        \n    this.el.execute_script(s);\n        \n        \n    \n    \n    \n}\n",
+                                    "|xns": "WebKit"
+                                }
+                            ]
+                        }
+                    ]
+                },
+                {
+                    "label": "Cancel",
+                    "pack": "add_action_widget,0",
+                    "xtype": "Button",
+                    "|xns": "Gtk",
+                    "listeners": {}
+                },
+                {
+                    "id": "ok_button",
+                    "label": "Add",
+                    "pack": "add_action_widget,1",
+                    "xtype": "Button",
+                    "|xns": "Gtk"
+                }
+            ]
+        }
+    ],
+    "permname": "",
+    "modOrder": ""
+}
\ No newline at end of file
diff --git a/Commit.js b/Commit.js
new file mode 100644 (file)
index 0000000..e56a48e
--- /dev/null
+++ b/Commit.js
@@ -0,0 +1,313 @@
+Gtk = imports.gi.Gtk;
+Gdk = imports.gi.Gdk;
+Pango = imports.gi.Pango;
+GLib = imports.gi.GLib;
+Gio = imports.gi.Gio;
+GObject = imports.gi.GObject;
+GtkSource = imports.gi.GtkSource;
+WebKit = imports.gi.WebKit;
+Vte = imports.gi.Vte;
+console = imports.console;
+XObject = imports.XObject.XObject;
+Commit=new XObject({
+    xtype: Gtk.Dialog,
+    listeners : {
+        destroy_event : function (self, event) {
+             this.el.hide();
+                        return false;
+        },
+        response : function (self, id) {
+          // hide
+             //if (id < 1) {
+                this.el.hide();
+                return;
+            //}
+            if (typeof(this.get('bug').getValue()) != 'object') {
+                print("ERROR");
+                return;
+            }
+         
+            this.el.hide();
+                
+            //var val = this.get('bug').getValue();
+             //   Seed.print(val);
+        }
+    },
+    ' modal' : true,
+    border_width : 3,
+    default_height : 500,
+    default_width : 800,
+    title : "Commit",
+    deletable : true,
+    modal : true,
+    show : function(c) {
+        
+        if (!this.el) {
+            this.init();
+        }
+        var _this = this;
+        
+        
+        this.files = c.files;
+        this.release = c.release;
+        this.rev = c.rev;
+        
+        this.repo = c.repo;
+    
+        this.get('/commitDate').el.set_text(c.changed);
+        this.get('/commitAuthor').el.set_text(c.author);
+        this.get('/commitMsg').el.get_buffer().set_text('');
+        this.get('/commitPatch').showDiff(c.files);
+        
+        this.el.show_all();
+        
+        var run_ret = this.el.run();
+        if (run_ret < 1 ) {
+            return false;
+        }
+        var buf = this.get('/commitMsg').el.get_buffer();
+        var e = {};
+        var s = {};
+        buf.get_start_iter(s);
+        buf.get_end_iter(e);
+        
+        var ret=  {
+            date :  this.get('/commitDate').el.get_text(),
+            author :  this.get('/commitAuthor').el.get_text(),
+            message : buf.get_text(s.value, e.value, false)
+        };
+     
+        return ret;
+        
+        
+        
+    },
+    items : [
+        {
+            xtype: Gtk.VBox,
+            pack : function(p,e) {
+                    p.el.get_content_area().pack_start(e.el,true,true,10);
+                },
+            items : [
+                {
+                    xtype: Gtk.HBox,
+                    pack : "pack_start,false,true,2",
+                    items : [
+                        {
+                            xtype: Gtk.Label,
+                            label : "Fixes",
+                            pack : "pack_start,false,false,10",
+                            width_request : 50
+                        },
+                        {
+                            xtype: Gtk.ComboBox,
+                            listeners : {
+                                changed : function (self) {
+                                   var val = this.el.get_child().get_text();
+                                   print(JSON.stringify(val));
+                                   if (!val.length) {
+                                       return;
+                                   }
+                                   
+                                   var name = this.get('/remoteName').el.get_text();
+                                   if (name.length) {
+                                       return;
+                                   }
+                                   // fill in name
+                                   var val = imports.Scm.Git.Repo.Repo.parseURL(val);
+                                   if ((typeof(val.host) != 'undefined') && val.host.length) {
+                                       var host = val.host;
+                                       // need to add github owner...
+                                        if (host.match(/github.com$/)) {
+                                          host += '.' + val.path.split('/').shift();
+                                        }
+                                   
+                                   
+                                        this.get('/remoteName').el.set_text(host);
+                                   }
+                                    
+                                   
+                                }
+                            },
+                            id : "commitFixes",
+                            init : function() {
+                                this.el = new Gtk.ComboBox.with_entry();
+                                
+                                
+                                this.model  = new XObject(this.model);
+                                this.model.init();
+                                this.el.set_model(this.model.el);
+                                this.el.set_entry_text_column (0);
+                                 XObject.prototype.init.call(this);
+                                
+                            },
+                            load : function(tr)
+                            {
+                                //this.insert(citer,iter,0);
+                                this.model.el.clear();
+                                
+                                var master = false;
+                                var working = false;
+                                
+                                for(var i =0 ; i < tr.length; i++) {
+                                    var ret = {  };
+                                    this.model.el.append(ret);
+                                    //print(JSON.stringify(ret,null,4));
+                                    if (tr[i].name == 'master') {
+                                        master = i;
+                                    }
+                                    if (tr[i].name == 'working') {
+                                        working = i;
+                                    }          
+                                    this.model.el.set_value(ret.iter, 0, '' + tr[i].name );
+                                    this.model.el.set_value(ret.iter, 1, '' + tr[i].rev  );
+                             
+                                    
+                                }     
+                                if (master !== false) {
+                                    this.el.set_active(master);
+                                }
+                                if (working !== false) {
+                                    this.el.set_active(working);
+                                }
+                                
+                            },
+                            model : {
+                                xtype: Gtk.ListStore,
+                                init : function() {
+                                    XObject.prototype.init.call(this);
+                                    this.el.set_column_types ( 3, [
+                                           GObject.TYPE_STRING, // file  
+                                          GObject.TYPE_STRING, // added
+                                          GObject.TYPE_STRING, // removed
+                                      ] );
+                                }
+                            }
+                        }
+                    ]
+                },
+                {
+                    xtype: Gtk.HBox,
+                    pack : "pack_start,false,true,2",
+                    items : [
+                        {
+                            xtype: Gtk.Label,
+                            label : "Date",
+                            pack : "pack_start,false,false,10",
+                            width_request : 50,
+                            xalign : 1
+                        },
+                        {
+                            xtype: Gtk.Entry,
+                            id : "commitDate"
+                        }
+                    ]
+                },
+                {
+                    xtype: Gtk.HBox,
+                    pack : "pack_start,false,true,2",
+                    items : [
+                        {
+                            xtype: Gtk.Label,
+                            label : "Author",
+                            pack : "pack_start,false,false,10",
+                            width_request : 50,
+                            xalign : 1
+                        },
+                        {
+                            xtype: Gtk.Entry,
+                            id : "commitAuthor"
+                        }
+                    ]
+                },
+                {
+                    xtype: Gtk.HBox,
+                    pack : "pack_start,false,false,2",
+                    items : [
+                        {
+                            xtype: Gtk.Label,
+                            label : "Message",
+                            pack : "pack_start,false,false,10",
+                            width_request : 50,
+                            xalign : 1
+                        },
+                        {
+                            xtype: Gtk.TextView,
+                            height_request : 100,
+                            id : "commitMsg",
+                            pack : "add"
+                        }
+                    ]
+                },
+                {
+                    xtype: Gtk.ScrolledWindow,
+                    height_request : 200,
+                    pack : "pack_end,true,true,0",
+                    init : function() {
+                        XObject.prototype.init.call(this);
+                          this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+                    },
+                    items : [
+                        {
+                            xtype: WebKit.WebView,
+                            id : "commitPatch",
+                            pack : "add",
+                            clear : function() {
+                                
+                                
+                                
+                                 
+                               // remove..
+                                var s  = "document.body.textContent='';"
+                                    
+                                this.el.execute_script(s);
+                                    
+                                    
+                                
+                                
+                                
+                            },
+                            showDiff : function(files) {
+                                this.clear();
+                                
+                                
+                                
+                                if (Commit.release === false) {
+                                    return;
+                                }
+                                
+                                var diff = Commit.repo.diff(files, Commit.release, Commit.rev);
+                                
+                               // remove..
+                                var s  = "var pre  = document.createElement('pre'); document.body.appendChild(pre);";
+                                s += "pre.textContent =  " +
+                                         JSON.stringify(Commit.repo.lastCmd + "\n") + '+  ' + 
+                                         JSON.stringify(diff) + ";";
+                                    
+                                this.el.execute_script(s);
+                                    
+                                    
+                                
+                                
+                                
+                            }
+                        }
+                    ]
+                }
+            ]
+        },
+        {
+            xtype: Gtk.Button,
+            label : "Cancel",
+            pack : "add_action_widget,0"
+        },
+        {
+            xtype: Gtk.Button,
+            id : "ok_button",
+            label : "Add",
+            pack : "add_action_widget,1"
+        }
+    ]
+});
+Commit.init();
+XObject.cache['/Commit'] = Commit;
diff --git a/Merger.bjs b/Merger.bjs
new file mode 100644 (file)
index 0000000..4f3b3d2
--- /dev/null
@@ -0,0 +1,276 @@
+{
+    "id": "file-gtk-5",
+    "name": "Merger",
+    "parent": "",
+    "title": false,
+    "path": "/home/alan/gitlive/gitlive/Merger.bjs",
+    "items": [
+        {
+            "listeners": {
+                "destroy_event": "function (self, event) {\n     this.el.hide();\n                return false;\n}",
+                "response": "function (self, id) {\n  // hide\n     //if (id < 1) {\n        this.el.hide();\n        return;\n    //}\n    if (typeof(this.get('bug').getValue()) != 'object') {\n        print(\"ERROR\");\n        return;\n    }\n \n    this.el.hide();\n        \n    //var val = this.get('bug').getValue();\n     //   Seed.print(val);\n}"
+            },
+            "border_width": 3,
+            "default_height": 700,
+            "default_width": 800,
+            "id": "Merger",
+            "title": "Merger",
+            "xtype": "Dialog",
+            "|deletable": "true",
+            "|show": "function(c) {\n    \n    if (!this.el) {\n        this.init();\n    }\n    var _this = this;\n     \n      //this.el.set_title(\"Merger - ??? \");\n//   this.el.set_title(\"Merger - \" + this.repo.repopath);\n\n\n     Merger.loading = true; // stop change firing on combos.\n     /// load up branches\n     \n     this.get('/historyTreeStore').el.clear();\n     this.get('/changedFilesStore').el.clear();\n     this.get('/patchview').clear();\n    \n     \n     \n     this.get('/workingCombo').load(Merger.repo.branches);\n     \n     this.get('/releaseCombo').load(Merger.repo.branches);\n\n\n\n\n     Merger.loading = false;\n\n    this.el.show_all();\n    //this.get('/ok_button').el.set_sensitive(false);\n    \n    // block until we return.\n    var run_ret = this.el.run();\n    if (run_ret < 1 ) {\n        return  \"DONE\";\n    }\n    print(\"RUN RETURN : \" + run_ret);\n    return \"DONE\";\n    //print(JSON.stringify(this.get('bug').getValue()));\n   // return this.get('bug').getValue();\n    //this.success = c.success;\n}\n",
+            "|xns": "Gtk",
+            "items": [
+                {
+                    "xtype": "VBox",
+                    "|pack": " function(p,e) {\n        p.el.get_content_area().pack_start(e.el,true,true,0)\n    }\n",
+                    "|xns": "Gtk",
+                    "items": [
+                        {
+                            "pack": "pack_start,false,true",
+                            "xtype": "HBox",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "label": "Working Branch",
+                                    "xtype": "Label",
+                                    "|xns": "Gtk"
+                                },
+                                {
+                                    "listeners": {
+                                        "changed": "function (self) {\n   this.get('/historyTreeStore').loadTree();\n}"
+                                    },
+                                    "id": "workingCombo",
+                                    "xtype": "ComboBox",
+                                    "|init": "function() {\n    this.el = new Gtk.ComboBox.with_entry();\n    \n    \n    this.model  = new XObject(this.model);\n    this.model.init();\n    this.el.set_model(this.model.el);\n    this.el.set_entry_text_column (0);\n     XObject.prototype.init.call(this);\n    \n}\n",
+                                    "|load": "function(tr)\n{\n    //this.insert(citer,iter,0);\n    this.model.el.clear();\n    \n    var master = false;\n    var working = false;\n    \n    for(var i =0 ; i < tr.length; i++) {\n        if (!tr[i].name.length) {\n            continue;\n        }\n        var ret = {  };\n        this.model.el.append(ret);\n        //print(JSON.stringify(ret,null,4));\n        if (tr[i].name == 'master') {\n            master = i;\n        }\n        if (tr[i].name == 'working') {\n            working = i;\n        }          \n        this.model.el.set_value(ret.iter, 0, '' + tr[i].name );\n        this.model.el.set_value(ret.iter, 1, '' + tr[i].rev  );\n \n        \n    }     \n    if (master !== false) {\n        this.el.set_active(master);\n    }\n    if (working !== false) {\n        this.el.set_active(working);\n    }\n    \n}",
+                                    "|xns": "Gtk",
+                                    "items": [
+                                        {
+                                            "*prop": "model",
+                                            "xtype": "ListStore",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.set_column_types ( 3, [\n           GObject.TYPE_STRING, // file  \n          GObject.TYPE_STRING, // added\n          GObject.TYPE_STRING, // removed\n      ] );\n}\n",
+                                            "|xns": "Gtk"
+                                        }
+                                    ]
+                                },
+                                {
+                                    "label": "Release Branch",
+                                    "xtype": "Label",
+                                    "|xns": "Gtk"
+                                },
+                                {
+                                    "listeners": {
+                                        "changed": "function (self) {\n   this.get('/historyTreeStore').loadTree();\n}"
+                                    },
+                                    "id": "releaseCombo",
+                                    "xtype": "ComboBox",
+                                    "|init": "function() {\n    this.el = new Gtk.ComboBox.with_entry();\n    \n    \n    this.model  = new XObject(this.model);\n    this.model.init();\n    this.el.set_model(this.model.el);\n    this.el.set_entry_text_column (0);\n     XObject.prototype.init.call(this);\n    \n}\n",
+                                    "|load": "function(tr)\n{\n    //this.insert(citer,iter,0);\n    this.model.el.clear();\n    \n    var master = false;\n    var release = false;\n    \n    for(var i =0 ; i < tr.length; i++) {\n        var ret = {  };\n        if (!tr[i].name.length) {\n            continue;\n        }\n        \n        this.model.el.append(ret);\n        //print(JSON.stringify(ret,null,4));\n        if (tr[i].name == 'master') {\n            master = i;\n        }\n        if (tr[i].name == 'release') {\n            release = i;\n        }\n         \n        this.model.el.set_value(ret.iter, 0, '' + tr[i].name );\n        this.model.el.set_value(ret.iter, 1, '' + tr[i].rev  );\n \n        \n    }     \n    if (master !== false) {\n        this.el.set_active(master);\n    }\n    if (release !== false) {\n        this.el.set_active(release);\n    }\n    \n}",
+                                    "|xns": "Gtk",
+                                    "items": [
+                                        {
+                                            "*prop": "model",
+                                            "xtype": "ListStore",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.set_column_types ( 3, [\n           GObject.TYPE_STRING, // file  \n          GObject.TYPE_STRING, // added\n          GObject.TYPE_STRING, // removed\n      ] );\n}\n",
+                                            "|xns": "Gtk"
+                                        }
+                                    ]
+                                }
+                            ]
+                        },
+                        {
+                            "pack": "pack_end,true,true,0",
+                            "position": 400,
+                            "xtype": "VPaned",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "pack": "add",
+                                    "position": 200,
+                                    "xtype": "HPaned",
+                                    "|xns": "Gtk",
+                                    "items": [
+                                        {
+                                            "xtype": "ScrolledWindow",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n     this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "listeners": {
+                                                        "cursor_changed": "function (self) {\n\n    if (this.el.get_selection().count_selected_rows() < 1) {\n        //nothing?\n        return;\n    }\n    var model = this.get('/historyTreeStore');\n    var ret = {};        \n     var s = this.el.get_selection();\n    s.get_selected(ret);\n    \n    var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();\n     print(\"OUT?\" + value);// id..\n    // load the list in the right grid..\n    var Repo = imports.Scm.Git.Repo.Repo;\n    \n    \n   \n    if (model.release === false) {\n        return;\n    }\n    model.rev = value;\n   \n    var files = Merger.repo.changedFiles('/',   'rev', model.release + '..' + value);\n    this.get('/changedFilesStore').load(files);\n    return true;\n\n}"
+                                                    },
+                                                    "pack": "add",
+                                                    "xtype": "TreeView",
+                                                    "|init": "function() {\n    XObject.prototype.init.call(this);\n        var description = new Pango.FontDescription.c_new();\n   description.set_size(8000);\n     this.el.modify_font(description);\n\n     this.selection = this.el.get_selection();\n      this.selection.set_mode( Gtk.SelectionMode.SINGLE);\n    var _this = this;\n    /*\n 780                                                                     \n 781                                                                         // is this really needed??\n 782                                                                         this.selection.signal['changed'].connect(function() {\n 783                                                                                 _this.get('/LeftTree.view').listeners.cursor_changed.apply(\n 784                                                                                     _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']\n 785                                                                                 );\n 786                                                                         });\n 787                                                                         \n */\n }\n",
+                                                    "|xns": "Gtk",
+                                                    "items": [
+                                                        {
+                                                            "id": "historyTreeStore",
+                                                            "pack": "set_model",
+                                                            "release": false,
+                                                            "xtype": "TreeStore",
+                                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.set_column_types ( 3, [\n       GObject.TYPE_STRING, // title \n      GObject.TYPE_STRING, // rev \n  ] );\n}\n",
+                                                            "|load": "function(tr,iter)\n{\n    //this.insert(citer,iter,0);\n    if (!iter) {\n        this.el.clear();\n    }\n    \n    for(var i =0 ; i < tr.length; i++) {\n        var ret = {  };\n        if (iter) {\n            this.el.insert(ret ,iter,-1);\n        } else {\n            this.el.append(ret);\n        }\n        //print(JSON.stringify(ret,null,4));\n         \n          \n        this.el.set_value(ret.iter, 0, ''  +  tr[i].text );\n        this.el.set_value(ret.iter, 1, '' + tr[i].rev  );\n \n        if (tr[i].children && tr[i].children.length) {\n            this.load(tr[i].children, ret.iter);\n        }\n    }     \n}",
+                                                            "|loadTree": "function() {\n\n   this.working = false;\n   if (Merger.loading) {\n        return;\n   }\n   \n   \n   var wid = this.get('/workingCombo').el.get_active();\n   var rid = this.get('/releaseCombo').el.get_active();\n   if (wid < 0 || rid < 0 || rid == wid) {\n        return;\n   }\n   \n   var w = Merger.repo.branches[wid];\n   var r = Merger.repo.branches[rid];\n   \n\n\n    var rev = r.name + '..' + w.name;\n    this.release = r.name;\n    this.working = w.name;\n    \n    // this takes some time, lets. try and dialog it..\n\n    \n    \n    \n    var msg = new Gtk.MessageDialog( {\n        buttons : Gtk.ButtonsType.NONE,\n        text: \"Loading History\"\n        \n    });\n    \n    msg.set_transient_for(Merger.el);\n    msg.set_modal(true);\n    msg.show_all();\n\n    var hist = Merger.repo.dayTree('/', false, 'rev', rev);\n    msg.hide();\n    \n    this.load(hist);\n        \n       \n}\n",
+                                                            "|xns": "Gtk"
+                                                        },
+                                                        {
+                                                            "pack": "append_column",
+                                                            "title": "Changes",
+                                                            "xtype": "TreeViewColumn",
+                                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 0 );\n\n}\n",
+                                                            "|xns": "Gtk",
+                                                            "items": [
+                                                                {
+                                                                    "pack": "pack_start",
+                                                                    "xtype": "CellRendererText",
+                                                                    "|xns": "Gtk"
+                                                                }
+                                                            ]
+                                                        }
+                                                    ]
+                                                }
+                                            ]
+                                        },
+                                        {
+                                            "xtype": "ScrolledWindow",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n      this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "listeners": {
+                                                        "cursor_changed": "function (self) {\n  // SEE SELECTION.CHANGED\n    var files = this.files();\n    this.get('/patchview').showDiff(files); \n    //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();\n     //print(\"OUT?\" + value);// id..\n    // load the list in the right grid..\n     \n    return true;\n\n}"
+                                                    },
+                                                    "id": "changedFilesView",
+                                                    "pack": "add",
+                                                    "xtype": "TreeView",
+                                                    "|files": "function() {\n     if (this.el.get_selection().count_selected_rows() < 1) {\n        //nothing? - clea it?\n        return [];\n    }\n\n    var ret = {};         \n \n\n     var s = this.el.get_selection();\n     var files = [];\n      s.selected_foreach(function(model,p,iter) {\n    \n       files.push( model.get_value(iter, 0).value.get_string());\n     \n    });\n    return files;\n}\n",
+                                                    "|init": "function() {\n    XObject.prototype.init.call(this);\n        var description = new Pango.FontDescription.c_new();\n   description.set_size(8000);\n     this.el.modify_font(description);\n\n     this.selection = this.el.get_selection();\n      this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);\n    var _this = this;\n  this.selection.signal['changed'].connect(function() {\n     _this.listeners.cursor_changed.apply(\n          _this, [ _this, '']\n       );\n             });\n  }\n",
+                                                    "|xns": "Gtk",
+                                                    "items": [
+                                                        {
+                                                            "id": "changedFilesStore",
+                                                            "pack": "set_model",
+                                                            "xtype": "ListStore",
+                                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.set_column_types ( 3, [\n       GObject.TYPE_STRING, // file  \n      GObject.TYPE_STRING, // added\n      GObject.TYPE_STRING, // removed\n  ] );\n}\n",
+                                                            "|load": "function(tr)\n{\n    //this.insert(citer,iter,0);\n    this.el.clear();\n    for(var i =0 ; i < tr.length; i++) {\n        var ret = {  };\n       \n        this.el.append(ret);\n        \n        //print(JSON.stringify(ret,null,4));\n         \n          \n        this.el.set_value(ret.iter, 0, ''  +  tr[i].filename );\n        this.el.set_value(ret.iter, 1, '' + tr[i].added  );\n        this.el.set_value(ret.iter, 2, '' + tr[i].removed  );\n \n        \n    }     \n}",
+                                                            "|xns": "Gtk"
+                                                        },
+                                                        {
+                                                            "resizable": true,
+                                                            "min_width": 200,
+                                                            "pack": "append_column",
+                                                            "title": "Filename",
+                                                            "xtype": "TreeViewColumn",
+                                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 0 );\n\n}\n",
+                                                            "|xns": "Gtk",
+                                                            "items": [
+                                                                {
+                                                                    "pack": "pack_start",
+                                                                    "xtype": "CellRendererText",
+                                                                    "|xns": "Gtk"
+                                                                }
+                                                            ]
+                                                        },
+                                                        {
+                                                            "min_width": 50,
+                                                            "pack": "append_column",
+                                                            "title": "Added",
+                                                            "xtype": "TreeViewColumn",
+                                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 1 );\n\n}\n",
+                                                            "|xns": "Gtk",
+                                                            "items": [
+                                                                {
+                                                                    "pack": "pack_start",
+                                                                    "xtype": "CellRendererText",
+                                                                    "|xns": "Gtk"
+                                                                }
+                                                            ]
+                                                        },
+                                                        {
+                                                            "min_width": 50,
+                                                            "pack": "append_column",
+                                                            "title": "Removed",
+                                                            "xtype": "TreeViewColumn",
+                                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 2 );\n\n}\n",
+                                                            "|xns": "Gtk",
+                                                            "items": [
+                                                                {
+                                                                    "pack": "pack_start",
+                                                                    "xtype": "CellRendererText",
+                                                                    "|xns": "Gtk"
+                                                                }
+                                                            ]
+                                                        }
+                                                    ]
+                                                },
+                                                {
+                                                    "|xns": "Gtk",
+                                                    "xtype": "TreeView",
+                                                    "pack": false,
+                                                    "items": [
+                                                        {
+                                                            "|xns": "Gtk",
+                                                            "xtype": "ListStore",
+                                                            "pack": false
+                                                        }
+                                                    ]
+                                                }
+                                            ]
+                                        }
+                                    ]
+                                },
+                                {
+                                    "xtype": "VBox",
+                                    "|xns": "Gtk",
+                                    "items": [
+                                        {
+                                            "pack": "pack_start,false,false,0",
+                                            "xtype": "HBox",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "listeners": {
+                                                        "clicked": "function (self) {\n    \n     \n     var model = this.get('/historyTreeStore');\n    \n    if (model.release === false) {\n        return;\n    }\n    \n \n    var files = this.get('/changedFilesView').files();\n    \n     if (!files.length) {\n        return; // error.!\n    }\n    var diff = Merger.repo.diff(files, model.release, model.rev);\n   \n   \n   print(\"history?\");\n   \n    \n    var history =  Merger.repo.history(files, 1, 'rev', model.rev);\n    \n    print(\"History\" + JSON.stringify(history, null,4));\n    \n    Commit = imports.Commit.Commit;\n\n    Commit.el.set_modal(true);\n    Commit.el.set_transient_for(Merger.el);\n\n    var ce = Commit.show({\n        repo : Merger.repo,\n        files : files,\n        release : model.release,\n        rev : model.rev,\n        author : history[0].changeby,\n        changed : history[0].changed_raw\n        \n    \n    });\n    if (ce === false ) {\n        return;\n    }\n    \n    \n    var diff = Merger.repo.diff(files, model.release, model.rev);\n    \n    \n    print(JSON.stringify(ce,null,4));\n    //.... commit!!!\n    \n    imports.GitMonitor.GitMonitor.pause();\n    try { \n        \n        Merger.repo.checkout(model.release);\n        \n        print(\"Call apply patch\");\n        \n        Merger.repo.applyPatch(diff);\n        \n        var author = Merger.repo.parseAuthor(ce.author);\n        \n        print(\"Add new files.\");\n        // add all the files..\n        Merger.repo.add(files);\n        \n        print(\"Commit changes.\");\n        Merger.repo.commit({\n            name    : author.name,\n            email   : author.email,\n            author  : ce.author,\n            changed : ce.changed,\n            reason  : ce.message,\n            files : files\n            \n        });\n        \n       \n    } catch (e) {\n     //message..\n          \n        var msg = new Gtk.MessageDialog({\n                message_type: Gtk.MessageType.ERROR, \n                buttons : Gtk.ButtonsType.OK, \n                text: e.message\n        });\n        msg.run();\n        msg.destroy();\n        Merger.repo.stash(); // revert change.. - so we can go back...\n    }\n    Merger.repo.checkout(model.working);\n    \n    \n    // if gitlive was previously running warn the user that it is now paused..\n    \n    var cmsg = new Gtk.MessageDialog({\n            message_type: Gtk.MessageType.ERROR, \n            buttons : Gtk.ButtonsType.OK, \n            text: \"Git Live is now paused \"\n    });\n    cmsg.run();\n    cmsg.destroy();\n    GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 15, function() {\n         imports.GitMonitor.GitMonitor.resume();\n         return false; //only once.\n    });\n     \n    \n\n\n}   "
+                                                    },
+                                                    "label": "Commit diff (no merge)",
+                                                    "xtype": "Button",
+                                                    "|xns": "Gtk"
+                                                }
+                                            ]
+                                        },
+                                        {
+                                            "pack": "pack_end,true,true,0",
+                                            "xtype": "ScrolledWindow",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n      this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "id": "patchview",
+                                                    "pack": "add",
+                                                    "xtype": "WebView",
+                                                    "|clear": "function() {\n    \n    \n    \n     \n   // remove..\n    var s  = \"document.body.textContent='';\"\n        \n    this.el.execute_script(s);\n        \n        \n    \n    \n    \n}\n",
+                                                    "|showDiff": "function(files) {\n    this.clear();\n    \n    \n     var model = this.get('/historyTreeStore');\n    \n    if (model.release === false) {\n        return;\n    }\n    \n    var diff = Merger.repo.diff(files, model.release, model.rev);\n    \n   // remove..\n    var s  = \"var pre  = document.createElement('pre'); document.body.appendChild(pre);\";\n    s += \"pre.textContent =  \" +\n             JSON.stringify(Merger.repo.lastCmd + \"\\n\") + '+  ' + \n           JSON.stringify(diff) + \";\";\n    print(s);\n        \n    this.el.execute_script(s);\n        \n        \n    \n    \n    \n}\n",
+                                                    "|xns": "WebKit"
+                                                }
+                                            ]
+                                        }
+                                    ]
+                                }
+                            ]
+                        }
+                    ]
+                },
+                {
+                    "id": "ok_button",
+                    "label": "Close",
+                    "pack": "add_action_widget,1",
+                    "xtype": "Button",
+                    "|xns": "Gtk"
+                }
+            ]
+        }
+    ],
+    "permname": "",
+    "modOrder": ""
+}
\ No newline at end of file
diff --git a/Merger.js b/Merger.js
new file mode 100644 (file)
index 0000000..be1871f
--- /dev/null
+++ b/Merger.js
@@ -0,0 +1,767 @@
+Gtk = imports.gi.Gtk;
+Gdk = imports.gi.Gdk;
+Pango = imports.gi.Pango;
+GLib = imports.gi.GLib;
+Gio = imports.gi.Gio;
+GObject = imports.gi.GObject;
+GtkSource = imports.gi.GtkSource;
+WebKit = imports.gi.WebKit;
+Vte = imports.gi.Vte;
+console = imports.console;
+XObject = imports.XObject.XObject;
+Merger=new XObject({
+    xtype: Gtk.Dialog,
+    listeners : {
+        destroy_event : function (self, event) {
+             this.el.hide();
+                        return false;
+        },
+        response : function (self, id) {
+          // hide
+             //if (id < 1) {
+                this.el.hide();
+                return;
+            //}
+            if (typeof(this.get('bug').getValue()) != 'object') {
+                print("ERROR");
+                return;
+            }
+         
+            this.el.hide();
+                
+            //var val = this.get('bug').getValue();
+             //   Seed.print(val);
+        }
+    },
+    border_width : 3,
+    default_height : 700,
+    default_width : 800,
+    id : "Merger",
+    title : "Merger",
+    deletable : true,
+    show : function(c) {
+        
+        if (!this.el) {
+            this.init();
+        }
+        var _this = this;
+         
+          //this.el.set_title("Merger - ??? ");
+    //   this.el.set_title("Merger - " + this.repo.repopath);
+    
+    
+         Merger.loading = true; // stop change firing on combos.
+         /// load up branches
+         
+         this.get('/historyTreeStore').el.clear();
+         this.get('/changedFilesStore').el.clear();
+         this.get('/patchview').clear();
+        
+         
+         
+         this.get('/workingCombo').load(Merger.repo.branches);
+         
+         this.get('/releaseCombo').load(Merger.repo.branches);
+    
+    
+    
+    
+         Merger.loading = false;
+    
+        this.el.show_all();
+        //this.get('/ok_button').el.set_sensitive(false);
+        
+        // block until we return.
+        var run_ret = this.el.run();
+        if (run_ret < 1 ) {
+            return  "DONE";
+        }
+        print("RUN RETURN : " + run_ret);
+        return "DONE";
+        //print(JSON.stringify(this.get('bug').getValue()));
+       // return this.get('bug').getValue();
+        //this.success = c.success;
+    },
+    items : [
+        {
+            xtype: Gtk.VBox,
+            pack : function(p,e) {
+                    p.el.get_content_area().pack_start(e.el,true,true,0)
+                },
+            items : [
+                {
+                    xtype: Gtk.HBox,
+                    pack : "pack_start,false,true",
+                    items : [
+                        {
+                            xtype: Gtk.Label,
+                            label : "Working Branch"
+                        },
+                        {
+                            xtype: Gtk.ComboBox,
+                            listeners : {
+                                changed : function (self) {
+                                   this.get('/historyTreeStore').loadTree();
+                                }
+                            },
+                            id : "workingCombo",
+                            init : function() {
+                                this.el = new Gtk.ComboBox.with_entry();
+                                
+                                
+                                this.model  = new XObject(this.model);
+                                this.model.init();
+                                this.el.set_model(this.model.el);
+                                this.el.set_entry_text_column (0);
+                                 XObject.prototype.init.call(this);
+                                
+                            },
+                            load : function(tr)
+                            {
+                                //this.insert(citer,iter,0);
+                                this.model.el.clear();
+                                
+                                var master = false;
+                                var working = false;
+                                
+                                for(var i =0 ; i < tr.length; i++) {
+                                    if (!tr[i].name.length) {
+                                        continue;
+                                    }
+                                    var ret = {  };
+                                    this.model.el.append(ret);
+                                    //print(JSON.stringify(ret,null,4));
+                                    if (tr[i].name == 'master') {
+                                        master = i;
+                                    }
+                                    if (tr[i].name == 'working') {
+                                        working = i;
+                                    }          
+                                    this.model.el.set_value(ret.iter, 0, '' + tr[i].name );
+                                    this.model.el.set_value(ret.iter, 1, '' + tr[i].rev  );
+                             
+                                    
+                                }     
+                                if (master !== false) {
+                                    this.el.set_active(master);
+                                }
+                                if (working !== false) {
+                                    this.el.set_active(working);
+                                }
+                                
+                            },
+                            model : {
+                                xtype: Gtk.ListStore,
+                                init : function() {
+                                    XObject.prototype.init.call(this);
+                                    this.el.set_column_types ( 3, [
+                                           GObject.TYPE_STRING, // file  
+                                          GObject.TYPE_STRING, // added
+                                          GObject.TYPE_STRING, // removed
+                                      ] );
+                                }
+                            }
+                        },
+                        {
+                            xtype: Gtk.Label,
+                            label : "Release Branch"
+                        },
+                        {
+                            xtype: Gtk.ComboBox,
+                            listeners : {
+                                changed : function (self) {
+                                   this.get('/historyTreeStore').loadTree();
+                                }
+                            },
+                            id : "releaseCombo",
+                            init : function() {
+                                this.el = new Gtk.ComboBox.with_entry();
+                                
+                                
+                                this.model  = new XObject(this.model);
+                                this.model.init();
+                                this.el.set_model(this.model.el);
+                                this.el.set_entry_text_column (0);
+                                 XObject.prototype.init.call(this);
+                                
+                            },
+                            load : function(tr)
+                            {
+                                //this.insert(citer,iter,0);
+                                this.model.el.clear();
+                                
+                                var master = false;
+                                var release = false;
+                                
+                                for(var i =0 ; i < tr.length; i++) {
+                                    var ret = {  };
+                                    if (!tr[i].name.length) {
+                                        continue;
+                                    }
+                                    
+                                    this.model.el.append(ret);
+                                    //print(JSON.stringify(ret,null,4));
+                                    if (tr[i].name == 'master') {
+                                        master = i;
+                                    }
+                                    if (tr[i].name == 'release') {
+                                        release = i;
+                                    }
+                                     
+                                    this.model.el.set_value(ret.iter, 0, '' + tr[i].name );
+                                    this.model.el.set_value(ret.iter, 1, '' + tr[i].rev  );
+                             
+                                    
+                                }     
+                                if (master !== false) {
+                                    this.el.set_active(master);
+                                }
+                                if (release !== false) {
+                                    this.el.set_active(release);
+                                }
+                                
+                            },
+                            model : {
+                                xtype: Gtk.ListStore,
+                                init : function() {
+                                    XObject.prototype.init.call(this);
+                                    this.el.set_column_types ( 3, [
+                                           GObject.TYPE_STRING, // file  
+                                          GObject.TYPE_STRING, // added
+                                          GObject.TYPE_STRING, // removed
+                                      ] );
+                                }
+                            }
+                        }
+                    ]
+                },
+                {
+                    xtype: Gtk.VPaned,
+                    pack : "pack_end,true,true,0",
+                    position : 400,
+                    items : [
+                        {
+                            xtype: Gtk.HPaned,
+                            pack : "add",
+                            position : 200,
+                            items : [
+                                {
+                                    xtype: Gtk.ScrolledWindow,
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                         this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+                                    },
+                                    items : [
+                                        {
+                                            xtype: Gtk.TreeView,
+                                            listeners : {
+                                                cursor_changed : function (self) {
+                                                
+                                                    if (this.el.get_selection().count_selected_rows() < 1) {
+                                                        //nothing?
+                                                        return;
+                                                    }
+                                                    var model = this.get('/historyTreeStore');
+                                                    var ret = {};        
+                                                     var s = this.el.get_selection();
+                                                    s.get_selected(ret);
+                                                    
+                                                    var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
+                                                     print("OUT?" + value);// id..
+                                                    // load the list in the right grid..
+                                                    var Repo = imports.Scm.Git.Repo.Repo;
+                                                    
+                                                    
+                                                   
+                                                    if (model.release === false) {
+                                                        return;
+                                                    }
+                                                    model.rev = value;
+                                                   
+                                                    var files = Merger.repo.changedFiles('/',   'rev', model.release + '..' + value);
+                                                    this.get('/changedFilesStore').load(files);
+                                                    return true;
+                                                
+                                                }
+                                            },
+                                            pack : "add",
+                                            init : function() {
+                                                XObject.prototype.init.call(this);
+                                                    var description = new Pango.FontDescription.c_new();
+                                               description.set_size(8000);
+                                                 this.el.modify_font(description);
+                                            
+                                                 this.selection = this.el.get_selection();
+                                                  this.selection.set_mode( Gtk.SelectionMode.SINGLE);
+                                                var _this = this;
+                                                /*
+                                             780                                                                     
+                                             781                                                                         // is this really needed??
+                                             782                                                                         this.selection.signal['changed'].connect(function() {
+                                             783                                                                                 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
+                                             784                                                                                     _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
+                                             785                                                                                 );
+                                             786                                                                         });
+                                             787                                                                         
+                                             */
+                                             },
+                                            items : [
+                                                {
+                                                    xtype: Gtk.TreeStore,
+                                                    id : "historyTreeStore",
+                                                    pack : "set_model",
+                                                    release : false,
+                                                    init : function() {
+                                                        XObject.prototype.init.call(this);
+                                                        this.el.set_column_types ( 3, [
+                                                           GObject.TYPE_STRING, // title 
+                                                          GObject.TYPE_STRING, // rev 
+                                                      ] );
+                                                    },
+                                                    load : function(tr,iter)
+                                                    {
+                                                        //this.insert(citer,iter,0);
+                                                        if (!iter) {
+                                                            this.el.clear();
+                                                        }
+                                                        
+                                                        for(var i =0 ; i < tr.length; i++) {
+                                                            var ret = {  };
+                                                            if (iter) {
+                                                                this.el.insert(ret ,iter,-1);
+                                                            } else {
+                                                                this.el.append(ret);
+                                                            }
+                                                            //print(JSON.stringify(ret,null,4));
+                                                             
+                                                              
+                                                            this.el.set_value(ret.iter, 0, ''  +  tr[i].text );
+                                                            this.el.set_value(ret.iter, 1, '' + tr[i].rev  );
+                                                     
+                                                            if (tr[i].children && tr[i].children.length) {
+                                                                this.load(tr[i].children, ret.iter);
+                                                            }
+                                                        }     
+                                                    },
+                                                    loadTree : function() {
+                                                    
+                                                       this.working = false;
+                                                       if (Merger.loading) {
+                                                            return;
+                                                       }
+                                                       
+                                                       
+                                                       var wid = this.get('/workingCombo').el.get_active();
+                                                       var rid = this.get('/releaseCombo').el.get_active();
+                                                       if (wid < 0 || rid < 0 || rid == wid) {
+                                                            return;
+                                                       }
+                                                       
+                                                       var w = Merger.repo.branches[wid];
+                                                       var r = Merger.repo.branches[rid];
+                                                       
+                                                    
+                                                    
+                                                        var rev = r.name + '..' + w.name;
+                                                        this.release = r.name;
+                                                        this.working = w.name;
+                                                        
+                                                        // this takes some time, lets. try and dialog it..
+                                                    
+                                                        
+                                                        
+                                                        
+                                                        var msg = new Gtk.MessageDialog( {
+                                                            buttons : Gtk.ButtonsType.NONE,
+                                                            text: "Loading History"
+                                                            
+                                                        });
+                                                        
+                                                        msg.set_transient_for(Merger.el);
+                                                        msg.set_modal(true);
+                                                        msg.show_all();
+                                                    
+                                                        var hist = Merger.repo.dayTree('/', false, 'rev', rev);
+                                                        msg.hide();
+                                                        
+                                                        this.load(hist);
+                                                            
+                                                           
+                                                    }
+                                                },
+                                                {
+                                                    xtype: Gtk.TreeViewColumn,
+                                                    pack : "append_column",
+                                                    title : "Changes",
+                                                    init : function() {
+                                                        XObject.prototype.init.call(this);
+                                                        this.el.add_attribute(this.items[0].el , 'markup', 0 );
+                                                    
+                                                    },
+                                                    items : [
+                                                        {
+                                                            xtype: Gtk.CellRendererText,
+                                                            pack : "pack_start"
+                                                        }
+                                                    ]
+                                                }
+                                            ]
+                                        }
+                                    ]
+                                },
+                                {
+                                    xtype: Gtk.ScrolledWindow,
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                          this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+                                    },
+                                    items : [
+                                        {
+                                            xtype: Gtk.TreeView,
+                                            listeners : {
+                                                cursor_changed : function (self) {
+                                                  // SEE SELECTION.CHANGED
+                                                    var files = this.files();
+                                                    this.get('/patchview').showDiff(files); 
+                                                    //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
+                                                     //print("OUT?" + value);// id..
+                                                    // load the list in the right grid..
+                                                     
+                                                    return true;
+                                                
+                                                }
+                                            },
+                                            id : "changedFilesView",
+                                            pack : "add",
+                                            files : function() {
+                                                 if (this.el.get_selection().count_selected_rows() < 1) {
+                                                    //nothing? - clea it?
+                                                    return [];
+                                                }
+                                            
+                                                var ret = {};         
+                                             
+                                            
+                                                 var s = this.el.get_selection();
+                                                 var files = [];
+                                                  s.selected_foreach(function(model,p,iter) {
+                                                
+                                                   files.push( model.get_value(iter, 0).value.get_string());
+                                                 
+                                                });
+                                                return files;
+                                            },
+                                            init : function() {
+                                                XObject.prototype.init.call(this);
+                                                    var description = new Pango.FontDescription.c_new();
+                                               description.set_size(8000);
+                                                 this.el.modify_font(description);
+                                            
+                                                 this.selection = this.el.get_selection();
+                                                  this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);
+                                                var _this = this;
+                                              this.selection.signal['changed'].connect(function() {
+                                                 _this.listeners.cursor_changed.apply(
+                                                      _this, [ _this, '']
+                                                   );
+                                                         });
+                                              },
+                                            items : [
+                                                {
+                                                    xtype: Gtk.ListStore,
+                                                    id : "changedFilesStore",
+                                                    pack : "set_model",
+                                                    init : function() {
+                                                        XObject.prototype.init.call(this);
+                                                        this.el.set_column_types ( 3, [
+                                                           GObject.TYPE_STRING, // file  
+                                                          GObject.TYPE_STRING, // added
+                                                          GObject.TYPE_STRING, // removed
+                                                      ] );
+                                                    },
+                                                    load : function(tr)
+                                                    {
+                                                        //this.insert(citer,iter,0);
+                                                        this.el.clear();
+                                                        for(var i =0 ; i < tr.length; i++) {
+                                                            var ret = {  };
+                                                           
+                                                            this.el.append(ret);
+                                                            
+                                                            //print(JSON.stringify(ret,null,4));
+                                                             
+                                                              
+                                                            this.el.set_value(ret.iter, 0, ''  +  tr[i].filename );
+                                                            this.el.set_value(ret.iter, 1, '' + tr[i].added  );
+                                                            this.el.set_value(ret.iter, 2, '' + tr[i].removed  );
+                                                     
+                                                            
+                                                        }     
+                                                    }
+                                                },
+                                                {
+                                                    xtype: Gtk.TreeViewColumn,
+                                                    resizable : true,
+                                                    min_width : 200,
+                                                    pack : "append_column",
+                                                    title : "Filename",
+                                                    init : function() {
+                                                        XObject.prototype.init.call(this);
+                                                        this.el.add_attribute(this.items[0].el , 'markup', 0 );
+                                                    
+                                                    },
+                                                    items : [
+                                                        {
+                                                            xtype: Gtk.CellRendererText,
+                                                            pack : "pack_start"
+                                                        }
+                                                    ]
+                                                },
+                                                {
+                                                    xtype: Gtk.TreeViewColumn,
+                                                    min_width : 50,
+                                                    pack : "append_column",
+                                                    title : "Added",
+                                                    init : function() {
+                                                        XObject.prototype.init.call(this);
+                                                        this.el.add_attribute(this.items[0].el , 'markup', 1 );
+                                                    
+                                                    },
+                                                    items : [
+                                                        {
+                                                            xtype: Gtk.CellRendererText,
+                                                            pack : "pack_start"
+                                                        }
+                                                    ]
+                                                },
+                                                {
+                                                    xtype: Gtk.TreeViewColumn,
+                                                    min_width : 50,
+                                                    pack : "append_column",
+                                                    title : "Removed",
+                                                    init : function() {
+                                                        XObject.prototype.init.call(this);
+                                                        this.el.add_attribute(this.items[0].el , 'markup', 2 );
+                                                    
+                                                    },
+                                                    items : [
+                                                        {
+                                                            xtype: Gtk.CellRendererText,
+                                                            pack : "pack_start"
+                                                        }
+                                                    ]
+                                                }
+                                            ]
+                                        },
+                                        {
+                                            xtype: Gtk.TreeView,
+                                            pack : false,
+                                            items : [
+                                                {
+                                                    xtype: Gtk.ListStore,
+                                                    pack : false
+                                                }
+                                            ]
+                                        }
+                                    ]
+                                }
+                            ]
+                        },
+                        {
+                            xtype: Gtk.VBox,
+                            items : [
+                                {
+                                    xtype: Gtk.HBox,
+                                    pack : "pack_start,false,false,0",
+                                    items : [
+                                        {
+                                            xtype: Gtk.Button,
+                                            listeners : {
+                                                clicked : function (self) {
+                                                    
+                                                     
+                                                     var model = this.get('/historyTreeStore');
+                                                    
+                                                    if (model.release === false) {
+                                                        return;
+                                                    }
+                                                    
+                                                 
+                                                    var files = this.get('/changedFilesView').files();
+                                                    
+                                                     if (!files.length) {
+                                                        return; // error.!
+                                                    }
+                                                    var diff = Merger.repo.diff(files, model.release, model.rev);
+                                                   
+                                                   
+                                                   print("history?");
+                                                   
+                                                    
+                                                    var history =  Merger.repo.history(files, 1, 'rev', model.rev);
+                                                    
+                                                    print("History" + JSON.stringify(history, null,4));
+                                                    
+                                                    Commit = imports.Commit.Commit;
+                                                
+                                                    Commit.el.set_modal(true);
+                                                    Commit.el.set_transient_for(Merger.el);
+                                                
+                                                    var ce = Commit.show({
+                                                        repo : Merger.repo,
+                                                        files : files,
+                                                        release : model.release,
+                                                        rev : model.rev,
+                                                        author : history[0].changeby,
+                                                        changed : history[0].changed_raw
+                                                        
+                                                    
+                                                    });
+                                                    if (ce === false ) {
+                                                        return;
+                                                    }
+                                                    
+                                                    
+                                                    var diff = Merger.repo.diff(files, model.release, model.rev);
+                                                    
+                                                    
+                                                    print(JSON.stringify(ce,null,4));
+                                                    //.... commit!!!
+                                                    
+                                                    imports.GitMonitor.GitMonitor.pause();
+                                                    try { 
+                                                        
+                                                        Merger.repo.checkout(model.release);
+                                                        
+                                                        print("Call apply patch");
+                                                        
+                                                        Merger.repo.applyPatch(diff);
+                                                        
+                                                        var author = Merger.repo.parseAuthor(ce.author);
+                                                        
+                                                        print("Add new files.");
+                                                        // add all the files..
+                                                        Merger.repo.add(files);
+                                                        
+                                                        print("Commit changes.");
+                                                        Merger.repo.commit({
+                                                            name    : author.name,
+                                                            email   : author.email,
+                                                            author  : ce.author,
+                                                            changed : ce.changed,
+                                                            reason  : ce.message,
+                                                            files : files
+                                                            
+                                                        });
+                                                        
+                                                       
+                                                    } catch (e) {
+                                                     //message..
+                                                          
+                                                        var msg = new Gtk.MessageDialog({
+                                                                message_type: Gtk.MessageType.ERROR, 
+                                                                buttons : Gtk.ButtonsType.OK, 
+                                                                text: e.message
+                                                        });
+                                                        msg.run();
+                                                        msg.destroy();
+                                                        Merger.repo.stash(); // revert change.. - so we can go back...
+                                                    }
+                                                    Merger.repo.checkout(model.working);
+                                                    
+                                                    
+                                                    // if gitlive was previously running warn the user that it is now paused..
+                                                    
+                                                    var cmsg = new Gtk.MessageDialog({
+                                                            message_type: Gtk.MessageType.ERROR, 
+                                                            buttons : Gtk.ButtonsType.OK, 
+                                                            text: "Git Live is now paused "
+                                                    });
+                                                    cmsg.run();
+                                                    cmsg.destroy();
+                                                    GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 15, function() {
+                                                         imports.GitMonitor.GitMonitor.resume();
+                                                         return false; //only once.
+                                                    });
+                                                     
+                                                    
+                                                
+                                                
+                                                }
+                                            },
+                                            label : "Commit diff (no merge)"
+                                        }
+                                    ]
+                                },
+                                {
+                                    xtype: Gtk.ScrolledWindow,
+                                    pack : "pack_end,true,true,0",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                          this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+                                    },
+                                    items : [
+                                        {
+                                            xtype: WebKit.WebView,
+                                            id : "patchview",
+                                            pack : "add",
+                                            clear : function() {
+                                                
+                                                
+                                                
+                                                 
+                                               // remove..
+                                                var s  = "document.body.textContent='';"
+                                                    
+                                                this.el.execute_script(s);
+                                                    
+                                                    
+                                                
+                                                
+                                                
+                                            },
+                                            showDiff : function(files) {
+                                                this.clear();
+                                                
+                                                
+                                                 var model = this.get('/historyTreeStore');
+                                                
+                                                if (model.release === false) {
+                                                    return;
+                                                }
+                                                
+                                                var diff = Merger.repo.diff(files, model.release, model.rev);
+                                                
+                                               // remove..
+                                                var s  = "var pre  = document.createElement('pre'); document.body.appendChild(pre);";
+                                                s += "pre.textContent =  " +
+                                                         JSON.stringify(Merger.repo.lastCmd + "\n") + '+  ' + 
+                                                       JSON.stringify(diff) + ";";
+                                                print(s);
+                                                    
+                                                this.el.execute_script(s);
+                                                    
+                                                    
+                                                
+                                                
+                                                
+                                            }
+                                        }
+                                    ]
+                                }
+                            ]
+                        }
+                    ]
+                }
+            ]
+        },
+        {
+            xtype: Gtk.Button,
+            id : "ok_button",
+            label : "Close",
+            pack : "add_action_widget,1"
+        }
+    ]
+});
+Merger.init();
+XObject.cache['/Merger'] = Merger;
diff --git a/RemoteEdit.bjs b/RemoteEdit.bjs
new file mode 100644 (file)
index 0000000..2759ce9
--- /dev/null
@@ -0,0 +1,102 @@
+{
+    "id": "file-gtk-5",
+    "name": "RemoteEdit",
+    "parent": "",
+    "title": false,
+    "path": "/home/alan/gitlive/gitlive/RemoteEdit.bjs",
+    "items": [
+        {
+            "listeners": {
+                "destroy_event": "function (self, event) {\n     this.el.hide();\n                return false;\n}",
+                "response": "function (self, id) {\n  // hide\n     //if (id < 1) {\n        this.el.hide();\n        return;\n    //}\n    if (typeof(this.get('bug').getValue()) != 'object') {\n        print(\"ERROR\");\n        return;\n    }\n \n    this.el.hide();\n        \n    //var val = this.get('bug').getValue();\n     //   Seed.print(val);\n}"
+            },
+            " modal": true,
+            "border_width": 3,
+            "default_height": 150,
+            "default_width": 500,
+            "title": "Remotes",
+            "xtype": "Dialog",
+            "|deletable": true,
+            "|modal": true,
+            "|show": "function(c) {\n    \n    if (!this.el) {\n        this.init();\n    }\n    var _this = this;\n    //this.get('/remotesStore').load();\n    this.get('/remoteURL').el.get_child().set_text('');\n    this.get('/remoteName').el.set_text('');\n    \n    \n    this.el.show_all();\n    \n    var run_ret = this.el.run();\n    if (run_ret < 1 ) {\n        return false;\n    }\n    var ret=  {\n        url :  this.get('/remoteURL').el.get_child().get_text(),\n        name :  this.get('/remoteName').el.get_text()\n    };\n    \n    return ret;\n    \n    \n    \n}\n",
+            "|xns": "Gtk",
+            "items": [
+                {
+                    "xtype": "VBox",
+                    "|pack": " function(p,e) {\n        p.el.get_content_area().pack_start(e.el,true,true,10);\n    }\n",
+                    "|xns": "Gtk",
+                    "items": [
+                        {
+                            "pack": "pack_start,false,true,10",
+                            "xtype": "HBox",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "label": "URL :",
+                                    "pack": "pack_start,false,false,10",
+                                    "width_request": 50,
+                                    "xtype": "Label",
+                                    "|xns": "Gtk"
+                                },
+                                {
+                                    "listeners": {
+                                        "changed": "function (self) {\n   var val = this.el.get_child().get_text();\n   print(JSON.stringify(val));\n   if (!val.length) {\n       return;\n   }\n   \n   var name = this.get('/remoteName').el.get_text();\n   if (name.length) {\n       return;\n   }\n   // fill in name\n   var val = imports.Scm.Git.Repo.Repo.parseURL(val);\n   if ((typeof(val.host) != 'undefined') && val.host.length) {\n       var host = val.host;\n       // need to add github owner...\n        if (host.match(/github.com$/)) {\n          host += '.' + val.path.split('/').shift();\n        }\n   \n   \n        this.get('/remoteName').el.set_text(host);\n   }\n    \n   \n}"
+                                    },
+                                    "id": "remoteURL",
+                                    "xtype": "ComboBox",
+                                    "|init": "function() {\n    this.el = new Gtk.ComboBox.with_entry();\n    \n    \n    this.model  = new XObject(this.model);\n    this.model.init();\n    this.el.set_model(this.model.el);\n    this.el.set_entry_text_column (0);\n     XObject.prototype.init.call(this);\n    \n}\n",
+                                    "|load": "function(tr)\n{\n    //this.insert(citer,iter,0);\n    this.model.el.clear();\n    \n    var master = false;\n    var working = false;\n    \n    for(var i =0 ; i < tr.length; i++) {\n        var ret = {  };\n        this.model.el.append(ret);\n        //print(JSON.stringify(ret,null,4));\n        if (tr[i].name == 'master') {\n            master = i;\n        }\n        if (tr[i].name == 'working') {\n            working = i;\n        }          \n        this.model.el.set_value(ret.iter, 0, '' + tr[i].name );\n        this.model.el.set_value(ret.iter, 1, '' + tr[i].rev  );\n \n        \n    }     \n    if (master !== false) {\n        this.el.set_active(master);\n    }\n    if (working !== false) {\n        this.el.set_active(working);\n    }\n    \n}",
+                                    "|xns": "Gtk",
+                                    "items": [
+                                        {
+                                            "*prop": "model",
+                                            "xtype": "ListStore",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.set_column_types ( 3, [\n           GObject.TYPE_STRING, // file  \n          GObject.TYPE_STRING, // added\n          GObject.TYPE_STRING, // removed\n      ] );\n}\n",
+                                            "|xns": "Gtk"
+                                        }
+                                    ]
+                                }
+                            ]
+                        },
+                        {
+                            "pack": "pack_start,false,true,10",
+                            "xtype": "HBox",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "label": "Name : ",
+                                    "pack": "pack_start,false,false,10",
+                                    "width_request": 50,
+                                    "xalign": 1,
+                                    "xtype": "Label",
+                                    "|xns": "Gtk"
+                                },
+                                {
+                                    "id": "remoteName",
+                                    "xtype": "Entry",
+                                    "|xns": "Gtk"
+                                }
+                            ]
+                        }
+                    ]
+                },
+                {
+                    "label": "Cancel",
+                    "pack": "add_action_widget,0",
+                    "xtype": "Button",
+                    "|xns": "Gtk",
+                    "listeners": {}
+                },
+                {
+                    "id": "ok_button",
+                    "label": "Add",
+                    "pack": "add_action_widget,1",
+                    "xtype": "Button",
+                    "|xns": "Gtk"
+                }
+            ]
+        }
+    ],
+    "permname": "",
+    "modOrder": "0"
+}
\ No newline at end of file
diff --git a/RemoteEdit.js b/RemoteEdit.js
new file mode 100644 (file)
index 0000000..5ab0874
--- /dev/null
@@ -0,0 +1,207 @@
+Gtk = imports.gi.Gtk;
+Gdk = imports.gi.Gdk;
+Pango = imports.gi.Pango;
+GLib = imports.gi.GLib;
+Gio = imports.gi.Gio;
+GObject = imports.gi.GObject;
+GtkSource = imports.gi.GtkSource;
+WebKit = imports.gi.WebKit;
+Vte = imports.gi.Vte;
+console = imports.console;
+XObject = imports.XObject.XObject;
+RemoteEdit=new XObject({
+    xtype: Gtk.Dialog,
+    listeners : {
+        destroy_event : function (self, event) {
+             this.el.hide();
+                        return false;
+        },
+        response : function (self, id) {
+          // hide
+             //if (id < 1) {
+                this.el.hide();
+                return;
+            //}
+            if (typeof(this.get('bug').getValue()) != 'object') {
+                print("ERROR");
+                return;
+            }
+         
+            this.el.hide();
+                
+            //var val = this.get('bug').getValue();
+             //   Seed.print(val);
+        }
+    },
+    ' modal' : true,
+    border_width : 3,
+    default_height : 150,
+    default_width : 500,
+    title : "Remotes",
+    deletable : true,
+    modal : true,
+    show : function(c) {
+        
+        if (!this.el) {
+            this.init();
+        }
+        var _this = this;
+        //this.get('/remotesStore').load();
+        this.get('/remoteURL').el.get_child().set_text('');
+        this.get('/remoteName').el.set_text('');
+        
+        
+        this.el.show_all();
+        
+        var run_ret = this.el.run();
+        if (run_ret < 1 ) {
+            return false;
+        }
+        var ret=  {
+            url :  this.get('/remoteURL').el.get_child().get_text(),
+            name :  this.get('/remoteName').el.get_text()
+        };
+        
+        return ret;
+        
+        
+        
+    },
+    items : [
+        {
+            xtype: Gtk.VBox,
+            pack : function(p,e) {
+                    p.el.get_content_area().pack_start(e.el,true,true,10);
+                },
+            items : [
+                {
+                    xtype: Gtk.HBox,
+                    pack : "pack_start,false,true,10",
+                    items : [
+                        {
+                            xtype: Gtk.Label,
+                            label : "URL :",
+                            pack : "pack_start,false,false,10",
+                            width_request : 50
+                        },
+                        {
+                            xtype: Gtk.ComboBox,
+                            listeners : {
+                                changed : function (self) {
+                                   var val = this.el.get_child().get_text();
+                                   print(JSON.stringify(val));
+                                   if (!val.length) {
+                                       return;
+                                   }
+                                   
+                                   var name = this.get('/remoteName').el.get_text();
+                                   if (name.length) {
+                                       return;
+                                   }
+                                   // fill in name
+                                   var val = imports.Scm.Git.Repo.Repo.parseURL(val);
+                                   if ((typeof(val.host) != 'undefined') && val.host.length) {
+                                       var host = val.host;
+                                       // need to add github owner...
+                                        if (host.match(/github.com$/)) {
+                                          host += '.' + val.path.split('/').shift();
+                                        }
+                                   
+                                   
+                                        this.get('/remoteName').el.set_text(host);
+                                   }
+                                    
+                                   
+                                }
+                            },
+                            id : "remoteURL",
+                            init : function() {
+                                this.el = new Gtk.ComboBox.with_entry();
+                                
+                                
+                                this.model  = new XObject(this.model);
+                                this.model.init();
+                                this.el.set_model(this.model.el);
+                                this.el.set_entry_text_column (0);
+                                 XObject.prototype.init.call(this);
+                                
+                            },
+                            load : function(tr)
+                            {
+                                //this.insert(citer,iter,0);
+                                this.model.el.clear();
+                                
+                                var master = false;
+                                var working = false;
+                                
+                                for(var i =0 ; i < tr.length; i++) {
+                                    var ret = {  };
+                                    this.model.el.append(ret);
+                                    //print(JSON.stringify(ret,null,4));
+                                    if (tr[i].name == 'master') {
+                                        master = i;
+                                    }
+                                    if (tr[i].name == 'working') {
+                                        working = i;
+                                    }          
+                                    this.model.el.set_value(ret.iter, 0, '' + tr[i].name );
+                                    this.model.el.set_value(ret.iter, 1, '' + tr[i].rev  );
+                             
+                                    
+                                }     
+                                if (master !== false) {
+                                    this.el.set_active(master);
+                                }
+                                if (working !== false) {
+                                    this.el.set_active(working);
+                                }
+                                
+                            },
+                            model : {
+                                xtype: Gtk.ListStore,
+                                init : function() {
+                                    XObject.prototype.init.call(this);
+                                    this.el.set_column_types ( 3, [
+                                           GObject.TYPE_STRING, // file  
+                                          GObject.TYPE_STRING, // added
+                                          GObject.TYPE_STRING, // removed
+                                      ] );
+                                }
+                            }
+                        }
+                    ]
+                },
+                {
+                    xtype: Gtk.HBox,
+                    pack : "pack_start,false,true,10",
+                    items : [
+                        {
+                            xtype: Gtk.Label,
+                            label : "Name : ",
+                            pack : "pack_start,false,false,10",
+                            width_request : 50,
+                            xalign : 1
+                        },
+                        {
+                            xtype: Gtk.Entry,
+                            id : "remoteName"
+                        }
+                    ]
+                }
+            ]
+        },
+        {
+            xtype: Gtk.Button,
+            label : "Cancel",
+            pack : "add_action_widget,0"
+        },
+        {
+            xtype: Gtk.Button,
+            id : "ok_button",
+            label : "Add",
+            pack : "add_action_widget,1"
+        }
+    ]
+});
+RemoteEdit.init();
+XObject.cache['/RemoteEdit'] = RemoteEdit;
diff --git a/Remotes.bjs b/Remotes.bjs
new file mode 100644 (file)
index 0000000..0d195f4
--- /dev/null
@@ -0,0 +1,152 @@
+{
+    "id": "file-gtk-4",
+    "name": "Remotes",
+    "parent": "",
+    "title": false,
+    "path": "/home/alan/gitlive/gitlive/Remotes.bjs",
+    "items": [
+        {
+            "listeners": {
+                "destroy_event": "function (self, event) {\n     this.el.hide();\n                return false;\n}",
+                "response": "function (self, id) {\n  // hide\n     //if (id < 1) {\n        this.el.hide();\n        return;\n    //}\n    if (typeof(this.get('bug').getValue()) != 'object') {\n        print(\"ERROR\");\n        return;\n    }\n \n    this.el.hide();\n        \n    //var val = this.get('bug').getValue();\n     //   Seed.print(val);\n}"
+            },
+            " modal": true,
+            "border_width": 3,
+            "default_height": 300,
+            "default_width": 500,
+            "title": "Remotes",
+            "xtype": "Dialog",
+            "|deletable": true,
+            "|modal": true,
+            "|show": "function(c) {\n    \n    if (!this.el) {\n        this.init();\n    }\n    var _this = this;\n    this.get('/remotesStore').load();\n    this.el.show_all();\n    \n    var run_ret = this.el.run();\n    if (run_ret < 1 ) {\n        return  \"DONE\";\n    }\n    print(\"RUN RETURN : \" + run_ret);\n    return \"DONE\";\n    \n}\n",
+            "|xns": "Gtk",
+            "items": [
+                {
+                    "xtype": "VBox",
+                    "|pack": " function(p,e) {\n        p.el.get_content_area().pack_start(e.el,true,true,0)\n    }\n",
+                    "|xns": "Gtk",
+                    "items": [
+                        {
+                            "pack": "pack_start,false,true",
+                            "xtype": "HBox",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "listeners": {
+                                        "clicked": "function (self) {\n\n        \n    var RemoteEdit=    imports.RemoteEdit.RemoteEdit\n     RemoteEdit.repo = Remotes.repo;\n    RemoteEdit.el.set_transient_for(Remotes.el);\n\n    var res =  RemoteEdit.show();\n    \n    if (res != false) {\n        Remotes.repo.remotes(res);\n    }\n    \n    this.get('/remotesStore').load();\n\n    \n}"
+                                    },
+                                    "label": "Add",
+                                    "pack": "add",
+                                    "xtype": "Button",
+                                    "|xns": "Gtk"
+                                }
+                            ]
+                        },
+                        {
+                            "xtype": "ScrolledWindow",
+                            "|init": "function() {\n    XObject.prototype.init.call(this);\n      this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "listeners": {
+                                        "cursor_changed": "function (self)\n{\n\n   return;\n  // SEE SELECTION.CHANGED\n    if (this.el.get_selection().count_selected_rows() < 1) {\n        //nothing? - clea it?\n        return;\n    }\n        var ret = {};         \n    var model = this.get('/changedFilesStore');\n\n     var s = this.el.get_selection();\n     var files = [];\n    s.selected_foreach(function(model,p,iter) {\n    \n       files.push( model.get_value(iter, 0).value.get_string());\n     \n    });\n    this.get('/patchview').showDiff(files); \n    //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();\n     //print(\"OUT?\" + value);// id..\n    // load the list in the right grid..\n     \n    return true;\n\n}"
+                                    },
+                                    "id": "remotesView",
+                                    "pack": "add",
+                                    "xtype": "TreeView",
+                                    "|init": "function() {\n    XObject.prototype.init.call(this);\n        var description = new Pango.FontDescription.c_new();\n   description.set_size(8000);\n     this.el.modify_font(description);\n\n     this.selection = this.el.get_selection();\n      this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);\n    var _this = this;\n  this.selection.signal['changed'].connect(function() {\n     _this.listeners.cursor_changed.apply(\n          _this, [ _this, '']\n       );\n             });\n  }\n",
+                                    "|xns": "Gtk",
+                                    "items": [
+                                        {
+                                            "id": "remotesStore",
+                                            "pack": "set_model",
+                                            "xtype": "ListStore",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.set_column_types ( 3, [\n       GObject.TYPE_STRING, // file  \n      GObject.TYPE_STRING, // added\n      GObject.TYPE_STRING, // removed\n  ] );\n}\n",
+                                            "|load": "function(tr)\n{\n    //this.insert(citer,iter,0);\n    this.el.clear();\n    \n    var tr = Remotes.repo.remotes();\n    \n    \n    for(var i =0 ; i < tr.length; i++) {\n        var ret = {  };\n       \n        this.el.append(ret);\n        \n        //print(JSON.stringify(ret,null,4));\n         \n          \n        this.el.set_value(ret.iter, 0, ''  +  tr[i].name );\n        this.el.set_value(ret.iter, 1, '' + tr[i].url );\n       this.el.set_value(ret.iter, 2, '' + tr[i].type );\n \n        \n    }     \n}",
+                                            "|xns": "Gtk"
+                                        },
+                                        {
+                                            "min_width": 70,
+                                            "pack": "append_column",
+                                            "resizable": true,
+                                            "title": "Name",
+                                            "xtype": "TreeViewColumn",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 0 );\n\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "pack": "pack_start",
+                                                    "xtype": "CellRendererText",
+                                                    "|xns": "Gtk"
+                                                }
+                                            ]
+                                        },
+                                        {
+                                            "min_width": 70,
+                                            "pack": "append_column",
+                                            "resizable": true,
+                                            "title": "Type",
+                                            "xtype": "TreeViewColumn",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 2 );\n\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "pack": "pack_start",
+                                                    "xtype": "CellRendererText",
+                                                    "|xns": "Gtk"
+                                                }
+                                            ]
+                                        },
+                                        {
+                                            "min_width": 200,
+                                            "pack": "append_column",
+                                            "title": "URL",
+                                            "xtype": "TreeViewColumn",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 1 );\n\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "pack": "pack_start",
+                                                    "xtype": "CellRendererText",
+                                                    "|xns": "Gtk"
+                                                }
+                                            ]
+                                        }
+                                    ]
+                                },
+                                {
+                                    "|xns": "Gtk",
+                                    "xtype": "TreeView",
+                                    "pack": false,
+                                    "items": [
+                                        {
+                                            "|xns": "Gtk",
+                                            "xtype": "ListStore",
+                                            "pack": false
+                                        }
+                                    ]
+                                }
+                            ]
+                        }
+                    ]
+                },
+                {
+                    "label": "Cancel",
+                    "pack": "add_action_widget,0",
+                    "xtype": "Button",
+                    "|xns": "Gtk",
+                    "listeners": {}
+                },
+                {
+                    "id": "ok_button",
+                    "label": "OK",
+                    "pack": "add_action_widget,1",
+                    "xtype": "Button",
+                    "|xns": "Gtk"
+                }
+            ]
+        }
+    ],
+    "permname": "",
+    "modOrder": "0"
+}
\ No newline at end of file
diff --git a/Remotes.js b/Remotes.js
new file mode 100644 (file)
index 0000000..f36424f
--- /dev/null
@@ -0,0 +1,272 @@
+Gtk = imports.gi.Gtk;
+Gdk = imports.gi.Gdk;
+Pango = imports.gi.Pango;
+GLib = imports.gi.GLib;
+Gio = imports.gi.Gio;
+GObject = imports.gi.GObject;
+GtkSource = imports.gi.GtkSource;
+WebKit = imports.gi.WebKit;
+Vte = imports.gi.Vte;
+console = imports.console;
+XObject = imports.XObject.XObject;
+Remotes=new XObject({
+    xtype: Gtk.Dialog,
+    listeners : {
+        destroy_event : function (self, event) {
+             this.el.hide();
+                        return false;
+        },
+        response : function (self, id) {
+          // hide
+             //if (id < 1) {
+                this.el.hide();
+                return;
+            //}
+            if (typeof(this.get('bug').getValue()) != 'object') {
+                print("ERROR");
+                return;
+            }
+         
+            this.el.hide();
+                
+            //var val = this.get('bug').getValue();
+             //   Seed.print(val);
+        }
+    },
+    ' modal' : true,
+    border_width : 3,
+    default_height : 300,
+    default_width : 500,
+    title : "Remotes",
+    deletable : true,
+    modal : true,
+    show : function(c) {
+        
+        if (!this.el) {
+            this.init();
+        }
+        var _this = this;
+        this.get('/remotesStore').load();
+        this.el.show_all();
+        
+        var run_ret = this.el.run();
+        if (run_ret < 1 ) {
+            return  "DONE";
+        }
+        print("RUN RETURN : " + run_ret);
+        return "DONE";
+        
+    },
+    items : [
+        {
+            xtype: Gtk.VBox,
+            pack : function(p,e) {
+                    p.el.get_content_area().pack_start(e.el,true,true,0)
+                },
+            items : [
+                {
+                    xtype: Gtk.HBox,
+                    pack : "pack_start,false,true",
+                    items : [
+                        {
+                            xtype: Gtk.Button,
+                            listeners : {
+                                clicked : function (self) {
+                                
+                                        
+                                    var RemoteEdit=    imports.RemoteEdit.RemoteEdit
+                                     RemoteEdit.repo = Remotes.repo;
+                                    RemoteEdit.el.set_transient_for(Remotes.el);
+                                
+                                    var res =  RemoteEdit.show();
+                                    
+                                    if (res != false) {
+                                        Remotes.repo.remotes(res);
+                                    }
+                                    
+                                    this.get('/remotesStore').load();
+                                
+                                    
+                                }
+                            },
+                            label : "Add",
+                            pack : "add"
+                        }
+                    ]
+                },
+                {
+                    xtype: Gtk.ScrolledWindow,
+                    init : function() {
+                        XObject.prototype.init.call(this);
+                          this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+                    },
+                    items : [
+                        {
+                            xtype: Gtk.TreeView,
+                            listeners : {
+                                cursor_changed : function (self)
+                                {
+                                
+                                   return;
+                                  // SEE SELECTION.CHANGED
+                                    if (this.el.get_selection().count_selected_rows() < 1) {
+                                        //nothing? - clea it?
+                                        return;
+                                    }
+                                        var ret = {};         
+                                    var model = this.get('/changedFilesStore');
+                                
+                                     var s = this.el.get_selection();
+                                     var files = [];
+                                    s.selected_foreach(function(model,p,iter) {
+                                    
+                                       files.push( model.get_value(iter, 0).value.get_string());
+                                     
+                                    });
+                                    this.get('/patchview').showDiff(files); 
+                                    //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
+                                     //print("OUT?" + value);// id..
+                                    // load the list in the right grid..
+                                     
+                                    return true;
+                                
+                                }
+                            },
+                            id : "remotesView",
+                            pack : "add",
+                            init : function() {
+                                XObject.prototype.init.call(this);
+                                    var description = new Pango.FontDescription.c_new();
+                               description.set_size(8000);
+                                 this.el.modify_font(description);
+                            
+                                 this.selection = this.el.get_selection();
+                                  this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);
+                                var _this = this;
+                              this.selection.signal['changed'].connect(function() {
+                                 _this.listeners.cursor_changed.apply(
+                                      _this, [ _this, '']
+                                   );
+                                         });
+                              },
+                            items : [
+                                {
+                                    xtype: Gtk.ListStore,
+                                    id : "remotesStore",
+                                    pack : "set_model",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                        this.el.set_column_types ( 3, [
+                                           GObject.TYPE_STRING, // file  
+                                          GObject.TYPE_STRING, // added
+                                          GObject.TYPE_STRING, // removed
+                                      ] );
+                                    },
+                                    load : function(tr)
+                                    {
+                                        //this.insert(citer,iter,0);
+                                        this.el.clear();
+                                        
+                                        var tr = Remotes.repo.remotes();
+                                        
+                                        
+                                        for(var i =0 ; i < tr.length; i++) {
+                                            var ret = {  };
+                                           
+                                            this.el.append(ret);
+                                            
+                                            //print(JSON.stringify(ret,null,4));
+                                             
+                                              
+                                            this.el.set_value(ret.iter, 0, ''  +  tr[i].name );
+                                            this.el.set_value(ret.iter, 1, '' + tr[i].url );
+                                           this.el.set_value(ret.iter, 2, '' + tr[i].type );
+                                     
+                                            
+                                        }     
+                                    }
+                                },
+                                {
+                                    xtype: Gtk.TreeViewColumn,
+                                    min_width : 70,
+                                    pack : "append_column",
+                                    resizable : true,
+                                    title : "Name",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                        this.el.add_attribute(this.items[0].el , 'markup', 0 );
+                                    
+                                    },
+                                    items : [
+                                        {
+                                            xtype: Gtk.CellRendererText,
+                                            pack : "pack_start"
+                                        }
+                                    ]
+                                },
+                                {
+                                    xtype: Gtk.TreeViewColumn,
+                                    min_width : 70,
+                                    pack : "append_column",
+                                    resizable : true,
+                                    title : "Type",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                        this.el.add_attribute(this.items[0].el , 'markup', 2 );
+                                    
+                                    },
+                                    items : [
+                                        {
+                                            xtype: Gtk.CellRendererText,
+                                            pack : "pack_start"
+                                        }
+                                    ]
+                                },
+                                {
+                                    xtype: Gtk.TreeViewColumn,
+                                    min_width : 200,
+                                    pack : "append_column",
+                                    title : "URL",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                        this.el.add_attribute(this.items[0].el , 'markup', 1 );
+                                    
+                                    },
+                                    items : [
+                                        {
+                                            xtype: Gtk.CellRendererText,
+                                            pack : "pack_start"
+                                        }
+                                    ]
+                                }
+                            ]
+                        },
+                        {
+                            xtype: Gtk.TreeView,
+                            pack : false,
+                            items : [
+                                {
+                                    xtype: Gtk.ListStore,
+                                    pack : false
+                                }
+                            ]
+                        }
+                    ]
+                }
+            ]
+        },
+        {
+            xtype: Gtk.Button,
+            label : "Cancel",
+            pack : "add_action_widget,0"
+        },
+        {
+            xtype: Gtk.Button,
+            id : "ok_button",
+            label : "OK",
+            pack : "add_action_widget,1"
+        }
+    ]
+});
+Remotes.init();
+XObject.cache['/Remotes'] = Remotes;