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);
87 repo.doMerge(_this.actionsel.selectedAction(),
88 _this.ticketsel.selectedTicketId(),
89 _this.name.el.get_text()
100 this.el.show.connect( (self) => {
107 // user defined functions
108 public void show ( RooTicket ticket )
110 // this.el.set_gravity(Gdk.Gravity.NORTH);
114 this.ticket = ticket;
116 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
117 GLib.debug("Loading tickets");
121 _this.dbmodel.loadTickets();
122 _this.actionmodel.loadActions();
125 public class Xcls_VBox2 : Object
128 private MergeBranch _this;
134 public Xcls_VBox2(MergeBranch _owner )
137 this.el = new Gtk.VBox( true, 0 );
141 // set gobject values
142 var child_0 = new Xcls_Table3( _this );
144 this.el.pack_start ( child_0.el , false,false,0 );
147 // user defined functions
149 public class Xcls_Table3 : Object
152 private MergeBranch _this;
158 public Xcls_Table3(MergeBranch _owner )
161 this.el = new Gtk.Table( 2, 2, false );
165 // set gobject values
167 this.el.column_spacing = 2;
168 var child_0 = new Xcls_Label4( _this );
170 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
171 var child_1 = new Xcls_actionsel( _this );
173 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
174 var child_2 = new Xcls_Label8( _this );
176 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
177 var child_3 = new Xcls_ticketsel( _this );
179 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
180 var child_4 = new Xcls_Label12( _this );
182 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
183 var child_5 = new Xcls_name( _this );
185 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
188 // user defined functions
190 public class Xcls_Label4 : Object
193 private MergeBranch _this;
199 public Xcls_Label4(MergeBranch _owner )
202 this.el = new Gtk.Label( "Do what?" );
206 // set gobject values
207 this.el.justify = Gtk.Justification.RIGHT;
208 this.el.xalign = 0.900000f;
209 this.el.visible = true;
212 // user defined functions
215 public class Xcls_actionsel : Object
217 public Gtk.ComboBox el;
218 private MergeBranch _this;
225 public Xcls_actionsel(MergeBranch _owner )
228 _this.actionsel = this;
229 this.el = new Gtk.ComboBox();
232 this.loading = false;
234 // set gobject values
235 var child_0 = new Xcls_actioncellrenderer( _this );
237 this.el.pack_start ( child_0.el , true );
238 var child_1 = new Xcls_actionmodel( _this );
240 this.el.set_model ( child_1.el );
244 this.el.add_attribute(_this.actioncellrenderer.el , "markup", 1 );
247 this.el.changed.connect( () => {
251 _this.name.updateText();
252 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
256 // user defined functions
257 public string selectedAction () {
261 this.el.get_active_iter (out iter);
262 _this.actionmodel.el.get_value (iter, 0, out val1);
264 return (string) val1;
267 public class Xcls_actioncellrenderer : Object
269 public Gtk.CellRendererText el;
270 private MergeBranch _this;
276 public Xcls_actioncellrenderer(MergeBranch _owner )
279 _this.actioncellrenderer = this;
280 this.el = new Gtk.CellRendererText();
284 // set gobject values
287 // user defined functions
290 public class Xcls_actionmodel : Object
292 public Gtk.ListStore el;
293 private MergeBranch _this;
299 public Xcls_actionmodel(MergeBranch _owner )
302 _this.actionmodel = this;
303 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
307 // set gobject values
310 // user defined functions
311 public void loadActions () {
315 _this.actionsel.loading = true;
324 el.set_value(iter, 0, "");
325 el.set_value(iter, 1, "-- select action --");
327 _this.actionsel.el.set_active_iter(iter);
330 el.set_value(iter, 0, "CLOSE");
331 el.set_value(iter, 1, "Merge changes to master - and CLOSE ticket");
335 el.set_value(iter, 0, "LEAVE");
336 el.set_value(iter, 1, "Merge changes to master - and LEAVE ticket open");
339 el.set_value(iter, 0, "MASTER");
340 el.set_value(iter, 1, "Merge changes FROM master into this branch");
343 el.set_value(iter, 0, "EXIT");
344 el.set_value(iter, 1, "Switch back to MASTER branch - no merge");
348 _this.actionsel.loading = false;
349 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
355 public class Xcls_Label8 : Object
358 private MergeBranch _this;
364 public Xcls_Label8(MergeBranch _owner )
367 this.el = new Gtk.Label( "Select Ticket" );
371 // set gobject values
372 this.el.justify = Gtk.Justification.RIGHT;
373 this.el.xalign = 0.900000f;
374 this.el.visible = true;
377 // user defined functions
380 public class Xcls_ticketsel : Object
382 public Gtk.ComboBox el;
383 private MergeBranch _this;
390 public Xcls_ticketsel(MergeBranch _owner )
393 _this.ticketsel = this;
394 this.el = new Gtk.ComboBox();
397 this.loading = false;
399 // set gobject values
400 var child_0 = new Xcls_dbcellrenderer( _this );
402 this.el.pack_start ( child_0.el , true );
403 var child_1 = new Xcls_dbmodel( _this );
405 this.el.set_model ( child_1.el );
409 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
412 this.el.changed.connect( () => {
418 _this.name.updateText();
419 //_this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
421 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
425 // user defined functions
426 public string selectedTicketId () {
431 this.el.get_active_iter (out iter);
432 _this.dbmodel.el.get_value (iter, 0, out val1);
435 return (string) val1;
442 public class Xcls_dbcellrenderer : Object
444 public Gtk.CellRendererText el;
445 private MergeBranch _this;
451 public Xcls_dbcellrenderer(MergeBranch _owner )
454 _this.dbcellrenderer = this;
455 this.el = new Gtk.CellRendererText();
459 // set gobject values
462 // user defined functions
465 public class Xcls_dbmodel : Object
467 public Gtk.ListStore el;
468 private MergeBranch _this;
474 public Xcls_dbmodel(MergeBranch _owner )
477 _this.dbmodel = this;
478 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
482 // set gobject values
485 // user defined functions
486 public void loadTickets () {
488 RooTicket.singleton().loadTickets();
490 _this.ticketsel.loading = true;
499 el.set_value(iter, 0, "");
500 el.set_value(iter, 1, "-- select a ticket --");
502 _this.ticketsel.el.set_active_iter(iter);
503 var tickets = RooTicket.singleton().tickets;
504 foreach(var ticket in tickets) {
508 el.set_value(iter, 0, ticket.id);
509 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
510 if (_this.ticket.id == ticket.id) {
511 _this.ticketsel.el.set_active_iter(iter);
516 _this.ticketsel.loading = false;
517 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
523 public class Xcls_Label12 : Object
526 private MergeBranch _this;
532 public Xcls_Label12(MergeBranch _owner )
535 this.el = new Gtk.Label( "Use this commit message" );
539 // set gobject values
540 this.el.justify = Gtk.Justification.RIGHT;
541 this.el.xalign = 0.900000f;
544 // user defined functions
547 public class Xcls_name : Object
550 private MergeBranch _this;
556 public Xcls_name(MergeBranch _owner )
560 this.el = new Gtk.Entry();
564 // set gobject values
565 this.el.visible = true;
568 // user defined functions
569 public void updateText () {
570 var ticket_id = _this.ticketsel.selectedTicketId();
572 RooTicket ticket = null
573 if (ticket_id.length > 0){
574 ticket = RooTicket.singleton().getById(ticket_id);
577 var name = RooTicket.singleton().usernameLocal();
578 var action = _this.actionsel.selectedAction();
579 this.el.set_editable(true);
581 case "CLOSE": // merge changes and close..
582 this.el.set_text("Fix #%s - %s".printf(ticket_id, ticket != null ? ticket.summary : ""));
584 case "LEAVE": // partial fix
585 this.el.set_text("Partial Fix #%s - %s".printf(ticket_id, ticket != null ? ticket.summary : ""));
587 case "MASTER": // merge master
588 case "EXIT": // just switch back...
589 this.el.set_editable(false);
590 this.el.set_text(""); // not relivant..
594 break; /// don't fix the text value.
602 public class Xcls_Button14 : Object
604 public Gtk.Button el;
605 private MergeBranch _this;
611 public Xcls_Button14(MergeBranch _owner )
614 this.el = new Gtk.Button();
618 // set gobject values
619 this.el.relief = Gtk.ReliefStyle.NONE;
620 this.el.label = "Cancel";
623 // user defined functions
626 public class Xcls_Button15 : Object
628 public Gtk.Button el;
629 private MergeBranch _this;
635 public Xcls_Button15(MergeBranch _owner )
638 this.el = new Gtk.Button();
642 // set gobject values
643 this.el.label = "Do Merge";
646 // user defined functions