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_notebook notebook;
16 public Xcls_label_select_ticket label_select_ticket;
17 public Xcls_label_create_ticket label_create_ticket;
18 public Xcls_label_quick_commit label_quick_commit;
19 public Xcls_select_ticket_tab select_ticket_tab;
20 public Xcls_branch_table branch_table;
21 public Xcls_projectsel projectsel;
22 public Xcls_prcellrenderer prcellrenderer;
23 public Xcls_prmodel prmodel;
24 public Xcls_ticketsel ticketsel;
25 public Xcls_dbcellrenderer dbcellrenderer;
26 public Xcls_dbmodel dbmodel;
27 public Xcls_name name;
28 public Xcls_branchbtn branchbtn;
29 public Xcls_btn_not_me btn_not_me;
30 public Xcls_btn_closed btn_closed;
31 public Xcls_scrolled_window scrolled_window;
32 public Xcls_view view;
33 public Xcls_branch_spinner branch_spinner;
34 public Xcls_create_ticket_tab create_ticket_tab;
35 public Xcls_table table;
36 public Xcls_project_id project_id;
37 public Xcls_tprcellrenderer tprcellrenderer;
38 public Xcls_tprmodel tprmodel;
39 public Xcls_summary summary;
40 public Xcls_milestone_id milestone_id;
41 public Xcls_msmodel msmodel;
42 public Xcls_description description;
43 public Xcls_priority_id priority_id;
44 public Xcls_primodel primodel;
45 public Xcls_severity_id severity_id;
46 public Xcls_sevmodel sevmodel;
47 public Xcls_classification_id classification_id;
48 public Xcls_clmodel clmodel;
49 public Xcls_developer_id developer_id;
50 public Xcls_devmodel devmodel;
51 public Xcls_quick_commit_tab quick_commit_tab;
52 public Xcls_commit_message commit_message;
53 public Xcls_createbtn createbtn;
54 public Xcls_diff_sv diff_sv;
55 public Xcls_diff_view diff_view;
60 public Gee.ArrayList<GitMonitorQueue> queue;
66 this.el = new Gtk.Dialog();
74 this.el.title = "Create a working branch ";
75 this.el.default_height = 500;
76 this.el.default_width = 500;
77 this.el.deletable = true;
79 var child_0 = new Xcls_notebook( _this );
81 this.el.get_content_area().add ( child_0.el );
84 this.el.delete_event.connect( (self, event) => {
89 this.el.response.connect( (self, response_id) => {
91 GLib.debug("got %d", (int) response_id);
96 // have they selected a ticket..
97 // make that the current active ticket?
98 // we really need to store locally what ticket is being worked on..
99 // in theory we could be working on multiple project and not merging..
100 // -- each repo would have their active ticket (only one per repo)
101 // -- so we could just store that in there
102 // -- initial load can check the contents of the ticket files on first scan.
105 if (response_id < 1) {
107 this.running = false;
108 GitMonitor.gitmonitor.start();
113 switch(response_id) {
117 var ticket_id = _this.ticketsel.selectedTicketId();
119 if (this.repo != null) {
120 var bn = _this.name.el.get_text();
122 var res = this.repo.setActiveTicket(
123 RooTicket.singleton().getById(ticket_id != "" ? ticket_id : "-1"), bn
126 // start the monitoring..
127 GitMonitor.gitmonitor.start();
132 case 2: // create ticket + branch
134 var tid = RooTicket.singleton().createTicket(
136 _this.project_id.selectedProjectId(),
138 _this.milestone_id.selectedMilestoneId(),
139 _this.priority_id.selectedPriorityId() ,
140 _this.severity_id.selectedSeverityId() ,
141 _this.classification_id.selectedClassificationId() ,
142 _this.developer_id.selectedDeveloperId(),
143 _this.summary.el.get_text() ,
144 _this.description.el.buffer.text
146 var ticket = RooTicket.singleton().getById(tid);
147 var name = RooTicket.singleton().usernameLocal();
148 var bn = "wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName());
151 var res = this.repo.setActiveTicket( ticket, bn );
153 // start the monitoring..
154 GitMonitor.gitmonitor.start();
162 case 3: // just commit...
163 _this.repo.git({ "commit" , "-a" ,"-m", _this.commit_message.el.get_text() });
165 _this.repo.loadBranches();
166 _this.repo.loadStatus();
167 GitMonitor.gitmonitor.start();
172 this.running = false;
182 // user defined functions
183 public void show ( GitRepo repo, Gee.ArrayList<GitMonitorQueue> queue, string tid = "" )
185 // this.el.set_gravity(Gdk.Gravity.NORTH);
186 if (this.running) { // should not happen!!
187 GLib.error("new branch show called, when already being displayed?");
193 GitMonitor.gitmonitor.stop();
204 _this.table.el.hide(); // hide ticket layout
205 _this.diff_sv.el.hide();
206 _this.el.resize( 500,100);
208 this.el.set_keep_above(true);
210 _this.notebook.el.set_current_page(0);
212 _this.select_ticket_tab.load_data(tid);
213 _this.create_ticket_tab.load_data();
214 //_this.quick_commit_tab.load_data();
215 _this.commit_message.el.set_text("");
216 _this.diff_view.el.get_buffer().set_text( this.repo.diffWorking() );
219 this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
220 this.el.resize( 500,100); // not sure why it grows..
227 public class Xcls_notebook : Object
229 public Gtk.Notebook el;
230 private NewBranch _this;
236 public Xcls_notebook(NewBranch _owner )
239 _this.notebook = this;
240 this.el = new Gtk.Notebook();
244 // set gobject values
245 this.el.vexpand = true;
246 var child_0 = new Xcls_label_select_ticket( _this );
248 var child_1 = new Xcls_label_create_ticket( _this );
250 var child_2 = new Xcls_label_quick_commit( _this );
252 var child_3 = new Xcls_select_ticket_tab( _this );
254 this.el.append_page ( child_3.el , _this.label_select_ticket.el );
255 var child_4 = new Xcls_create_ticket_tab( _this );
257 this.el.append_page ( child_4.el , _this.label_create_ticket.el );
258 var child_5 = new Xcls_quick_commit_tab( _this );
260 this.el.append_page ( child_5.el , _this.label_quick_commit.el );
263 this.el.switch_page.connect( (page, page_num) => {
264 GLib.debug("Switch to page: %d", (int)page_num);
267 _this.table.el.hide(); // hide ticket layout
268 _this.diff_sv.el.hide();
269 _this.el.resize( 500,100);
270 break; // do nothing.. it's already loaded at start.
272 _this.diff_sv.el.hide();
273 _this.table.el.show();
274 _this.el.resize( 500,100);
275 // _this.create_ticket_tab.load_data();
278 _this.quick_commit_tab.load_data();
279 _this.diff_sv.el.show();
280 _this.el.resize( 500,100);
288 // user defined functions
290 public class Xcls_label_select_ticket : Object
293 private NewBranch _this;
299 public Xcls_label_select_ticket(NewBranch _owner )
302 _this.label_select_ticket = this;
303 this.el = new Gtk.Label( "Select Existing Ticket to work on" );
307 // set gobject values
310 // user defined functions
313 public class Xcls_label_create_ticket : Object
316 private NewBranch _this;
322 public Xcls_label_create_ticket(NewBranch _owner )
325 _this.label_create_ticket = this;
326 this.el = new Gtk.Label( "Create a New Ticket" );
330 // set gobject values
333 // user defined functions
336 public class Xcls_label_quick_commit : Object
339 private NewBranch _this;
345 public Xcls_label_quick_commit(NewBranch _owner )
348 _this.label_quick_commit = this;
349 this.el = new Gtk.Label( "Quick Commit" );
353 // set gobject values
356 // user defined functions
359 public class Xcls_select_ticket_tab : Object
362 private NewBranch _this;
368 public Xcls_select_ticket_tab(NewBranch _owner )
371 _this.select_ticket_tab = this;
372 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
376 // set gobject values
377 this.el.homogeneous = false;
378 var child_0 = new Xcls_branch_table( _this );
380 this.el.pack_start ( child_0.el , false,false,0 );
381 var child_1 = new Xcls_scrolled_window( _this );
383 this.el.add ( child_1.el );
384 var child_2 = new Xcls_branch_spinner( _this );
386 this.el.add ( child_2.el );
389 // user defined functions
390 public void load_data (string tid = "") {
393 _this.branch_table.el.hide();
394 _this.scrolled_window.el.hide();
395 _this.branch_spinner.el.show();
396 _this.branch_spinner.el.start();
397 _this.el.resize( 500,100);
398 Timeout.add(200, () => {
401 GLib.debug("Loading tickets");
403 var curproj = RooProject.getProjectByRepo(_this.repo);
404 _this.prmodel.loadProjects(curproj == null ? "" : curproj.id);
406 _this.dbmodel.loadTickets(curproj == null ? "": curproj.id, tid);
407 _this.branchbtn.updateState();
409 _this.ticketsel.el.get_child().get_style_context().remove_class("warning");
411 var name = RooTicket.singleton().usernameLocal();
412 var ticket = RooTicket.singleton().getById(tid);
413 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
415 _this.ticketsel.el.get_child().get_style_context().add_class("warning");
417 _this.view.loadTicket(tid);
418 _this.branch_table.el.show();
419 _this.branch_spinner.el.stop();
420 _this.branch_spinner.el.hide();
421 _this.el.resize( 500,100);
427 public class Xcls_branch_table : Object
430 private NewBranch _this;
436 public Xcls_branch_table(NewBranch _owner )
439 _this.branch_table = this;
440 this.el = new Gtk.Table( 5, 5, true );
444 // set gobject values
445 this.el.expand = false;
447 this.el.column_spacing = 4;
448 this.el.vexpand = false;
449 var child_0 = new Xcls_Label8( _this );
451 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
452 var child_1 = new Xcls_Label9( _this );
454 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
455 var child_2 = new Xcls_projectsel( _this );
457 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
458 var child_3 = new Xcls_ticketsel( _this );
460 this.el.attach_defaults ( child_3.el , 1,5,1,2 );
461 var child_4 = new Xcls_Label16( _this );
463 this.el.attach_defaults ( child_4.el , 0,1,3,4 );
464 var child_5 = new Xcls_name( _this );
466 this.el.attach_defaults ( child_5.el , 0,4,4,5 );
467 var child_6 = new Xcls_branchbtn( _this );
469 this.el.attach_defaults ( child_6.el , 4,5,4,5 );
470 var child_7 = new Xcls_Box19( _this );
472 this.el.attach_defaults ( child_7.el , 0,5,2,3 );
475 // user defined functions
477 public class Xcls_Label8 : Object
480 private NewBranch _this;
486 public Xcls_Label8(NewBranch _owner )
489 this.el = new Gtk.Label( "Project" );
493 // set gobject values
494 this.el.halign = Gtk.Align.START;
495 this.el.justify = Gtk.Justification.RIGHT;
496 this.el.visible = true;
499 // user defined functions
502 public class Xcls_Label9 : Object
505 private NewBranch _this;
511 public Xcls_Label9(NewBranch _owner )
514 this.el = new Gtk.Label( "Ticket" );
518 // set gobject values
519 this.el.halign = Gtk.Align.START;
520 this.el.visible = true;
523 // user defined functions
526 public class Xcls_projectsel : Object
528 public Gtk.ComboBox el;
529 private NewBranch _this;
536 public Xcls_projectsel(NewBranch _owner )
539 _this.projectsel = this;
540 this.el = new Gtk.ComboBox.with_entry();
543 this.loading = false;
545 // set gobject values
546 var child_0 = new Xcls_prcellrenderer( _this );
548 this.el.pack_start ( child_0.el , true );
549 var child_1 = new Xcls_prmodel( _this );
551 this.el.set_model ( child_1.el );
555 this.el.set_entry_text_column(1);
558 this.el.changed.connect( () => {
562 var project_id = this.selectedProjectId();
563 _this.dbmodel.loadTickets(project_id);
566 /*if (this.loading) {
569 var ticket_id = this.selectedTicketId();
571 var name = RooTicket.singleton().usernameLocal();
573 if (ticket_id == "" || ticket_id == null) {
575 var dt = new DateTime.now_local();
576 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
581 var ticket = RooTicket.singleton().getById(ticket_id);
583 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
585 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
590 // user defined functions
591 public string selectedProjectId () {
596 this.el.get_active_iter (out iter);
597 _this.prmodel.el.get_value (iter, 0, out val1);
600 return (string) val1;
607 public class Xcls_prcellrenderer : Object
609 public Gtk.CellRendererText el;
610 private NewBranch _this;
616 public Xcls_prcellrenderer(NewBranch _owner )
619 _this.prcellrenderer = this;
620 this.el = new Gtk.CellRendererText();
624 // set gobject values
627 // user defined functions
630 public class Xcls_prmodel : Object
632 public Gtk.ListStore el;
633 private NewBranch _this;
639 public Xcls_prmodel(NewBranch _owner )
642 _this.prmodel = this;
643 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
647 // set gobject values
650 // user defined functions
651 public void loadProjects (string id) {
655 _this.projectsel.loading = true;
664 el.set_value(iter, 0, "");
665 el.set_value(iter, 1, "-- select a project --");
667 _this.projectsel.el.set_active_iter(iter);
670 foreach(var project in RooProject.projects()) {
674 el.set_value(iter, 0, project.id);
675 el.set_value(iter, 1, project.name );
676 if (id == project.id) {
677 _this.projectsel.el.set_active_iter(iter);
682 _this.projectsel.loading = false;
683 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
689 public class Xcls_ticketsel : Object
691 public Gtk.ComboBox el;
692 private NewBranch _this;
699 public Xcls_ticketsel(NewBranch _owner )
702 _this.ticketsel = this;
703 this.el = new Gtk.ComboBox.with_entry();
706 this.loading = false;
708 // set gobject values
709 var child_0 = new Xcls_dbcellrenderer( _this );
711 this.el.pack_start ( child_0.el , true );
712 var child_1 = new Xcls_dbmodel( _this );
714 this.el.set_model ( child_1.el );
718 //this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
719 this.el.set_entry_text_column(1);
720 this.el.get_child().set_sensitive(false);
723 this.el.changed.connect( () => {
727 var ticket_id = this.selectedTicketId();
729 var name = RooTicket.singleton().usernameLocal();
731 this.el.get_child().get_style_context().remove_class("warning");
732 if (ticket_id == "" || ticket_id == null) {
734 var dt = new DateTime.now_local();
735 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
736 _this.view.loadTicket("");
738 this.el.get_child().get_style_context().add_class("warning");
739 _this.createbtn.updateState();
744 var ticket = RooTicket.singleton().getById(ticket_id);
746 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
747 _this.scrolled_window.el.show();
749 _this.view.loadTicket(ticket.id);
750 _this.branchbtn.updateState();
752 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
756 // user defined functions
757 public string selectedTicketId () {
762 this.el.get_active_iter (out iter);
763 _this.dbmodel.el.get_value (iter, 0, out val1);
766 return (string) val1;
773 public class Xcls_dbcellrenderer : Object
775 public Gtk.CellRendererText el;
776 private NewBranch _this;
782 public Xcls_dbcellrenderer(NewBranch _owner )
785 _this.dbcellrenderer = this;
786 this.el = new Gtk.CellRendererText();
790 // set gobject values
793 // user defined functions
796 public class Xcls_dbmodel : Object
798 public Gtk.ListStore el;
799 private NewBranch _this;
805 public Xcls_dbmodel(NewBranch _owner )
808 _this.dbmodel = this;
809 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
813 // set gobject values
816 // user defined functions
817 public void loadTickets (string project_id , string tid = "") {
821 // fixme .. get project id from selection..
823 RooTicket.singleton().loadTickets(
825 _this.btn_not_me.el.active ? RooTicket.Who.ANYBODY : RooTicket.Who.ME,
826 _this.btn_closed.el.active ? RooTicket.Status.ALL : RooTicket.Status.ACTIVE
829 _this.ticketsel.loading = true;
838 el.set_value(iter, 0, "");
839 el.set_value(iter, 1, "-- select a ticket --");
841 _this.ticketsel.el.set_active_iter(iter);
842 var tickets = RooTicket.singleton().tickets;
843 foreach(var ticket in tickets) {
847 el.set_value(iter, 0, ticket.id);
848 el.set_value(iter, 1, "#%s %s".printf( ticket.id, ticket.summary));
850 if (ticket.id == tid) {
851 _this.ticketsel.el.set_active_iter(iter);
856 _this.ticketsel.loading = false;
857 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
863 public class Xcls_Label16 : Object
866 private NewBranch _this;
872 public Xcls_Label16(NewBranch _owner )
875 this.el = new Gtk.Label( "Use this as branch name" );
879 // set gobject values
880 this.el.halign = Gtk.Align.START;
881 this.el.justify = Gtk.Justification.RIGHT;
882 this.el.xalign = 0.900000f;
885 // user defined functions
888 public class Xcls_name : Object
891 private NewBranch _this;
897 public Xcls_name(NewBranch _owner )
901 this.el = new Gtk.Entry();
905 // set gobject values
906 this.el.visible = true;
909 // user defined functions
912 public class Xcls_branchbtn : Object
914 public Gtk.Button el;
915 private NewBranch _this;
921 public Xcls_branchbtn(NewBranch _owner )
924 _this.branchbtn = this;
925 this.el = new Gtk.Button();
929 // set gobject values
930 this.el.label = "Create Branch";
935 this.el.get_style_context().add_class("suggested-action");
939 this.el.clicked.connect( () => {
941 GLib.debug("fire response = 1");
943 var ticket_id = _this.ticketsel.selectedTicketId();
945 if (ticket_id == "") {
946 _this.ticketsel.el.get_child().get_style_context().add_class("warning");
950 _this.el.response(1);
954 // user defined functions
955 public void updateState () {
957 var ticket_id = _this.ticketsel.selectedTicketId();
959 if (ticket_id == "") {
960 this.el.set_sensitive(false);
964 this.el.set_sensitive(true);
969 public class Xcls_Box19 : Object
972 private NewBranch _this;
978 public Xcls_Box19(NewBranch _owner )
981 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
985 // set gobject values
986 var child_0 = new Xcls_btn_not_me( _this );
988 this.el.add ( child_0.el );
989 var child_1 = new Xcls_btn_closed( _this );
991 this.el.add ( child_1.el );
992 var child_2 = new Xcls_Label22( _this );
994 this.el.add ( child_2.el );
997 // user defined functions
999 public class Xcls_btn_not_me : Object
1001 public Gtk.CheckButton el;
1002 private NewBranch _this;
1008 public Xcls_btn_not_me(NewBranch _owner )
1011 _this.btn_not_me = this;
1012 this.el = new Gtk.CheckButton();
1016 // set gobject values
1017 this.el.label = "Show tickets not assigned to me";
1020 this.el.toggled.connect( () => {
1021 var project_id = _this.projectsel.selectedProjectId();
1022 _this.dbmodel.loadTickets(project_id);
1026 // user defined functions
1029 public class Xcls_btn_closed : Object
1031 public Gtk.CheckButton el;
1032 private NewBranch _this;
1038 public Xcls_btn_closed(NewBranch _owner )
1041 _this.btn_closed = this;
1042 this.el = new Gtk.CheckButton();
1046 // set gobject values
1047 this.el.label = "Show closed Tickets";
1050 this.el.toggled.connect( () => {
1051 var project_id = _this.projectsel.selectedProjectId();
1052 _this.dbmodel.loadTickets(project_id);
1057 // user defined functions
1060 public class Xcls_Label22 : Object
1062 public Gtk.Label el;
1063 private NewBranch _this;
1069 public Xcls_Label22(NewBranch _owner )
1072 this.el = new Gtk.Label( "<a href=\"refresh\">Refresh Ticket list</a>" );
1076 // set gobject values
1077 this.el.halign = Gtk.Align.END;
1078 this.el.hexpand = true;
1079 this.el.use_markup = true;
1082 this.el.activate_link.connect( (uri) => {
1083 if (uri == "refresh") {
1084 RooProject.reload();
1085 var curproj = RooProject.getProjectByRepo(_this.repo);
1086 _this.prmodel.loadProjects(curproj == null ? "": curproj.id);
1088 _this.dbmodel.loadTickets(curproj == null ? "": curproj.id);
1094 // user defined functions
1099 public class Xcls_scrolled_window : Object
1101 public Gtk.ScrolledWindow el;
1102 private NewBranch _this;
1108 public Xcls_scrolled_window(NewBranch _owner )
1111 _this.scrolled_window = this;
1112 this.el = new Gtk.ScrolledWindow( null, null );
1116 // set gobject values
1117 this.el.height_request = 500;
1118 this.el.vexpand = true;
1119 this.el.visible = false;
1120 var child_0 = new Xcls_view( _this );
1122 this.el.add ( child_0.el );
1127 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1131 // user defined functions
1133 public class Xcls_view : Object
1135 public WebKit.WebView el;
1136 private NewBranch _this;
1142 public Xcls_view(NewBranch _owner )
1146 this.el = new WebKit.WebView();
1150 // set gobject values
1153 // user defined functions
1154 public void loadTicket (string tid) {
1156 _this.el.get_size(out w, out h);
1159 _this.scrolled_window.el.hide();
1160 _this.el.resize(w, 150);
1162 _this.scrolled_window.el.show();
1163 _this.el.resize(w, 800);
1166 var rs = RooTicket.singleton();
1167 var uri = new WebKit.URIRequest("https://roojs.com/admin.php/MTrack/View/" + tid);
1168 var hd = uri.get_http_headers();
1169 var authCode = Base64.encode ("%s:%s".printf(rs.username, rs.password).data);
1170 hd.append("Authorization", "Basic %s".printf(authCode));
1172 this.el.load_request(uri);
1177 public class Xcls_branch_spinner : Object
1179 public Gtk.Spinner el;
1180 private NewBranch _this;
1186 public Xcls_branch_spinner(NewBranch _owner )
1189 _this.branch_spinner = this;
1190 this.el = new Gtk.Spinner();
1194 // set gobject values
1195 this.el.hexpand = true;
1196 this.el.vexpand = true;
1199 // user defined functions
1203 public class Xcls_create_ticket_tab : Object
1206 private NewBranch _this;
1212 public Xcls_create_ticket_tab(NewBranch _owner )
1215 _this.create_ticket_tab = this;
1216 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1220 // set gobject values
1221 this.el.homogeneous = false;
1222 var child_0 = new Xcls_table( _this );
1224 this.el.pack_start ( child_0.el , false,false,0 );
1227 // user defined functions
1228 public void load_data () {
1230 // _this.table.el.hide();
1231 //_this.spinner.el.show();
1232 //_this.spinner.el.start();
1234 Timeout.add_seconds(1, () => {
1236 RooProject? curproj = null;
1237 if (_this.repo != null) {
1238 curproj = RooProject.getProjectByRepo(_this.repo);
1240 _this.tprmodel.loadProjects(curproj == null ? "" : curproj.id);
1241 if (curproj != null) {
1244 var rt = RooTicket.singleton();
1245 rt.loadProjectOptions(curproj.id);
1247 _this.msmodel.loadMilestones();
1248 _this.primodel.loadPriorities();
1249 _this.sevmodel.loadSeverities();
1250 _this.clmodel.loadClassifications();
1251 _this.devmodel.loadDevelopers();
1254 _this.summary.el.set_text("");
1255 _this.description.el.buffer.text = "";
1256 //_this.spinner.el.stop();
1257 // _this.spinner.el.hide();
1259 //_this.table.el.show();
1260 //_this.summary.el.grab_focus();
1266 public class Xcls_table : Object
1268 public Gtk.Table el;
1269 private NewBranch _this;
1275 public Xcls_table(NewBranch _owner )
1279 this.el = new Gtk.Table( 14, 4, true );
1283 // set gobject values
1284 this.el.expand = false;
1286 this.el.column_spacing = 4;
1287 this.el.vexpand = false;
1288 var child_0 = new Xcls_Label28( _this );
1290 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
1291 var child_1 = new Xcls_Label29( _this );
1293 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
1294 var child_2 = new Xcls_project_id( _this );
1296 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
1297 var child_3 = new Xcls_summary( _this );
1299 this.el.attach_defaults ( child_3.el , 1,4,1,2 );
1300 var child_4 = new Xcls_Label34( _this );
1302 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
1303 var child_5 = new Xcls_milestone_id( _this );
1305 this.el.attach_defaults ( child_5.el , 0,1,3,4 );
1306 var child_6 = new Xcls_Label37( _this );
1308 this.el.attach_defaults ( child_6.el , 1,4,2,3 );
1309 var child_7 = new Xcls_description( _this );
1311 this.el.attach_defaults ( child_7.el , 1,4,3,12 );
1312 var child_8 = new Xcls_Label39( _this );
1314 this.el.attach_defaults ( child_8.el , 0,1,4,5 );
1315 var child_9 = new Xcls_priority_id( _this );
1317 this.el.attach_defaults ( child_9.el , 0,1,5,6 );
1318 var child_10 = new Xcls_Label42( _this );
1320 this.el.attach_defaults ( child_10.el , 0,1,6,7 );
1321 var child_11 = new Xcls_severity_id( _this );
1323 this.el.attach_defaults ( child_11.el , 0,1,7,8 );
1324 var child_12 = new Xcls_Label45( _this );
1326 this.el.attach_defaults ( child_12.el , 0,1,8,9 );
1327 var child_13 = new Xcls_classification_id( _this );
1329 this.el.attach_defaults ( child_13.el , 0,1,9,10 );
1330 var child_14 = new Xcls_Label48( _this );
1332 this.el.attach_defaults ( child_14.el , 0,1,10,11 );
1333 var child_15 = new Xcls_developer_id( _this );
1335 this.el.attach_defaults ( child_15.el , 0,1,11,12 );
1336 var child_16 = new Xcls_Button51( _this );
1338 this.el.attach_defaults ( child_16.el , 0,4,13,14 );
1341 // user defined functions
1343 public class Xcls_Label28 : Object
1345 public Gtk.Label el;
1346 private NewBranch _this;
1352 public Xcls_Label28(NewBranch _owner )
1355 this.el = new Gtk.Label( "Project" );
1359 // set gobject values
1360 this.el.halign = Gtk.Align.START;
1361 this.el.visible = true;
1364 // user defined functions
1367 public class Xcls_Label29 : Object
1369 public Gtk.Label el;
1370 private NewBranch _this;
1376 public Xcls_Label29(NewBranch _owner )
1379 this.el = new Gtk.Label( "Summary" );
1383 // set gobject values
1384 this.el.halign = Gtk.Align.START;
1385 this.el.visible = true;
1388 // user defined functions
1391 public class Xcls_project_id : Object
1393 public Gtk.ComboBox el;
1394 private NewBranch _this;
1398 public bool loading;
1401 public Xcls_project_id(NewBranch _owner )
1404 _this.project_id = this;
1405 this.el = new Gtk.ComboBox.with_entry();
1408 this.loading = false;
1410 // set gobject values
1411 var child_0 = new Xcls_tprcellrenderer( _this );
1413 this.el.pack_start ( child_0.el , true );
1414 var child_1 = new Xcls_tprmodel( _this );
1416 this.el.set_model ( child_1.el );
1420 this.el.set_entry_text_column(1);
1423 this.el.changed.connect( () => {
1427 var project_id = this.selectedProjectId();
1429 var rt = RooTicket.singleton();
1430 rt.loadProjectOptions(project_id);
1432 _this.msmodel.loadMilestones();
1433 _this.primodel.loadPriorities();
1434 _this.sevmodel.loadSeverities();
1435 _this.clmodel.loadClassifications();
1436 _this.devmodel.loadDevelopers();
1438 // affects projects and milestones..
1441 /*if (this.loading) {
1444 var ticket_id = this.selectedTicketId();
1446 var name = RooTicket.singleton().usernameLocal();
1448 if (ticket_id == "" || ticket_id == null) {
1450 var dt = new DateTime.now_local();
1451 _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
1456 var ticket = RooTicket.singleton().getById(ticket_id);
1458 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
1460 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
1465 // user defined functions
1466 public string selectedProjectId () {
1471 this.el.get_active_iter (out iter);
1472 _this.tprmodel.el.get_value (iter, 0, out val1);
1475 return (string) val1;
1482 public class Xcls_tprcellrenderer : Object
1484 public Gtk.CellRendererText el;
1485 private NewBranch _this;
1491 public Xcls_tprcellrenderer(NewBranch _owner )
1494 _this.tprcellrenderer = this;
1495 this.el = new Gtk.CellRendererText();
1499 // set gobject values
1502 // user defined functions
1505 public class Xcls_tprmodel : Object
1507 public Gtk.ListStore el;
1508 private NewBranch _this;
1514 public Xcls_tprmodel(NewBranch _owner )
1517 _this.tprmodel = this;
1518 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
1522 // set gobject values
1525 // user defined functions
1526 public void loadProjects (string id) {
1529 _this.project_id.loading = true;
1535 el.append(out iter);
1538 el.set_value(iter, 0, "");
1539 el.set_value(iter, 1, "-- select a project --");
1541 _this.project_id.el.set_active_iter(iter);
1544 foreach(var project in RooProject.projects()) {
1546 el.append(out iter);
1548 el.set_value(iter, 0, project.id);
1549 el.set_value(iter, 1, project.name );
1550 if (id == project.id) {
1551 _this.project_id.el.set_active_iter(iter);
1556 _this.project_id.loading = false;
1557 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
1563 public class Xcls_summary : Object
1565 public Gtk.Entry el;
1566 private NewBranch _this;
1572 public Xcls_summary(NewBranch _owner )
1575 _this.summary = this;
1576 this.el = new Gtk.Entry();
1580 // set gobject values
1581 this.el.visible = true;
1584 // user defined functions
1587 public class Xcls_Label34 : Object
1589 public Gtk.Label el;
1590 private NewBranch _this;
1596 public Xcls_Label34(NewBranch _owner )
1599 this.el = new Gtk.Label( "Milestone" );
1603 // set gobject values
1604 this.el.halign = Gtk.Align.START;
1605 this.el.justify = Gtk.Justification.RIGHT;
1606 this.el.xalign = 0.900000f;
1609 // user defined functions
1612 public class Xcls_milestone_id : Object
1614 public Gtk.ComboBox el;
1615 private NewBranch _this;
1619 public bool loading;
1622 public Xcls_milestone_id(NewBranch _owner )
1625 _this.milestone_id = this;
1626 this.el = new Gtk.ComboBox.with_entry();
1629 this.loading = false;
1631 // set gobject values
1632 var child_0 = new Xcls_msmodel( _this );
1634 this.el.set_model ( child_0.el );
1638 this.el.set_entry_text_column(1);
1641 // user defined functions
1642 public string selectedMilestoneId () {
1647 this.el.get_active_iter (out iter);
1648 _this.msmodel.el.get_value (iter, 0, out val1);
1651 return (string) val1;
1658 public class Xcls_msmodel : Object
1660 public Gtk.ListStore el;
1661 private NewBranch _this;
1667 public Xcls_msmodel(NewBranch _owner )
1670 _this.msmodel = this;
1671 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
1675 // set gobject values
1678 // user defined functions
1679 public void loadMilestones ( ) {
1681 var rt = RooTicket.singleton();
1682 // rt.loadProjects();
1684 _this.milestone_id.loading = true;
1690 el.append(out iter);
1693 el.set_value(iter, 0, "");
1694 el.set_value(iter, 1, "-- select a milestone --");
1695 _this.milestone_id.el.set_active_iter(iter);
1697 var projects = rt.milestones;
1698 foreach(var project in projects) {
1700 el.append(out iter);
1702 el.set_value(iter, 0, project.id);
1703 el.set_value(iter, 1, project.display_name );
1704 // if (id == project.id) {
1705 // _this.milestone.el.set_active_iter(iter);
1711 _this.milestone_id.loading = false;
1712 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
1718 public class Xcls_Label37 : Object
1720 public Gtk.Label el;
1721 private NewBranch _this;
1727 public Xcls_Label37(NewBranch _owner )
1730 this.el = new Gtk.Label( "Description" );
1734 // set gobject values
1735 this.el.halign = Gtk.Align.START;
1738 // user defined functions
1741 public class Xcls_description : Object
1743 public Gtk.TextView el;
1744 private NewBranch _this;
1750 public Xcls_description(NewBranch _owner )
1753 _this.description = this;
1754 this.el = new Gtk.TextView();
1758 // set gobject values
1759 this.el.border_width = 1;
1762 // user defined functions
1765 public class Xcls_Label39 : Object
1767 public Gtk.Label el;
1768 private NewBranch _this;
1774 public Xcls_Label39(NewBranch _owner )
1777 this.el = new Gtk.Label( "Priority" );
1781 // set gobject values
1782 this.el.halign = Gtk.Align.START;
1783 this.el.xalign = 0.900000f;
1786 // user defined functions
1789 public class Xcls_priority_id : Object
1791 public Gtk.ComboBox el;
1792 private NewBranch _this;
1796 public bool loading;
1799 public Xcls_priority_id(NewBranch _owner )
1802 _this.priority_id = this;
1803 this.el = new Gtk.ComboBox.with_entry();
1806 this.loading = false;
1808 // set gobject values
1809 var child_0 = new Xcls_primodel( _this );
1811 this.el.set_model ( child_0.el );
1815 this.el.set_entry_text_column(1);
1818 // user defined functions
1819 public string selectedPriorityId () {
1824 this.el.get_active_iter (out iter);
1825 _this.primodel.el.get_value (iter, 0, out val1);
1828 return (string) val1;
1835 public class Xcls_primodel : Object
1837 public Gtk.ListStore el;
1838 private NewBranch _this;
1844 public Xcls_primodel(NewBranch _owner )
1847 _this.primodel = this;
1848 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
1852 // set gobject values
1855 // user defined functions
1856 public void loadPriorities ( ) {
1858 var rt = RooTicket.singleton();
1859 // rt.loadProjects();
1861 _this.priority_id.loading = true;
1868 var projects = rt.priorities;
1869 foreach(var project in projects) {
1871 el.append(out iter);
1873 el.set_value(iter, 0, project.id);
1874 el.set_value(iter, 1, project.display_name );
1875 if ("normal" == project.name) {
1876 _this.priority_id.el.set_active_iter(iter);
1881 _this.priority_id.loading = false;
1888 public class Xcls_Label42 : Object
1890 public Gtk.Label el;
1891 private NewBranch _this;
1897 public Xcls_Label42(NewBranch _owner )
1900 this.el = new Gtk.Label( "Severity" );
1904 // set gobject values
1905 this.el.halign = Gtk.Align.START;
1908 // user defined functions
1911 public class Xcls_severity_id : Object
1913 public Gtk.ComboBox el;
1914 private NewBranch _this;
1918 public bool loading;
1921 public Xcls_severity_id(NewBranch _owner )
1924 _this.severity_id = this;
1925 this.el = new Gtk.ComboBox.with_entry();
1928 this.loading = false;
1930 // set gobject values
1931 var child_0 = new Xcls_sevmodel( _this );
1933 this.el.set_model ( child_0.el );
1937 this.el.set_entry_text_column(1);
1940 // user defined functions
1941 public string selectedSeverityId () {
1946 this.el.get_active_iter (out iter);
1947 _this.sevmodel.el.get_value (iter, 0, out val1);
1950 return (string) val1;
1957 public class Xcls_sevmodel : Object
1959 public Gtk.ListStore el;
1960 private NewBranch _this;
1966 public Xcls_sevmodel(NewBranch _owner )
1969 _this.sevmodel = this;
1970 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
1974 // set gobject values
1977 // user defined functions
1978 public void loadSeverities () {
1980 var rt = RooTicket.singleton();
1981 //rt.loadProjects();
1983 _this.severity_id.loading = true;
1989 var projects = rt.serverities;
1990 foreach(var project in projects) {
1992 el.append(out iter);
1994 el.set_value(iter, 0, project.id);
1995 el.set_value(iter, 1, project.display_name );
1996 if ("normal" == project.name) {
1997 _this.severity_id.el.set_active_iter(iter);
2002 _this.severity_id.loading = false;
2003 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
2009 public class Xcls_Label45 : Object
2011 public Gtk.Label el;
2012 private NewBranch _this;
2018 public Xcls_Label45(NewBranch _owner )
2021 this.el = new Gtk.Label( "Classification" );
2025 // set gobject values
2026 this.el.halign = Gtk.Align.START;
2029 // user defined functions
2032 public class Xcls_classification_id : Object
2034 public Gtk.ComboBox el;
2035 private NewBranch _this;
2039 public bool loading;
2042 public Xcls_classification_id(NewBranch _owner )
2045 _this.classification_id = this;
2046 this.el = new Gtk.ComboBox.with_entry();
2049 this.loading = false;
2051 // set gobject values
2052 var child_0 = new Xcls_clmodel( _this );
2054 this.el.set_model ( child_0.el );
2058 this.el.set_entry_text_column(1);
2061 // user defined functions
2062 public string selectedClassificationId () {
2067 this.el.get_active_iter (out iter);
2068 _this.clmodel.el.get_value (iter, 0, out val1);
2071 return (string) val1;
2078 public class Xcls_clmodel : Object
2080 public Gtk.ListStore el;
2081 private NewBranch _this;
2087 public Xcls_clmodel(NewBranch _owner )
2090 _this.clmodel = this;
2091 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
2095 // set gobject values
2098 // user defined functions
2099 public void loadClassifications ( ) {
2101 var rt = RooTicket.singleton();
2102 // rt.loadProjects();
2104 _this.classification_id.loading = true;
2110 el.append(out iter);
2113 var projects = rt.classifications;
2114 foreach(var project in projects) {
2116 el.append(out iter);
2118 el.set_value(iter, 0, project.id);
2119 el.set_value(iter, 1, project.display_name );
2120 if ("bug" == project.name) {
2121 _this.classification_id.el.set_active_iter(iter);
2126 _this.classification_id.loading = false;
2127 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
2133 public class Xcls_Label48 : Object
2135 public Gtk.Label el;
2136 private NewBranch _this;
2142 public Xcls_Label48(NewBranch _owner )
2145 this.el = new Gtk.Label( "Assign to" );
2149 // set gobject values
2150 this.el.halign = Gtk.Align.START;
2153 // user defined functions
2156 public class Xcls_developer_id : Object
2158 public Gtk.ComboBox el;
2159 private NewBranch _this;
2163 public bool loading;
2166 public Xcls_developer_id(NewBranch _owner )
2169 _this.developer_id = this;
2170 this.el = new Gtk.ComboBox.with_entry();
2173 this.loading = false;
2175 // set gobject values
2176 var child_0 = new Xcls_devmodel( _this );
2178 this.el.set_model ( child_0.el );
2182 this.el.set_entry_text_column(1);
2185 // user defined functions
2186 public string selectedDeveloperId () {
2191 this.el.get_active_iter (out iter);
2192 _this.devmodel.el.get_value (iter, 0, out val1);
2195 return (string) val1;
2202 public class Xcls_devmodel : Object
2204 public Gtk.ListStore el;
2205 private NewBranch _this;
2211 public Xcls_devmodel(NewBranch _owner )
2214 _this.devmodel = this;
2215 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
2219 // set gobject values
2222 // user defined functions
2223 public void loadDevelopers ( ) {
2225 var rt = RooTicket.singleton();
2226 //rt.loadProjects();
2228 _this.developer_id.loading = true;
2234 el.append(out iter);
2237 el.set_value(iter, 0, "");
2238 el.set_value(iter, 1, "-- select a developer --");
2240 _this.developer_id.el.set_active_iter(iter);
2243 var peps = rt.developers;
2244 foreach(var p in peps) {
2246 el.append(out iter);
2248 el.set_value(iter, 0, p.id);
2249 el.set_value(iter, 1, p.display_name );
2250 if (rt.authuser_id == p.id) {
2251 _this.developer_id.el.set_active_iter(iter);
2255 _this.developer_id.loading = false;
2256 //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
2262 public class Xcls_Button51 : Object
2264 public Gtk.Button el;
2265 private NewBranch _this;
2271 public Xcls_Button51(NewBranch _owner )
2274 this.el = new Gtk.Button();
2278 // set gobject values
2279 this.el.label = "Create Ticket & Branch";
2284 this.el.get_style_context().add_class("suggested-action");
2288 this.el.clicked.connect( () => {
2289 GLib.debug("fire response = 1");
2292 var invalid = false;
2294 // validate first...
2295 _this.project_id.el.get_child().get_style_context().remove_class("warning");
2296 if (_this.project_id.selectedProjectId() == "") {
2297 _this.project_id.el.get_child().get_style_context().add_class("warning");
2301 _this.milestone_id.el.get_child().get_style_context().remove_class("warning");
2303 _this.priority_id.el.get_child().get_style_context().remove_class("warning");
2304 if (_this.priority_id.selectedPriorityId() == "") {
2305 _this.priority_id.el.get_child().get_style_context().add_class("warning");
2309 _this.classification_id.el.get_child().get_style_context().remove_class("warning");
2310 if (_this.classification_id.selectedClassificationId() == "") {
2311 _this.classification_id.el.get_child().get_style_context().add_class("warning");
2315 _this.developer_id.el.get_child().get_style_context().remove_class("warning");
2316 if (_this.developer_id.selectedDeveloperId() == "") {
2317 _this.developer_id.el.get_child().get_style_context().add_class("warning");
2321 _this.summary.el.get_style_context().remove_class("warning");
2322 if (_this.summary.el.get_text() == "") {
2323 _this.summary.el.get_style_context().add_class("warning");
2327 _this.description.el.get_style_context().remove_class("warning");
2332 GLib.debug("for is valid");
2334 _this.el.response(2);
2338 // user defined functions
2343 public class Xcls_quick_commit_tab : Object
2346 private NewBranch _this;
2352 public Xcls_quick_commit_tab(NewBranch _owner )
2355 _this.quick_commit_tab = this;
2356 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
2360 // set gobject values
2361 this.el.homogeneous = false;
2362 var child_0 = new Xcls_Table53( _this );
2364 this.el.pack_start ( child_0.el , false,false,0 );
2365 var child_1 = new Xcls_diff_sv( _this );
2367 this.el.add ( child_1.el );
2370 // user defined functions
2371 public void load_data () {
2373 _this.createbtn.updateState();
2376 public class Xcls_Table53 : Object
2378 public Gtk.Table el;
2379 private NewBranch _this;
2385 public Xcls_Table53(NewBranch _owner )
2388 this.el = new Gtk.Table( 3, 5, true );
2392 // set gobject values
2393 this.el.expand = false;
2395 this.el.column_spacing = 4;
2396 this.el.vexpand = false;
2397 var child_0 = new Xcls_Label54( _this );
2399 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
2400 var child_1 = new Xcls_commit_message( _this );
2402 this.el.attach_defaults ( child_1.el , 0,5,1,2 );
2403 var child_2 = new Xcls_createbtn( _this );
2405 this.el.attach_defaults ( child_2.el , 0,5,2,3 );
2408 // user defined functions
2410 public class Xcls_Label54 : Object
2412 public Gtk.Label el;
2413 private NewBranch _this;
2419 public Xcls_Label54(NewBranch _owner )
2422 this.el = new Gtk.Label( "Just commit with this comment" );
2426 // set gobject values
2427 this.el.halign = Gtk.Align.START;
2428 this.el.justify = Gtk.Justification.RIGHT;
2429 this.el.xalign = 0.900000f;
2432 // user defined functions
2435 public class Xcls_commit_message : Object
2437 public Gtk.Entry el;
2438 private NewBranch _this;
2444 public Xcls_commit_message(NewBranch _owner )
2447 _this.commit_message = this;
2448 this.el = new Gtk.Entry();
2452 // set gobject values
2453 this.el.visible = true;
2456 this.el.key_release_event.connect( () => {
2458 _this.createbtn.updateState();
2463 // user defined functions
2466 public class Xcls_createbtn : Object
2468 public Gtk.Button el;
2469 private NewBranch _this;
2475 public Xcls_createbtn(NewBranch _owner )
2478 _this.createbtn = this;
2479 this.el = new Gtk.Button();
2483 // set gobject values
2484 this.el.label = "Commit Changes";
2489 this.el.get_style_context().add_class("suggested-action");
2493 this.el.clicked.connect( () => {
2495 GLib.debug("fire response = 1");
2499 _this.el.response(3);
2503 // user defined functions
2504 public void updateState () {
2506 var msg = _this.commit_message.el.get_text();
2509 this.el.set_sensitive(false);
2513 this.el.set_sensitive(true);
2519 public class Xcls_diff_sv : Object
2521 public Gtk.ScrolledWindow el;
2522 private NewBranch _this;
2528 public Xcls_diff_sv(NewBranch _owner )
2531 _this.diff_sv = this;
2532 this.el = new Gtk.ScrolledWindow( null, null );
2536 // set gobject values
2537 this.el.height_request = 400;
2538 this.el.vexpand = true;
2539 this.el.visible = false;
2540 var child_0 = new Xcls_diff_view( _this );
2542 this.el.add ( child_0.el );
2545 // user defined functions
2547 public class Xcls_diff_view : Object
2549 public Gtk.SourceView el;
2550 private NewBranch _this;
2556 public Xcls_diff_view(NewBranch _owner )
2559 _this.diff_view = this;
2560 this.el = new Gtk.SourceView();
2566 var description = Pango.FontDescription.from_string("monospace");
2567 description.set_size(9000);
2568 this.el.override_font(description);
2569 var lm = Gtk.SourceLanguageManager.get_default();
2571 ((Gtk.SourceBuffer)(this.el.get_buffer())).set_language(
2572 lm.get_language("diff")
2576 // user defined functions