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",
440 XObject.prototype.init.call(this);
441 var description = new Pango.FontDescription.c_new();
442 description.set_size(8000);
443 this.el.modify_font(description);
445 this.selection = this.el.get_selection();
446 this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);
448 this.selection.signal['changed'].connect(function() {
449 _this.listeners.cursor_changed.apply(
456 xtype: Gtk.ListStore,
457 id : "changedFilesStore",
460 XObject.prototype.init.call(this);
461 this.el.set_column_types ( 3, [
462 GObject.TYPE_STRING, // file
463 GObject.TYPE_STRING, // added
464 GObject.TYPE_STRING, // removed
469 //this.insert(citer,iter,0);
471 for(var i =0 ; i < tr.length; i++) {
476 //print(JSON.stringify(ret,null,4));
479 this.el.set_value(ret.iter, 0, '' + tr[i].filename );
480 this.el.set_value(ret.iter, 1, '' + tr[i].added );
481 this.el.set_value(ret.iter, 2, '' + tr[i].removed );
488 xtype: Gtk.TreeViewColumn,
491 pack : "append_column",
494 XObject.prototype.init.call(this);
495 this.el.add_attribute(this.items[0].el , 'markup', 0 );
500 xtype: Gtk.CellRendererText,
506 xtype: Gtk.TreeViewColumn,
508 pack : "append_column",
511 XObject.prototype.init.call(this);
512 this.el.add_attribute(this.items[0].el , 'markup', 1 );
517 xtype: Gtk.CellRendererText,
523 xtype: Gtk.TreeViewColumn,
525 pack : "append_column",
528 XObject.prototype.init.call(this);
529 this.el.add_attribute(this.items[0].el , 'markup', 2 );
534 xtype: Gtk.CellRendererText,
546 xtype: Gtk.ListStore,
560 pack : "pack_start,false,false,0",
564 label : "Commit diff (no merge)"
568 label : "Commit diff (merge after)"
573 xtype: Gtk.ScrolledWindow,
574 pack : "pack_end,true,true,0",
576 XObject.prototype.init.call(this);
577 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
581 xtype: WebKit.WebView,
590 var s = "document.body.textContent='';"
592 this.el.execute_script(s);
599 showDiff : function(files) {
603 var model = this.get('/historyTreeStore');
605 if (model.release === false) {
609 var diff = Merger.repo.diff(files, model.release, model.rev);
612 var s = "var pre = document.createElement('pre'); document.body.appendChild(pre);";
613 s += "pre.textContent = " +
614 JSON.stringify(Merger.repo.lastCmd + "\n") + '+ ' +
615 JSON.stringify(diff) + ";";
618 this.el.execute_script(s);
638 pack : "add_action_widget,1"
643 XObject.cache['/Merger'] = Merger;