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_ticketsel ticketsel;
16 public Xcls_dbcellrenderer dbcellrenderer;
17 public Xcls_dbmodel dbmodel;
18 public Xcls_ticketsel ticketsel;
19 public Xcls_dbcellrenderer dbcellrenderer;
20 public Xcls_dbmodel dbmodel;
21 public Xcls_name name;
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 ( GitRepo repo )
104 // this.el.set_gravity(Gdk.Gravity.NORTH);
110 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
111 GLib.debug("Loading tickets");
115 _this.dbmodel.loadTickets();
118 public class Xcls_VBox2 : Object
121 private MergeBranch _this;
127 public Xcls_VBox2(MergeBranch _owner )
130 this.el = new Gtk.VBox( true, 0 );
134 // set gobject values
135 var child_0 = new Xcls_Table3( _this );
137 this.el.pack_start ( child_0.el , false,false,0 );
140 // user defined functions
142 public class Xcls_Table3 : Object
145 private MergeBranch _this;
151 public Xcls_Table3(MergeBranch _owner )
154 this.el = new Gtk.Table( 2, 2, false );
158 // set gobject values
160 this.el.column_spacing = 2;
161 var child_0 = new Xcls_Label4( _this );
163 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
164 var child_1 = new Xcls_ticketsel( _this );
166 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
167 var child_2 = new Xcls_Label8( _this );
169 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
170 var child_3 = new Xcls_ticketsel( _this );
172 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
173 var child_4 = new Xcls_Label12( _this );
175 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
176 var child_5 = new Xcls_name( _this );
178 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
181 // user defined functions
183 public class Xcls_Label4 : Object
186 private MergeBranch _this;
192 public Xcls_Label4(MergeBranch _owner )
195 this.el = new Gtk.Label( "Select Action" );
199 // set gobject values
200 this.el.justify = Gtk.Justification.RIGHT;
201 this.el.xalign = 0.900000f;
202 this.el.visible = true;
205 // user defined functions
208 public class Xcls_ticketsel : Object
210 public Gtk.ComboBox el;
211 private MergeBranch _this;
218 public Xcls_ticketsel(MergeBranch _owner )
221 _this.ticketsel = this;
222 this.el = new Gtk.ComboBox();
225 this.loading = false;
227 // set gobject values
228 var child_0 = new Xcls_dbcellrenderer( _this );
230 this.el.pack_start ( child_0.el , true );
231 var child_1 = new Xcls_dbmodel( _this );
233 this.el.set_model ( child_1.el );
237 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
240 this.el.changed.connect( () => {
244 var ticket_id = this.selectedTicketId();
246 var name = RooTicket.singleton().usernameLocal();
248 if (ticket_id == "" || ticket_id == null) {
250 var dt = new DateTime.now_local();
251 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
256 var ticket = RooTicket.singleton().getById(ticket_id);
258 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
260 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
264 // user defined functions
265 public string selectedTicketId () {
270 this.el.get_active_iter (out iter);
271 _this.dbmodel.el.get_value (iter, 0, out val1);
274 return (string) val1;
281 public class Xcls_dbcellrenderer : Object
283 public Gtk.CellRendererText el;
284 private MergeBranch _this;
290 public Xcls_dbcellrenderer(MergeBranch _owner )
293 _this.dbcellrenderer = this;
294 this.el = new Gtk.CellRendererText();
298 // set gobject values
301 // user defined functions
304 public class Xcls_dbmodel : Object
306 public Gtk.ListStore el;
307 private MergeBranch _this;
313 public Xcls_dbmodel(MergeBranch _owner )
316 _this.dbmodel = this;
317 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
321 // set gobject values
324 // user defined functions
325 public void loadTickets () {
327 RooTicket.singleton().loadTickets();
329 _this.ticketsel.loading = true;
338 el.set_value(iter, 0, "");
339 el.set_value(iter, 1, "-- select a ticket --");
341 _this.ticketsel.el.set_active_iter(iter);
342 var tickets = RooTicket.singleton().tickets;
343 foreach(var ticket in tickets) {
347 el.set_value(iter, 0, ticket.id);
348 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
350 //if (data.get(i) == cur) {
351 // _this.build_module.el.set_active_iter(iter);
356 _this.ticketsel.loading = false;
357 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
363 public class Xcls_Label8 : Object
366 private MergeBranch _this;
372 public Xcls_Label8(MergeBranch _owner )
375 this.el = new Gtk.Label( "Select Ticket" );
379 // set gobject values
380 this.el.justify = Gtk.Justification.RIGHT;
381 this.el.xalign = 0.900000f;
382 this.el.visible = true;
385 // user defined functions
388 public class Xcls_ticketsel : Object
390 public Gtk.ComboBox el;
391 private MergeBranch _this;
398 public Xcls_ticketsel(MergeBranch _owner )
401 _this.ticketsel = this;
402 this.el = new Gtk.ComboBox();
405 this.loading = false;
407 // set gobject values
408 var child_0 = new Xcls_dbcellrenderer( _this );
410 this.el.pack_start ( child_0.el , true );
411 var child_1 = new Xcls_dbmodel( _this );
413 this.el.set_model ( child_1.el );
417 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
420 this.el.changed.connect( () => {
424 var ticket_id = this.selectedTicketId();
426 var name = RooTicket.singleton().usernameLocal();
428 if (ticket_id == "" || ticket_id == null) {
430 var dt = new DateTime.now_local();
431 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
436 var ticket = RooTicket.singleton().getById(ticket_id);
438 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
440 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
444 // user defined functions
445 public string selectedTicketId () {
450 this.el.get_active_iter (out iter);
451 _this.dbmodel.el.get_value (iter, 0, out val1);
454 return (string) val1;
461 public class Xcls_dbcellrenderer : Object
463 public Gtk.CellRendererText el;
464 private MergeBranch _this;
470 public Xcls_dbcellrenderer(MergeBranch _owner )
473 _this.dbcellrenderer = this;
474 this.el = new Gtk.CellRendererText();
478 // set gobject values
481 // user defined functions
484 public class Xcls_dbmodel : Object
486 public Gtk.ListStore el;
487 private MergeBranch _this;
493 public Xcls_dbmodel(MergeBranch _owner )
496 _this.dbmodel = this;
497 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
501 // set gobject values
504 // user defined functions
505 public void loadTickets () {
507 RooTicket.singleton().loadTickets();
509 _this.ticketsel.loading = true;
518 el.set_value(iter, 0, "");
519 el.set_value(iter, 1, "-- select a ticket --");
521 _this.ticketsel.el.set_active_iter(iter);
522 var tickets = RooTicket.singleton().tickets;
523 foreach(var ticket in tickets) {
527 el.set_value(iter, 0, ticket.id);
528 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
530 //if (data.get(i) == cur) {
531 // _this.build_module.el.set_active_iter(iter);
536 _this.ticketsel.loading = false;
537 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
543 public class Xcls_Label12 : Object
546 private MergeBranch _this;
552 public Xcls_Label12(MergeBranch _owner )
555 this.el = new Gtk.Label( "or use this as branch name" );
559 // set gobject values
560 this.el.justify = Gtk.Justification.RIGHT;
561 this.el.xalign = 0.900000f;
564 // user defined functions
567 public class Xcls_name : Object
570 private MergeBranch _this;
576 public Xcls_name(MergeBranch _owner )
580 this.el = new Gtk.Entry();
584 // set gobject values
585 this.el.visible = true;
588 // user defined functions
593 public class Xcls_Button14 : Object
595 public Gtk.Button el;
596 private MergeBranch _this;
602 public Xcls_Button14(MergeBranch _owner )
605 this.el = new Gtk.Button();
609 // set gobject values
610 this.el.relief = Gtk.ReliefStyle.NONE;
611 this.el.label = "Do not create Branch";
614 // user defined functions
617 public class Xcls_Button15 : Object
619 public Gtk.Button el;
620 private MergeBranch _this;
626 public Xcls_Button15(MergeBranch _owner )
629 this.el = new Gtk.Button();
633 // set gobject values
634 this.el.label = "Create Branch";
637 // user defined functions