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"
110 this.el = new Gtk.ComboBox.with_entry();
113 this.model = new XObject(this.model);
115 this.el.set_model(this.model.el);
116 this.el.set_entry_text_column (0);
117 XObject.prototype.init.call(this);
122 //this.insert(citer,iter,0);
123 this.model.el.clear();
125 for(var i =0 ; i < tr.length; i++) {
127 this.model.el.append(ret);
128 //print(JSON.stringify(ret,null,4));
131 this.model.el.set_value(ret.iter, 0, '' + tr[i].name );
132 this.model.el.set_value(ret.iter, 1, '' + tr[i].rev );
140 xtype: Gtk.ListStore,
142 XObject.prototype.init.call(this);
143 this.el.set_column_types ( 3, [
144 GObject.TYPE_STRING, // file
145 GObject.TYPE_STRING, // added
146 GObject.TYPE_STRING, // removed
153 label : "Release Branch"
159 this.el = new Gtk.ComboBox.with_entry();
162 this.model = new XObject(this.model);
164 this.el.set_model(this.model.el);
165 this.el.set_entry_text_column (0);
166 XObject.prototype.init.call(this);
170 xtype: Gtk.ListStore,
172 XObject.prototype.init.call(this);
173 this.el.set_column_types ( 3, [
174 GObject.TYPE_STRING, // file
175 GObject.TYPE_STRING, // added
176 GObject.TYPE_STRING, // removed
181 //this.insert(citer,iter,0);
184 for(var i =0 ; i < tr.length; i++) {
187 //print(JSON.stringify(ret,null,4));
190 this.el.set_value(ret.iter, 0, '' + tr[i].name );
191 this.el.set_value(ret.iter, 1, '' + tr[i].rev );
202 pack : "pack_end,true,true,0",
211 xtype: Gtk.ScrolledWindow,
213 XObject.prototype.init.call(this);
214 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
220 cursor_changed : function (self) {
222 if (this.el.get_selection().count_selected_rows() < 1) {
226 var model = this.get('/historyTreeStore');
228 var s = this.el.get_selection();
231 var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
232 print("OUT?" + value);// id..
233 // load the list in the right grid..
234 var Repo = imports.Scm.Git.Repo.Repo;
238 var files = Merger.repo.changedFiles('/', 'rev', 'github..' + value);
239 this.get('/changedFilesStore').load(files);
246 XObject.prototype.init.call(this);
247 var description = new Pango.FontDescription.c_new();
248 description.set_size(8000);
249 this.el.modify_font(description);
251 this.selection = this.el.get_selection();
252 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
256 781 // is this really needed??
257 782 this.selection.signal['changed'].connect(function() {
258 783 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
259 784 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
267 xtype: Gtk.TreeStore,
268 id : "historyTreeStore",
271 XObject.prototype.init.call(this);
272 this.el.set_column_types ( 3, [
273 GObject.TYPE_STRING, // title
274 GObject.TYPE_STRING, // rev
277 load : function(tr,iter)
279 //this.insert(citer,iter,0);
284 for(var i =0 ; i < tr.length; i++) {
287 this.el.insert(ret ,iter,-1);
291 //print(JSON.stringify(ret,null,4));
294 this.el.set_value(ret.iter, 0, '' + tr[i].text );
295 this.el.set_value(ret.iter, 1, '' + tr[i].rev );
297 if (tr[i].children && tr[i].children.length) {
298 this.load(tr[i].children, ret.iter);
304 xtype: Gtk.TreeViewColumn,
305 pack : "append_column",
307 XObject.prototype.init.call(this);
308 this.el.add_attribute(this.items[0].el , 'markup', 0 );
313 xtype: Gtk.CellRendererText,
323 xtype: Gtk.ScrolledWindow,
325 XObject.prototype.init.call(this);
326 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
332 cursor_changed : function (self) {
333 // SEE SELECTION.CHANGED
334 if (this.el.get_selection().count_selected_rows() < 1) {
335 //nothing? - clea it?
339 var model = this.get('/changedFilesStore');
341 var s = this.el.get_selection();
343 s.selected_foreach(function(model,p,iter) {
345 files.push( model.get_value(iter, 0).value.get_string());
348 this.get('/patchview').showDiff(files);
349 //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
350 //print("OUT?" + value);// id..
351 // load the list in the right grid..
357 id : "changedFilesView",
360 XObject.prototype.init.call(this);
361 var description = new Pango.FontDescription.c_new();
362 description.set_size(8000);
363 this.el.modify_font(description);
365 this.selection = this.el.get_selection();
366 this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);
368 this.selection.signal['changed'].connect(function() {
369 _this.listeners.cursor_changed.apply(
376 xtype: Gtk.ListStore,
377 id : "changedFilesStore",
380 XObject.prototype.init.call(this);
381 this.el.set_column_types ( 3, [
382 GObject.TYPE_STRING, // file
383 GObject.TYPE_STRING, // added
384 GObject.TYPE_STRING, // removed
389 //this.insert(citer,iter,0);
391 for(var i =0 ; i < tr.length; i++) {
396 //print(JSON.stringify(ret,null,4));
399 this.el.set_value(ret.iter, 0, '' + tr[i].filename );
400 this.el.set_value(ret.iter, 1, '' + tr[i].added );
401 this.el.set_value(ret.iter, 2, '' + tr[i].removed );
408 xtype: Gtk.TreeViewColumn,
411 pack : "append_column",
414 XObject.prototype.init.call(this);
415 this.el.add_attribute(this.items[0].el , 'markup', 0 );
420 xtype: Gtk.CellRendererText,
426 xtype: Gtk.TreeViewColumn,
428 pack : "append_column",
431 XObject.prototype.init.call(this);
432 this.el.add_attribute(this.items[0].el , 'markup', 1 );
437 xtype: Gtk.CellRendererText,
443 xtype: Gtk.TreeViewColumn,
445 pack : "append_column",
448 XObject.prototype.init.call(this);
449 this.el.add_attribute(this.items[0].el , 'markup', 2 );
454 xtype: Gtk.CellRendererText,
466 xtype: Gtk.ListStore,
480 pack : "pack_start,false,false,0",
484 label : "Commit diff (no merge)"
488 label : "Commit diff (merge after)"
493 xtype: Gtk.ScrolledWindow,
494 pack : "pack_end,true,true,0",
496 XObject.prototype.init.call(this);
497 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
501 xtype: WebKit.WebView,
504 showDiff : function(files) {
507 var diff = Merger.repo.diff(files, 'github', 'master');
510 var s = "document.body.textContent='';var pre = document.createElement('pre'); document.body.appendChild(pre);";
511 s += "pre.textContent = " +
512 JSON.stringify(repo.lastCmd + "\n") + '+ ' +
513 JSON.stringify(diff) + ";";
516 this.el.execute_script(s);
535 pack : "add_action_widget,0"
541 pack : "add_action_widget,1"
546 XObject.cache['/Merger'] = Merger;