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 < 1) {
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();
97 // user defined functions
98 public void show ( GitRepo repo, Gee.ArrayList<GitMonitorQueue> queue )
100 // this.el.set_gravity(Gdk.Gravity.NORTH);
101 if (this.running) { // should not happen!!
102 GLib.error("new branch show called, when already being displayed?");
107 GitMonitor.gitmonitor.stop();
114 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
115 this.el.set_default_size( 500,200); // not sure why it grows..
116 GLib.debug("Loading tickets");
120 this.el.set_keep_above(true);
123 var curproj = RooTicket.singleton().getProjectByRepo(this.repo);
124 _this.prmodel.loadProjects(curproj == null ? "" : curproj.id);
126 _this.dbmodel.loadTickets(curproj == null ? "": curproj.id);
130 public class Xcls_VBox2 : Object
133 private NewBranch _this;
139 public Xcls_VBox2(NewBranch _owner )
142 this.el = new Gtk.VBox( true, 0 );
146 // set gobject values
147 var child_0 = new Xcls_Table3( _this );
149 this.el.pack_start ( child_0.el , false,false,0 );
152 // user defined functions
154 public class Xcls_Table3 : Object
157 private NewBranch _this;
163 public Xcls_Table3(NewBranch _owner )
166 this.el = new Gtk.Table( 5, 5, true );
170 // set gobject values
171 this.el.expand = false;
173 this.el.column_spacing = 4;
174 this.el.vexpand = false;
175 var child_0 = new Xcls_Label4( _this );
177 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
178 var child_1 = new Xcls_Label5( _this );
180 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
181 var child_2 = new Xcls_projectsel( _this );
183 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
184 var child_3 = new Xcls_ticketsel( _this );
186 this.el.attach_defaults ( child_3.el , 1,4,1,2 );
187 var child_4 = new Xcls_Button12( _this );
189 this.el.attach_defaults ( child_4.el , 4,5,1,2 );
190 var child_5 = new Xcls_Label13( _this );
192 this.el.attach_defaults ( child_5.el , 0,1,3,4 );
193 var child_6 = new Xcls_name( _this );
195 this.el.attach_defaults ( child_6.el , 0,4,4,5 );
196 var child_7 = new Xcls_Button15( _this );
198 this.el.attach_defaults ( child_7.el , 4,5,4,5 );
199 var child_8 = new Xcls_Box16( _this );
201 this.el.attach_defaults ( child_8.el , 0,5,2,3 );
204 // user defined functions
206 public class Xcls_Label4 : Object
209 private NewBranch _this;
215 public Xcls_Label4(NewBranch _owner )
218 this.el = new Gtk.Label( "Project" );
222 // set gobject values
223 this.el.halign = Gtk.Align.START;
224 this.el.justify = Gtk.Justification.RIGHT;
225 this.el.visible = true;
228 // user defined functions
231 public class Xcls_Label5 : Object
234 private NewBranch _this;
240 public Xcls_Label5(NewBranch _owner )
243 this.el = new Gtk.Label( "Ticket" );
247 // set gobject values
248 this.el.halign = Gtk.Align.START;
249 this.el.visible = true;
252 // user defined functions
255 public class Xcls_projectsel : Object
257 public Gtk.ComboBox el;
258 private NewBranch _this;
265 public Xcls_projectsel(NewBranch _owner )
268 _this.projectsel = this;
269 this.el = new Gtk.ComboBox.with_entry();
272 this.loading = false;
274 // set gobject values
275 var child_0 = new Xcls_prcellrenderer( _this );
277 this.el.pack_start ( child_0.el , true );
278 var child_1 = new Xcls_prmodel( _this );
280 this.el.set_model ( child_1.el );
284 this.el.set_entry_text_column(1);
287 this.el.changed.connect( () => {
291 var project_id = this.selectedProjectId();
292 _this.dbmodel.loadTickets(project_id);
295 /*if (this.loading) {
298 var ticket_id = this.selectedTicketId();
300 var name = RooTicket.singleton().usernameLocal();
302 if (ticket_id == "" || ticket_id == null) {
304 var dt = new DateTime.now_local();
305 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
310 var ticket = RooTicket.singleton().getById(ticket_id);
312 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
314 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
319 // user defined functions
320 public string selectedProjectId () {
325 this.el.get_active_iter (out iter);
326 _this.prmodel.el.get_value (iter, 0, out val1);
329 return (string) val1;
336 public class Xcls_prcellrenderer : Object
338 public Gtk.CellRendererText el;
339 private NewBranch _this;
345 public Xcls_prcellrenderer(NewBranch _owner )
348 _this.prcellrenderer = this;
349 this.el = new Gtk.CellRendererText();
353 // set gobject values
356 // user defined functions
359 public class Xcls_prmodel : Object
361 public Gtk.ListStore el;
362 private NewBranch _this;
368 public Xcls_prmodel(NewBranch _owner )
371 _this.prmodel = this;
372 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
376 // set gobject values
379 // user defined functions
380 public void loadProjects (string id) {
382 var rt = RooTicket.singleton();
385 _this.projectsel.loading = true;
394 el.set_value(iter, 0, "");
395 el.set_value(iter, 1, "-- select a project --");
397 _this.projectsel.el.set_active_iter(iter);
399 var projects = rt.projects;
400 foreach(var project in projects) {
404 el.set_value(iter, 0, project.id);
405 el.set_value(iter, 1, project.name );
406 if (id == project.id) {
407 _this.projectsel.el.set_active_iter(iter);
412 _this.projectsel.loading = false;
413 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
419 public class Xcls_ticketsel : Object
421 public Gtk.ComboBox el;
422 private NewBranch _this;
429 public Xcls_ticketsel(NewBranch _owner )
432 _this.ticketsel = this;
433 this.el = new Gtk.ComboBox.with_entry();
436 this.loading = false;
438 // set gobject values
439 var child_0 = new Xcls_dbcellrenderer( _this );
441 this.el.pack_start ( child_0.el , true );
442 var child_1 = new Xcls_dbmodel( _this );
444 this.el.set_model ( child_1.el );
448 //this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
449 this.el.set_entry_text_column(1);
452 this.el.changed.connect( () => {
456 var ticket_id = this.selectedTicketId();
458 var name = RooTicket.singleton().usernameLocal();
460 if (ticket_id == "" || ticket_id == null) {
462 var dt = new DateTime.now_local();
463 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
468 var ticket = RooTicket.singleton().getById(ticket_id);
470 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
472 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
476 // user defined functions
477 public string selectedTicketId () {
482 this.el.get_active_iter (out iter);
483 _this.dbmodel.el.get_value (iter, 0, out val1);
486 return (string) val1;
493 public class Xcls_dbcellrenderer : Object
495 public Gtk.CellRendererText el;
496 private NewBranch _this;
502 public Xcls_dbcellrenderer(NewBranch _owner )
505 _this.dbcellrenderer = this;
506 this.el = new Gtk.CellRendererText();
510 // set gobject values
513 // user defined functions
516 public class Xcls_dbmodel : Object
518 public Gtk.ListStore el;
519 private NewBranch _this;
525 public Xcls_dbmodel(NewBranch _owner )
528 _this.dbmodel = this;
529 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
533 // set gobject values
536 // user defined functions
537 public void loadTickets (string project_id) {
539 RooTicket.singleton().loadTickets(project_id);
541 _this.ticketsel.loading = true;
550 el.set_value(iter, 0, "");
551 el.set_value(iter, 1, "-- select a ticket --");
553 _this.ticketsel.el.set_active_iter(iter);
554 var tickets = RooTicket.singleton().tickets;
555 foreach(var ticket in tickets) {
559 el.set_value(iter, 0, ticket.id);
560 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
562 //if (data.get(i) == cur) {
563 // _this.build_module.el.set_active_iter(iter);
568 _this.ticketsel.loading = false;
569 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
575 public class Xcls_Button12 : Object
577 public Gtk.Button el;
578 private NewBranch _this;
584 public Xcls_Button12(NewBranch _owner )
587 this.el = new Gtk.Button();
591 // set gobject values
592 this.el.expand = false;
593 this.el.label = "New Ticket";
596 // user defined functions
599 public class Xcls_Label13 : Object
602 private NewBranch _this;
608 public Xcls_Label13(NewBranch _owner )
611 this.el = new Gtk.Label( "Use this as branch name" );
615 // set gobject values
616 this.el.halign = Gtk.Align.START;
617 this.el.justify = Gtk.Justification.RIGHT;
618 this.el.xalign = 0.900000f;
621 // user defined functions
624 public class Xcls_name : Object
627 private NewBranch _this;
633 public Xcls_name(NewBranch _owner )
637 this.el = new Gtk.Entry();
641 // set gobject values
642 this.el.visible = true;
645 // user defined functions
648 public class Xcls_Button15 : Object
650 public Gtk.Button el;
651 private NewBranch _this;
657 public Xcls_Button15(NewBranch _owner )
660 this.el = new Gtk.Button();
664 // set gobject values
665 this.el.label = "Create Branch";
670 this.el.get_style_context().add_class("suggested-action");
674 this.el.activate.connect( () => {
675 _this.el.response(1);
679 // user defined functions
682 public class Xcls_Box16 : Object
685 private NewBranch _this;
691 public Xcls_Box16(NewBranch _owner )
694 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
698 // set gobject values
699 var child_0 = new Xcls_CheckButton17( _this );
701 this.el.add ( child_0.el );
702 var child_1 = new Xcls_CheckButton18( _this );
704 this.el.add ( child_1.el );
705 var child_2 = new Xcls_Label19( _this );
707 this.el.add ( child_2.el );
710 // user defined functions
712 public class Xcls_CheckButton17 : Object
714 public Gtk.CheckButton el;
715 private NewBranch _this;
721 public Xcls_CheckButton17(NewBranch _owner )
724 this.el = new Gtk.CheckButton();
728 // set gobject values
729 this.el.label = "Show tickets not assigned to me";
732 this.el.activate.connect( () => {
733 var project_id = _this.projectsel.selectedProjectId();
734 _this.dbmodel.loadTickets(project_id);
738 // user defined functions
741 public class Xcls_CheckButton18 : Object
743 public Gtk.CheckButton el;
744 private NewBranch _this;
750 public Xcls_CheckButton18(NewBranch _owner )
753 this.el = new Gtk.CheckButton();
757 // set gobject values
758 this.el.label = "Show closed Tickets";
761 this.el.activate.connect( () => {
762 _this.dbmodel.loadTickets(curproj == null ? "": curproj.id);
767 // user defined functions
770 public class Xcls_Label19 : Object
773 private NewBranch _this;
779 public Xcls_Label19(NewBranch _owner )
782 this.el = new Gtk.Label( "<a href=\"refresh\">Refresh Ticket list</a>" );
786 // set gobject values
787 this.el.halign = Gtk.Align.END;
788 this.el.hexpand = true;
789 this.el.use_markup = true;
792 this.el.activate_link.connect( (uri) => {
793 if (uri == "refresh") {
794 var curproj = RooTicket.singleton().getProjectByRepo(_this.repo);
795 _this.prmodel.loadProjects(curproj == null ? "": curproj.id);
797 _this.dbmodel.loadTickets(curproj == null ? "": curproj.id);
803 // user defined functions