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_Button15( _this );
50 this.el.add_action_widget ( child_1.el , 0 );
51 var child_2 = new Xcls_Button16( _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, false );
172 // set gobject values
173 this.el.expand = true;
175 this.el.column_spacing = 2;
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,5,3,4 );
200 // user defined functions
202 public class Xcls_Label4 : Object
205 private NewBranch _this;
211 public Xcls_Label4(NewBranch _owner )
214 this.el = new Gtk.Label( "Project" );
218 // set gobject values
219 this.el.halign = Gtk.Align.START;
220 this.el.justify = Gtk.Justification.RIGHT;
221 this.el.visible = true;
224 // user defined functions
227 public class Xcls_Label5 : Object
230 private NewBranch _this;
236 public Xcls_Label5(NewBranch _owner )
239 this.el = new Gtk.Label( "Ticket" );
243 // set gobject values
244 this.el.halign = Gtk.Align.START;
245 this.el.visible = true;
248 // user defined functions
251 public class Xcls_ticketsel : Object
253 public Gtk.ComboBox el;
254 private NewBranch _this;
261 public Xcls_ticketsel(NewBranch _owner )
264 _this.ticketsel = this;
265 this.el = new Gtk.ComboBox();
268 this.loading = false;
270 // set gobject values
271 var child_0 = new Xcls_dbcellrenderer( _this );
273 this.el.pack_start ( child_0.el , true );
274 var child_1 = new Xcls_dbmodel( _this );
276 this.el.set_model ( child_1.el );
280 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
283 this.el.changed.connect( () => {
287 var ticket_id = this.selectedTicketId();
289 var name = RooTicket.singleton().usernameLocal();
291 if (ticket_id == "" || ticket_id == null) {
293 var dt = new DateTime.now_local();
294 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
299 var ticket = RooTicket.singleton().getById(ticket_id);
301 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
303 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
307 // user defined functions
308 public string selectedTicketId () {
313 this.el.get_active_iter (out iter);
314 _this.dbmodel.el.get_value (iter, 0, out val1);
317 return (string) val1;
324 public class Xcls_dbcellrenderer : Object
326 public Gtk.CellRendererText el;
327 private NewBranch _this;
333 public Xcls_dbcellrenderer(NewBranch _owner )
336 _this.dbcellrenderer = this;
337 this.el = new Gtk.CellRendererText();
341 // set gobject values
344 // user defined functions
347 public class Xcls_dbmodel : Object
349 public Gtk.ListStore el;
350 private NewBranch _this;
356 public Xcls_dbmodel(NewBranch _owner )
359 _this.dbmodel = this;
360 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
364 // set gobject values
367 // user defined functions
368 public void loadTickets () {
370 RooTicket.singleton().loadTickets();
372 _this.ticketsel.loading = true;
381 el.set_value(iter, 0, "");
382 el.set_value(iter, 1, "-- select a ticket --");
384 _this.ticketsel.el.set_active_iter(iter);
385 var tickets = RooTicket.singleton().tickets;
386 foreach(var ticket in tickets) {
390 el.set_value(iter, 0, ticket.id);
391 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
393 //if (data.get(i) == cur) {
394 // _this.build_module.el.set_active_iter(iter);
399 _this.ticketsel.loading = false;
400 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
406 public class Xcls_ticketsel : Object
408 public Gtk.ComboBox el;
409 private NewBranch _this;
416 public Xcls_ticketsel(NewBranch _owner )
419 _this.ticketsel = this;
420 this.el = new Gtk.ComboBox();
423 this.loading = false;
425 // set gobject values
426 var child_0 = new Xcls_dbcellrenderer( _this );
428 this.el.pack_start ( child_0.el , true );
429 var child_1 = new Xcls_dbmodel( _this );
431 this.el.set_model ( child_1.el );
435 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
438 this.el.changed.connect( () => {
442 var ticket_id = this.selectedTicketId();
444 var name = RooTicket.singleton().usernameLocal();
446 if (ticket_id == "" || ticket_id == null) {
448 var dt = new DateTime.now_local();
449 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
454 var ticket = RooTicket.singleton().getById(ticket_id);
456 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
458 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
462 // user defined functions
463 public string selectedTicketId () {
468 this.el.get_active_iter (out iter);
469 _this.dbmodel.el.get_value (iter, 0, out val1);
472 return (string) val1;
479 public class Xcls_dbcellrenderer : Object
481 public Gtk.CellRendererText el;
482 private NewBranch _this;
488 public Xcls_dbcellrenderer(NewBranch _owner )
491 _this.dbcellrenderer = this;
492 this.el = new Gtk.CellRendererText();
496 // set gobject values
499 // user defined functions
502 public class Xcls_dbmodel : Object
504 public Gtk.ListStore el;
505 private NewBranch _this;
511 public Xcls_dbmodel(NewBranch _owner )
514 _this.dbmodel = this;
515 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
519 // set gobject values
522 // user defined functions
523 public void loadTickets () {
525 RooTicket.singleton().loadTickets();
527 _this.ticketsel.loading = true;
536 el.set_value(iter, 0, "");
537 el.set_value(iter, 1, "-- select a ticket --");
539 _this.ticketsel.el.set_active_iter(iter);
540 var tickets = RooTicket.singleton().tickets;
541 foreach(var ticket in tickets) {
545 el.set_value(iter, 0, ticket.id);
546 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
548 //if (data.get(i) == cur) {
549 // _this.build_module.el.set_active_iter(iter);
554 _this.ticketsel.loading = false;
555 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
561 public class Xcls_Button12 : Object
563 public Gtk.Button el;
564 private NewBranch _this;
570 public Xcls_Button12(NewBranch _owner )
573 this.el = new Gtk.Button();
577 // set gobject values
578 this.el.expand = false;
579 this.el.label = "New Ticket";
582 // user defined functions
585 public class Xcls_Label13 : Object
588 private NewBranch _this;
594 public Xcls_Label13(NewBranch _owner )
597 this.el = new Gtk.Label( "Use this as branch name" );
601 // set gobject values
602 this.el.halign = Gtk.Align.START;
603 this.el.justify = Gtk.Justification.RIGHT;
604 this.el.xalign = 0.900000f;
607 // user defined functions
610 public class Xcls_name : Object
613 private NewBranch _this;
619 public Xcls_name(NewBranch _owner )
623 this.el = new Gtk.Entry();
627 // set gobject values
628 this.el.visible = true;
631 // user defined functions
636 public class Xcls_Button15 : Object
638 public Gtk.Button el;
639 private NewBranch _this;
645 public Xcls_Button15(NewBranch _owner )
648 this.el = new Gtk.Button();
652 // set gobject values
653 this.el.relief = Gtk.ReliefStyle.NONE;
654 this.el.label = "Do not create Branch";
657 // user defined functions
660 public class Xcls_Button16 : Object
662 public Gtk.Button el;
663 private NewBranch _this;
669 public Xcls_Button16(NewBranch _owner )
672 this.el = new Gtk.Button();
676 // set gobject values
677 this.el.label = "Create Branch";
680 // user defined functions