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;
25 public Xcls_view view;
30 public Gee.ArrayList<GitMonitorQueue> queue;
36 this.el = new Gtk.Dialog();
44 this.el.title = "Create a working branch ";
45 this.el.default_height = 200;
46 this.el.default_width = 500;
47 this.el.deletable = true;
49 var child_0 = new Xcls_Box2( _this );
51 this.el.get_content_area().add ( child_0.el );
54 this.el.delete_event.connect( (self, event) => {
59 this.el.response.connect( (self, response_id) => {
61 GLib.debug("got %d", (int) response_id);
62 if (response_id < 1) {
68 // have they selected a ticket..
69 // make that the current active ticket?
70 // we really need to store locally what ticket is being worked on..
71 // in theory we could be working on multiple project and not merging..
72 // -- each repo would have their active ticket (only one per repo)
73 // -- so we could just store that in there
74 // -- initial load can check the contents of the ticket files on first scan.
75 var ticket_id = _this.ticketsel.selectedTicketId();
77 if (this.repo != null) {
78 var bn = _this.name.el.get_text();
80 var res = this.repo.setActiveTicket(
81 RooTicket.singleton().getById(ticket_id != "" ? ticket_id : "-1"), bn
84 // start the monitoring..
85 GitMonitor.gitmonitor.start();
101 // user defined functions
102 public void show ( GitRepo repo, Gee.ArrayList<GitMonitorQueue> queue, string tid = "" )
104 // this.el.set_gravity(Gdk.Gravity.NORTH);
105 if (this.running) { // should not happen!!
106 GLib.error("new branch show called, when already being displayed?");
111 GitMonitor.gitmonitor.stop();
117 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
118 this.el.set_default_size( 500,200); // not sure why it grows..
119 GLib.debug("Loading tickets");
123 this.el.set_keep_above(true);
126 var curproj = RooTicket.singleton().getProjectByRepo(this.repo);
127 _this.prmodel.loadProjects(curproj == null ? "" : curproj.id);
129 _this.dbmodel.loadTickets(curproj == null ? "": curproj.id, tid);
131 var name = RooTicket.singleton().usernameLocal();
132 var ticket = RooTicket.singleton().getById(tid);
133 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
139 public class Xcls_Box2 : Object
142 private NewBranch _this;
148 public Xcls_Box2(NewBranch _owner )
151 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
155 // set gobject values
156 var child_0 = new Xcls_Table3( _this );
158 this.el.pack_start ( child_0.el , false,false,0 );
159 var child_1 = new Xcls_scrolled_window( _this );
161 this.el.add ( child_1.el );
164 // user defined functions
166 public class Xcls_Table3 : Object
169 private NewBranch _this;
175 public Xcls_Table3(NewBranch _owner )
178 this.el = new Gtk.Table( 5, 5, true );
182 // set gobject values
183 this.el.expand = false;
185 this.el.column_spacing = 4;
186 this.el.vexpand = false;
187 var child_0 = new Xcls_Label4( _this );
189 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
190 var child_1 = new Xcls_Label5( _this );
192 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
193 var child_2 = new Xcls_projectsel( _this );
195 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
196 var child_3 = new Xcls_ticketsel( _this );
198 this.el.attach_defaults ( child_3.el , 1,4,1,2 );
199 var child_4 = new Xcls_Button12( _this );
201 this.el.attach_defaults ( child_4.el , 4,5,1,2 );
202 var child_5 = new Xcls_Label13( _this );
204 this.el.attach_defaults ( child_5.el , 0,1,3,4 );
205 var child_6 = new Xcls_name( _this );
207 this.el.attach_defaults ( child_6.el , 0,4,4,5 );
208 var child_7 = new Xcls_Button15( _this );
210 this.el.attach_defaults ( child_7.el , 4,5,4,5 );
211 var child_8 = new Xcls_Box16( _this );
213 this.el.attach_defaults ( child_8.el , 0,5,2,3 );
216 // user defined functions
218 public class Xcls_Label4 : Object
221 private NewBranch _this;
227 public Xcls_Label4(NewBranch _owner )
230 this.el = new Gtk.Label( "Project" );
234 // set gobject values
235 this.el.halign = Gtk.Align.START;
236 this.el.justify = Gtk.Justification.RIGHT;
237 this.el.visible = true;
240 // user defined functions
243 public class Xcls_Label5 : Object
246 private NewBranch _this;
252 public Xcls_Label5(NewBranch _owner )
255 this.el = new Gtk.Label( "Ticket" );
259 // set gobject values
260 this.el.halign = Gtk.Align.START;
261 this.el.visible = true;
264 // user defined functions
267 public class Xcls_projectsel : Object
269 public Gtk.ComboBox el;
270 private NewBranch _this;
277 public Xcls_projectsel(NewBranch _owner )
280 _this.projectsel = this;
281 this.el = new Gtk.ComboBox.with_entry();
284 this.loading = false;
286 // set gobject values
287 var child_0 = new Xcls_prcellrenderer( _this );
289 this.el.pack_start ( child_0.el , true );
290 var child_1 = new Xcls_prmodel( _this );
292 this.el.set_model ( child_1.el );
296 this.el.set_entry_text_column(1);
299 this.el.changed.connect( () => {
303 var project_id = this.selectedProjectId();
304 _this.dbmodel.loadTickets(project_id);
307 /*if (this.loading) {
310 var ticket_id = this.selectedTicketId();
312 var name = RooTicket.singleton().usernameLocal();
314 if (ticket_id == "" || ticket_id == null) {
316 var dt = new DateTime.now_local();
317 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
322 var ticket = RooTicket.singleton().getById(ticket_id);
324 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
326 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
331 // user defined functions
332 public string selectedProjectId () {
337 this.el.get_active_iter (out iter);
338 _this.prmodel.el.get_value (iter, 0, out val1);
341 return (string) val1;
348 public class Xcls_prcellrenderer : Object
350 public Gtk.CellRendererText el;
351 private NewBranch _this;
357 public Xcls_prcellrenderer(NewBranch _owner )
360 _this.prcellrenderer = this;
361 this.el = new Gtk.CellRendererText();
365 // set gobject values
368 // user defined functions
371 public class Xcls_prmodel : Object
373 public Gtk.ListStore el;
374 private NewBranch _this;
380 public Xcls_prmodel(NewBranch _owner )
383 _this.prmodel = this;
384 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
388 // set gobject values
391 // user defined functions
392 public void loadProjects (string id) {
394 var rt = RooTicket.singleton();
397 _this.projectsel.loading = true;
406 el.set_value(iter, 0, "");
407 el.set_value(iter, 1, "-- select a project --");
409 _this.projectsel.el.set_active_iter(iter);
411 var projects = rt.projects;
412 foreach(var project in projects) {
416 el.set_value(iter, 0, project.id);
417 el.set_value(iter, 1, project.name );
418 if (id == project.id) {
419 _this.projectsel.el.set_active_iter(iter);
424 _this.projectsel.loading = false;
425 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
431 public class Xcls_ticketsel : Object
433 public Gtk.ComboBox el;
434 private NewBranch _this;
441 public Xcls_ticketsel(NewBranch _owner )
444 _this.ticketsel = this;
445 this.el = new Gtk.ComboBox.with_entry();
448 this.loading = false;
450 // set gobject values
451 var child_0 = new Xcls_dbcellrenderer( _this );
453 this.el.pack_start ( child_0.el , true );
454 var child_1 = new Xcls_dbmodel( _this );
456 this.el.set_model ( child_1.el );
460 //this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
461 this.el.set_entry_text_column(1);
464 this.el.changed.connect( () => {
468 var ticket_id = this.selectedTicketId();
470 var name = RooTicket.singleton().usernameLocal();
472 if (ticket_id == "" || ticket_id == null) {
474 var dt = new DateTime.now_local();
475 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
480 var ticket = RooTicket.singleton().getById(ticket_id);
482 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
484 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
488 // user defined functions
489 public string selectedTicketId () {
494 this.el.get_active_iter (out iter);
495 _this.dbmodel.el.get_value (iter, 0, out val1);
498 return (string) val1;
505 public class Xcls_dbcellrenderer : Object
507 public Gtk.CellRendererText el;
508 private NewBranch _this;
514 public Xcls_dbcellrenderer(NewBranch _owner )
517 _this.dbcellrenderer = this;
518 this.el = new Gtk.CellRendererText();
522 // set gobject values
525 // user defined functions
528 public class Xcls_dbmodel : Object
530 public Gtk.ListStore el;
531 private NewBranch _this;
537 public Xcls_dbmodel(NewBranch _owner )
540 _this.dbmodel = this;
541 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
545 // set gobject values
548 // user defined functions
549 public void loadTickets (string project_id , string tid = "") {
553 // fixme .. get project id from selection..
555 RooTicket.singleton().loadTickets(
557 _this.btn_not_me.el.active ? RooTicket.Who.ANYBODY : RooTicket.Who.ME,
558 _this.btn_closed.el.active ? RooTicket.Status.ALL : RooTicket.Status.ACTIVE
561 _this.ticketsel.loading = true;
570 el.set_value(iter, 0, "");
571 el.set_value(iter, 1, "-- select a ticket --");
573 _this.ticketsel.el.set_active_iter(iter);
574 var tickets = RooTicket.singleton().tickets;
575 foreach(var ticket in tickets) {
579 el.set_value(iter, 0, ticket.id);
580 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
582 if (ticket.id == tid) {
583 _this.ticketsel.el.set_active_iter(iter);
588 _this.ticketsel.loading = false;
589 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
595 public class Xcls_Button12 : Object
597 public Gtk.Button el;
598 private NewBranch _this;
604 public Xcls_Button12(NewBranch _owner )
607 this.el = new Gtk.Button();
611 // set gobject values
612 this.el.expand = false;
613 this.el.label = "New Ticket";
616 this.el.clicked.connect( () => {
617 _this.el.response(-1);
618 Ticket.singleton().show(_this.repo);
623 // user defined functions
626 public class Xcls_Label13 : Object
629 private NewBranch _this;
635 public Xcls_Label13(NewBranch _owner )
638 this.el = new Gtk.Label( "Use this as branch name" );
642 // set gobject values
643 this.el.halign = Gtk.Align.START;
644 this.el.justify = Gtk.Justification.RIGHT;
645 this.el.xalign = 0.900000f;
648 // user defined functions
651 public class Xcls_name : Object
654 private NewBranch _this;
660 public Xcls_name(NewBranch _owner )
664 this.el = new Gtk.Entry();
668 // set gobject values
669 this.el.visible = true;
672 // user defined functions
675 public class Xcls_Button15 : Object
677 public Gtk.Button el;
678 private NewBranch _this;
684 public Xcls_Button15(NewBranch _owner )
687 this.el = new Gtk.Button();
691 // set gobject values
692 this.el.label = "Create Branch";
697 this.el.get_style_context().add_class("suggested-action");
701 this.el.clicked.connect( () => {
702 GLib.debug("fire response = 1");
703 _this.el.response(1);
707 // user defined functions
710 public class Xcls_Box16 : Object
713 private NewBranch _this;
719 public Xcls_Box16(NewBranch _owner )
722 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
726 // set gobject values
727 var child_0 = new Xcls_btn_not_me( _this );
729 this.el.add ( child_0.el );
730 var child_1 = new Xcls_btn_closed( _this );
732 this.el.add ( child_1.el );
733 var child_2 = new Xcls_Label19( _this );
735 this.el.add ( child_2.el );
738 // user defined functions
740 public class Xcls_btn_not_me : Object
742 public Gtk.CheckButton el;
743 private NewBranch _this;
749 public Xcls_btn_not_me(NewBranch _owner )
752 _this.btn_not_me = this;
753 this.el = new Gtk.CheckButton();
757 // set gobject values
758 this.el.label = "Show tickets not assigned to me";
761 this.el.toggled.connect( () => {
762 var project_id = _this.projectsel.selectedProjectId();
763 _this.dbmodel.loadTickets(project_id);
767 // user defined functions
770 public class Xcls_btn_closed : Object
772 public Gtk.CheckButton el;
773 private NewBranch _this;
779 public Xcls_btn_closed(NewBranch _owner )
782 _this.btn_closed = this;
783 this.el = new Gtk.CheckButton();
787 // set gobject values
788 this.el.label = "Show closed Tickets";
791 this.el.toggled.connect( () => {
792 var project_id = _this.projectsel.selectedProjectId();
793 _this.dbmodel.loadTickets(project_id);
798 // user defined functions
801 public class Xcls_Label19 : Object
804 private NewBranch _this;
810 public Xcls_Label19(NewBranch _owner )
813 this.el = new Gtk.Label( "<a href=\"refresh\">Refresh Ticket list</a>" );
817 // set gobject values
818 this.el.halign = Gtk.Align.END;
819 this.el.hexpand = true;
820 this.el.use_markup = true;
823 this.el.activate_link.connect( (uri) => {
824 if (uri == "refresh") {
825 var curproj = RooTicket.singleton().getProjectByRepo(_this.repo);
826 _this.prmodel.loadProjects(curproj == null ? "": curproj.id);
828 _this.dbmodel.loadTickets(curproj == null ? "": curproj.id);
834 // user defined functions
839 public class Xcls_scrolled_window : Object
841 public Gtk.ScrolledWindow el;
842 private NewBranch _this;
848 public Xcls_scrolled_window(NewBranch _owner )
851 _this.scrolled_window = this;
852 this.el = new Gtk.ScrolledWindow( null, null );
856 // set gobject values
857 var child_0 = new Xcls_view( _this );
859 this.el.add ( child_0.el );
864 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
868 // user defined functions
870 public class Xcls_view : Object
872 public WebKit.WebView el;
873 private NewBranch _this;
879 public Xcls_view(NewBranch _owner )
883 this.el = new WebKit.WebView();
888 // user defined functions