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);
55 this.get('/workingCombo').load(Merger.repo.branches);
57 this.get('/releaseCombo').load(Merger.repo.branches);
60 //this.get('/ok_button').el.set_sensitive(false);
62 // block until we return.
63 var run_ret = this.el.run();
67 print("RUN RETURN : " + run_ret);
69 //print(JSON.stringify(this.get('bug').getValue()));
70 // return this.get('bug').getValue();
71 //this.success = c.success;
76 pack : function(p,e) {
77 p.el.get_content_area().pack_start(e.el,true,true,0)
82 pack : "pack_start,false,true",
86 label : "Release Branch",
92 changed : function (self) {
93 this.get('/historyTreeStore').loadTree();
98 this.el = new Gtk.ComboBox.with_entry();
101 this.model = new XObject(this.model);
103 this.el.set_model(this.model.el);
104 this.el.set_entry_text_column (0);
105 XObject.prototype.init.call(this);
110 //this.insert(citer,iter,0);
111 this.model.el.clear();
116 for(var i =0 ; i < tr.length; i++) {
118 this.model.el.append(ret);
119 //print(JSON.stringify(ret,null,4));
120 if (tr[i].name == 'master') {
123 if (tr[i].name == 'working') {
126 this.model.el.set_value(ret.iter, 0, '' + tr[i].name );
127 this.model.el.set_value(ret.iter, 1, '' + tr[i].rev );
131 if (master !== false) {
132 this.el.set_active(master);
134 if (working !== false) {
135 this.el.set_active(working);
140 xtype: Gtk.ListStore,
142 XObject.prototype.init.call(this);
143 this.el.set_column_types ( 3, [
144 GObject.TYPE_STRING, // file
145 GObject.TYPE_STRING, // added
146 GObject.TYPE_STRING, // removed
153 label : "Release Branch"
158 changed : function (self) {
159 this.get('/historyTreeStore').loadTree();
164 this.el = new Gtk.ComboBox.with_entry();
167 this.model = new XObject(this.model);
169 this.el.set_model(this.model.el);
170 this.el.set_entry_text_column (0);
171 XObject.prototype.init.call(this);
176 //this.insert(citer,iter,0);
177 this.model.el.clear();
182 for(var i =0 ; i < tr.length; i++) {
184 this.model.el.append(ret);
185 //print(JSON.stringify(ret,null,4));
186 if (tr[i].name == 'master') {
189 if (tr[i].name == 'release') {
192 this.model.el.set_value(ret.iter, 0, '' + tr[i].name );
193 this.model.el.set_value(ret.iter, 1, '' + tr[i].rev );
197 if (master !== false) {
198 this.el.set_active(master);
200 if (release !== false) {
201 this.el.set_active(release);
206 xtype: Gtk.ListStore,
208 XObject.prototype.init.call(this);
209 this.el.set_column_types ( 3, [
210 GObject.TYPE_STRING, // file
211 GObject.TYPE_STRING, // added
212 GObject.TYPE_STRING, // removed
221 pack : "pack_end,true,true,0",
230 xtype: Gtk.ScrolledWindow,
232 XObject.prototype.init.call(this);
233 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
239 cursor_changed : function (self) {
241 if (this.el.get_selection().count_selected_rows() < 1) {
245 var model = this.get('/historyTreeStore');
247 var s = this.el.get_selection();
250 var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
251 print("OUT?" + value);// id..
252 // load the list in the right grid..
253 var Repo = imports.Scm.Git.Repo.Repo;
257 if (model.release === false) {
262 var files = Merger.repo.changedFiles('/', 'rev', model.release + '..' + value);
263 this.get('/changedFilesStore').load(files);
270 XObject.prototype.init.call(this);
271 var description = new Pango.FontDescription.c_new();
272 description.set_size(8000);
273 this.el.modify_font(description);
275 this.selection = this.el.get_selection();
276 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
280 781 // is this really needed??
281 782 this.selection.signal['changed'].connect(function() {
282 783 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
283 784 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
291 xtype: Gtk.TreeStore,
292 id : "historyTreeStore",
296 XObject.prototype.init.call(this);
297 this.el.set_column_types ( 3, [
298 GObject.TYPE_STRING, // title
299 GObject.TYPE_STRING, // rev
302 load : function(tr,iter)
304 //this.insert(citer,iter,0);
309 for(var i =0 ; i < tr.length; i++) {
312 this.el.insert(ret ,iter,-1);
316 //print(JSON.stringify(ret,null,4));
319 this.el.set_value(ret.iter, 0, '' + tr[i].text );
320 this.el.set_value(ret.iter, 1, '' + tr[i].rev );
322 if (tr[i].children && tr[i].children.length) {
323 this.load(tr[i].children, ret.iter);
327 loadTree : function() {
329 this.working = false;
331 var wid = this.get('/workingCombo').el.get_active();
332 var rid = this.get('/releaseCombo').el.get_active();
333 if (wid < 0 || rid < 0 || rid == wid) {
337 var w = Merger.repo.branches[wid];
338 var r = Merger.repo.branches[rid];
342 var rev = r.name + '..' + w.name;
343 this.release = r.name;
345 var hist = Merger.repo.dayTree('/', false, 'rev', rev);
352 xtype: Gtk.TreeViewColumn,
353 pack : "append_column",
355 XObject.prototype.init.call(this);
356 this.el.add_attribute(this.items[0].el , 'markup', 0 );
361 xtype: Gtk.CellRendererText,
371 xtype: Gtk.ScrolledWindow,
373 XObject.prototype.init.call(this);
374 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
380 cursor_changed : function (self) {
381 // SEE SELECTION.CHANGED
382 if (this.el.get_selection().count_selected_rows() < 1) {
383 //nothing? - clea it?
387 var model = this.get('/changedFilesStore');
389 var s = this.el.get_selection();
391 s.selected_foreach(function(model,p,iter) {
393 files.push( model.get_value(iter, 0).value.get_string());
396 this.get('/patchview').showDiff(files);
397 //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
398 //print("OUT?" + value);// id..
399 // load the list in the right grid..
405 id : "changedFilesView",
408 XObject.prototype.init.call(this);
409 var description = new Pango.FontDescription.c_new();
410 description.set_size(8000);
411 this.el.modify_font(description);
413 this.selection = this.el.get_selection();
414 this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);
416 this.selection.signal['changed'].connect(function() {
417 _this.listeners.cursor_changed.apply(
424 xtype: Gtk.ListStore,
425 id : "changedFilesStore",
428 XObject.prototype.init.call(this);
429 this.el.set_column_types ( 3, [
430 GObject.TYPE_STRING, // file
431 GObject.TYPE_STRING, // added
432 GObject.TYPE_STRING, // removed
437 //this.insert(citer,iter,0);
439 for(var i =0 ; i < tr.length; i++) {
444 //print(JSON.stringify(ret,null,4));
447 this.el.set_value(ret.iter, 0, '' + tr[i].filename );
448 this.el.set_value(ret.iter, 1, '' + tr[i].added );
449 this.el.set_value(ret.iter, 2, '' + tr[i].removed );
456 xtype: Gtk.TreeViewColumn,
459 pack : "append_column",
462 XObject.prototype.init.call(this);
463 this.el.add_attribute(this.items[0].el , 'markup', 0 );
468 xtype: Gtk.CellRendererText,
474 xtype: Gtk.TreeViewColumn,
476 pack : "append_column",
479 XObject.prototype.init.call(this);
480 this.el.add_attribute(this.items[0].el , 'markup', 1 );
485 xtype: Gtk.CellRendererText,
491 xtype: Gtk.TreeViewColumn,
493 pack : "append_column",
496 XObject.prototype.init.call(this);
497 this.el.add_attribute(this.items[0].el , 'markup', 2 );
502 xtype: Gtk.CellRendererText,
514 xtype: Gtk.ListStore,
528 pack : "pack_start,false,false,0",
532 label : "Commit diff (no merge)"
536 label : "Commit diff (merge after)"
541 xtype: Gtk.ScrolledWindow,
542 pack : "pack_end,true,true,0",
544 XObject.prototype.init.call(this);
545 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
549 xtype: WebKit.WebView,
552 showDiff : function(files) {
556 var model = this.get('/historyTreeStore');
558 if (model.release === false) {
562 var diff = Merger.repo.diff(files, model.release, model.rev);
565 var s = "document.body.textContent='';var pre = document.createElement('pre'); document.body.appendChild(pre);";
566 s += "pre.textContent = " +
567 JSON.stringify(Merger.repo.lastCmd + "\n") + '+ ' +
568 JSON.stringify(diff) + ";";
571 this.el.execute_script(s);
590 pack : "add_action_widget,0"
596 pack : "add_action_widget,1"
601 XObject.cache['/Merger'] = Merger;