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 : "Working Branch"
91 changed : function (self) {
92 this.get('/historyTreeStore').loadTree();
97 this.el = new Gtk.ComboBox.with_entry();
100 this.model = new XObject(this.model);
102 this.el.set_model(this.model.el);
103 this.el.set_entry_text_column (0);
104 XObject.prototype.init.call(this);
109 //this.insert(citer,iter,0);
110 this.model.el.clear();
115 for(var i =0 ; i < tr.length; i++) {
117 this.model.el.append(ret);
118 //print(JSON.stringify(ret,null,4));
119 if (tr[i].name == 'master') {
122 if (tr[i].name == 'working') {
125 this.model.el.set_value(ret.iter, 0, '' + tr[i].name );
126 this.model.el.set_value(ret.iter, 1, '' + tr[i].rev );
130 if (master !== false) {
131 this.el.set_active(master);
133 if (working !== false) {
134 this.el.set_active(working);
139 xtype: Gtk.ListStore,
141 XObject.prototype.init.call(this);
142 this.el.set_column_types ( 3, [
143 GObject.TYPE_STRING, // file
144 GObject.TYPE_STRING, // added
145 GObject.TYPE_STRING, // removed
152 label : "Release Branch"
157 changed : function (self) {
158 this.get('/historyTreeStore').loadTree();
163 this.el = new Gtk.ComboBox.with_entry();
166 this.model = new XObject(this.model);
168 this.el.set_model(this.model.el);
169 this.el.set_entry_text_column (0);
170 XObject.prototype.init.call(this);
175 //this.insert(citer,iter,0);
176 this.model.el.clear();
181 for(var i =0 ; i < tr.length; i++) {
183 this.model.el.append(ret);
184 //print(JSON.stringify(ret,null,4));
185 if (tr[i].name == 'master') {
188 if (tr[i].name == 'release') {
191 this.model.el.set_value(ret.iter, 0, '' + tr[i].name );
192 this.model.el.set_value(ret.iter, 1, '' + tr[i].rev );
196 if (master !== false) {
197 this.el.set_active(master);
199 if (release !== false) {
200 this.el.set_active(release);
205 xtype: Gtk.ListStore,
207 XObject.prototype.init.call(this);
208 this.el.set_column_types ( 3, [
209 GObject.TYPE_STRING, // file
210 GObject.TYPE_STRING, // added
211 GObject.TYPE_STRING, // removed
220 pack : "pack_end,true,true,0",
229 xtype: Gtk.ScrolledWindow,
231 XObject.prototype.init.call(this);
232 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
238 cursor_changed : function (self) {
240 if (this.el.get_selection().count_selected_rows() < 1) {
244 var model = this.get('/historyTreeStore');
246 var s = this.el.get_selection();
249 var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
250 print("OUT?" + value);// id..
251 // load the list in the right grid..
252 var Repo = imports.Scm.Git.Repo.Repo;
256 if (model.release === false) {
261 var files = Merger.repo.changedFiles('/', 'rev', model.release + '..' + value);
262 this.get('/changedFilesStore').load(files);
269 XObject.prototype.init.call(this);
270 var description = new Pango.FontDescription.c_new();
271 description.set_size(8000);
272 this.el.modify_font(description);
274 this.selection = this.el.get_selection();
275 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
279 781 // is this really needed??
280 782 this.selection.signal['changed'].connect(function() {
281 783 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
282 784 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
290 xtype: Gtk.TreeStore,
291 id : "historyTreeStore",
295 XObject.prototype.init.call(this);
296 this.el.set_column_types ( 3, [
297 GObject.TYPE_STRING, // title
298 GObject.TYPE_STRING, // rev
301 load : function(tr,iter)
303 //this.insert(citer,iter,0);
308 for(var i =0 ; i < tr.length; i++) {
311 this.el.insert(ret ,iter,-1);
315 //print(JSON.stringify(ret,null,4));
318 this.el.set_value(ret.iter, 0, '' + tr[i].text );
319 this.el.set_value(ret.iter, 1, '' + tr[i].rev );
321 if (tr[i].children && tr[i].children.length) {
322 this.load(tr[i].children, ret.iter);
326 loadTree : function() {
328 this.working = false;
330 var wid = this.get('workingCombo').el.get_active();
331 var rid = this.get('releaseCombo').el.get_active();
332 if (wid < 0 || rid < 0 || rid == wid) {
336 var w = Merger.repo.branches[wid];
337 var r = Merger.repo.branches[rid];
341 var rev = r.name + '..' + w.name;
342 this.release = r.name;
344 var hist = Merger.repo.dayTree('/', false, 'rev', rev);
351 xtype: Gtk.TreeViewColumn,
352 pack : "append_column",
354 XObject.prototype.init.call(this);
355 this.el.add_attribute(this.items[0].el , 'markup', 0 );
360 xtype: Gtk.CellRendererText,
370 xtype: Gtk.ScrolledWindow,
372 XObject.prototype.init.call(this);
373 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
379 cursor_changed : function (self) {
380 // SEE SELECTION.CHANGED
381 if (this.el.get_selection().count_selected_rows() < 1) {
382 //nothing? - clea it?
386 var model = this.get('/changedFilesStore');
388 var s = this.el.get_selection();
390 s.selected_foreach(function(model,p,iter) {
392 files.push( model.get_value(iter, 0).value.get_string());
395 this.get('/patchview').showDiff(files);
396 //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
397 //print("OUT?" + value);// id..
398 // load the list in the right grid..
404 id : "changedFilesView",
407 XObject.prototype.init.call(this);
408 var description = new Pango.FontDescription.c_new();
409 description.set_size(8000);
410 this.el.modify_font(description);
412 this.selection = this.el.get_selection();
413 this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);
415 this.selection.signal['changed'].connect(function() {
416 _this.listeners.cursor_changed.apply(
423 xtype: Gtk.ListStore,
424 id : "changedFilesStore",
427 XObject.prototype.init.call(this);
428 this.el.set_column_types ( 3, [
429 GObject.TYPE_STRING, // file
430 GObject.TYPE_STRING, // added
431 GObject.TYPE_STRING, // removed
436 //this.insert(citer,iter,0);
438 for(var i =0 ; i < tr.length; i++) {
443 //print(JSON.stringify(ret,null,4));
446 this.el.set_value(ret.iter, 0, '' + tr[i].filename );
447 this.el.set_value(ret.iter, 1, '' + tr[i].added );
448 this.el.set_value(ret.iter, 2, '' + tr[i].removed );
455 xtype: Gtk.TreeViewColumn,
458 pack : "append_column",
461 XObject.prototype.init.call(this);
462 this.el.add_attribute(this.items[0].el , 'markup', 0 );
467 xtype: Gtk.CellRendererText,
473 xtype: Gtk.TreeViewColumn,
475 pack : "append_column",
478 XObject.prototype.init.call(this);
479 this.el.add_attribute(this.items[0].el , 'markup', 1 );
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', 2 );
501 xtype: Gtk.CellRendererText,
513 xtype: Gtk.ListStore,
527 pack : "pack_start,false,false,0",
531 label : "Commit diff (no merge)"
535 label : "Commit diff (merge after)"
540 xtype: Gtk.ScrolledWindow,
541 pack : "pack_end,true,true,0",
543 XObject.prototype.init.call(this);
544 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
548 xtype: WebKit.WebView,
551 showDiff : function(files) {
555 var model = this.get('/historyTreeStore');
557 if (model.release === false) {
561 var diff = Merger.repo.diff(files, model.release, model.rev);
564 var s = "document.body.textContent='';var pre = document.createElement('pre'); document.body.appendChild(pre);";
565 s += "pre.textContent = " +
566 JSON.stringify(repo.lastCmd + "\n") + '+ ' +
567 JSON.stringify(diff) + ";";
570 this.el.execute_script(s);
589 pack : "add_action_widget,0"
595 pack : "add_action_widget,1"
600 XObject.cache['/Merger'] = Merger;