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, string tid = "" )
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();
115 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
116 this.el.set_default_size( 500,200); // not sure why it grows..
117 GLib.debug("Loading tickets");
121 this.el.set_keep_above(true);
124 var curproj = RooTicket.singleton().getProjectByRepo(this.repo);
125 _this.prmodel.loadProjects(curproj == null ? "" : curproj.id);
127 _this.dbmodel.loadTickets(curproj == null ? "": curproj.id, tid);
131 public class Xcls_VBox2 : Object
134 private NewBranch _this;
140 public Xcls_VBox2(NewBranch _owner )
143 this.el = new Gtk.VBox( true, 0 );
147 // set gobject values
148 var child_0 = new Xcls_Table3( _this );
150 this.el.pack_start ( child_0.el , false,false,0 );
153 // user defined functions
155 public class Xcls_Table3 : Object
158 private NewBranch _this;
164 public Xcls_Table3(NewBranch _owner )
167 this.el = new Gtk.Table( 5, 5, true );
171 // set gobject values
172 this.el.expand = false;
174 this.el.column_spacing = 4;
175 this.el.vexpand = false;
176 var child_0 = new Xcls_Label4( _this );
178 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
179 var child_1 = new Xcls_Label5( _this );
181 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
182 var child_2 = new Xcls_projectsel( _this );
184 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
185 var child_3 = new Xcls_ticketsel( _this );
187 this.el.attach_defaults ( child_3.el , 1,4,1,2 );
188 var child_4 = new Xcls_Button12( _this );
190 this.el.attach_defaults ( child_4.el , 4,5,1,2 );
191 var child_5 = new Xcls_Label13( _this );
193 this.el.attach_defaults ( child_5.el , 0,1,3,4 );
194 var child_6 = new Xcls_name( _this );
196 this.el.attach_defaults ( child_6.el , 0,4,4,5 );
197 var child_7 = new Xcls_Button15( _this );
199 this.el.attach_defaults ( child_7.el , 4,5,4,5 );
200 var child_8 = new Xcls_Box16( _this );
202 this.el.attach_defaults ( child_8.el , 0,5,2,3 );
205 // user defined functions
207 public class Xcls_Label4 : Object
210 private NewBranch _this;
216 public Xcls_Label4(NewBranch _owner )
219 this.el = new Gtk.Label( "Project" );
223 // set gobject values
224 this.el.halign = Gtk.Align.START;
225 this.el.justify = Gtk.Justification.RIGHT;
226 this.el.visible = true;
229 // user defined functions
232 public class Xcls_Label5 : Object
235 private NewBranch _this;
241 public Xcls_Label5(NewBranch _owner )
244 this.el = new Gtk.Label( "Ticket" );
248 // set gobject values
249 this.el.halign = Gtk.Align.START;
250 this.el.visible = true;
253 // user defined functions
256 public class Xcls_projectsel : Object
258 public Gtk.ComboBox el;
259 private NewBranch _this;
266 public Xcls_projectsel(NewBranch _owner )
269 _this.projectsel = this;
270 this.el = new Gtk.ComboBox.with_entry();
273 this.loading = false;
275 // set gobject values
276 var child_0 = new Xcls_prcellrenderer( _this );
278 this.el.pack_start ( child_0.el , true );
279 var child_1 = new Xcls_prmodel( _this );
281 this.el.set_model ( child_1.el );
285 this.el.set_entry_text_column(1);
288 this.el.changed.connect( () => {
292 var project_id = this.selectedProjectId();
293 _this.dbmodel.loadTickets(project_id);
296 /*if (this.loading) {
299 var ticket_id = this.selectedTicketId();
301 var name = RooTicket.singleton().usernameLocal();
303 if (ticket_id == "" || ticket_id == null) {
305 var dt = new DateTime.now_local();
306 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
311 var ticket = RooTicket.singleton().getById(ticket_id);
313 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
315 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
320 // user defined functions
321 public string selectedProjectId () {
326 this.el.get_active_iter (out iter);
327 _this.prmodel.el.get_value (iter, 0, out val1);
330 return (string) val1;
337 public class Xcls_prcellrenderer : Object
339 public Gtk.CellRendererText el;
340 private NewBranch _this;
346 public Xcls_prcellrenderer(NewBranch _owner )
349 _this.prcellrenderer = this;
350 this.el = new Gtk.CellRendererText();
354 // set gobject values
357 // user defined functions
360 public class Xcls_prmodel : Object
362 public Gtk.ListStore el;
363 private NewBranch _this;
369 public Xcls_prmodel(NewBranch _owner )
372 _this.prmodel = this;
373 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
377 // set gobject values
380 // user defined functions
381 public void loadProjects (string id) {
383 var rt = RooTicket.singleton();
386 _this.projectsel.loading = true;
395 el.set_value(iter, 0, "");
396 el.set_value(iter, 1, "-- select a project --");
398 _this.projectsel.el.set_active_iter(iter);
400 var projects = rt.projects;
401 foreach(var project in projects) {
405 el.set_value(iter, 0, project.id);
406 el.set_value(iter, 1, project.name );
407 if (id == project.id) {
408 _this.projectsel.el.set_active_iter(iter);
413 _this.projectsel.loading = false;
414 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
420 public class Xcls_ticketsel : Object
422 public Gtk.ComboBox el;
423 private NewBranch _this;
430 public Xcls_ticketsel(NewBranch _owner )
433 _this.ticketsel = this;
434 this.el = new Gtk.ComboBox.with_entry();
437 this.loading = false;
439 // set gobject values
440 var child_0 = new Xcls_dbcellrenderer( _this );
442 this.el.pack_start ( child_0.el , true );
443 var child_1 = new Xcls_dbmodel( _this );
445 this.el.set_model ( child_1.el );
449 //this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
450 this.el.set_entry_text_column(1);
453 this.el.changed.connect( () => {
457 var ticket_id = this.selectedTicketId();
459 var name = RooTicket.singleton().usernameLocal();
461 if (ticket_id == "" || ticket_id == null) {
463 var dt = new DateTime.now_local();
464 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
469 var ticket = RooTicket.singleton().getById(ticket_id);
471 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
473 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
477 // user defined functions
478 public string selectedTicketId () {
483 this.el.get_active_iter (out iter);
484 _this.dbmodel.el.get_value (iter, 0, out val1);
487 return (string) val1;
494 public class Xcls_dbcellrenderer : Object
496 public Gtk.CellRendererText el;
497 private NewBranch _this;
503 public Xcls_dbcellrenderer(NewBranch _owner )
506 _this.dbcellrenderer = this;
507 this.el = new Gtk.CellRendererText();
511 // set gobject values
514 // user defined functions
517 public class Xcls_dbmodel : Object
519 public Gtk.ListStore el;
520 private NewBranch _this;
526 public Xcls_dbmodel(NewBranch _owner )
529 _this.dbmodel = this;
530 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
534 // set gobject values
537 // user defined functions
538 public void loadTickets (string project_id , string tid = "") {
542 // fixme .. get project id from selection..
544 RooTicket.singleton().loadTickets(
546 _this.btn_not_me.el.active ? RooTicket.Who.ANYBODY : RooTicket.Who.ME,
547 _this.btn_closed.el.active ? RooTicket.Status.ALL : RooTicket.Status.ACTIVE
550 _this.ticketsel.loading = true;
559 el.set_value(iter, 0, "");
560 el.set_value(iter, 1, "-- select a ticket --");
562 _this.ticketsel.el.set_active_iter(iter);
563 var tickets = RooTicket.singleton().tickets;
564 foreach(var ticket in tickets) {
568 el.set_value(iter, 0, ticket.id);
569 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
571 if (ticket.id == tid) {
572 _this.ticketsel.el.set_active_iter(iter);
577 _this.ticketsel.loading = false;
578 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
584 public class Xcls_Button12 : Object
586 public Gtk.Button el;
587 private NewBranch _this;
593 public Xcls_Button12(NewBranch _owner )
596 this.el = new Gtk.Button();
600 // set gobject values
601 this.el.expand = false;
602 this.el.label = "New Ticket";
605 this.el.clicked.connect( () => {
606 _this.el.response(-1);
607 Ticket.singleton().show(_this.repo);
612 // user defined functions
615 public class Xcls_Label13 : Object
618 private NewBranch _this;
624 public Xcls_Label13(NewBranch _owner )
627 this.el = new Gtk.Label( "Use this as branch name" );
631 // set gobject values
632 this.el.halign = Gtk.Align.START;
633 this.el.justify = Gtk.Justification.RIGHT;
634 this.el.xalign = 0.900000f;
637 // user defined functions
640 public class Xcls_name : Object
643 private NewBranch _this;
649 public Xcls_name(NewBranch _owner )
653 this.el = new Gtk.Entry();
657 // set gobject values
658 this.el.visible = true;
661 // user defined functions
664 public class Xcls_Button15 : Object
666 public Gtk.Button el;
667 private NewBranch _this;
673 public Xcls_Button15(NewBranch _owner )
676 this.el = new Gtk.Button();
680 // set gobject values
681 this.el.label = "Create Branch";
686 this.el.get_style_context().add_class("suggested-action");
690 this.el.clicked.connect( () => {
691 GLib.debug("fire response = 1");
692 _this.el.response(1);
696 // user defined functions
699 public class Xcls_Box16 : Object
702 private NewBranch _this;
708 public Xcls_Box16(NewBranch _owner )
711 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
715 // set gobject values
716 var child_0 = new Xcls_btn_not_me( _this );
718 this.el.add ( child_0.el );
719 var child_1 = new Xcls_btn_closed( _this );
721 this.el.add ( child_1.el );
722 var child_2 = new Xcls_Label19( _this );
724 this.el.add ( child_2.el );
727 // user defined functions
729 public class Xcls_btn_not_me : Object
731 public Gtk.CheckButton el;
732 private NewBranch _this;
738 public Xcls_btn_not_me(NewBranch _owner )
741 _this.btn_not_me = this;
742 this.el = new Gtk.CheckButton();
746 // set gobject values
747 this.el.label = "Show tickets not assigned to me";
750 this.el.toggled.connect( () => {
751 var project_id = _this.projectsel.selectedProjectId();
752 _this.dbmodel.loadTickets(project_id);
756 // user defined functions
759 public class Xcls_btn_closed : Object
761 public Gtk.CheckButton el;
762 private NewBranch _this;
768 public Xcls_btn_closed(NewBranch _owner )
771 _this.btn_closed = this;
772 this.el = new Gtk.CheckButton();
776 // set gobject values
777 this.el.label = "Show closed Tickets";
780 this.el.toggled.connect( () => {
781 var project_id = _this.projectsel.selectedProjectId();
782 _this.dbmodel.loadTickets(project_id);
787 // user defined functions
790 public class Xcls_Label19 : Object
793 private NewBranch _this;
799 public Xcls_Label19(NewBranch _owner )
802 this.el = new Gtk.Label( "<a href=\"refresh\">Refresh Ticket list</a>" );
806 // set gobject values
807 this.el.halign = Gtk.Align.END;
808 this.el.hexpand = true;
809 this.el.use_markup = true;
812 this.el.activate_link.connect( (uri) => {
813 if (uri == "refresh") {
814 var curproj = RooTicket.singleton().getProjectByRepo(_this.repo);
815 _this.prmodel.loadProjects(curproj == null ? "": curproj.id);
817 _this.dbmodel.loadTickets(curproj == null ? "": curproj.id);
823 // user defined functions