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 var files = this.files();
415 this.get('/patchview').showDiff(files);
416 //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
417 //print("OUT?" + value);// id..
418 // load the list in the right grid..
424 id : "changedFilesView",
427 if (this.el.get_selection().count_selected_rows() < 1) {
428 //nothing? - clea it?
433 var model = this.get('/changedFilesStore');
435 var s = this.el.get_selection();
437 s.selected_foreach(function(model,p,iter) {
439 files.push( model.get_value(iter, 0).value.get_string());
445 XObject.prototype.init.call(this);
446 var description = new Pango.FontDescription.c_new();
447 description.set_size(8000);
448 this.el.modify_font(description);
450 this.selection = this.el.get_selection();
451 this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);
453 this.selection.signal['changed'].connect(function() {
454 _this.listeners.cursor_changed.apply(
461 xtype: Gtk.ListStore,
462 id : "changedFilesStore",
465 XObject.prototype.init.call(this);
466 this.el.set_column_types ( 3, [
467 GObject.TYPE_STRING, // file
468 GObject.TYPE_STRING, // added
469 GObject.TYPE_STRING, // removed
474 //this.insert(citer,iter,0);
476 for(var i =0 ; i < tr.length; i++) {
481 //print(JSON.stringify(ret,null,4));
484 this.el.set_value(ret.iter, 0, '' + tr[i].filename );
485 this.el.set_value(ret.iter, 1, '' + tr[i].added );
486 this.el.set_value(ret.iter, 2, '' + tr[i].removed );
493 xtype: Gtk.TreeViewColumn,
496 pack : "append_column",
499 XObject.prototype.init.call(this);
500 this.el.add_attribute(this.items[0].el , 'markup', 0 );
505 xtype: Gtk.CellRendererText,
511 xtype: Gtk.TreeViewColumn,
513 pack : "append_column",
516 XObject.prototype.init.call(this);
517 this.el.add_attribute(this.items[0].el , 'markup', 1 );
522 xtype: Gtk.CellRendererText,
528 xtype: Gtk.TreeViewColumn,
530 pack : "append_column",
533 XObject.prototype.init.call(this);
534 this.el.add_attribute(this.items[0].el , 'markup', 2 );
539 xtype: Gtk.CellRendererText,
551 xtype: Gtk.ListStore,
565 pack : "pack_start,false,false,0",
570 clicked : function (self) {
571 Commit = imports.Commit.Commit;
572 Commit.repo = Merger.repo;
573 Merger.el.set_transient_for(Commit.el);
576 files : this.get('/changedFilesView').files()
583 label : "Commit diff (no merge)"
588 xtype: Gtk.ScrolledWindow,
589 pack : "pack_end,true,true,0",
591 XObject.prototype.init.call(this);
592 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
596 xtype: WebKit.WebView,
605 var s = "document.body.textContent='';"
607 this.el.execute_script(s);
614 showDiff : function(files) {
618 var model = this.get('/historyTreeStore');
620 if (model.release === false) {
624 var diff = Merger.repo.diff(files, model.release, model.rev);
627 var s = "var pre = document.createElement('pre'); document.body.appendChild(pre);";
628 s += "pre.textContent = " +
629 JSON.stringify(Merger.repo.lastCmd + "\n") + '+ ' +
630 JSON.stringify(diff) + ";";
633 this.el.execute_script(s);
653 pack : "add_action_widget,1"
658 XObject.cache['/Merger'] = Merger;