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_projectsel projectsel;
16 public Xcls_prcellrenderer prcellrenderer;
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_projectsel( _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.attach_defaults ( child_7.el , 4,5,3,4 );
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_projectsel : Object
256 public Gtk.ComboBox el;
257 private NewBranch _this;
264 public Xcls_projectsel(NewBranch _owner )
267 _this.projectsel = this;
268 this.el = new Gtk.ComboBox();
271 this.loading = false;
273 // set gobject values
274 var child_0 = new Xcls_prcellrenderer( _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.prcellrenderer.el , "markup", 1 );
286 this.el.changed.connect( () => {
287 /*if (this.loading) {
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);
311 // user defined functions
312 public string selectedTicketId () {
317 this.el.get_active_iter (out iter);
318 _this.dbmodel.el.get_value (iter, 0, out val1);
321 return (string) val1;
328 public class Xcls_prcellrenderer : Object
330 public Gtk.CellRendererText el;
331 private NewBranch _this;
337 public Xcls_prcellrenderer(NewBranch _owner )
340 _this.prcellrenderer = this;
341 this.el = new Gtk.CellRendererText();
345 // set gobject values
348 // user defined functions
351 public class Xcls_dbmodel : Object
353 public Gtk.ListStore el;
354 private NewBranch _this;
360 public Xcls_dbmodel(NewBranch _owner )
363 _this.dbmodel = this;
364 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
368 // set gobject values
371 // user defined functions
372 public void loadTickets () {
374 RooTicket.singleton().loadTickets();
376 _this.ticketsel.loading = true;
385 el.set_value(iter, 0, "");
386 el.set_value(iter, 1, "-- select a ticket --");
388 _this.ticketsel.el.set_active_iter(iter);
389 var tickets = RooTicket.singleton().tickets;
390 foreach(var ticket in tickets) {
394 el.set_value(iter, 0, ticket.id);
395 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
397 //if (data.get(i) == cur) {
398 // _this.build_module.el.set_active_iter(iter);
403 _this.ticketsel.loading = false;
404 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
410 public class Xcls_ticketsel : Object
412 public Gtk.ComboBox el;
413 private NewBranch _this;
420 public Xcls_ticketsel(NewBranch _owner )
423 _this.ticketsel = this;
424 this.el = new Gtk.ComboBox();
427 this.loading = false;
429 // set gobject values
430 var child_0 = new Xcls_dbcellrenderer( _this );
432 this.el.pack_start ( child_0.el , true );
433 var child_1 = new Xcls_dbmodel( _this );
435 this.el.set_model ( child_1.el );
439 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
442 this.el.changed.connect( () => {
446 var ticket_id = this.selectedTicketId();
448 var name = RooTicket.singleton().usernameLocal();
450 if (ticket_id == "" || ticket_id == null) {
452 var dt = new DateTime.now_local();
453 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
458 var ticket = RooTicket.singleton().getById(ticket_id);
460 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
462 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
466 // user defined functions
467 public string selectedTicketId () {
472 this.el.get_active_iter (out iter);
473 _this.dbmodel.el.get_value (iter, 0, out val1);
476 return (string) val1;
483 public class Xcls_dbcellrenderer : Object
485 public Gtk.CellRendererText el;
486 private NewBranch _this;
492 public Xcls_dbcellrenderer(NewBranch _owner )
495 _this.dbcellrenderer = this;
496 this.el = new Gtk.CellRendererText();
500 // set gobject values
503 // user defined functions
506 public class Xcls_dbmodel : Object
508 public Gtk.ListStore el;
509 private NewBranch _this;
515 public Xcls_dbmodel(NewBranch _owner )
518 _this.dbmodel = this;
519 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
523 // set gobject values
526 // user defined functions
527 public void loadTickets () {
529 RooTicket.singleton().loadTickets();
531 _this.ticketsel.loading = true;
540 el.set_value(iter, 0, "");
541 el.set_value(iter, 1, "-- select a ticket --");
543 _this.ticketsel.el.set_active_iter(iter);
544 var tickets = RooTicket.singleton().tickets;
545 foreach(var ticket in tickets) {
549 el.set_value(iter, 0, ticket.id);
550 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
552 //if (data.get(i) == cur) {
553 // _this.build_module.el.set_active_iter(iter);
558 _this.ticketsel.loading = false;
559 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
565 public class Xcls_Button12 : Object
567 public Gtk.Button el;
568 private NewBranch _this;
574 public Xcls_Button12(NewBranch _owner )
577 this.el = new Gtk.Button();
581 // set gobject values
582 this.el.expand = false;
583 this.el.label = "New Ticket";
586 // user defined functions
589 public class Xcls_Label13 : Object
592 private NewBranch _this;
598 public Xcls_Label13(NewBranch _owner )
601 this.el = new Gtk.Label( "Use this as branch name" );
605 // set gobject values
606 this.el.halign = Gtk.Align.START;
607 this.el.justify = Gtk.Justification.RIGHT;
608 this.el.xalign = 0.900000f;
611 // user defined functions
614 public class Xcls_name : Object
617 private NewBranch _this;
623 public Xcls_name(NewBranch _owner )
627 this.el = new Gtk.Entry();
631 // set gobject values
632 this.el.visible = true;
635 // user defined functions
638 public class Xcls_Button15 : Object
640 public Gtk.Button el;
641 private NewBranch _this;
647 public Xcls_Button15(NewBranch _owner )
650 this.el = new Gtk.Button();
654 // set gobject values
655 this.el.label = "Create Branch";
660 this.get_style_contect().add_class("suggested-action");
664 // user defined functions
669 public class Xcls_Button16 : Object
671 public Gtk.Button el;
672 private NewBranch _this;
678 public Xcls_Button16(NewBranch _owner )
681 this.el = new Gtk.Button();
685 // set gobject values
686 this.el.relief = Gtk.ReliefStyle.NONE;
687 this.el.label = "Do not create Branch";
690 // user defined functions
693 public class Xcls_Button17 : Object
695 public Gtk.Button el;
696 private NewBranch _this;
702 public Xcls_Button17(NewBranch _owner )
705 this.el = new Gtk.Button();
709 // set gobject values
710 this.el.label = "Create Branch";
713 // user defined functions