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",
87 clicked : function (self) {
91 var hist = Merger.repo.dayTree('/', false, 'rev', 'github..master');
92 this.get('/historyTreeStore').load(hist);
99 label : "Select Branch",
104 label : "Working Branch"
109 changed : function (self) {
110 this.get('/historyTreeStore').loadTree();
115 this.el = new Gtk.ComboBox.with_entry();
118 this.model = new XObject(this.model);
120 this.el.set_model(this.model.el);
121 this.el.set_entry_text_column (0);
122 XObject.prototype.init.call(this);
127 //this.insert(citer,iter,0);
128 this.model.el.clear();
133 for(var i =0 ; i < tr.length; i++) {
135 this.model.el.append(ret);
136 //print(JSON.stringify(ret,null,4));
137 if (tr[i].name == 'master') {
140 if (tr[i].name == 'working') {
143 this.model.el.set_value(ret.iter, 0, '' + tr[i].name );
144 this.model.el.set_value(ret.iter, 1, '' + tr[i].rev );
148 if (master !== false) {
149 this.el.set_active(master);
151 if (working !== false) {
152 this.el.set_active(working);
157 xtype: Gtk.ListStore,
159 XObject.prototype.init.call(this);
160 this.el.set_column_types ( 3, [
161 GObject.TYPE_STRING, // file
162 GObject.TYPE_STRING, // added
163 GObject.TYPE_STRING, // removed
170 label : "Release Branch"
175 changed : function (self) {
176 this.get('/historyTreeStore').loadTree();
181 this.el = new Gtk.ComboBox.with_entry();
184 this.model = new XObject(this.model);
186 this.el.set_model(this.model.el);
187 this.el.set_entry_text_column (0);
188 XObject.prototype.init.call(this);
193 //this.insert(citer,iter,0);
194 this.model.el.clear();
199 for(var i =0 ; i < tr.length; i++) {
201 this.model.el.append(ret);
202 //print(JSON.stringify(ret,null,4));
203 if (tr[i].name == 'master') {
206 if (tr[i].name == 'release') {
209 this.model.el.set_value(ret.iter, 0, '' + tr[i].name );
210 this.model.el.set_value(ret.iter, 1, '' + tr[i].rev );
214 if (master !== false) {
215 this.el.set_active(master);
217 if (release !== false) {
218 this.el.set_active(release);
223 xtype: Gtk.ListStore,
225 XObject.prototype.init.call(this);
226 this.el.set_column_types ( 3, [
227 GObject.TYPE_STRING, // file
228 GObject.TYPE_STRING, // added
229 GObject.TYPE_STRING, // removed
238 pack : "pack_end,true,true,0",
247 xtype: Gtk.ScrolledWindow,
249 XObject.prototype.init.call(this);
250 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
256 cursor_changed : function (self) {
258 if (this.el.get_selection().count_selected_rows() < 1) {
262 var model = this.get('/historyTreeStore');
264 var s = this.el.get_selection();
267 var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
268 print("OUT?" + value);// id..
269 // load the list in the right grid..
270 var Repo = imports.Scm.Git.Repo.Repo;
274 if (model.release === false) {
279 var files = Merger.repo.changedFiles('/', 'rev', model.release + '..' + value);
280 this.get('/changedFilesStore').load(files);
287 XObject.prototype.init.call(this);
288 var description = new Pango.FontDescription.c_new();
289 description.set_size(8000);
290 this.el.modify_font(description);
292 this.selection = this.el.get_selection();
293 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
297 781 // is this really needed??
298 782 this.selection.signal['changed'].connect(function() {
299 783 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
300 784 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
308 xtype: Gtk.TreeStore,
309 id : "historyTreeStore",
313 XObject.prototype.init.call(this);
314 this.el.set_column_types ( 3, [
315 GObject.TYPE_STRING, // title
316 GObject.TYPE_STRING, // rev
319 load : function(tr,iter)
321 //this.insert(citer,iter,0);
326 for(var i =0 ; i < tr.length; i++) {
329 this.el.insert(ret ,iter,-1);
333 //print(JSON.stringify(ret,null,4));
336 this.el.set_value(ret.iter, 0, '' + tr[i].text );
337 this.el.set_value(ret.iter, 1, '' + tr[i].rev );
339 if (tr[i].children && tr[i].children.length) {
340 this.load(tr[i].children, ret.iter);
344 loadTree : function() {
346 this.working = false;
348 var wid = this.get('workingCombo').el.get_active();
349 var rid = this.get('releaseCombo').el.get_active();
350 if (wid < 0 || rid < 0 || rid == wid) {
354 var w = Merger.repo.branches[wid];
355 var r = Merger.repo.branches[rid];
359 var rev = r.name + '..' + w.name;
360 this.release = r.name;
362 var hist = Merger.repo.dayTree('/', false, 'rev', rev);
369 xtype: Gtk.TreeViewColumn,
370 pack : "append_column",
372 XObject.prototype.init.call(this);
373 this.el.add_attribute(this.items[0].el , 'markup', 0 );
378 xtype: Gtk.CellRendererText,
388 xtype: Gtk.ScrolledWindow,
390 XObject.prototype.init.call(this);
391 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
397 cursor_changed : function (self) {
398 // SEE SELECTION.CHANGED
399 if (this.el.get_selection().count_selected_rows() < 1) {
400 //nothing? - clea it?
404 var model = this.get('/changedFilesStore');
406 var s = this.el.get_selection();
408 s.selected_foreach(function(model,p,iter) {
410 files.push( model.get_value(iter, 0).value.get_string());
413 this.get('/patchview').showDiff(files);
414 //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
415 //print("OUT?" + value);// id..
416 // load the list in the right grid..
422 id : "changedFilesView",
425 XObject.prototype.init.call(this);
426 var description = new Pango.FontDescription.c_new();
427 description.set_size(8000);
428 this.el.modify_font(description);
430 this.selection = this.el.get_selection();
431 this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);
433 this.selection.signal['changed'].connect(function() {
434 _this.listeners.cursor_changed.apply(
441 xtype: Gtk.ListStore,
442 id : "changedFilesStore",
445 XObject.prototype.init.call(this);
446 this.el.set_column_types ( 3, [
447 GObject.TYPE_STRING, // file
448 GObject.TYPE_STRING, // added
449 GObject.TYPE_STRING, // removed
454 //this.insert(citer,iter,0);
456 for(var i =0 ; i < tr.length; i++) {
461 //print(JSON.stringify(ret,null,4));
464 this.el.set_value(ret.iter, 0, '' + tr[i].filename );
465 this.el.set_value(ret.iter, 1, '' + tr[i].added );
466 this.el.set_value(ret.iter, 2, '' + tr[i].removed );
473 xtype: Gtk.TreeViewColumn,
476 pack : "append_column",
479 XObject.prototype.init.call(this);
480 this.el.add_attribute(this.items[0].el , 'markup', 0 );
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', 1 );
502 xtype: Gtk.CellRendererText,
508 xtype: Gtk.TreeViewColumn,
510 pack : "append_column",
513 XObject.prototype.init.call(this);
514 this.el.add_attribute(this.items[0].el , 'markup', 2 );
519 xtype: Gtk.CellRendererText,
531 xtype: Gtk.ListStore,
545 pack : "pack_start,false,false,0",
549 label : "Commit diff (no merge)"
553 label : "Commit diff (merge after)"
558 xtype: Gtk.ScrolledWindow,
559 pack : "pack_end,true,true,0",
561 XObject.prototype.init.call(this);
562 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
566 xtype: WebKit.WebView,
569 showDiff : function(files) {
572 var diff = Merger.repo.diff(files, 'github', 'master');
575 var s = "document.body.textContent='';var pre = document.createElement('pre'); document.body.appendChild(pre);";
576 s += "pre.textContent = " +
577 JSON.stringify(repo.lastCmd + "\n") + '+ ' +
578 JSON.stringify(diff) + ";";
581 this.el.execute_script(s);
600 pack : "add_action_widget,0"
606 pack : "add_action_widget,1"
611 XObject.cache['/Merger'] = Merger;