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;
22 public Xcls_btn_not_me btn_not_me;
23 public Xcls_btn_closed btn_closed;
28 public Gee.ArrayList<GitMonitorQueue> queue;
34 this.el = new Gtk.Dialog();
42 this.el.title = "Create a working branch ";
43 this.el.default_height = 200;
44 this.el.default_width = 500;
45 this.el.deletable = true;
47 var child_0 = new Xcls_VBox2( _this );
49 this.el.get_content_area().add ( child_0.el );
52 this.el.delete_event.connect( (self, event) => {
57 this.el.response.connect( (self, response_id) => {
59 GLib.debug("got %d", (int) response_id);
60 if (response_id < 1) {
66 // have they selected a ticket..
67 // make that the current active ticket?
68 // we really need to store locally what ticket is being worked on..
69 // in theory we could be working on multiple project and not merging..
70 // -- each repo would have their active ticket (only one per repo)
71 // -- so we could just store that in there
72 // -- initial load can check the contents of the ticket files on first scan.
73 var ticket_id = _this.ticketsel.selectedTicketId();
75 if (this.repo != null) {
76 var bn = _this.name.el.get_text();
78 var res = this.repo.setActiveTicket(
79 RooTicket.singleton().getById(ticket_id != "" ? ticket_id : "-1"), bn
82 // start the monitoring..
83 GitMonitor.gitmonitor.start();
99 // user defined functions
100 public void show ( GitRepo repo, Gee.ArrayList<GitMonitorQueue> queue )
102 // this.el.set_gravity(Gdk.Gravity.NORTH);
103 if (this.running) { // should not happen!!
104 GLib.error("new branch show called, when already being displayed?");
109 GitMonitor.gitmonitor.stop();
116 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
117 this.el.set_default_size( 500,200); // not sure why it grows..
118 GLib.debug("Loading tickets");
122 this.el.set_keep_above(true);
125 var curproj = RooTicket.singleton().getProjectByRepo(this.repo);
126 _this.prmodel.loadProjects(curproj == null ? "" : curproj.id);
128 _this.dbmodel.loadTickets(curproj == null ? "": curproj.id);
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, 5, true );
172 // set gobject values
173 this.el.expand = false;
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,3,4 );
195 var child_6 = new Xcls_name( _this );
197 this.el.attach_defaults ( child_6.el , 0,4,4,5 );
198 var child_7 = new Xcls_Button15( _this );
200 this.el.attach_defaults ( child_7.el , 4,5,4,5 );
201 var child_8 = new Xcls_Box16( _this );
203 this.el.attach_defaults ( child_8.el , 0,5,2,3 );
206 // user defined functions
208 public class Xcls_Label4 : Object
211 private NewBranch _this;
217 public Xcls_Label4(NewBranch _owner )
220 this.el = new Gtk.Label( "Project" );
224 // set gobject values
225 this.el.halign = Gtk.Align.START;
226 this.el.justify = Gtk.Justification.RIGHT;
227 this.el.visible = true;
230 // user defined functions
233 public class Xcls_Label5 : Object
236 private NewBranch _this;
242 public Xcls_Label5(NewBranch _owner )
245 this.el = new Gtk.Label( "Ticket" );
249 // set gobject values
250 this.el.halign = Gtk.Align.START;
251 this.el.visible = true;
254 // user defined functions
257 public class Xcls_projectsel : Object
259 public Gtk.ComboBox el;
260 private NewBranch _this;
267 public Xcls_projectsel(NewBranch _owner )
270 _this.projectsel = this;
271 this.el = new Gtk.ComboBox.with_entry();
274 this.loading = false;
276 // set gobject values
277 var child_0 = new Xcls_prcellrenderer( _this );
279 this.el.pack_start ( child_0.el , true );
280 var child_1 = new Xcls_prmodel( _this );
282 this.el.set_model ( child_1.el );
286 this.el.set_entry_text_column(1);
289 this.el.changed.connect( () => {
293 var project_id = this.selectedProjectId();
294 _this.dbmodel.loadTickets(project_id);
297 /*if (this.loading) {
300 var ticket_id = this.selectedTicketId();
302 var name = RooTicket.singleton().usernameLocal();
304 if (ticket_id == "" || ticket_id == null) {
306 var dt = new DateTime.now_local();
307 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
312 var ticket = RooTicket.singleton().getById(ticket_id);
314 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
316 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
321 // user defined functions
322 public string selectedProjectId () {
327 this.el.get_active_iter (out iter);
328 _this.prmodel.el.get_value (iter, 0, out val1);
331 return (string) val1;
338 public class Xcls_prcellrenderer : Object
340 public Gtk.CellRendererText el;
341 private NewBranch _this;
347 public Xcls_prcellrenderer(NewBranch _owner )
350 _this.prcellrenderer = this;
351 this.el = new Gtk.CellRendererText();
355 // set gobject values
358 // user defined functions
361 public class Xcls_prmodel : Object
363 public Gtk.ListStore el;
364 private NewBranch _this;
370 public Xcls_prmodel(NewBranch _owner )
373 _this.prmodel = this;
374 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
378 // set gobject values
381 // user defined functions
382 public void loadProjects (string id) {
384 var rt = RooTicket.singleton();
387 _this.projectsel.loading = true;
396 el.set_value(iter, 0, "");
397 el.set_value(iter, 1, "-- select a project --");
399 _this.projectsel.el.set_active_iter(iter);
401 var projects = rt.projects;
402 foreach(var project in projects) {
406 el.set_value(iter, 0, project.id);
407 el.set_value(iter, 1, project.name );
408 if (id == project.id) {
409 _this.projectsel.el.set_active_iter(iter);
414 _this.projectsel.loading = false;
415 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
421 public class Xcls_ticketsel : Object
423 public Gtk.ComboBox el;
424 private NewBranch _this;
431 public Xcls_ticketsel(NewBranch _owner )
434 _this.ticketsel = this;
435 this.el = new Gtk.ComboBox.with_entry();
438 this.loading = false;
440 // set gobject values
441 var child_0 = new Xcls_dbcellrenderer( _this );
443 this.el.pack_start ( child_0.el , true );
444 var child_1 = new Xcls_dbmodel( _this );
446 this.el.set_model ( child_1.el );
450 //this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
451 this.el.set_entry_text_column(1);
454 this.el.changed.connect( () => {
458 var ticket_id = this.selectedTicketId();
460 var name = RooTicket.singleton().usernameLocal();
462 if (ticket_id == "" || ticket_id == null) {
464 var dt = new DateTime.now_local();
465 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
470 var ticket = RooTicket.singleton().getById(ticket_id);
472 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
474 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
478 // user defined functions
479 public string selectedTicketId () {
484 this.el.get_active_iter (out iter);
485 _this.dbmodel.el.get_value (iter, 0, out val1);
488 return (string) val1;
495 public class Xcls_dbcellrenderer : Object
497 public Gtk.CellRendererText el;
498 private NewBranch _this;
504 public Xcls_dbcellrenderer(NewBranch _owner )
507 _this.dbcellrenderer = this;
508 this.el = new Gtk.CellRendererText();
512 // set gobject values
515 // user defined functions
518 public class Xcls_dbmodel : Object
520 public Gtk.ListStore el;
521 private NewBranch _this;
527 public Xcls_dbmodel(NewBranch _owner )
530 _this.dbmodel = this;
531 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
535 // set gobject values
538 // user defined functions
539 public void loadTickets (string project_id) {
543 // fixme .. get project id from selection..
545 RooTicket.singleton().loadTickets(
547 _this.btn_not_me.el.active ? RooTicket.NotMe.TRUE : RooTicket.NotMe.FALSE,
548 _this.btn_closed.el.active ? RooTicket.Closed.TRUE : RooTicket.Closed.FALSE
551 _this.ticketsel.loading = true;
560 el.set_value(iter, 0, "");
561 el.set_value(iter, 1, "-- select a ticket --");
563 _this.ticketsel.el.set_active_iter(iter);
564 var tickets = RooTicket.singleton().tickets;
565 foreach(var ticket in tickets) {
569 el.set_value(iter, 0, ticket.id);
570 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
572 //if (data.get(i) == cur) {
573 // _this.build_module.el.set_active_iter(iter);
578 _this.ticketsel.loading = false;
579 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
585 public class Xcls_Button12 : Object
587 public Gtk.Button el;
588 private NewBranch _this;
594 public Xcls_Button12(NewBranch _owner )
597 this.el = new Gtk.Button();
601 // set gobject values
602 this.el.expand = false;
603 this.el.label = "New Ticket";
606 this.el.clicked.connect( () => {
607 Ticket.singleton().show(_this.repo);
611 // user defined functions
614 public class Xcls_Label13 : Object
617 private NewBranch _this;
623 public Xcls_Label13(NewBranch _owner )
626 this.el = new Gtk.Label( "Use this as branch name" );
630 // set gobject values
631 this.el.halign = Gtk.Align.START;
632 this.el.justify = Gtk.Justification.RIGHT;
633 this.el.xalign = 0.900000f;
636 // user defined functions
639 public class Xcls_name : Object
642 private NewBranch _this;
648 public Xcls_name(NewBranch _owner )
652 this.el = new Gtk.Entry();
656 // set gobject values
657 this.el.visible = true;
660 // user defined functions
663 public class Xcls_Button15 : Object
665 public Gtk.Button el;
666 private NewBranch _this;
672 public Xcls_Button15(NewBranch _owner )
675 this.el = new Gtk.Button();
679 // set gobject values
680 this.el.label = "Create Branch";
685 this.el.get_style_context().add_class("suggested-action");
689 this.el.clicked.connect( () => {
690 GLib.debug("fire response = 1");
691 _this.el.response(1);
695 // user defined functions
698 public class Xcls_Box16 : Object
701 private NewBranch _this;
707 public Xcls_Box16(NewBranch _owner )
710 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
714 // set gobject values
715 var child_0 = new Xcls_btn_not_me( _this );
717 this.el.add ( child_0.el );
718 var child_1 = new Xcls_btn_closed( _this );
720 this.el.add ( child_1.el );
721 var child_2 = new Xcls_Label19( _this );
723 this.el.add ( child_2.el );
726 // user defined functions
728 public class Xcls_btn_not_me : Object
730 public Gtk.CheckButton el;
731 private NewBranch _this;
737 public Xcls_btn_not_me(NewBranch _owner )
740 _this.btn_not_me = this;
741 this.el = new Gtk.CheckButton();
745 // set gobject values
746 this.el.label = "Show tickets not assigned to me";
749 this.el.toggled.connect( () => {
750 var project_id = _this.projectsel.selectedProjectId();
751 _this.dbmodel.loadTickets(project_id);
755 // user defined functions
758 public class Xcls_btn_closed : Object
760 public Gtk.CheckButton el;
761 private NewBranch _this;
767 public Xcls_btn_closed(NewBranch _owner )
770 _this.btn_closed = this;
771 this.el = new Gtk.CheckButton();
775 // set gobject values
776 this.el.label = "Show closed Tickets";
779 this.el.toggled.connect( () => {
780 var project_id = _this.projectsel.selectedProjectId();
781 _this.dbmodel.loadTickets(project_id);
786 // user defined functions
789 public class Xcls_Label19 : Object
792 private NewBranch _this;
798 public Xcls_Label19(NewBranch _owner )
801 this.el = new Gtk.Label( "<a href=\"refresh\">Refresh Ticket list</a>" );
805 // set gobject values
806 this.el.halign = Gtk.Align.END;
807 this.el.hexpand = true;
808 this.el.use_markup = true;
811 this.el.activate_link.connect( (uri) => {
812 if (uri == "refresh") {
813 var curproj = RooTicket.singleton().getProjectByRepo(_this.repo);
814 _this.prmodel.loadProjects(curproj == null ? "": curproj.id);
816 _this.dbmodel.loadTickets(curproj == null ? "": curproj.id);
822 // user defined functions