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 var files = Merger.repo.changedFiles('/', 'rev', 'github..' + value);
275 this.get('/changedFilesStore').load(files);
282 XObject.prototype.init.call(this);
283 var description = new Pango.FontDescription.c_new();
284 description.set_size(8000);
285 this.el.modify_font(description);
287 this.selection = this.el.get_selection();
288 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
292 781 // is this really needed??
293 782 this.selection.signal['changed'].connect(function() {
294 783 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
295 784 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
303 xtype: Gtk.TreeStore,
304 id : "historyTreeStore",
306 loadTree : function() {
310 XObject.prototype.init.call(this);
311 this.el.set_column_types ( 3, [
312 GObject.TYPE_STRING, // title
313 GObject.TYPE_STRING, // rev
316 load : function(tr,iter)
318 //this.insert(citer,iter,0);
323 for(var i =0 ; i < tr.length; i++) {
326 this.el.insert(ret ,iter,-1);
330 //print(JSON.stringify(ret,null,4));
333 this.el.set_value(ret.iter, 0, '' + tr[i].text );
334 this.el.set_value(ret.iter, 1, '' + tr[i].rev );
336 if (tr[i].children && tr[i].children.length) {
337 this.load(tr[i].children, ret.iter);
343 xtype: Gtk.TreeViewColumn,
344 pack : "append_column",
346 XObject.prototype.init.call(this);
347 this.el.add_attribute(this.items[0].el , 'markup', 0 );
352 xtype: Gtk.CellRendererText,
362 xtype: Gtk.ScrolledWindow,
364 XObject.prototype.init.call(this);
365 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
371 cursor_changed : function (self) {
372 // SEE SELECTION.CHANGED
373 if (this.el.get_selection().count_selected_rows() < 1) {
374 //nothing? - clea it?
378 var model = this.get('/changedFilesStore');
380 var s = this.el.get_selection();
382 s.selected_foreach(function(model,p,iter) {
384 files.push( model.get_value(iter, 0).value.get_string());
387 this.get('/patchview').showDiff(files);
388 //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
389 //print("OUT?" + value);// id..
390 // load the list in the right grid..
396 id : "changedFilesView",
399 XObject.prototype.init.call(this);
400 var description = new Pango.FontDescription.c_new();
401 description.set_size(8000);
402 this.el.modify_font(description);
404 this.selection = this.el.get_selection();
405 this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);
407 this.selection.signal['changed'].connect(function() {
408 _this.listeners.cursor_changed.apply(
415 xtype: Gtk.ListStore,
416 id : "changedFilesStore",
419 XObject.prototype.init.call(this);
420 this.el.set_column_types ( 3, [
421 GObject.TYPE_STRING, // file
422 GObject.TYPE_STRING, // added
423 GObject.TYPE_STRING, // removed
428 //this.insert(citer,iter,0);
430 for(var i =0 ; i < tr.length; i++) {
435 //print(JSON.stringify(ret,null,4));
438 this.el.set_value(ret.iter, 0, '' + tr[i].filename );
439 this.el.set_value(ret.iter, 1, '' + tr[i].added );
440 this.el.set_value(ret.iter, 2, '' + tr[i].removed );
447 xtype: Gtk.TreeViewColumn,
450 pack : "append_column",
453 XObject.prototype.init.call(this);
454 this.el.add_attribute(this.items[0].el , 'markup', 0 );
459 xtype: Gtk.CellRendererText,
465 xtype: Gtk.TreeViewColumn,
467 pack : "append_column",
470 XObject.prototype.init.call(this);
471 this.el.add_attribute(this.items[0].el , 'markup', 1 );
476 xtype: Gtk.CellRendererText,
482 xtype: Gtk.TreeViewColumn,
484 pack : "append_column",
487 XObject.prototype.init.call(this);
488 this.el.add_attribute(this.items[0].el , 'markup', 2 );
493 xtype: Gtk.CellRendererText,
505 xtype: Gtk.ListStore,
519 pack : "pack_start,false,false,0",
523 label : "Commit diff (no merge)"
527 label : "Commit diff (merge after)"
532 xtype: Gtk.ScrolledWindow,
533 pack : "pack_end,true,true,0",
535 XObject.prototype.init.call(this);
536 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
540 xtype: WebKit.WebView,
543 showDiff : function(files) {
546 var diff = Merger.repo.diff(files, 'github', 'master');
549 var s = "document.body.textContent='';var pre = document.createElement('pre'); document.body.appendChild(pre);";
550 s += "pre.textContent = " +
551 JSON.stringify(repo.lastCmd + "\n") + '+ ' +
552 JSON.stringify(diff) + ";";
555 this.el.execute_script(s);
574 pack : "add_action_widget,0"
580 pack : "add_action_widget,1"
585 XObject.cache['/Merger'] = Merger;