3 Pango = imports.gi.Pango;
4 GLib = imports.gi.GLib;
6 GObject = imports.gi.GObject;
7 GtkSource = imports.gi.GtkSource;
8 WebKit = imports.gi.WebKit;
10 console = imports.console;
11 XObject = imports.XObject.XObject;
15 destroy_event : function (self, event) {
19 response : function (self, id) {
25 if (typeof(this.get('bug').getValue()) != 'object') {
32 //var val = this.get('bug').getValue();
49 //this.el.set_title("Merger - ??? ");
50 // this.el.set_title("Merger - " + this.repo.repopath);
53 Merger.loading = true; // stop change firing on combos.
56 this.get('/historyTreeStore').el.clear();
57 this.get('/changedFilesStore').el.clear();
58 this.get('/patchview').clear();
62 this.get('/workingCombo').load(Merger.repo.branches);
64 this.get('/releaseCombo').load(Merger.repo.branches);
69 Merger.loading = false;
72 //this.get('/ok_button').el.set_sensitive(false);
74 // block until we return.
75 var run_ret = this.el.run();
79 print("RUN RETURN : " + run_ret);
81 //print(JSON.stringify(this.get('bug').getValue()));
82 // return this.get('bug').getValue();
83 //this.success = c.success;
88 pack : function(p,e) {
89 p.el.get_content_area().pack_start(e.el,true,true,0)
94 pack : "pack_start,false,true",
98 label : "Working Branch"
103 changed : function (self) {
104 this.get('/historyTreeStore').loadTree();
109 this.el = new Gtk.ComboBox.with_entry();
112 this.model = new XObject(this.model);
114 this.el.set_model(this.model.el);
115 this.el.set_entry_text_column (0);
116 XObject.prototype.init.call(this);
121 //this.insert(citer,iter,0);
122 this.model.el.clear();
127 for(var i =0 ; i < tr.length; i++) {
129 this.model.el.append(ret);
130 //print(JSON.stringify(ret,null,4));
131 if (tr[i].name == 'master') {
134 if (tr[i].name == 'working') {
137 this.model.el.set_value(ret.iter, 0, '' + tr[i].name );
138 this.model.el.set_value(ret.iter, 1, '' + tr[i].rev );
142 if (master !== false) {
143 this.el.set_active(master);
145 if (working !== false) {
146 this.el.set_active(working);
151 xtype: Gtk.ListStore,
153 XObject.prototype.init.call(this);
154 this.el.set_column_types ( 3, [
155 GObject.TYPE_STRING, // file
156 GObject.TYPE_STRING, // added
157 GObject.TYPE_STRING, // removed
164 label : "Release Branch"
169 changed : function (self) {
170 this.get('/historyTreeStore').loadTree();
175 this.el = new Gtk.ComboBox.with_entry();
178 this.model = new XObject(this.model);
180 this.el.set_model(this.model.el);
181 this.el.set_entry_text_column (0);
182 XObject.prototype.init.call(this);
187 //this.insert(citer,iter,0);
188 this.model.el.clear();
193 for(var i =0 ; i < tr.length; i++) {
195 this.model.el.append(ret);
196 //print(JSON.stringify(ret,null,4));
197 if (tr[i].name == 'master') {
200 if (tr[i].name == 'release') {
203 this.model.el.set_value(ret.iter, 0, '' + tr[i].name );
204 this.model.el.set_value(ret.iter, 1, '' + tr[i].rev );
208 if (master !== false) {
209 this.el.set_active(master);
211 if (release !== false) {
212 this.el.set_active(release);
217 xtype: Gtk.ListStore,
219 XObject.prototype.init.call(this);
220 this.el.set_column_types ( 3, [
221 GObject.TYPE_STRING, // file
222 GObject.TYPE_STRING, // added
223 GObject.TYPE_STRING, // removed
232 pack : "pack_end,true,true,0",
241 xtype: Gtk.ScrolledWindow,
243 XObject.prototype.init.call(this);
244 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
250 cursor_changed : function (self) {
252 if (this.el.get_selection().count_selected_rows() < 1) {
256 var model = this.get('/historyTreeStore');
258 var s = this.el.get_selection();
261 var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
262 print("OUT?" + value);// id..
263 // load the list in the right grid..
264 var Repo = imports.Scm.Git.Repo.Repo;
268 if (model.release === false) {
273 var files = Merger.repo.changedFiles('/', 'rev', model.release + '..' + value);
274 this.get('/changedFilesStore').load(files);
281 XObject.prototype.init.call(this);
282 var description = new Pango.FontDescription.c_new();
283 description.set_size(8000);
284 this.el.modify_font(description);
286 this.selection = this.el.get_selection();
287 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
291 781 // is this really needed??
292 782 this.selection.signal['changed'].connect(function() {
293 783 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
294 784 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
302 xtype: Gtk.TreeStore,
303 id : "historyTreeStore",
307 XObject.prototype.init.call(this);
308 this.el.set_column_types ( 3, [
309 GObject.TYPE_STRING, // title
310 GObject.TYPE_STRING, // rev
313 load : function(tr,iter)
315 //this.insert(citer,iter,0);
320 for(var i =0 ; i < tr.length; i++) {
323 this.el.insert(ret ,iter,-1);
327 //print(JSON.stringify(ret,null,4));
330 this.el.set_value(ret.iter, 0, '' + tr[i].text );
331 this.el.set_value(ret.iter, 1, '' + tr[i].rev );
333 if (tr[i].children && tr[i].children.length) {
334 this.load(tr[i].children, ret.iter);
338 loadTree : function() {
340 this.working = false;
341 if (Merger.loading) {
346 var wid = this.get('/workingCombo').el.get_active();
347 var rid = this.get('/releaseCombo').el.get_active();
348 if (wid < 0 || rid < 0 || rid == wid) {
352 var w = Merger.repo.branches[wid];
353 var r = Merger.repo.branches[rid];
357 var rev = r.name + '..' + w.name;
358 this.release = r.name;
360 // this takes some time, lets. try and dialog it..
365 var msg = new Gtk.MessageDialog( {
366 buttons : Gtk.ButtonsType.NONE,
367 text: "Loading History"
371 msg.set_transient_for(Merger.el);
374 var hist = Merger.repo.dayTree('/', false, 'rev', rev);
383 xtype: Gtk.TreeViewColumn,
384 pack : "append_column",
387 XObject.prototype.init.call(this);
388 this.el.add_attribute(this.items[0].el , 'markup', 0 );
393 xtype: Gtk.CellRendererText,
403 xtype: Gtk.ScrolledWindow,
405 XObject.prototype.init.call(this);
406 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
412 cursor_changed : function (self) {
413 // SEE SELECTION.CHANGED
414 if (this.el.get_selection().count_selected_rows() < 1) {
415 //nothing? - clea it?
419 var model = this.get('/changedFilesStore');
421 var s = this.el.get_selection();
423 s.selected_foreach(function(model,p,iter) {
425 files.push( model.get_value(iter, 0).value.get_string());
428 this.get('/patchview').showDiff(files);
429 //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
430 //print("OUT?" + value);// id..
431 // load the list in the right grid..
437 id : "changedFilesView",
443 XObject.prototype.init.call(this);
444 var description = new Pango.FontDescription.c_new();
445 description.set_size(8000);
446 this.el.modify_font(description);
448 this.selection = this.el.get_selection();
449 this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);
451 this.selection.signal['changed'].connect(function() {
452 _this.listeners.cursor_changed.apply(
459 xtype: Gtk.ListStore,
460 id : "changedFilesStore",
463 XObject.prototype.init.call(this);
464 this.el.set_column_types ( 3, [
465 GObject.TYPE_STRING, // file
466 GObject.TYPE_STRING, // added
467 GObject.TYPE_STRING, // removed
472 //this.insert(citer,iter,0);
474 for(var i =0 ; i < tr.length; i++) {
479 //print(JSON.stringify(ret,null,4));
482 this.el.set_value(ret.iter, 0, '' + tr[i].filename );
483 this.el.set_value(ret.iter, 1, '' + tr[i].added );
484 this.el.set_value(ret.iter, 2, '' + tr[i].removed );
491 xtype: Gtk.TreeViewColumn,
494 pack : "append_column",
497 XObject.prototype.init.call(this);
498 this.el.add_attribute(this.items[0].el , 'markup', 0 );
503 xtype: Gtk.CellRendererText,
509 xtype: Gtk.TreeViewColumn,
511 pack : "append_column",
514 XObject.prototype.init.call(this);
515 this.el.add_attribute(this.items[0].el , 'markup', 1 );
520 xtype: Gtk.CellRendererText,
526 xtype: Gtk.TreeViewColumn,
528 pack : "append_column",
531 XObject.prototype.init.call(this);
532 this.el.add_attribute(this.items[0].el , 'markup', 2 );
537 xtype: Gtk.CellRendererText,
549 xtype: Gtk.ListStore,
563 pack : "pack_start,false,false,0",
568 clicked : function (self) {
569 Commit = imports.Commit.Commit;
570 Commit.repo = Merger.repo;
571 Merger.el.set_transient_for(Commit.el);
581 label : "Commit diff (no merge)"
585 label : "Commit diff (merge after)"
590 xtype: Gtk.ScrolledWindow,
591 pack : "pack_end,true,true,0",
593 XObject.prototype.init.call(this);
594 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
598 xtype: WebKit.WebView,
607 var s = "document.body.textContent='';"
609 this.el.execute_script(s);
616 showDiff : function(files) {
620 var model = this.get('/historyTreeStore');
622 if (model.release === false) {
626 var diff = Merger.repo.diff(files, model.release, model.rev);
629 var s = "var pre = document.createElement('pre'); document.body.appendChild(pre);";
630 s += "pre.textContent = " +
631 JSON.stringify(Merger.repo.lastCmd + "\n") + '+ ' +
632 JSON.stringify(diff) + ";";
635 this.el.execute_script(s);
655 pack : "add_action_widget,1"
660 XObject.cache['/Merger'] = Merger;