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);
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);
121 xtype: Gtk.ListStore,
123 XObject.prototype.init.call(this);
124 this.el.set_column_types ( 3, [
125 GObject.TYPE_STRING, // file
126 GObject.TYPE_STRING, // added
127 GObject.TYPE_STRING, // removed
132 //this.insert(citer,iter,0);
135 for(var i =0 ; i < tr.length; i++) {
138 //print(JSON.stringify(ret,null,4));
141 this.el.set_value(ret.iter, 0, '' + tr[i].name );
142 this.el.set_value(ret.iter, 1, '' + tr[i].rev );
151 label : "Release Branch"
157 this.el = new Gtk.ComboBox.with_entry();
160 this.model = new XObject(this.model);
162 this.el.set_model(this.model.el);
163 this.el.set_entry_text_column (0);
164 XObject.prototype.init.call(this);
168 xtype: Gtk.ListStore,
170 XObject.prototype.init.call(this);
171 this.el.set_column_types ( 3, [
172 GObject.TYPE_STRING, // file
173 GObject.TYPE_STRING, // added
174 GObject.TYPE_STRING, // removed
179 //this.insert(citer,iter,0);
182 for(var i =0 ; i < tr.length; i++) {
185 //print(JSON.stringify(ret,null,4));
188 this.el.set_value(ret.iter, 0, '' + tr[i].name );
189 this.el.set_value(ret.iter, 1, '' + tr[i].rev );
200 pack : "pack_end,true,true,0",
209 xtype: Gtk.ScrolledWindow,
211 XObject.prototype.init.call(this);
212 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
218 cursor_changed : function (self) {
220 if (this.el.get_selection().count_selected_rows() < 1) {
224 var model = this.get('/historyTreeStore');
226 var s = this.el.get_selection();
229 var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
230 print("OUT?" + value);// id..
231 // load the list in the right grid..
232 var Repo = imports.Scm.Git.Repo.Repo;
236 var files = Merger.repo.changedFiles('/', 'rev', 'github..' + value);
237 this.get('/changedFilesStore').load(files);
244 XObject.prototype.init.call(this);
245 var description = new Pango.FontDescription.c_new();
246 description.set_size(8000);
247 this.el.modify_font(description);
249 this.selection = this.el.get_selection();
250 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
254 781 // is this really needed??
255 782 this.selection.signal['changed'].connect(function() {
256 783 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
257 784 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
265 xtype: Gtk.TreeStore,
266 id : "historyTreeStore",
269 XObject.prototype.init.call(this);
270 this.el.set_column_types ( 3, [
271 GObject.TYPE_STRING, // title
272 GObject.TYPE_STRING, // rev
275 load : function(tr,iter)
277 //this.insert(citer,iter,0);
282 for(var i =0 ; i < tr.length; i++) {
285 this.el.insert(ret ,iter,-1);
289 //print(JSON.stringify(ret,null,4));
292 this.el.set_value(ret.iter, 0, '' + tr[i].text );
293 this.el.set_value(ret.iter, 1, '' + tr[i].rev );
295 if (tr[i].children && tr[i].children.length) {
296 this.load(tr[i].children, ret.iter);
302 xtype: Gtk.TreeViewColumn,
303 pack : "append_column",
305 XObject.prototype.init.call(this);
306 this.el.add_attribute(this.items[0].el , 'markup', 0 );
311 xtype: Gtk.CellRendererText,
321 xtype: Gtk.ScrolledWindow,
323 XObject.prototype.init.call(this);
324 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
330 cursor_changed : function (self) {
331 // SEE SELECTION.CHANGED
332 if (this.el.get_selection().count_selected_rows() < 1) {
333 //nothing? - clea it?
337 var model = this.get('/changedFilesStore');
339 var s = this.el.get_selection();
341 s.selected_foreach(function(model,p,iter) {
343 files.push( model.get_value(iter, 0).value.get_string());
346 this.get('/patchview').showDiff(files);
347 //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
348 //print("OUT?" + value);// id..
349 // load the list in the right grid..
355 id : "changedFilesView",
358 XObject.prototype.init.call(this);
359 var description = new Pango.FontDescription.c_new();
360 description.set_size(8000);
361 this.el.modify_font(description);
363 this.selection = this.el.get_selection();
364 this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);
366 this.selection.signal['changed'].connect(function() {
367 _this.listeners.cursor_changed.apply(
374 xtype: Gtk.ListStore,
375 id : "changedFilesStore",
378 XObject.prototype.init.call(this);
379 this.el.set_column_types ( 3, [
380 GObject.TYPE_STRING, // file
381 GObject.TYPE_STRING, // added
382 GObject.TYPE_STRING, // removed
387 //this.insert(citer,iter,0);
389 for(var i =0 ; i < tr.length; i++) {
394 //print(JSON.stringify(ret,null,4));
397 this.el.set_value(ret.iter, 0, '' + tr[i].filename );
398 this.el.set_value(ret.iter, 1, '' + tr[i].added );
399 this.el.set_value(ret.iter, 2, '' + tr[i].removed );
406 xtype: Gtk.TreeViewColumn,
409 pack : "append_column",
412 XObject.prototype.init.call(this);
413 this.el.add_attribute(this.items[0].el , 'markup', 0 );
418 xtype: Gtk.CellRendererText,
424 xtype: Gtk.TreeViewColumn,
426 pack : "append_column",
429 XObject.prototype.init.call(this);
430 this.el.add_attribute(this.items[0].el , 'markup', 1 );
435 xtype: Gtk.CellRendererText,
441 xtype: Gtk.TreeViewColumn,
443 pack : "append_column",
446 XObject.prototype.init.call(this);
447 this.el.add_attribute(this.items[0].el , 'markup', 2 );
452 xtype: Gtk.CellRendererText,
464 xtype: Gtk.ListStore,
478 pack : "pack_start,false,false,0",
482 label : "Commit diff (no merge)"
486 label : "Commit diff (merge after)"
491 xtype: Gtk.ScrolledWindow,
492 pack : "pack_end,true,true,0",
494 XObject.prototype.init.call(this);
495 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
499 xtype: WebKit.WebView,
502 showDiff : function(files) {
505 var diff = Merger.repo.diff(files, 'github', 'master');
508 var s = "document.body.textContent='';var pre = document.createElement('pre'); document.body.appendChild(pre);";
509 s += "pre.textContent = " +
510 JSON.stringify(repo.lastCmd + "\n") + '+ ' +
511 JSON.stringify(diff) + ";";
514 this.el.execute_script(s);
533 pack : "add_action_widget,0"
539 pack : "add_action_widget,1"
544 XObject.cache['/Merger'] = Merger;