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);
129 var name = RooTicket.singleton().usernameLocal();
130 var ticket = RooTicket.singleton().getById(tid);
131 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
137 public class Xcls_VBox2 : Object
140 private NewBranch _this;
146 public Xcls_VBox2(NewBranch _owner )
149 this.el = new Gtk.VBox( true, 0 );
153 // set gobject values
154 var child_0 = new Xcls_Table3( _this );
156 this.el.pack_start ( child_0.el , false,false,0 );
159 // user defined functions
161 public class Xcls_Table3 : Object
164 private NewBranch _this;
170 public Xcls_Table3(NewBranch _owner )
173 this.el = new Gtk.Table( 5, 5, true );
177 // set gobject values
178 this.el.expand = false;
180 this.el.column_spacing = 4;
181 this.el.vexpand = false;
182 var child_0 = new Xcls_Label4( _this );
184 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
185 var child_1 = new Xcls_Label5( _this );
187 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
188 var child_2 = new Xcls_projectsel( _this );
190 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
191 var child_3 = new Xcls_ticketsel( _this );
193 this.el.attach_defaults ( child_3.el , 1,4,1,2 );
194 var child_4 = new Xcls_Button12( _this );
196 this.el.attach_defaults ( child_4.el , 4,5,1,2 );
197 var child_5 = new Xcls_Label13( _this );
199 this.el.attach_defaults ( child_5.el , 0,1,3,4 );
200 var child_6 = new Xcls_name( _this );
202 this.el.attach_defaults ( child_6.el , 0,4,4,5 );
203 var child_7 = new Xcls_Button15( _this );
205 this.el.attach_defaults ( child_7.el , 4,5,4,5 );
206 var child_8 = new Xcls_Box16( _this );
208 this.el.attach_defaults ( child_8.el , 0,5,2,3 );
211 // user defined functions
213 public class Xcls_Label4 : Object
216 private NewBranch _this;
222 public Xcls_Label4(NewBranch _owner )
225 this.el = new Gtk.Label( "Project" );
229 // set gobject values
230 this.el.halign = Gtk.Align.START;
231 this.el.justify = Gtk.Justification.RIGHT;
232 this.el.visible = true;
235 // user defined functions
238 public class Xcls_Label5 : Object
241 private NewBranch _this;
247 public Xcls_Label5(NewBranch _owner )
250 this.el = new Gtk.Label( "Ticket" );
254 // set gobject values
255 this.el.halign = Gtk.Align.START;
256 this.el.visible = true;
259 // user defined functions
262 public class Xcls_projectsel : Object
264 public Gtk.ComboBox el;
265 private NewBranch _this;
272 public Xcls_projectsel(NewBranch _owner )
275 _this.projectsel = this;
276 this.el = new Gtk.ComboBox.with_entry();
279 this.loading = false;
281 // set gobject values
282 var child_0 = new Xcls_prcellrenderer( _this );
284 this.el.pack_start ( child_0.el , true );
285 var child_1 = new Xcls_prmodel( _this );
287 this.el.set_model ( child_1.el );
291 this.el.set_entry_text_column(1);
294 this.el.changed.connect( () => {
298 var project_id = this.selectedProjectId();
299 _this.dbmodel.loadTickets(project_id);
302 /*if (this.loading) {
305 var ticket_id = this.selectedTicketId();
307 var name = RooTicket.singleton().usernameLocal();
309 if (ticket_id == "" || ticket_id == null) {
311 var dt = new DateTime.now_local();
312 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
317 var ticket = RooTicket.singleton().getById(ticket_id);
319 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
321 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
326 // user defined functions
327 public string selectedProjectId () {
332 this.el.get_active_iter (out iter);
333 _this.prmodel.el.get_value (iter, 0, out val1);
336 return (string) val1;
343 public class Xcls_prcellrenderer : Object
345 public Gtk.CellRendererText el;
346 private NewBranch _this;
352 public Xcls_prcellrenderer(NewBranch _owner )
355 _this.prcellrenderer = this;
356 this.el = new Gtk.CellRendererText();
360 // set gobject values
363 // user defined functions
366 public class Xcls_prmodel : Object
368 public Gtk.ListStore el;
369 private NewBranch _this;
375 public Xcls_prmodel(NewBranch _owner )
378 _this.prmodel = this;
379 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
383 // set gobject values
386 // user defined functions
387 public void loadProjects (string id) {
389 var rt = RooTicket.singleton();
392 _this.projectsel.loading = true;
401 el.set_value(iter, 0, "");
402 el.set_value(iter, 1, "-- select a project --");
404 _this.projectsel.el.set_active_iter(iter);
406 var projects = rt.projects;
407 foreach(var project in projects) {
411 el.set_value(iter, 0, project.id);
412 el.set_value(iter, 1, project.name );
413 if (id == project.id) {
414 _this.projectsel.el.set_active_iter(iter);
419 _this.projectsel.loading = false;
420 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
426 public class Xcls_ticketsel : Object
428 public Gtk.ComboBox el;
429 private NewBranch _this;
436 public Xcls_ticketsel(NewBranch _owner )
439 _this.ticketsel = this;
440 this.el = new Gtk.ComboBox.with_entry();
443 this.loading = false;
445 // set gobject values
446 var child_0 = new Xcls_dbcellrenderer( _this );
448 this.el.pack_start ( child_0.el , true );
449 var child_1 = new Xcls_dbmodel( _this );
451 this.el.set_model ( child_1.el );
455 //this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
456 this.el.set_entry_text_column(1);
459 this.el.changed.connect( () => {
463 var ticket_id = this.selectedTicketId();
465 var name = RooTicket.singleton().usernameLocal();
467 if (ticket_id == "" || ticket_id == null) {
469 var dt = new DateTime.now_local();
470 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
475 var ticket = RooTicket.singleton().getById(ticket_id);
477 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
479 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
483 // user defined functions
484 public string selectedTicketId () {
489 this.el.get_active_iter (out iter);
490 _this.dbmodel.el.get_value (iter, 0, out val1);
493 return (string) val1;
500 public class Xcls_dbcellrenderer : Object
502 public Gtk.CellRendererText el;
503 private NewBranch _this;
509 public Xcls_dbcellrenderer(NewBranch _owner )
512 _this.dbcellrenderer = this;
513 this.el = new Gtk.CellRendererText();
517 // set gobject values
520 // user defined functions
523 public class Xcls_dbmodel : Object
525 public Gtk.ListStore el;
526 private NewBranch _this;
532 public Xcls_dbmodel(NewBranch _owner )
535 _this.dbmodel = this;
536 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
540 // set gobject values
543 // user defined functions
544 public void loadTickets (string project_id , string tid = "") {
548 // fixme .. get project id from selection..
550 RooTicket.singleton().loadTickets(
552 _this.btn_not_me.el.active ? RooTicket.Who.ANYBODY : RooTicket.Who.ME,
553 _this.btn_closed.el.active ? RooTicket.Status.ALL : RooTicket.Status.ACTIVE
556 _this.ticketsel.loading = true;
565 el.set_value(iter, 0, "");
566 el.set_value(iter, 1, "-- select a ticket --");
568 _this.ticketsel.el.set_active_iter(iter);
569 var tickets = RooTicket.singleton().tickets;
570 foreach(var ticket in tickets) {
574 el.set_value(iter, 0, ticket.id);
575 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
577 if (ticket.id == tid) {
578 _this.ticketsel.el.set_active_iter(iter);
583 _this.ticketsel.loading = false;
584 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
590 public class Xcls_Button12 : Object
592 public Gtk.Button el;
593 private NewBranch _this;
599 public Xcls_Button12(NewBranch _owner )
602 this.el = new Gtk.Button();
606 // set gobject values
607 this.el.expand = false;
608 this.el.label = "New Ticket";
611 this.el.clicked.connect( () => {
612 _this.el.response(-1);
613 Ticket.singleton().show(_this.repo);
618 // user defined functions
621 public class Xcls_Label13 : Object
624 private NewBranch _this;
630 public Xcls_Label13(NewBranch _owner )
633 this.el = new Gtk.Label( "Use this as branch name" );
637 // set gobject values
638 this.el.halign = Gtk.Align.START;
639 this.el.justify = Gtk.Justification.RIGHT;
640 this.el.xalign = 0.900000f;
643 // user defined functions
646 public class Xcls_name : Object
649 private NewBranch _this;
655 public Xcls_name(NewBranch _owner )
659 this.el = new Gtk.Entry();
663 // set gobject values
664 this.el.visible = true;
667 // user defined functions
670 public class Xcls_Button15 : Object
672 public Gtk.Button el;
673 private NewBranch _this;
679 public Xcls_Button15(NewBranch _owner )
682 this.el = new Gtk.Button();
686 // set gobject values
687 this.el.label = "Create Branch";
692 this.el.get_style_context().add_class("suggested-action");
696 this.el.clicked.connect( () => {
697 GLib.debug("fire response = 1");
698 _this.el.response(1);
702 // user defined functions
705 public class Xcls_Box16 : Object
708 private NewBranch _this;
714 public Xcls_Box16(NewBranch _owner )
717 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
721 // set gobject values
722 var child_0 = new Xcls_btn_not_me( _this );
724 this.el.add ( child_0.el );
725 var child_1 = new Xcls_btn_closed( _this );
727 this.el.add ( child_1.el );
728 var child_2 = new Xcls_Label19( _this );
730 this.el.add ( child_2.el );
733 // user defined functions
735 public class Xcls_btn_not_me : Object
737 public Gtk.CheckButton el;
738 private NewBranch _this;
744 public Xcls_btn_not_me(NewBranch _owner )
747 _this.btn_not_me = this;
748 this.el = new Gtk.CheckButton();
752 // set gobject values
753 this.el.label = "Show tickets not assigned to me";
756 this.el.toggled.connect( () => {
757 var project_id = _this.projectsel.selectedProjectId();
758 _this.dbmodel.loadTickets(project_id);
762 // user defined functions
765 public class Xcls_btn_closed : Object
767 public Gtk.CheckButton el;
768 private NewBranch _this;
774 public Xcls_btn_closed(NewBranch _owner )
777 _this.btn_closed = this;
778 this.el = new Gtk.CheckButton();
782 // set gobject values
783 this.el.label = "Show closed Tickets";
786 this.el.toggled.connect( () => {
787 var project_id = _this.projectsel.selectedProjectId();
788 _this.dbmodel.loadTickets(project_id);
793 // user defined functions
796 public class Xcls_Label19 : Object
799 private NewBranch _this;
805 public Xcls_Label19(NewBranch _owner )
808 this.el = new Gtk.Label( "<a href=\"refresh\">Refresh Ticket list</a>" );
812 // set gobject values
813 this.el.halign = Gtk.Align.END;
814 this.el.hexpand = true;
815 this.el.use_markup = true;
818 this.el.activate_link.connect( (uri) => {
819 if (uri == "refresh") {
820 var curproj = RooTicket.singleton().getProjectByRepo(_this.repo);
821 _this.prmodel.loadProjects(curproj == null ? "": curproj.id);
823 _this.dbmodel.loadTickets(curproj == null ? "": curproj.id);
829 // user defined functions