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();
128 for(var i =0 ; i < tr.length; i++) {
130 this.model.el.append(ret);
131 //print(JSON.stringify(ret,null,4));
132 if (tr[i].name == 'master') {
135 if (tr[i].name == 'working') {
138 this.model.el.set_value(ret.iter, 0, '' + tr[i].name );
139 this.model.el.set_value(ret.iter, 1, '' + tr[i].rev );
143 if (master !== false) {
144 this.el.set_active(master);
146 if (working !== false) {
147 this.el.set_active(working);
152 xtype: Gtk.ListStore,
154 XObject.prototype.init.call(this);
155 this.el.set_column_types ( 3, [
156 GObject.TYPE_STRING, // file
157 GObject.TYPE_STRING, // added
158 GObject.TYPE_STRING, // removed
165 label : "Release Branch"
171 this.el = new Gtk.ComboBox.with_entry();
174 this.model = new XObject(this.model);
176 this.el.set_model(this.model.el);
177 this.el.set_entry_text_column (0);
178 XObject.prototype.init.call(this);
183 //this.insert(citer,iter,0);
184 this.model.el.clear();
189 for(var i =0 ; i < tr.length; i++) {
191 this.model.el.append(ret);
192 //print(JSON.stringify(ret,null,4));
193 if (tr[i].name == 'master') {
196 if (tr[i].name == 'release') {
199 this.model.el.set_value(ret.iter, 0, '' + tr[i].name );
200 this.model.el.set_value(ret.iter, 1, '' + tr[i].rev );
204 if (master !== false) {
205 this.el.set_active(master);
207 if (release !== false) {
208 this.el.set_active(release);
213 xtype: Gtk.ListStore,
215 XObject.prototype.init.call(this);
216 this.el.set_column_types ( 3, [
217 GObject.TYPE_STRING, // file
218 GObject.TYPE_STRING, // added
219 GObject.TYPE_STRING, // removed
228 pack : "pack_end,true,true,0",
237 xtype: Gtk.ScrolledWindow,
239 XObject.prototype.init.call(this);
240 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
246 cursor_changed : function (self) {
248 if (this.el.get_selection().count_selected_rows() < 1) {
252 var model = this.get('/historyTreeStore');
254 var s = this.el.get_selection();
257 var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
258 print("OUT?" + value);// id..
259 // load the list in the right grid..
260 var Repo = imports.Scm.Git.Repo.Repo;
264 var files = Merger.repo.changedFiles('/', 'rev', 'github..' + value);
265 this.get('/changedFilesStore').load(files);
272 XObject.prototype.init.call(this);
273 var description = new Pango.FontDescription.c_new();
274 description.set_size(8000);
275 this.el.modify_font(description);
277 this.selection = this.el.get_selection();
278 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
282 781 // is this really needed??
283 782 this.selection.signal['changed'].connect(function() {
284 783 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
285 784 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
293 xtype: Gtk.TreeStore,
294 id : "historyTreeStore",
297 XObject.prototype.init.call(this);
298 this.el.set_column_types ( 3, [
299 GObject.TYPE_STRING, // title
300 GObject.TYPE_STRING, // rev
303 load : function(tr,iter)
305 //this.insert(citer,iter,0);
310 for(var i =0 ; i < tr.length; i++) {
313 this.el.insert(ret ,iter,-1);
317 //print(JSON.stringify(ret,null,4));
320 this.el.set_value(ret.iter, 0, '' + tr[i].text );
321 this.el.set_value(ret.iter, 1, '' + tr[i].rev );
323 if (tr[i].children && tr[i].children.length) {
324 this.load(tr[i].children, ret.iter);
330 xtype: Gtk.TreeViewColumn,
331 pack : "append_column",
333 XObject.prototype.init.call(this);
334 this.el.add_attribute(this.items[0].el , 'markup', 0 );
339 xtype: Gtk.CellRendererText,
349 xtype: Gtk.ScrolledWindow,
351 XObject.prototype.init.call(this);
352 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
358 cursor_changed : function (self) {
359 // SEE SELECTION.CHANGED
360 if (this.el.get_selection().count_selected_rows() < 1) {
361 //nothing? - clea it?
365 var model = this.get('/changedFilesStore');
367 var s = this.el.get_selection();
369 s.selected_foreach(function(model,p,iter) {
371 files.push( model.get_value(iter, 0).value.get_string());
374 this.get('/patchview').showDiff(files);
375 //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
376 //print("OUT?" + value);// id..
377 // load the list in the right grid..
383 id : "changedFilesView",
386 XObject.prototype.init.call(this);
387 var description = new Pango.FontDescription.c_new();
388 description.set_size(8000);
389 this.el.modify_font(description);
391 this.selection = this.el.get_selection();
392 this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);
394 this.selection.signal['changed'].connect(function() {
395 _this.listeners.cursor_changed.apply(
402 xtype: Gtk.ListStore,
403 id : "changedFilesStore",
406 XObject.prototype.init.call(this);
407 this.el.set_column_types ( 3, [
408 GObject.TYPE_STRING, // file
409 GObject.TYPE_STRING, // added
410 GObject.TYPE_STRING, // removed
415 //this.insert(citer,iter,0);
417 for(var i =0 ; i < tr.length; i++) {
422 //print(JSON.stringify(ret,null,4));
425 this.el.set_value(ret.iter, 0, '' + tr[i].filename );
426 this.el.set_value(ret.iter, 1, '' + tr[i].added );
427 this.el.set_value(ret.iter, 2, '' + tr[i].removed );
434 xtype: Gtk.TreeViewColumn,
437 pack : "append_column",
440 XObject.prototype.init.call(this);
441 this.el.add_attribute(this.items[0].el , 'markup', 0 );
446 xtype: Gtk.CellRendererText,
452 xtype: Gtk.TreeViewColumn,
454 pack : "append_column",
457 XObject.prototype.init.call(this);
458 this.el.add_attribute(this.items[0].el , 'markup', 1 );
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', 2 );
480 xtype: Gtk.CellRendererText,
492 xtype: Gtk.ListStore,
506 pack : "pack_start,false,false,0",
510 label : "Commit diff (no merge)"
514 label : "Commit diff (merge after)"
519 xtype: Gtk.ScrolledWindow,
520 pack : "pack_end,true,true,0",
522 XObject.prototype.init.call(this);
523 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
527 xtype: WebKit.WebView,
530 showDiff : function(files) {
533 var diff = Merger.repo.diff(files, 'github', 'master');
536 var s = "document.body.textContent='';var pre = document.createElement('pre'); document.body.appendChild(pre);";
537 s += "pre.textContent = " +
538 JSON.stringify(repo.lastCmd + "\n") + '+ ' +
539 JSON.stringify(diff) + ";";
542 this.el.execute_script(s);
561 pack : "add_action_widget,0"
567 pack : "add_action_widget,1"
572 XObject.cache['/Merger'] = Merger;