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;
24 public Xcls_scrolled_window scrolled_window;
29 public Gee.ArrayList<GitMonitorQueue> queue;
35 this.el = new Gtk.Dialog();
43 this.el.title = "Create a working branch ";
44 this.el.default_height = 200;
45 this.el.default_width = 500;
46 this.el.deletable = true;
48 var child_0 = new Xcls_Box2( _this );
50 this.el.get_content_area().add ( child_0.el );
53 this.el.delete_event.connect( (self, event) => {
58 this.el.response.connect( (self, response_id) => {
60 GLib.debug("got %d", (int) response_id);
61 if (response_id < 1) {
67 // have they selected a ticket..
68 // make that the current active ticket?
69 // we really need to store locally what ticket is being worked on..
70 // in theory we could be working on multiple project and not merging..
71 // -- each repo would have their active ticket (only one per repo)
72 // -- so we could just store that in there
73 // -- initial load can check the contents of the ticket files on first scan.
74 var ticket_id = _this.ticketsel.selectedTicketId();
76 if (this.repo != null) {
77 var bn = _this.name.el.get_text();
79 var res = this.repo.setActiveTicket(
80 RooTicket.singleton().getById(ticket_id != "" ? ticket_id : "-1"), bn
83 // start the monitoring..
84 GitMonitor.gitmonitor.start();
100 // user defined functions
101 public void show ( GitRepo repo, Gee.ArrayList<GitMonitorQueue> queue, string tid = "" )
103 // this.el.set_gravity(Gdk.Gravity.NORTH);
104 if (this.running) { // should not happen!!
105 GLib.error("new branch show called, when already being displayed?");
110 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, tid);
130 var name = RooTicket.singleton().usernameLocal();
131 var ticket = RooTicket.singleton().getById(tid);
132 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
138 public class Xcls_Box2 : Object
141 private NewBranch _this;
147 public Xcls_Box2(NewBranch _owner )
150 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
154 // set gobject values
155 var child_0 = new Xcls_Table3( _this );
157 this.el.pack_start ( child_0.el , false,false,0 );
158 var child_1 = new Xcls_scrolled_window( _this );
160 this.el.add ( child_1.el );
163 // user defined functions
165 public class Xcls_Table3 : Object
168 private NewBranch _this;
174 public Xcls_Table3(NewBranch _owner )
177 this.el = new Gtk.Table( 5, 5, true );
181 // set gobject values
182 this.el.expand = false;
184 this.el.column_spacing = 4;
185 this.el.vexpand = false;
186 var child_0 = new Xcls_Label4( _this );
188 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
189 var child_1 = new Xcls_Label5( _this );
191 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
192 var child_2 = new Xcls_projectsel( _this );
194 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
195 var child_3 = new Xcls_ticketsel( _this );
197 this.el.attach_defaults ( child_3.el , 1,4,1,2 );
198 var child_4 = new Xcls_Button12( _this );
200 this.el.attach_defaults ( child_4.el , 4,5,1,2 );
201 var child_5 = new Xcls_Label13( _this );
203 this.el.attach_defaults ( child_5.el , 0,1,3,4 );
204 var child_6 = new Xcls_name( _this );
206 this.el.attach_defaults ( child_6.el , 0,4,4,5 );
207 var child_7 = new Xcls_Button15( _this );
209 this.el.attach_defaults ( child_7.el , 4,5,4,5 );
210 var child_8 = new Xcls_Box16( _this );
212 this.el.attach_defaults ( child_8.el , 0,5,2,3 );
215 // user defined functions
217 public class Xcls_Label4 : Object
220 private NewBranch _this;
226 public Xcls_Label4(NewBranch _owner )
229 this.el = new Gtk.Label( "Project" );
233 // set gobject values
234 this.el.halign = Gtk.Align.START;
235 this.el.justify = Gtk.Justification.RIGHT;
236 this.el.visible = true;
239 // user defined functions
242 public class Xcls_Label5 : Object
245 private NewBranch _this;
251 public Xcls_Label5(NewBranch _owner )
254 this.el = new Gtk.Label( "Ticket" );
258 // set gobject values
259 this.el.halign = Gtk.Align.START;
260 this.el.visible = true;
263 // user defined functions
266 public class Xcls_projectsel : Object
268 public Gtk.ComboBox el;
269 private NewBranch _this;
276 public Xcls_projectsel(NewBranch _owner )
279 _this.projectsel = this;
280 this.el = new Gtk.ComboBox.with_entry();
283 this.loading = false;
285 // set gobject values
286 var child_0 = new Xcls_prcellrenderer( _this );
288 this.el.pack_start ( child_0.el , true );
289 var child_1 = new Xcls_prmodel( _this );
291 this.el.set_model ( child_1.el );
295 this.el.set_entry_text_column(1);
298 this.el.changed.connect( () => {
302 var project_id = this.selectedProjectId();
303 _this.dbmodel.loadTickets(project_id);
306 /*if (this.loading) {
309 var ticket_id = this.selectedTicketId();
311 var name = RooTicket.singleton().usernameLocal();
313 if (ticket_id == "" || ticket_id == null) {
315 var dt = new DateTime.now_local();
316 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
321 var ticket = RooTicket.singleton().getById(ticket_id);
323 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
325 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
330 // user defined functions
331 public string selectedProjectId () {
336 this.el.get_active_iter (out iter);
337 _this.prmodel.el.get_value (iter, 0, out val1);
340 return (string) val1;
347 public class Xcls_prcellrenderer : Object
349 public Gtk.CellRendererText el;
350 private NewBranch _this;
356 public Xcls_prcellrenderer(NewBranch _owner )
359 _this.prcellrenderer = this;
360 this.el = new Gtk.CellRendererText();
364 // set gobject values
367 // user defined functions
370 public class Xcls_prmodel : Object
372 public Gtk.ListStore el;
373 private NewBranch _this;
379 public Xcls_prmodel(NewBranch _owner )
382 _this.prmodel = this;
383 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
387 // set gobject values
390 // user defined functions
391 public void loadProjects (string id) {
393 var rt = RooTicket.singleton();
396 _this.projectsel.loading = true;
405 el.set_value(iter, 0, "");
406 el.set_value(iter, 1, "-- select a project --");
408 _this.projectsel.el.set_active_iter(iter);
410 var projects = rt.projects;
411 foreach(var project in projects) {
415 el.set_value(iter, 0, project.id);
416 el.set_value(iter, 1, project.name );
417 if (id == project.id) {
418 _this.projectsel.el.set_active_iter(iter);
423 _this.projectsel.loading = false;
424 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
430 public class Xcls_ticketsel : Object
432 public Gtk.ComboBox el;
433 private NewBranch _this;
440 public Xcls_ticketsel(NewBranch _owner )
443 _this.ticketsel = this;
444 this.el = new Gtk.ComboBox.with_entry();
447 this.loading = false;
449 // set gobject values
450 var child_0 = new Xcls_dbcellrenderer( _this );
452 this.el.pack_start ( child_0.el , true );
453 var child_1 = new Xcls_dbmodel( _this );
455 this.el.set_model ( child_1.el );
459 //this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
460 this.el.set_entry_text_column(1);
463 this.el.changed.connect( () => {
467 var ticket_id = this.selectedTicketId();
469 var name = RooTicket.singleton().usernameLocal();
471 if (ticket_id == "" || ticket_id == null) {
473 var dt = new DateTime.now_local();
474 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
479 var ticket = RooTicket.singleton().getById(ticket_id);
481 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
483 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
487 // user defined functions
488 public string selectedTicketId () {
493 this.el.get_active_iter (out iter);
494 _this.dbmodel.el.get_value (iter, 0, out val1);
497 return (string) val1;
504 public class Xcls_dbcellrenderer : Object
506 public Gtk.CellRendererText el;
507 private NewBranch _this;
513 public Xcls_dbcellrenderer(NewBranch _owner )
516 _this.dbcellrenderer = this;
517 this.el = new Gtk.CellRendererText();
521 // set gobject values
524 // user defined functions
527 public class Xcls_dbmodel : Object
529 public Gtk.ListStore el;
530 private NewBranch _this;
536 public Xcls_dbmodel(NewBranch _owner )
539 _this.dbmodel = this;
540 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
544 // set gobject values
547 // user defined functions
548 public void loadTickets (string project_id , string tid = "") {
552 // fixme .. get project id from selection..
554 RooTicket.singleton().loadTickets(
556 _this.btn_not_me.el.active ? RooTicket.Who.ANYBODY : RooTicket.Who.ME,
557 _this.btn_closed.el.active ? RooTicket.Status.ALL : RooTicket.Status.ACTIVE
560 _this.ticketsel.loading = true;
569 el.set_value(iter, 0, "");
570 el.set_value(iter, 1, "-- select a ticket --");
572 _this.ticketsel.el.set_active_iter(iter);
573 var tickets = RooTicket.singleton().tickets;
574 foreach(var ticket in tickets) {
578 el.set_value(iter, 0, ticket.id);
579 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
581 if (ticket.id == tid) {
582 _this.ticketsel.el.set_active_iter(iter);
587 _this.ticketsel.loading = false;
588 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
594 public class Xcls_Button12 : Object
596 public Gtk.Button el;
597 private NewBranch _this;
603 public Xcls_Button12(NewBranch _owner )
606 this.el = new Gtk.Button();
610 // set gobject values
611 this.el.expand = false;
612 this.el.label = "New Ticket";
615 this.el.clicked.connect( () => {
616 _this.el.response(-1);
617 Ticket.singleton().show(_this.repo);
622 // user defined functions
625 public class Xcls_Label13 : Object
628 private NewBranch _this;
634 public Xcls_Label13(NewBranch _owner )
637 this.el = new Gtk.Label( "Use this as branch name" );
641 // set gobject values
642 this.el.halign = Gtk.Align.START;
643 this.el.justify = Gtk.Justification.RIGHT;
644 this.el.xalign = 0.900000f;
647 // user defined functions
650 public class Xcls_name : Object
653 private NewBranch _this;
659 public Xcls_name(NewBranch _owner )
663 this.el = new Gtk.Entry();
667 // set gobject values
668 this.el.visible = true;
671 // user defined functions
674 public class Xcls_Button15 : Object
676 public Gtk.Button el;
677 private NewBranch _this;
683 public Xcls_Button15(NewBranch _owner )
686 this.el = new Gtk.Button();
690 // set gobject values
691 this.el.label = "Create Branch";
696 this.el.get_style_context().add_class("suggested-action");
700 this.el.clicked.connect( () => {
701 GLib.debug("fire response = 1");
702 _this.el.response(1);
706 // user defined functions
709 public class Xcls_Box16 : Object
712 private NewBranch _this;
718 public Xcls_Box16(NewBranch _owner )
721 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
725 // set gobject values
726 var child_0 = new Xcls_btn_not_me( _this );
728 this.el.add ( child_0.el );
729 var child_1 = new Xcls_btn_closed( _this );
731 this.el.add ( child_1.el );
732 var child_2 = new Xcls_Label19( _this );
734 this.el.add ( child_2.el );
737 // user defined functions
739 public class Xcls_btn_not_me : Object
741 public Gtk.CheckButton el;
742 private NewBranch _this;
748 public Xcls_btn_not_me(NewBranch _owner )
751 _this.btn_not_me = this;
752 this.el = new Gtk.CheckButton();
756 // set gobject values
757 this.el.label = "Show tickets not assigned to me";
760 this.el.toggled.connect( () => {
761 var project_id = _this.projectsel.selectedProjectId();
762 _this.dbmodel.loadTickets(project_id);
766 // user defined functions
769 public class Xcls_btn_closed : Object
771 public Gtk.CheckButton el;
772 private NewBranch _this;
778 public Xcls_btn_closed(NewBranch _owner )
781 _this.btn_closed = this;
782 this.el = new Gtk.CheckButton();
786 // set gobject values
787 this.el.label = "Show closed Tickets";
790 this.el.toggled.connect( () => {
791 var project_id = _this.projectsel.selectedProjectId();
792 _this.dbmodel.loadTickets(project_id);
797 // user defined functions
800 public class Xcls_Label19 : Object
803 private NewBranch _this;
809 public Xcls_Label19(NewBranch _owner )
812 this.el = new Gtk.Label( "<a href=\"refresh\">Refresh Ticket list</a>" );
816 // set gobject values
817 this.el.halign = Gtk.Align.END;
818 this.el.hexpand = true;
819 this.el.use_markup = true;
822 this.el.activate_link.connect( (uri) => {
823 if (uri == "refresh") {
824 var curproj = RooTicket.singleton().getProjectByRepo(_this.repo);
825 _this.prmodel.loadProjects(curproj == null ? "": curproj.id);
827 _this.dbmodel.loadTickets(curproj == null ? "": curproj.id);
833 // user defined functions
838 public class Xcls_scrolled_window : Object
840 public Gtk.ScrolledWindow el;
841 private NewBranch _this;
847 public Xcls_scrolled_window(NewBranch _owner )
850 _this.scrolled_window = this;
851 this.el = new Gtk.ScrolledWindow( null, null );
855 // set gobject values
856 var child_0 = new Xcls_WebView21( _this );
858 this.el.add ( child_0.el );
863 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
867 // user defined functions
869 public class Xcls_WebView21 : Object
871 public WebKit.WebView el;
872 private NewBranch _this;
878 public Xcls_WebView21(NewBranch _owner )
881 this.el = new WebKit.WebView();
893 // user defined functions