1 static NewBranch _NewBranch;
3 public class NewBranch : Object
6 private NewBranch _this;
8 public static NewBranch singleton()
10 if (_NewBranch == null) {
11 _NewBranch= new NewBranch();
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;
26 public Gee.ArrayList<GitMonitorQueue> queue;
32 this.el = new Gtk.Dialog();
40 this.el.title = "Create a working branch ";
41 this.el.default_height = 200;
42 this.el.default_width = 500;
43 this.el.deletable = true;
45 var child_0 = new Xcls_VBox2( _this );
47 this.el.get_content_area().add ( child_0.el );
48 var child_1 = new Xcls_Button16( _this );
50 this.el.add_action_widget ( child_1.el , 0 );
51 var child_2 = new Xcls_Button17( _this );
53 this.el.add_action_widget ( child_2.el , 1 );
56 this.el.delete_event.connect( (self, event) => {
61 this.el.response.connect( (self, response_id) => {
63 GLib.debug("got %d", (int) response_id);
64 if (response_id == 0) {
70 // have they selected a ticket..
71 // make that the current active ticket?
72 // we really need to store locally what ticket is being worked on..
73 // in theory we could be working on multiple project and not merging..
74 // -- each repo would have their active ticket (only one per repo)
75 // -- so we could just store that in there
76 // -- initial load can check the contents of the ticket files on first scan.
77 var ticket_id = _this.ticketsel.selectedTicketId();
79 if (this.repo != null) {
80 var bn = _this.name.el.get_text();
82 var res = this.repo.setActiveTicket(
83 RooTicket.singleton().getById(ticket_id != "" ? ticket_id : "-1"), bn
86 // start the monitoring..
87 GitMonitor.gitmonitor.start();
101 this.el.show.connect( (self) => {
108 // user defined functions
109 public void show ( GitRepo repo, Gee.ArrayList<GitMonitorQueue> queue )
111 // this.el.set_gravity(Gdk.Gravity.NORTH);
112 if (this.running) { // should not happen!!
113 GLib.error("new branch show called, when already being displayed?");
118 GitMonitor.gitmonitor.stop();
122 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
123 GLib.debug("Loading tickets");
127 this.el.set_keep_above(true);
128 _this.dbmodel.loadTickets();
132 public class Xcls_VBox2 : Object
135 private NewBranch _this;
141 public Xcls_VBox2(NewBranch _owner )
144 this.el = new Gtk.VBox( true, 0 );
148 // set gobject values
149 var child_0 = new Xcls_Table3( _this );
151 this.el.pack_start ( child_0.el , false,false,0 );
154 // user defined functions
156 public class Xcls_Table3 : Object
159 private NewBranch _this;
165 public Xcls_Table3(NewBranch _owner )
168 this.el = new Gtk.Table( 5, 6, true );
172 // set gobject values
173 this.el.expand = true;
175 this.el.column_spacing = 4;
176 this.el.vexpand = false;
177 var child_0 = new Xcls_Label4( _this );
179 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
180 var child_1 = new Xcls_Label5( _this );
182 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
183 var child_2 = new Xcls_ticketsel( _this );
185 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
186 var child_3 = new Xcls_ticketsel( _this );
188 this.el.attach_defaults ( child_3.el , 1,4,1,2 );
189 var child_4 = new Xcls_Button12( _this );
191 this.el.attach_defaults ( child_4.el , 4,5,1,2 );
192 var child_5 = new Xcls_Label13( _this );
194 this.el.attach_defaults ( child_5.el , 0,1,2,3 );
195 var child_6 = new Xcls_name( _this );
197 this.el.attach_defaults ( child_6.el , 0,4,3,4 );
198 var child_7 = new Xcls_Button15( _this );
200 this.el.add_action_widget ( child_7.el , 1 );
203 // user defined functions
205 public class Xcls_Label4 : Object
208 private NewBranch _this;
214 public Xcls_Label4(NewBranch _owner )
217 this.el = new Gtk.Label( "Project" );
221 // set gobject values
222 this.el.halign = Gtk.Align.START;
223 this.el.justify = Gtk.Justification.RIGHT;
224 this.el.visible = true;
227 // user defined functions
230 public class Xcls_Label5 : Object
233 private NewBranch _this;
239 public Xcls_Label5(NewBranch _owner )
242 this.el = new Gtk.Label( "Ticket" );
246 // set gobject values
247 this.el.halign = Gtk.Align.START;
248 this.el.visible = true;
251 // user defined functions
254 public class Xcls_ticketsel : Object
256 public Gtk.ComboBox el;
257 private NewBranch _this;
264 public Xcls_ticketsel(NewBranch _owner )
267 _this.ticketsel = this;
268 this.el = new Gtk.ComboBox();
271 this.loading = false;
273 // set gobject values
274 var child_0 = new Xcls_dbcellrenderer( _this );
276 this.el.pack_start ( child_0.el , true );
277 var child_1 = new Xcls_dbmodel( _this );
279 this.el.set_model ( child_1.el );
283 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
286 this.el.changed.connect( () => {
290 var ticket_id = this.selectedTicketId();
292 var name = RooTicket.singleton().usernameLocal();
294 if (ticket_id == "" || ticket_id == null) {
296 var dt = new DateTime.now_local();
297 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
302 var ticket = RooTicket.singleton().getById(ticket_id);
304 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
306 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
310 // user defined functions
311 public string selectedTicketId () {
316 this.el.get_active_iter (out iter);
317 _this.dbmodel.el.get_value (iter, 0, out val1);
320 return (string) val1;
327 public class Xcls_dbcellrenderer : Object
329 public Gtk.CellRendererText el;
330 private NewBranch _this;
336 public Xcls_dbcellrenderer(NewBranch _owner )
339 _this.dbcellrenderer = this;
340 this.el = new Gtk.CellRendererText();
344 // set gobject values
347 // user defined functions
350 public class Xcls_dbmodel : Object
352 public Gtk.ListStore el;
353 private NewBranch _this;
359 public Xcls_dbmodel(NewBranch _owner )
362 _this.dbmodel = this;
363 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
367 // set gobject values
370 // user defined functions
371 public void loadTickets () {
373 RooTicket.singleton().loadTickets();
375 _this.ticketsel.loading = true;
384 el.set_value(iter, 0, "");
385 el.set_value(iter, 1, "-- select a ticket --");
387 _this.ticketsel.el.set_active_iter(iter);
388 var tickets = RooTicket.singleton().tickets;
389 foreach(var ticket in tickets) {
393 el.set_value(iter, 0, ticket.id);
394 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
396 //if (data.get(i) == cur) {
397 // _this.build_module.el.set_active_iter(iter);
402 _this.ticketsel.loading = false;
403 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
409 public class Xcls_ticketsel : Object
411 public Gtk.ComboBox el;
412 private NewBranch _this;
419 public Xcls_ticketsel(NewBranch _owner )
422 _this.ticketsel = this;
423 this.el = new Gtk.ComboBox();
426 this.loading = false;
428 // set gobject values
429 var child_0 = new Xcls_dbcellrenderer( _this );
431 this.el.pack_start ( child_0.el , true );
432 var child_1 = new Xcls_dbmodel( _this );
434 this.el.set_model ( child_1.el );
438 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
441 this.el.changed.connect( () => {
445 var ticket_id = this.selectedTicketId();
447 var name = RooTicket.singleton().usernameLocal();
449 if (ticket_id == "" || ticket_id == null) {
451 var dt = new DateTime.now_local();
452 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
457 var ticket = RooTicket.singleton().getById(ticket_id);
459 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
461 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
465 // user defined functions
466 public string selectedTicketId () {
471 this.el.get_active_iter (out iter);
472 _this.dbmodel.el.get_value (iter, 0, out val1);
475 return (string) val1;
482 public class Xcls_dbcellrenderer : Object
484 public Gtk.CellRendererText el;
485 private NewBranch _this;
491 public Xcls_dbcellrenderer(NewBranch _owner )
494 _this.dbcellrenderer = this;
495 this.el = new Gtk.CellRendererText();
499 // set gobject values
502 // user defined functions
505 public class Xcls_dbmodel : Object
507 public Gtk.ListStore el;
508 private NewBranch _this;
514 public Xcls_dbmodel(NewBranch _owner )
517 _this.dbmodel = this;
518 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
522 // set gobject values
525 // user defined functions
526 public void loadTickets () {
528 RooTicket.singleton().loadTickets();
530 _this.ticketsel.loading = true;
539 el.set_value(iter, 0, "");
540 el.set_value(iter, 1, "-- select a ticket --");
542 _this.ticketsel.el.set_active_iter(iter);
543 var tickets = RooTicket.singleton().tickets;
544 foreach(var ticket in tickets) {
548 el.set_value(iter, 0, ticket.id);
549 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
551 //if (data.get(i) == cur) {
552 // _this.build_module.el.set_active_iter(iter);
557 _this.ticketsel.loading = false;
558 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
564 public class Xcls_Button12 : Object
566 public Gtk.Button el;
567 private NewBranch _this;
573 public Xcls_Button12(NewBranch _owner )
576 this.el = new Gtk.Button();
580 // set gobject values
581 this.el.expand = false;
582 this.el.label = "New Ticket";
585 // user defined functions
588 public class Xcls_Label13 : Object
591 private NewBranch _this;
597 public Xcls_Label13(NewBranch _owner )
600 this.el = new Gtk.Label( "Use this as branch name" );
604 // set gobject values
605 this.el.halign = Gtk.Align.START;
606 this.el.justify = Gtk.Justification.RIGHT;
607 this.el.xalign = 0.900000f;
610 // user defined functions
613 public class Xcls_name : Object
616 private NewBranch _this;
622 public Xcls_name(NewBranch _owner )
626 this.el = new Gtk.Entry();
630 // set gobject values
631 this.el.visible = true;
634 // user defined functions
637 public class Xcls_Button15 : Object
639 public Gtk.Button el;
640 private NewBranch _this;
646 public Xcls_Button15(NewBranch _owner )
649 this.el = new Gtk.Button();
653 // set gobject values
654 this.el.label = "Create Branch";
657 // user defined functions
662 public class Xcls_Button16 : Object
664 public Gtk.Button el;
665 private NewBranch _this;
671 public Xcls_Button16(NewBranch _owner )
674 this.el = new Gtk.Button();
678 // set gobject values
679 this.el.relief = Gtk.ReliefStyle.NONE;
680 this.el.label = "Do not create Branch";
683 // user defined functions
686 public class Xcls_Button17 : Object
688 public Gtk.Button el;
689 private NewBranch _this;
695 public Xcls_Button17(NewBranch _owner )
698 this.el = new Gtk.Button();
702 // set gobject values
703 this.el.label = "Create Branch";
706 // user defined functions