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 changed : function (self) {
88 this.get('/historyTreeStore').loadTree();
93 this.el = new Gtk.ComboBox.with_entry();
96 this.model = new XObject(this.model);
98 this.el.set_model(this.model.el);
99 this.el.set_entry_text_column (0);
100 XObject.prototype.init.call(this);
105 //this.insert(citer,iter,0);
106 this.model.el.clear();
111 for(var i =0 ; i < tr.length; i++) {
113 this.model.el.append(ret);
114 //print(JSON.stringify(ret,null,4));
115 if (tr[i].name == 'master') {
118 if (tr[i].name == 'working') {
121 this.model.el.set_value(ret.iter, 0, '' + tr[i].name );
122 this.model.el.set_value(ret.iter, 1, '' + tr[i].rev );
126 if (master !== false) {
127 this.el.set_active(master);
129 if (working !== false) {
130 this.el.set_active(working);
135 xtype: Gtk.ListStore,
137 XObject.prototype.init.call(this);
138 this.el.set_column_types ( 3, [
139 GObject.TYPE_STRING, // file
140 GObject.TYPE_STRING, // added
141 GObject.TYPE_STRING, // removed
148 label : "Release Branch"
153 changed : function (self) {
154 this.get('/historyTreeStore').loadTree();
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);
171 //this.insert(citer,iter,0);
172 this.model.el.clear();
177 for(var i =0 ; i < tr.length; i++) {
179 this.model.el.append(ret);
180 //print(JSON.stringify(ret,null,4));
181 if (tr[i].name == 'master') {
184 if (tr[i].name == 'release') {
187 this.model.el.set_value(ret.iter, 0, '' + tr[i].name );
188 this.model.el.set_value(ret.iter, 1, '' + tr[i].rev );
192 if (master !== false) {
193 this.el.set_active(master);
195 if (release !== false) {
196 this.el.set_active(release);
201 xtype: Gtk.ListStore,
203 XObject.prototype.init.call(this);
204 this.el.set_column_types ( 3, [
205 GObject.TYPE_STRING, // file
206 GObject.TYPE_STRING, // added
207 GObject.TYPE_STRING, // removed
216 pack : "pack_end,true,true,0",
225 xtype: Gtk.ScrolledWindow,
227 XObject.prototype.init.call(this);
228 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
234 cursor_changed : function (self) {
236 if (this.el.get_selection().count_selected_rows() < 1) {
240 var model = this.get('/historyTreeStore');
242 var s = this.el.get_selection();
245 var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
246 print("OUT?" + value);// id..
247 // load the list in the right grid..
248 var Repo = imports.Scm.Git.Repo.Repo;
252 if (model.release === false) {
257 var files = Merger.repo.changedFiles('/', 'rev', model.release + '..' + value);
258 this.get('/changedFilesStore').load(files);
265 XObject.prototype.init.call(this);
266 var description = new Pango.FontDescription.c_new();
267 description.set_size(8000);
268 this.el.modify_font(description);
270 this.selection = this.el.get_selection();
271 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
275 781 // is this really needed??
276 782 this.selection.signal['changed'].connect(function() {
277 783 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
278 784 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
286 xtype: Gtk.TreeStore,
287 id : "historyTreeStore",
291 XObject.prototype.init.call(this);
292 this.el.set_column_types ( 3, [
293 GObject.TYPE_STRING, // title
294 GObject.TYPE_STRING, // rev
297 load : function(tr,iter)
299 //this.insert(citer,iter,0);
304 for(var i =0 ; i < tr.length; i++) {
307 this.el.insert(ret ,iter,-1);
311 //print(JSON.stringify(ret,null,4));
314 this.el.set_value(ret.iter, 0, '' + tr[i].text );
315 this.el.set_value(ret.iter, 1, '' + tr[i].rev );
317 if (tr[i].children && tr[i].children.length) {
318 this.load(tr[i].children, ret.iter);
322 loadTree : function() {
324 this.working = false;
326 var wid = this.get('/workingCombo').el.get_active();
327 var rid = this.get('/releaseCombo').el.get_active();
328 if (wid < 0 || rid < 0 || rid == wid) {
332 var w = Merger.repo.branches[wid];
333 var r = Merger.repo.branches[rid];
337 var rev = r.name + '..' + w.name;
338 this.release = r.name;
340 var hist = Merger.repo.dayTree('/', false, 'rev', rev);
347 xtype: Gtk.TreeViewColumn,
348 pack : "append_column",
350 XObject.prototype.init.call(this);
351 this.el.add_attribute(this.items[0].el , 'markup', 0 );
356 xtype: Gtk.CellRendererText,
366 xtype: Gtk.ScrolledWindow,
368 XObject.prototype.init.call(this);
369 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
375 cursor_changed : function (self) {
376 // SEE SELECTION.CHANGED
377 if (this.el.get_selection().count_selected_rows() < 1) {
378 //nothing? - clea it?
382 var model = this.get('/changedFilesStore');
384 var s = this.el.get_selection();
386 s.selected_foreach(function(model,p,iter) {
388 files.push( model.get_value(iter, 0).value.get_string());
391 this.get('/patchview').showDiff(files);
392 //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
393 //print("OUT?" + value);// id..
394 // load the list in the right grid..
400 id : "changedFilesView",
403 XObject.prototype.init.call(this);
404 var description = new Pango.FontDescription.c_new();
405 description.set_size(8000);
406 this.el.modify_font(description);
408 this.selection = this.el.get_selection();
409 this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);
411 this.selection.signal['changed'].connect(function() {
412 _this.listeners.cursor_changed.apply(
419 xtype: Gtk.ListStore,
420 id : "changedFilesStore",
423 XObject.prototype.init.call(this);
424 this.el.set_column_types ( 3, [
425 GObject.TYPE_STRING, // file
426 GObject.TYPE_STRING, // added
427 GObject.TYPE_STRING, // removed
432 //this.insert(citer,iter,0);
434 for(var i =0 ; i < tr.length; i++) {
439 //print(JSON.stringify(ret,null,4));
442 this.el.set_value(ret.iter, 0, '' + tr[i].filename );
443 this.el.set_value(ret.iter, 1, '' + tr[i].added );
444 this.el.set_value(ret.iter, 2, '' + tr[i].removed );
451 xtype: Gtk.TreeViewColumn,
454 pack : "append_column",
457 XObject.prototype.init.call(this);
458 this.el.add_attribute(this.items[0].el , 'markup', 0 );
463 xtype: Gtk.CellRendererText,
469 xtype: Gtk.TreeViewColumn,
471 pack : "append_column",
474 XObject.prototype.init.call(this);
475 this.el.add_attribute(this.items[0].el , 'markup', 1 );
480 xtype: Gtk.CellRendererText,
486 xtype: Gtk.TreeViewColumn,
488 pack : "append_column",
491 XObject.prototype.init.call(this);
492 this.el.add_attribute(this.items[0].el , 'markup', 2 );
497 xtype: Gtk.CellRendererText,
509 xtype: Gtk.ListStore,
523 pack : "pack_start,false,false,0",
527 label : "Commit diff (no merge)"
531 label : "Commit diff (merge after)"
536 xtype: Gtk.ScrolledWindow,
537 pack : "pack_end,true,true,0",
539 XObject.prototype.init.call(this);
540 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
544 xtype: WebKit.WebView,
547 showDiff : function(files) {
551 var model = this.get('/historyTreeStore');
553 if (model.release === false) {
557 var diff = Merger.repo.diff(files, model.release, model.rev);
560 var s = "document.body.textContent='';var pre = document.createElement('pre'); document.body.appendChild(pre);";
561 s += "pre.textContent = " +
562 JSON.stringify(repo.lastCmd + "\n") + '+ ' +
563 JSON.stringify(diff) + ";";
566 this.el.execute_script(s);
585 pack : "add_action_widget,0"
591 pack : "add_action_widget,1"
596 XObject.cache['/Merger'] = Merger;