1 static MergeBranch _MergeBranch;
3 public class MergeBranch : Object
6 private MergeBranch _this;
8 public static MergeBranch singleton()
10 if (_MergeBranch == null) {
11 _MergeBranch= new MergeBranch();
15 public Xcls_actionsel actionsel;
16 public Xcls_actioncellrenderer actioncellrenderer;
17 public Xcls_actionmodel actionmodel;
18 public Xcls_ticketsel ticketsel;
19 public Xcls_dbcellrenderer dbcellrenderer;
20 public Xcls_dbmodel dbmodel;
21 public Xcls_name name;
24 public RooTicket? ticket;
31 this.el = new Gtk.Dialog();
38 this.el.title = "Merge Branch";
39 this.el.default_height = 200;
40 this.el.default_width = 500;
41 this.el.deletable = true;
43 var child_0 = new Xcls_VBox2( _this );
45 this.el.get_content_area().add ( child_0.el );
46 var child_1 = new Xcls_Button14( _this );
48 this.el.add_action_widget ( child_1.el , 0 );
49 var child_2 = new Xcls_Button15( _this );
51 this.el.add_action_widget ( child_2.el , 1 );
54 this.el.delete_event.connect( (self, event) => {
59 this.el.response.connect( (self, response_id) => {
61 GLib.debug("got %d", (int) response_id);
62 if (response_id == 0) {
65 GitMonitor.gitmonitor.start();
69 // have they selected a ticket..
70 // make that the current active ticket?
71 // we really need to store locally what ticket is being worked on..
72 // in theory we could be working on multiple project and not merging..
73 // -- each repo would have their active ticket (only one per repo)
74 // -- so we could just store that in there
75 // -- initial load can check the contents of the ticket files on first scan.
76 var ticket_id = _this.ticketsel.selectedTicketId();
78 if (this.repo != null) {
79 var bn = _this.name.el.get_text();
80 if (ticket_id != "" ) {
81 this.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn);
83 this.repo.createBranchNamed(bn);
89 _this.actionsel.selectedAction(),
90 _this.ticketsel.selectedTicketId(),
91 _this.name.el.get_text()
98 GitMonitor.gitmonitor.start();
102 this.el.show.connect( (self) => {
109 // user defined functions
110 public void show ( RooTicket ticket )
112 // this.el.set_gravity(Gdk.Gravity.NORTH);
116 GitMonitor.gitmonitor.stop();
118 this.ticket = ticket;
120 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
121 GLib.debug("Loading tickets");
125 _this.dbmodel.loadTickets();
126 _this.actionmodel.loadActions();
130 public class Xcls_VBox2 : Object
133 private MergeBranch _this;
139 public Xcls_VBox2(MergeBranch _owner )
142 this.el = new Gtk.VBox( true, 0 );
146 // set gobject values
147 var child_0 = new Xcls_Table3( _this );
149 this.el.pack_start ( child_0.el , false,false,0 );
152 // user defined functions
154 public class Xcls_Table3 : Object
157 private MergeBranch _this;
163 public Xcls_Table3(MergeBranch _owner )
166 this.el = new Gtk.Table( 2, 2, false );
170 // set gobject values
172 this.el.column_spacing = 2;
173 var child_0 = new Xcls_Label4( _this );
175 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
176 var child_1 = new Xcls_actionsel( _this );
178 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
179 var child_2 = new Xcls_Label8( _this );
181 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
182 var child_3 = new Xcls_ticketsel( _this );
184 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
185 var child_4 = new Xcls_Label12( _this );
187 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
188 var child_5 = new Xcls_name( _this );
190 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
193 // user defined functions
195 public class Xcls_Label4 : Object
198 private MergeBranch _this;
204 public Xcls_Label4(MergeBranch _owner )
207 this.el = new Gtk.Label( "Do what?" );
211 // set gobject values
212 this.el.justify = Gtk.Justification.RIGHT;
213 this.el.xalign = 0.900000f;
214 this.el.visible = true;
217 // user defined functions
220 public class Xcls_actionsel : Object
222 public Gtk.ComboBox el;
223 private MergeBranch _this;
230 public Xcls_actionsel(MergeBranch _owner )
233 _this.actionsel = this;
234 this.el = new Gtk.ComboBox();
237 this.loading = false;
239 // set gobject values
240 var child_0 = new Xcls_actioncellrenderer( _this );
242 this.el.pack_start ( child_0.el , true );
243 var child_1 = new Xcls_actionmodel( _this );
245 this.el.set_model ( child_1.el );
249 this.el.add_attribute(_this.actioncellrenderer.el , "markup", 1 );
252 this.el.changed.connect( () => {
256 _this.name.updateText();
257 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
261 // user defined functions
262 public string selectedAction () {
266 this.el.get_active_iter (out iter);
267 _this.actionmodel.el.get_value (iter, 0, out val1);
269 return (string) val1;
272 public class Xcls_actioncellrenderer : Object
274 public Gtk.CellRendererText el;
275 private MergeBranch _this;
281 public Xcls_actioncellrenderer(MergeBranch _owner )
284 _this.actioncellrenderer = this;
285 this.el = new Gtk.CellRendererText();
289 // set gobject values
292 // user defined functions
295 public class Xcls_actionmodel : Object
297 public Gtk.ListStore el;
298 private MergeBranch _this;
304 public Xcls_actionmodel(MergeBranch _owner )
307 _this.actionmodel = this;
308 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
312 // set gobject values
315 // user defined functions
316 public void loadActions () {
320 _this.actionsel.loading = true;
329 el.set_value(iter, 0, "");
330 el.set_value(iter, 1, "-- select action --");
332 _this.actionsel.el.set_active_iter(iter);
335 el.set_value(iter, 0, "CLOSE");
336 el.set_value(iter, 1, "Merge changes to master - and CLOSE ticket");
340 el.set_value(iter, 0, "LEAVE");
341 el.set_value(iter, 1, "Merge changes to master - and LEAVE ticket open");
344 el.set_value(iter, 0, "MASTER");
345 el.set_value(iter, 1, "Merge changes FROM master into this branch");
348 el.set_value(iter, 0, "EXIT");
349 el.set_value(iter, 1, "Switch back to MASTER branch - no merge");
353 _this.actionsel.loading = false;
354 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
360 public class Xcls_Label8 : Object
363 private MergeBranch _this;
369 public Xcls_Label8(MergeBranch _owner )
372 this.el = new Gtk.Label( "Select Ticket" );
376 // set gobject values
377 this.el.justify = Gtk.Justification.RIGHT;
378 this.el.xalign = 0.900000f;
379 this.el.visible = true;
382 // user defined functions
385 public class Xcls_ticketsel : Object
387 public Gtk.ComboBox el;
388 private MergeBranch _this;
395 public Xcls_ticketsel(MergeBranch _owner )
398 _this.ticketsel = this;
399 this.el = new Gtk.ComboBox();
402 this.loading = false;
404 // set gobject values
405 var child_0 = new Xcls_dbcellrenderer( _this );
407 this.el.pack_start ( child_0.el , true );
408 var child_1 = new Xcls_dbmodel( _this );
410 this.el.set_model ( child_1.el );
414 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
417 this.el.changed.connect( () => {
423 _this.name.updateText();
424 //_this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
426 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
430 // user defined functions
431 public string selectedTicketId () {
436 this.el.get_active_iter (out iter);
437 _this.dbmodel.el.get_value (iter, 0, out val1);
440 return (string) val1;
447 public class Xcls_dbcellrenderer : Object
449 public Gtk.CellRendererText el;
450 private MergeBranch _this;
456 public Xcls_dbcellrenderer(MergeBranch _owner )
459 _this.dbcellrenderer = this;
460 this.el = new Gtk.CellRendererText();
464 // set gobject values
467 // user defined functions
470 public class Xcls_dbmodel : Object
472 public Gtk.ListStore el;
473 private MergeBranch _this;
479 public Xcls_dbmodel(MergeBranch _owner )
482 _this.dbmodel = this;
483 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
487 // set gobject values
490 // user defined functions
491 public void loadTickets () {
493 RooTicket.singleton().loadTickets();
495 _this.ticketsel.loading = true;
504 el.set_value(iter, 0, "");
505 el.set_value(iter, 1, "-- select a ticket --");
507 _this.ticketsel.el.set_active_iter(iter);
508 var tickets = RooTicket.singleton().tickets;
509 foreach(var ticket in tickets) {
513 el.set_value(iter, 0, ticket.id);
514 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
515 if (_this.ticket.id == ticket.id) {
516 _this.ticketsel.el.set_active_iter(iter);
521 _this.ticketsel.loading = false;
522 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
528 public class Xcls_Label12 : Object
531 private MergeBranch _this;
537 public Xcls_Label12(MergeBranch _owner )
540 this.el = new Gtk.Label( "Use this commit message" );
544 // set gobject values
545 this.el.justify = Gtk.Justification.RIGHT;
546 this.el.xalign = 0.900000f;
549 // user defined functions
552 public class Xcls_name : Object
555 private MergeBranch _this;
561 public Xcls_name(MergeBranch _owner )
565 this.el = new Gtk.Entry();
569 // set gobject values
570 this.el.visible = true;
573 // user defined functions
574 public void updateText () {
575 var ticket_id = _this.ticketsel.selectedTicketId();
577 RooTicket ticket = null;
578 if (ticket_id.length > 0){
579 ticket = RooTicket.singleton().getById(ticket_id);
582 var name = RooTicket.singleton().usernameLocal();
583 var action = _this.actionsel.selectedAction();
584 this.el.set_editable(true);
586 case "CLOSE": // merge changes and close..
587 this.el.set_text("Fix #%s - %s".printf(ticket_id, ticket != null ? ticket.summary : ""));
589 case "LEAVE": // partial fix
590 this.el.set_text("Partial Fix #%s - %s".printf(ticket_id, ticket != null ? ticket.summary : ""));
592 case "MASTER": // merge master
593 case "EXIT": // just switch back...
594 this.el.set_editable(false);
595 this.el.set_text(""); // not relivant..
599 break; /// don't fix the text value.
607 public class Xcls_Button14 : Object
609 public Gtk.Button el;
610 private MergeBranch _this;
616 public Xcls_Button14(MergeBranch _owner )
619 this.el = new Gtk.Button();
623 // set gobject values
624 this.el.relief = Gtk.ReliefStyle.NONE;
625 this.el.label = "Cancel";
628 // user defined functions
631 public class Xcls_Button15 : Object
633 public Gtk.Button el;
634 private MergeBranch _this;
640 public Xcls_Button15(MergeBranch _owner )
643 this.el = new Gtk.Button();
647 // set gobject values
648 this.el.label = "Do Merge";
651 // user defined functions