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);
94 this.el.show.connect( (self) => {
101 // user defined functions
102 public void show ( RooTicket ticket )
104 // this.el.set_gravity(Gdk.Gravity.NORTH);
108 this.ticket = ticket;
110 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
111 GLib.debug("Loading tickets");
115 _this.dbmodel.loadTickets();
116 _this.actionmodel.loadActions();
119 public class Xcls_VBox2 : Object
122 private MergeBranch _this;
128 public Xcls_VBox2(MergeBranch _owner )
131 this.el = new Gtk.VBox( true, 0 );
135 // set gobject values
136 var child_0 = new Xcls_Table3( _this );
138 this.el.pack_start ( child_0.el , false,false,0 );
141 // user defined functions
143 public class Xcls_Table3 : Object
146 private MergeBranch _this;
152 public Xcls_Table3(MergeBranch _owner )
155 this.el = new Gtk.Table( 2, 2, false );
159 // set gobject values
161 this.el.column_spacing = 2;
162 var child_0 = new Xcls_Label4( _this );
164 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
165 var child_1 = new Xcls_actionsel( _this );
167 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
168 var child_2 = new Xcls_Label8( _this );
170 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
171 var child_3 = new Xcls_ticketsel( _this );
173 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
174 var child_4 = new Xcls_Label12( _this );
176 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
177 var child_5 = new Xcls_name( _this );
179 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
182 // user defined functions
184 public class Xcls_Label4 : Object
187 private MergeBranch _this;
193 public Xcls_Label4(MergeBranch _owner )
196 this.el = new Gtk.Label( "Do what?" );
200 // set gobject values
201 this.el.justify = Gtk.Justification.RIGHT;
202 this.el.xalign = 0.900000f;
203 this.el.visible = true;
206 // user defined functions
209 public class Xcls_actionsel : Object
211 public Gtk.ComboBox el;
212 private MergeBranch _this;
219 public Xcls_actionsel(MergeBranch _owner )
222 _this.actionsel = this;
223 this.el = new Gtk.ComboBox();
226 this.loading = false;
228 // set gobject values
229 var child_0 = new Xcls_actioncellrenderer( _this );
231 this.el.pack_start ( child_0.el , true );
232 var child_1 = new Xcls_actionmodel( _this );
234 this.el.set_model ( child_1.el );
238 this.el.add_attribute(_this.actioncellrenderer.el , "markup", 1 );
241 this.el.changed.connect( () => {
245 var ticket_id = this.selectedTicketId();
247 var name = RooTicket.singleton().usernameLocal();
249 if (ticket_id == "" || ticket_id == null) {
251 var dt = new DateTime.now_local();
252 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
257 var ticket = RooTicket.singleton().getById(ticket_id);
259 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
261 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
265 // user defined functions
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.action.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( () => {
416 var ticket_id = this.selectedTicketId();
418 var name = RooTicket.singleton().usernameLocal();
420 if (ticket_id == "" || ticket_id == null) {
422 var dt = new DateTime.now_local();
423 // _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
427 _this.ticket = RooTicket.singleton().getById(ticket_id);
428 _this.name.updateText();
429 //_this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
431 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
435 // user defined functions
436 public string selectedTicketId () {
441 this.el.get_active_iter (out iter);
442 _this.dbmodel.el.get_value (iter, 0, out val1);
445 return (string) val1;
452 public class Xcls_dbcellrenderer : Object
454 public Gtk.CellRendererText el;
455 private MergeBranch _this;
461 public Xcls_dbcellrenderer(MergeBranch _owner )
464 _this.dbcellrenderer = this;
465 this.el = new Gtk.CellRendererText();
469 // set gobject values
472 // user defined functions
475 public class Xcls_dbmodel : Object
477 public Gtk.ListStore el;
478 private MergeBranch _this;
484 public Xcls_dbmodel(MergeBranch _owner )
487 _this.dbmodel = this;
488 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
492 // set gobject values
495 // user defined functions
496 public void loadTickets () {
498 RooTicket.singleton().loadTickets();
500 _this.ticketsel.loading = true;
509 el.set_value(iter, 0, "");
510 el.set_value(iter, 1, "-- select a ticket --");
512 _this.ticketsel.el.set_active_iter(iter);
513 var tickets = RooTicket.singleton().tickets;
514 foreach(var ticket in tickets) {
518 el.set_value(iter, 0, ticket.id);
519 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
520 if (_this.ticket.id == ticket.id) {
521 _this.ticketsel.el.set_active_iter(iter);
526 _this.ticketsel.loading = false;
527 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
533 public class Xcls_Label12 : Object
536 private MergeBranch _this;
542 public Xcls_Label12(MergeBranch _owner )
545 this.el = new Gtk.Label( "Use this commit message" );
549 // set gobject values
550 this.el.justify = Gtk.Justification.RIGHT;
551 this.el.xalign = 0.900000f;
554 // user defined functions
557 public class Xcls_name : Object
560 private MergeBranch _this;
566 public Xcls_name(MergeBranch _owner )
570 this.el = new Gtk.Entry();
574 // set gobject values
575 this.el.visible = true;
578 // user defined functions
583 public class Xcls_Button14 : Object
585 public Gtk.Button el;
586 private MergeBranch _this;
592 public Xcls_Button14(MergeBranch _owner )
595 this.el = new Gtk.Button();
599 // set gobject values
600 this.el.relief = Gtk.ReliefStyle.NONE;
601 this.el.label = "Cancel";
604 // user defined functions
607 public class Xcls_Button15 : Object
609 public Gtk.Button el;
610 private MergeBranch _this;
616 public Xcls_Button15(MergeBranch _owner )
619 this.el = new Gtk.Button();
623 // set gobject values
624 this.el.label = "Do Merge";
627 // user defined functions