From 61e930bbdeac15ffc04732732bc907d69e501bdc Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Mon, 19 Sep 2011 00:00:16 +0800 Subject: [PATCH] Revert "Branches.bjs" This reverts commit b6a12f0edbda49cd40f669ec6226cdf7e2962bd8. --- Branches.bjs | 152 +++++++++ Branches.js | 281 +++++++++++++++ Clones.bjs | 234 +++++++++++++ Clones.js | 549 +++++++++++++++++++++++++++++ Commit.bjs | 161 +++++++++ Commit.js | 313 +++++++++++++++++ Date.js | 835 +++++++++++++++++++++++++++++++++++++++++++++ GitMonitor.js | 379 ++++++++++++++++++++ Merger.bjs | 276 +++++++++++++++ Merger.js | 757 ++++++++++++++++++++++++++++++++++++++++ Monitor.js | 229 +++++++++++++ RemoteEdit.bjs | 102 ++++++ RemoteEdit.js | 207 +++++++++++ Remotes.bjs | 152 +++++++++ Remotes.js | 272 +++++++++++++++ Repo.js | 0 Spawn.js | 425 +++++++++++++++++++++++ StatusIcon.js | 239 +++++++++++++ WindowLog.js | 34 ++ XObject.js | 666 ++++++++++++++++++++++++++++++++++++ git_tool_notes.txt | 44 +++ gitlive.js | 74 ++++ 22 files changed, 6381 insertions(+) create mode 100644 Branches.bjs create mode 100644 Branches.js create mode 100644 Clones.bjs create mode 100644 Clones.js create mode 100644 Commit.bjs create mode 100644 Commit.js create mode 100644 Date.js create mode 100644 GitMonitor.js create mode 100644 Merger.bjs create mode 100644 Merger.js create mode 100644 Monitor.js create mode 100644 RemoteEdit.bjs create mode 100644 RemoteEdit.js create mode 100644 Remotes.bjs create mode 100644 Remotes.js create mode 100644 Repo.js create mode 100644 Spawn.js create mode 100644 StatusIcon.js create mode 100644 WindowLog.js create mode 100644 XObject.js create mode 100644 git_tool_notes.txt create mode 100644 gitlive.js diff --git a/Branches.bjs b/Branches.bjs new file mode 100644 index 00000000..1e8bd443 --- /dev/null +++ b/Branches.bjs @@ -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 index 00000000..5e617c79 --- /dev/null +++ b/Branches.js @@ -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 index 00000000..1f08553e --- /dev/null +++ b/Clones.bjs @@ -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 index 00000000..553a8add --- /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 index 00000000..b24740e6 --- /dev/null +++ b/Commit.bjs @@ -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 index 00000000..e56a48e1 --- /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/Date.js b/Date.js new file mode 100644 index 00000000..aff47005 --- /dev/null +++ b/Date.js @@ -0,0 +1,835 @@ +/* + * Based on: + * Ext JS Library 1.1.1 + * Copyright(c) 2006-2007, Ext JS, LLC. + * + * Originally Released Under LGPL - original licence link has changed is not relivant. + * + * Fork - LGPL + *