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').model.load(Merger.repo.branches);
57 this.get('/releaseCombo').model.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"
113 this.el = new Gtk.ComboBox.with_entry();
116 this.model = new XObject(this.model);
118 this.el.set_model(this.model.el);
119 this.el.set_entry_text_column (0);
120 XObject.prototype.init.call(this);
124 xtype: Gtk.ListStore,
126 XObject.prototype.init.call(this);
127 this.el.set_column_types ( 3, [
128 GObject.TYPE_STRING, // file
129 GObject.TYPE_STRING, // added
130 GObject.TYPE_STRING, // removed
135 //this.insert(citer,iter,0);
138 for(var i =0 ; i < tr.length; i++) {
141 //print(JSON.stringify(ret,null,4));
144 this.el.set_value(ret.iter, 0, '' + tr[i].name );
145 this.el.set_value(ret.iter, 1, '' + tr[i].rev );
156 label : "Release Branch"
162 this.el = new Gtk.ComboBox.with_entry();
165 this.model = new XObject(this.model);
167 this.el.set_model(this.model.el);
168 this.el.set_entry_text_column (0);
169 XObject.prototype.init.call(this);
173 xtype: Gtk.ListStore,
175 XObject.prototype.init.call(this);
176 this.el.set_column_types ( 3, [
177 GObject.TYPE_STRING, // file
178 GObject.TYPE_STRING, // added
179 GObject.TYPE_STRING, // removed
184 //this.insert(citer,iter,0);
187 for(var i =0 ; i < tr.length; i++) {
190 //print(JSON.stringify(ret,null,4));
193 this.el.set_value(ret.iter, 0, '' + tr[i].name );
194 this.el.set_value(ret.iter, 1, '' + tr[i].rev );
205 pack : "pack_end,true,true,0",
214 xtype: Gtk.ScrolledWindow,
216 XObject.prototype.init.call(this);
217 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
223 cursor_changed : function (self) {
225 if (this.el.get_selection().count_selected_rows() < 1) {
229 var model = this.get('/historyTreeStore');
231 var s = this.el.get_selection();
234 var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
235 print("OUT?" + value);// id..
236 // load the list in the right grid..
237 var Repo = imports.Scm.Git.Repo.Repo;
241 var files = Merger.repo.changedFiles('/', 'rev', 'github..' + value);
242 this.get('/changedFilesStore').load(files);
249 XObject.prototype.init.call(this);
250 var description = new Pango.FontDescription.c_new();
251 description.set_size(8000);
252 this.el.modify_font(description);
254 this.selection = this.el.get_selection();
255 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
259 781 // is this really needed??
260 782 this.selection.signal['changed'].connect(function() {
261 783 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
262 784 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
270 xtype: Gtk.TreeStore,
271 id : "historyTreeStore",
274 XObject.prototype.init.call(this);
275 this.el.set_column_types ( 3, [
276 GObject.TYPE_STRING, // title
277 GObject.TYPE_STRING, // rev
280 load : function(tr,iter)
282 //this.insert(citer,iter,0);
287 for(var i =0 ; i < tr.length; i++) {
290 this.el.insert(ret ,iter,-1);
294 //print(JSON.stringify(ret,null,4));
297 this.el.set_value(ret.iter, 0, '' + tr[i].text );
298 this.el.set_value(ret.iter, 1, '' + tr[i].rev );
300 if (tr[i].children && tr[i].children.length) {
301 this.load(tr[i].children, ret.iter);
307 xtype: Gtk.TreeViewColumn,
308 pack : "append_column",
310 XObject.prototype.init.call(this);
311 this.el.add_attribute(this.items[0].el , 'markup', 0 );
316 xtype: Gtk.CellRendererText,
326 xtype: Gtk.ScrolledWindow,
328 XObject.prototype.init.call(this);
329 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
335 cursor_changed : function (self) {
336 // SEE SELECTION.CHANGED
337 if (this.el.get_selection().count_selected_rows() < 1) {
338 //nothing? - clea it?
342 var model = this.get('/changedFilesStore');
344 var s = this.el.get_selection();
346 s.selected_foreach(function(model,p,iter) {
348 files.push( model.get_value(iter, 0).value.get_string());
351 this.get('/patchview').showDiff(files);
352 //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
353 //print("OUT?" + value);// id..
354 // load the list in the right grid..
360 id : "changedFilesView",
363 XObject.prototype.init.call(this);
364 var description = new Pango.FontDescription.c_new();
365 description.set_size(8000);
366 this.el.modify_font(description);
368 this.selection = this.el.get_selection();
369 this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);
371 this.selection.signal['changed'].connect(function() {
372 _this.listeners.cursor_changed.apply(
379 xtype: Gtk.ListStore,
380 id : "changedFilesStore",
383 XObject.prototype.init.call(this);
384 this.el.set_column_types ( 3, [
385 GObject.TYPE_STRING, // file
386 GObject.TYPE_STRING, // added
387 GObject.TYPE_STRING, // removed
392 //this.insert(citer,iter,0);
394 for(var i =0 ; i < tr.length; i++) {
399 //print(JSON.stringify(ret,null,4));
402 this.el.set_value(ret.iter, 0, '' + tr[i].filename );
403 this.el.set_value(ret.iter, 1, '' + tr[i].added );
404 this.el.set_value(ret.iter, 2, '' + tr[i].removed );
411 xtype: Gtk.TreeViewColumn,
414 pack : "append_column",
417 XObject.prototype.init.call(this);
418 this.el.add_attribute(this.items[0].el , 'markup', 0 );
423 xtype: Gtk.CellRendererText,
429 xtype: Gtk.TreeViewColumn,
431 pack : "append_column",
434 XObject.prototype.init.call(this);
435 this.el.add_attribute(this.items[0].el , 'markup', 1 );
440 xtype: Gtk.CellRendererText,
446 xtype: Gtk.TreeViewColumn,
448 pack : "append_column",
451 XObject.prototype.init.call(this);
452 this.el.add_attribute(this.items[0].el , 'markup', 2 );
457 xtype: Gtk.CellRendererText,
469 xtype: Gtk.ListStore,
483 pack : "pack_start,false,false,0",
487 label : "Commit diff (no merge)"
491 label : "Commit diff (merge after)"
496 xtype: Gtk.ScrolledWindow,
497 pack : "pack_end,true,true,0",
499 XObject.prototype.init.call(this);
500 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
504 xtype: WebKit.WebView,
507 showDiff : function(files) {
510 var diff = Merger.repo.diff(files, 'github', 'master');
513 var s = "document.body.textContent='';var pre = document.createElement('pre'); document.body.appendChild(pre);";
514 s += "pre.textContent = " +
515 JSON.stringify(repo.lastCmd + "\n") + '+ ' +
516 JSON.stringify(diff) + ";";
519 this.el.execute_script(s);
538 pack : "add_action_widget,0"
544 pack : "add_action_widget,1"
549 XObject.cache['/Merger'] = Merger;