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",
312 XObject.prototype.init.call(this);
313 this.el.set_column_types ( 3, [
314 GObject.TYPE_STRING, // title
315 GObject.TYPE_STRING, // rev
318 load : function(tr,iter)
320 //this.insert(citer,iter,0);
325 for(var i =0 ; i < tr.length; i++) {
328 this.el.insert(ret ,iter,-1);
332 //print(JSON.stringify(ret,null,4));
335 this.el.set_value(ret.iter, 0, '' + tr[i].text );
336 this.el.set_value(ret.iter, 1, '' + tr[i].rev );
338 if (tr[i].children && tr[i].children.length) {
339 this.load(tr[i].children, ret.iter);
343 loadTree : function() {
345 this.working = false;
347 var wid = this.get('workingCombo').el.get_active();
348 var rid = this.get('releaseCombo').el.get_active();
349 if (wid < 0 || rid < 0 || rid == wid) {
353 var w = Merger.repo.branches[wid];
354 var r = Merger.repo.branches[rid];
358 var rev = r.name + '..' + w.name;
359 this.working = r.name;
361 var hist = Merger.repo.dayTree('/', false, 'rev', rev);
368 xtype: Gtk.TreeViewColumn,
369 pack : "append_column",
371 XObject.prototype.init.call(this);
372 this.el.add_attribute(this.items[0].el , 'markup', 0 );
377 xtype: Gtk.CellRendererText,
387 xtype: Gtk.ScrolledWindow,
389 XObject.prototype.init.call(this);
390 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
396 cursor_changed : function (self) {
397 // SEE SELECTION.CHANGED
398 if (this.el.get_selection().count_selected_rows() < 1) {
399 //nothing? - clea it?
403 var model = this.get('/changedFilesStore');
405 var s = this.el.get_selection();
407 s.selected_foreach(function(model,p,iter) {
409 files.push( model.get_value(iter, 0).value.get_string());
412 this.get('/patchview').showDiff(files);
413 //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
414 //print("OUT?" + value);// id..
415 // load the list in the right grid..
421 id : "changedFilesView",
424 XObject.prototype.init.call(this);
425 var description = new Pango.FontDescription.c_new();
426 description.set_size(8000);
427 this.el.modify_font(description);
429 this.selection = this.el.get_selection();
430 this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);
432 this.selection.signal['changed'].connect(function() {
433 _this.listeners.cursor_changed.apply(
440 xtype: Gtk.ListStore,
441 id : "changedFilesStore",
444 XObject.prototype.init.call(this);
445 this.el.set_column_types ( 3, [
446 GObject.TYPE_STRING, // file
447 GObject.TYPE_STRING, // added
448 GObject.TYPE_STRING, // removed
453 //this.insert(citer,iter,0);
455 for(var i =0 ; i < tr.length; i++) {
460 //print(JSON.stringify(ret,null,4));
463 this.el.set_value(ret.iter, 0, '' + tr[i].filename );
464 this.el.set_value(ret.iter, 1, '' + tr[i].added );
465 this.el.set_value(ret.iter, 2, '' + tr[i].removed );
472 xtype: Gtk.TreeViewColumn,
475 pack : "append_column",
478 XObject.prototype.init.call(this);
479 this.el.add_attribute(this.items[0].el , 'markup', 0 );
484 xtype: Gtk.CellRendererText,
490 xtype: Gtk.TreeViewColumn,
492 pack : "append_column",
495 XObject.prototype.init.call(this);
496 this.el.add_attribute(this.items[0].el , 'markup', 1 );
501 xtype: Gtk.CellRendererText,
507 xtype: Gtk.TreeViewColumn,
509 pack : "append_column",
512 XObject.prototype.init.call(this);
513 this.el.add_attribute(this.items[0].el , 'markup', 2 );
518 xtype: Gtk.CellRendererText,
530 xtype: Gtk.ListStore,
544 pack : "pack_start,false,false,0",
548 label : "Commit diff (no merge)"
552 label : "Commit diff (merge after)"
557 xtype: Gtk.ScrolledWindow,
558 pack : "pack_end,true,true,0",
560 XObject.prototype.init.call(this);
561 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
565 xtype: WebKit.WebView,
568 showDiff : function(files) {
571 var diff = Merger.repo.diff(files, 'github', 'master');
574 var s = "document.body.textContent='';var pre = document.createElement('pre'); document.body.appendChild(pre);";
575 s += "pre.textContent = " +
576 JSON.stringify(repo.lastCmd + "\n") + '+ ' +
577 JSON.stringify(diff) + ";";
580 this.el.execute_script(s);
599 pack : "add_action_widget,0"
605 pack : "add_action_widget,1"
610 XObject.cache['/Merger'] = Merger;