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) {
68 // have they selected a ticket..
69 // make that the current active ticket?
70 // we really need to store locally what ticket is being worked on..
71 // in theory we could be working on multiple project and not merging..
72 // -- each repo would have their active ticket (only one per repo)
73 // -- so we could just store that in there
74 // -- initial load can check the contents of the ticket files on first scan.
75 var ticket_id = _this.ticketsel.selectedTicketId();
77 if (this.repo != null) {
78 var bn = _this.name.el.get_text();
79 if (ticket_id != "" ) {
80 this.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn);
82 this.repo.createBranchNamed(bn);
88 _this.actionsel.selectedAction(),
89 _this.ticketsel.selectedTicketId(),
90 _this.name.el.get_text()
101 this.el.show.connect( (self) => {
108 // user defined functions
109 public void show ( RooTicket ticket )
111 // this.el.set_gravity(Gdk.Gravity.NORTH);
115 this.ticket = ticket;
117 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
118 GLib.debug("Loading tickets");
122 _this.dbmodel.loadTickets();
123 _this.actionmodel.loadActions();
126 public class Xcls_VBox2 : Object
129 private MergeBranch _this;
135 public Xcls_VBox2(MergeBranch _owner )
138 this.el = new Gtk.VBox( true, 0 );
142 // set gobject values
143 var child_0 = new Xcls_Table3( _this );
145 this.el.pack_start ( child_0.el , false,false,0 );
148 // user defined functions
150 public class Xcls_Table3 : Object
153 private MergeBranch _this;
159 public Xcls_Table3(MergeBranch _owner )
162 this.el = new Gtk.Table( 2, 2, false );
166 // set gobject values
168 this.el.column_spacing = 2;
169 var child_0 = new Xcls_Label4( _this );
171 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
172 var child_1 = new Xcls_actionsel( _this );
174 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
175 var child_2 = new Xcls_Label8( _this );
177 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
178 var child_3 = new Xcls_ticketsel( _this );
180 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
181 var child_4 = new Xcls_Label12( _this );
183 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
184 var child_5 = new Xcls_name( _this );
186 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
189 // user defined functions
191 public class Xcls_Label4 : Object
194 private MergeBranch _this;
200 public Xcls_Label4(MergeBranch _owner )
203 this.el = new Gtk.Label( "Do what?" );
207 // set gobject values
208 this.el.justify = Gtk.Justification.RIGHT;
209 this.el.xalign = 0.900000f;
210 this.el.visible = true;
213 // user defined functions
216 public class Xcls_actionsel : Object
218 public Gtk.ComboBox el;
219 private MergeBranch _this;
226 public Xcls_actionsel(MergeBranch _owner )
229 _this.actionsel = this;
230 this.el = new Gtk.ComboBox();
233 this.loading = false;
235 // set gobject values
236 var child_0 = new Xcls_actioncellrenderer( _this );
238 this.el.pack_start ( child_0.el , true );
239 var child_1 = new Xcls_actionmodel( _this );
241 this.el.set_model ( child_1.el );
245 this.el.add_attribute(_this.actioncellrenderer.el , "markup", 1 );
248 this.el.changed.connect( () => {
252 _this.name.updateText();
253 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
257 // user defined functions
258 public string selectedAction () {
262 this.el.get_active_iter (out iter);
263 _this.actionmodel.el.get_value (iter, 0, out val1);
265 return (string) val1;
268 public class Xcls_actioncellrenderer : Object
270 public Gtk.CellRendererText el;
271 private MergeBranch _this;
277 public Xcls_actioncellrenderer(MergeBranch _owner )
280 _this.actioncellrenderer = this;
281 this.el = new Gtk.CellRendererText();
285 // set gobject values
288 // user defined functions
291 public class Xcls_actionmodel : Object
293 public Gtk.ListStore el;
294 private MergeBranch _this;
300 public Xcls_actionmodel(MergeBranch _owner )
303 _this.actionmodel = this;
304 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
308 // set gobject values
311 // user defined functions
312 public void loadActions () {
316 _this.actionsel.loading = true;
325 el.set_value(iter, 0, "");
326 el.set_value(iter, 1, "-- select action --");
328 _this.actionsel.el.set_active_iter(iter);
331 el.set_value(iter, 0, "CLOSE");
332 el.set_value(iter, 1, "Merge changes to master - and CLOSE ticket");
336 el.set_value(iter, 0, "LEAVE");
337 el.set_value(iter, 1, "Merge changes to master - and LEAVE ticket open");
340 el.set_value(iter, 0, "MASTER");
341 el.set_value(iter, 1, "Merge changes FROM master into this branch");
344 el.set_value(iter, 0, "EXIT");
345 el.set_value(iter, 1, "Switch back to MASTER branch - no merge");
349 _this.actionsel.loading = false;
350 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
356 public class Xcls_Label8 : Object
359 private MergeBranch _this;
365 public Xcls_Label8(MergeBranch _owner )
368 this.el = new Gtk.Label( "Select Ticket" );
372 // set gobject values
373 this.el.justify = Gtk.Justification.RIGHT;
374 this.el.xalign = 0.900000f;
375 this.el.visible = true;
378 // user defined functions
381 public class Xcls_ticketsel : Object
383 public Gtk.ComboBox el;
384 private MergeBranch _this;
391 public Xcls_ticketsel(MergeBranch _owner )
394 _this.ticketsel = this;
395 this.el = new Gtk.ComboBox();
398 this.loading = false;
400 // set gobject values
401 var child_0 = new Xcls_dbcellrenderer( _this );
403 this.el.pack_start ( child_0.el , true );
404 var child_1 = new Xcls_dbmodel( _this );
406 this.el.set_model ( child_1.el );
410 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
413 this.el.changed.connect( () => {
419 _this.name.updateText();
420 //_this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
422 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
426 // user defined functions
427 public string selectedTicketId () {
432 this.el.get_active_iter (out iter);
433 _this.dbmodel.el.get_value (iter, 0, out val1);
436 return (string) val1;
443 public class Xcls_dbcellrenderer : Object
445 public Gtk.CellRendererText el;
446 private MergeBranch _this;
452 public Xcls_dbcellrenderer(MergeBranch _owner )
455 _this.dbcellrenderer = this;
456 this.el = new Gtk.CellRendererText();
460 // set gobject values
463 // user defined functions
466 public class Xcls_dbmodel : Object
468 public Gtk.ListStore el;
469 private MergeBranch _this;
475 public Xcls_dbmodel(MergeBranch _owner )
478 _this.dbmodel = this;
479 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
483 // set gobject values
486 // user defined functions
487 public void loadTickets () {
489 RooTicket.singleton().loadTickets();
491 _this.ticketsel.loading = true;
500 el.set_value(iter, 0, "");
501 el.set_value(iter, 1, "-- select a ticket --");
503 _this.ticketsel.el.set_active_iter(iter);
504 var tickets = RooTicket.singleton().tickets;
505 foreach(var ticket in tickets) {
509 el.set_value(iter, 0, ticket.id);
510 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
511 if (_this.ticket.id == ticket.id) {
512 _this.ticketsel.el.set_active_iter(iter);
517 _this.ticketsel.loading = false;
518 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
524 public class Xcls_Label12 : Object
527 private MergeBranch _this;
533 public Xcls_Label12(MergeBranch _owner )
536 this.el = new Gtk.Label( "Use this commit message" );
540 // set gobject values
541 this.el.justify = Gtk.Justification.RIGHT;
542 this.el.xalign = 0.900000f;
545 // user defined functions
548 public class Xcls_name : Object
551 private MergeBranch _this;
557 public Xcls_name(MergeBranch _owner )
561 this.el = new Gtk.Entry();
565 // set gobject values
566 this.el.visible = true;
569 // user defined functions
570 public void updateText () {
571 var ticket_id = _this.ticketsel.selectedTicketId();
573 RooTicket ticket = null;
574 if (ticket_id.length > 0){
575 ticket = RooTicket.singleton().getById(ticket_id);
578 var name = RooTicket.singleton().usernameLocal();
579 var action = _this.actionsel.selectedAction();
580 this.el.set_editable(true);
582 case "CLOSE": // merge changes and close..
583 this.el.set_text("Fix #%s - %s".printf(ticket_id, ticket != null ? ticket.summary : ""));
585 case "LEAVE": // partial fix
586 this.el.set_text("Partial Fix #%s - %s".printf(ticket_id, ticket != null ? ticket.summary : ""));
588 case "MASTER": // merge master
589 case "EXIT": // just switch back...
590 this.el.set_editable(false);
591 this.el.set_text(""); // not relivant..
595 break; /// don't fix the text value.
603 public class Xcls_Button14 : Object
605 public Gtk.Button el;
606 private MergeBranch _this;
612 public Xcls_Button14(MergeBranch _owner )
615 this.el = new Gtk.Button();
619 // set gobject values
620 this.el.relief = Gtk.ReliefStyle.NONE;
621 this.el.label = "Cancel";
624 // user defined functions
627 public class Xcls_Button15 : Object
629 public Gtk.Button el;
630 private MergeBranch _this;
636 public Xcls_Button15(MergeBranch _owner )
639 this.el = new Gtk.Button();
643 // set gobject values
644 this.el.label = "Do Merge";
647 // user defined functions