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_prmodel prmodel;
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 );
50 this.el.delete_event.connect( (self, event) => {
55 this.el.response.connect( (self, response_id) => {
57 GLib.debug("got %d", (int) response_id);
58 if (response_id == 0) {
64 // have they selected a ticket..
65 // make that the current active ticket?
66 // we really need to store locally what ticket is being worked on..
67 // in theory we could be working on multiple project and not merging..
68 // -- each repo would have their active ticket (only one per repo)
69 // -- so we could just store that in there
70 // -- initial load can check the contents of the ticket files on first scan.
71 var ticket_id = _this.ticketsel.selectedTicketId();
73 if (this.repo != null) {
74 var bn = _this.name.el.get_text();
76 var res = this.repo.setActiveTicket(
77 RooTicket.singleton().getById(ticket_id != "" ? ticket_id : "-1"), bn
80 // start the monitoring..
81 GitMonitor.gitmonitor.start();
95 this.el.show.connect( (self) => {
102 // user defined functions
103 public void show ( GitRepo repo, Gee.ArrayList<GitMonitorQueue> queue )
105 // this.el.set_gravity(Gdk.Gravity.NORTH);
106 if (this.running) { // should not happen!!
107 GLib.error("new branch show called, when already being displayed?");
112 GitMonitor.gitmonitor.stop();
116 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
117 GLib.debug("Loading tickets");
121 this.el.set_keep_above(true);
122 _this.dbmodel.loadTickets();
126 public class Xcls_VBox2 : Object
129 private NewBranch _this;
135 public Xcls_VBox2(NewBranch _owner )
138 this.el = new Gtk.VBox( true, 0 );
142 // set gobject values
143 var child_0 = new Xcls_Table3( _this );
145 this.el.pack_start ( child_0.el , false,false,0 );
148 // user defined functions
150 public class Xcls_Table3 : Object
153 private NewBranch _this;
159 public Xcls_Table3(NewBranch _owner )
162 this.el = new Gtk.Table( 5, 6, true );
166 // set gobject values
167 this.el.expand = true;
169 this.el.column_spacing = 4;
170 this.el.vexpand = false;
171 var child_0 = new Xcls_Label4( _this );
173 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
174 var child_1 = new Xcls_Label5( _this );
176 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
177 var child_2 = new Xcls_projectsel( _this );
179 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
180 var child_3 = new Xcls_ticketsel( _this );
182 this.el.attach_defaults ( child_3.el , 1,4,1,2 );
183 var child_4 = new Xcls_Button12( _this );
185 this.el.attach_defaults ( child_4.el , 4,5,1,2 );
186 var child_5 = new Xcls_Label13( _this );
188 this.el.attach_defaults ( child_5.el , 0,1,2,3 );
189 var child_6 = new Xcls_name( _this );
191 this.el.attach_defaults ( child_6.el , 0,4,3,4 );
192 var child_7 = new Xcls_Button15( _this );
194 this.el.attach_defaults ( child_7.el , 4,5,3,4 );
197 // user defined functions
199 public class Xcls_Label4 : Object
202 private NewBranch _this;
208 public Xcls_Label4(NewBranch _owner )
211 this.el = new Gtk.Label( "Project" );
215 // set gobject values
216 this.el.halign = Gtk.Align.START;
217 this.el.justify = Gtk.Justification.RIGHT;
218 this.el.visible = true;
221 // user defined functions
224 public class Xcls_Label5 : Object
227 private NewBranch _this;
233 public Xcls_Label5(NewBranch _owner )
236 this.el = new Gtk.Label( "Ticket" );
240 // set gobject values
241 this.el.halign = Gtk.Align.START;
242 this.el.visible = true;
245 // user defined functions
248 public class Xcls_projectsel : Object
250 public Gtk.ComboBox el;
251 private NewBranch _this;
258 public Xcls_projectsel(NewBranch _owner )
261 _this.projectsel = this;
262 this.el = new Gtk.ComboBox();
265 this.loading = false;
267 // set gobject values
268 var child_0 = new Xcls_prcellrenderer( _this );
270 this.el.pack_start ( child_0.el , true );
271 var child_1 = new Xcls_prmodel( _this );
273 this.el.set_model ( child_1.el );
277 this.el.add_attribute(_this.prcellrenderer.el , "markup", 1 );
280 this.el.changed.connect( () => {
281 /*if (this.loading) {
284 var ticket_id = this.selectedTicketId();
286 var name = RooTicket.singleton().usernameLocal();
288 if (ticket_id == "" || ticket_id == null) {
290 var dt = new DateTime.now_local();
291 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
296 var ticket = RooTicket.singleton().getById(ticket_id);
298 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
300 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
305 // user defined functions
306 public string selectedTicketId () {
311 this.el.get_active_iter (out iter);
312 _this.dbmodel.el.get_value (iter, 0, out val1);
315 return (string) val1;
322 public class Xcls_prcellrenderer : Object
324 public Gtk.CellRendererText el;
325 private NewBranch _this;
331 public Xcls_prcellrenderer(NewBranch _owner )
334 _this.prcellrenderer = this;
335 this.el = new Gtk.CellRendererText();
339 // set gobject values
342 // user defined functions
345 public class Xcls_prmodel : Object
347 public Gtk.ListStore el;
348 private NewBranch _this;
354 public Xcls_prmodel(NewBranch _owner )
357 _this.prmodel = this;
358 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
362 // set gobject values
365 // user defined functions
366 public void loadTickets () {
368 RooTicket.singleton().loadTickets();
370 _this.ticketsel.loading = true;
379 el.set_value(iter, 0, "");
380 el.set_value(iter, 1, "-- select a ticket --");
382 _this.ticketsel.el.set_active_iter(iter);
383 var tickets = RooTicket.singleton().tickets;
384 foreach(var ticket in tickets) {
388 el.set_value(iter, 0, ticket.id);
389 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
391 //if (data.get(i) == cur) {
392 // _this.build_module.el.set_active_iter(iter);
397 _this.ticketsel.loading = false;
398 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
404 public class Xcls_ticketsel : Object
406 public Gtk.ComboBox el;
407 private NewBranch _this;
414 public Xcls_ticketsel(NewBranch _owner )
417 _this.ticketsel = this;
418 this.el = new Gtk.ComboBox();
421 this.loading = false;
423 // set gobject values
424 var child_0 = new Xcls_dbcellrenderer( _this );
426 this.el.pack_start ( child_0.el , true );
427 var child_1 = new Xcls_dbmodel( _this );
429 this.el.set_model ( child_1.el );
433 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
436 this.el.changed.connect( () => {
440 var ticket_id = this.selectedTicketId();
442 var name = RooTicket.singleton().usernameLocal();
444 if (ticket_id == "" || ticket_id == null) {
446 var dt = new DateTime.now_local();
447 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
452 var ticket = RooTicket.singleton().getById(ticket_id);
454 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
456 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
460 // user defined functions
461 public string selectedTicketId () {
466 this.el.get_active_iter (out iter);
467 _this.dbmodel.el.get_value (iter, 0, out val1);
470 return (string) val1;
477 public class Xcls_dbcellrenderer : Object
479 public Gtk.CellRendererText el;
480 private NewBranch _this;
486 public Xcls_dbcellrenderer(NewBranch _owner )
489 _this.dbcellrenderer = this;
490 this.el = new Gtk.CellRendererText();
494 // set gobject values
497 // user defined functions
500 public class Xcls_dbmodel : Object
502 public Gtk.ListStore el;
503 private NewBranch _this;
509 public Xcls_dbmodel(NewBranch _owner )
512 _this.dbmodel = this;
513 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
517 // set gobject values
520 // user defined functions
521 public void loadTickets () {
523 RooTicket.singleton().loadTickets();
525 _this.ticketsel.loading = true;
534 el.set_value(iter, 0, "");
535 el.set_value(iter, 1, "-- select a ticket --");
537 _this.ticketsel.el.set_active_iter(iter);
538 var tickets = RooTicket.singleton().tickets;
539 foreach(var ticket in tickets) {
543 el.set_value(iter, 0, ticket.id);
544 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
546 //if (data.get(i) == cur) {
547 // _this.build_module.el.set_active_iter(iter);
552 _this.ticketsel.loading = false;
553 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
559 public class Xcls_Button12 : Object
561 public Gtk.Button el;
562 private NewBranch _this;
568 public Xcls_Button12(NewBranch _owner )
571 this.el = new Gtk.Button();
575 // set gobject values
576 this.el.expand = false;
577 this.el.label = "New Ticket";
580 // user defined functions
583 public class Xcls_Label13 : Object
586 private NewBranch _this;
592 public Xcls_Label13(NewBranch _owner )
595 this.el = new Gtk.Label( "Use this as branch name" );
599 // set gobject values
600 this.el.halign = Gtk.Align.START;
601 this.el.justify = Gtk.Justification.RIGHT;
602 this.el.xalign = 0.900000f;
605 // user defined functions
608 public class Xcls_name : Object
611 private NewBranch _this;
617 public Xcls_name(NewBranch _owner )
621 this.el = new Gtk.Entry();
625 // set gobject values
626 this.el.visible = true;
629 // user defined functions
632 public class Xcls_Button15 : Object
634 public Gtk.Button el;
635 private NewBranch _this;
641 public Xcls_Button15(NewBranch _owner )
644 this.el = new Gtk.Button();
648 // set gobject values
649 this.el.label = "Create Branch";
654 this.el.get_style_context().add_class("suggested-action");
658 this.el.activate.connect( () => {
659 _this.el.response(1);
663 // user defined functions