NewBranch.bjs
[gitlive] / NewBranch.vala
1 static NewBranch  _NewBranch;
2
3 public class NewBranch : Object
4 {
5     public Gtk.Dialog el;
6     private NewBranch  _this;
7
8     public static NewBranch singleton()
9     {
10         if (_NewBranch == null) {
11             _NewBranch= new NewBranch();
12         }
13         return _NewBranch;
14     }
15     public Xcls_label_select_ticket label_select_ticket;
16     public Xcls_label_create_ticket label_create_ticket;
17     public Xcls_label_quick_commit label_quick_commit;
18     public Xcls_projectsel projectsel;
19     public Xcls_prcellrenderer prcellrenderer;
20     public Xcls_prmodel prmodel;
21     public Xcls_ticketsel ticketsel;
22     public Xcls_dbcellrenderer dbcellrenderer;
23     public Xcls_dbmodel dbmodel;
24     public Xcls_name name;
25     public Xcls_createbtn createbtn;
26     public Xcls_btn_not_me btn_not_me;
27     public Xcls_btn_closed btn_closed;
28     public Xcls_scrolled_window scrolled_window;
29     public Xcls_view view;
30
31         // my vars (def)
32     public GitRepo? repo;
33     public bool running;
34     public Gee.ArrayList<GitMonitorQueue> queue;
35
36     // ctor
37     public NewBranch()
38     {
39         _this = this;
40         this.el = new Gtk.Dialog();
41
42         // my vars (dec)
43         this.repo = null;
44         this.running = false;
45         this.queue = null;
46
47         // set gobject values
48         this.el.title = "Create a working branch ";
49         this.el.default_height = 500;
50         this.el.default_width = 500;
51         this.el.deletable = true;
52         this.el.modal = true;
53         var child_0 = new Xcls_Box2( _this );
54         child_0.ref();
55         this.el.get_content_area().add (  child_0.el  );
56         var child_1 = new Xcls_Notebook3( _this );
57         child_1.ref();
58         this.el.add (  child_1.el  );
59
60         //listeners
61         this.el.delete_event.connect( (self, event) => {
62             this.el.hide();
63             return true; 
64             //test  
65         });
66         this.el.response.connect( (self, response_id) =>  { 
67           
68                 GLib.debug("got %d", (int) response_id);
69                 
70                  
71                 
72                  
73                 // have they selected a ticket..
74                 // make that the current active ticket?
75                 // we really need to store locally what ticket is being worked on..
76                 // in theory we could be working on multiple project and not merging..
77                 // -- each repo would have their active ticket (only one per repo)
78                 // -- so we could just store that in there
79                 // -- initial load can check the contents of the ticket files on first scan.
80         
81                  
82                 if (response_id < 1) {
83                     _this.el.hide();    
84                     this.running = false; 
85                         return;
86                 }
87                 
88                 var ticket_id = _this.ticketsel.selectedTicketId();
89                 
90             if (this.repo != null) {
91                 var bn = _this.name.el.get_text();
92         
93                         var res = this.repo.setActiveTicket(                    
94                                  RooTicket.singleton().getById(ticket_id != "" ? ticket_id : "-1"), bn
95                          );
96                          if (res) {
97                                 // start the monitoring..
98                                  GitMonitor.gitmonitor.start();
99                                  
100                          }
101             }
102              
103         
104             this.running = false; 
105         
106                 this.el.hide();
107                  
108                  
109         
110                  
111         });
112     }
113
114     // user defined functions
115     public   void show ( GitRepo repo, Gee.ArrayList<GitMonitorQueue> queue, string tid = "" ) 
116     {
117          // this.el.set_gravity(Gdk.Gravity.NORTH);
118         if (this.running) { // should not happen!!
119                 GLib.error("new branch show called, when already being displayed?");
120         }
121         this.queue = queue;
122         
123         this.running  = true;
124         GitMonitor.gitmonitor.stop();
125         
126         this.repo = repo;
127         
128          
129         
130         this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
131         this.el.set_default_size( 500,200); // not sure why it grows..
132         GLib.debug("Loading tickets"); 
133          
134     
135         this.el.show_all();
136         this.el.set_keep_above(true);
137        
138         
139         var curproj = RooProject.getProjectByRepo(this.repo);
140          _this.prmodel.loadProjects(curproj == null ? "" : curproj.id);
141         
142         _this.dbmodel.loadTickets(curproj == null ? "": curproj.id, tid);
143         _this.createbtn.updateState();
144         
145         _this.ticketsel.el.get_child().get_style_context().remove_class("warning");
146         if (tid != "") { 
147                 var name = RooTicket.singleton().usernameLocal();
148                 var ticket = RooTicket.singleton().getById(tid);
149                 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
150         } else {
151                 _this.ticketsel.el.get_child().get_style_context().add_class("warning");
152         }
153         _this.view.loadTicket(tid);
154         this.el.run();
155     
156     }
157     public class Xcls_Box2 : Object
158     {
159         public Gtk.Box el;
160         private NewBranch  _this;
161
162
163             // my vars (def)
164
165         // ctor
166         public Xcls_Box2(NewBranch _owner )
167         {
168             _this = _owner;
169             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
170
171             // my vars (dec)
172
173             // set gobject values
174         }
175
176         // user defined functions
177     }
178
179     public class Xcls_Notebook3 : Object
180     {
181         public Gtk.Notebook el;
182         private NewBranch  _this;
183
184
185             // my vars (def)
186
187         // ctor
188         public Xcls_Notebook3(NewBranch _owner )
189         {
190             _this = _owner;
191             this.el = new Gtk.Notebook();
192
193             // my vars (dec)
194
195             // set gobject values
196             this.el.vexpand = true;
197             var child_0 = new Xcls_label_select_ticket( _this );
198             child_0.ref();
199             var child_1 = new Xcls_label_create_ticket( _this );
200             child_1.ref();
201             var child_2 = new Xcls_label_quick_commit( _this );
202             child_2.ref();
203             var child_3 = new Xcls_Box7( _this );
204             child_3.ref();
205             this.el.append_page (  child_3.el , _this.label_select_ticket.el );
206             var child_4 = new Xcls_Box27( _this );
207             child_4.ref();
208             this.el.append_page (  child_4.el , _this.label_create_ticket.el );
209             var child_5 = new Xcls_Box28( _this );
210             child_5.ref();
211             this.el.append_page (  child_5.el , _this.label_quick_commit.el );
212         }
213
214         // user defined functions
215     }
216     public class Xcls_label_select_ticket : Object
217     {
218         public Gtk.Label el;
219         private NewBranch  _this;
220
221
222             // my vars (def)
223
224         // ctor
225         public Xcls_label_select_ticket(NewBranch _owner )
226         {
227             _this = _owner;
228             _this.label_select_ticket = this;
229             this.el = new Gtk.Label( "Select Existing Ticket to work on" );
230
231             // my vars (dec)
232
233             // set gobject values
234         }
235
236         // user defined functions
237     }
238
239     public class Xcls_label_create_ticket : Object
240     {
241         public Gtk.Label el;
242         private NewBranch  _this;
243
244
245             // my vars (def)
246
247         // ctor
248         public Xcls_label_create_ticket(NewBranch _owner )
249         {
250             _this = _owner;
251             _this.label_create_ticket = this;
252             this.el = new Gtk.Label( "Create a new Ticket" );
253
254             // my vars (dec)
255
256             // set gobject values
257         }
258
259         // user defined functions
260     }
261
262     public class Xcls_label_quick_commit : Object
263     {
264         public Gtk.Label el;
265         private NewBranch  _this;
266
267
268             // my vars (def)
269
270         // ctor
271         public Xcls_label_quick_commit(NewBranch _owner )
272         {
273             _this = _owner;
274             _this.label_quick_commit = this;
275             this.el = new Gtk.Label( "Quick Commit" );
276
277             // my vars (dec)
278
279             // set gobject values
280         }
281
282         // user defined functions
283     }
284
285     public class Xcls_Box7 : Object
286     {
287         public Gtk.Box el;
288         private NewBranch  _this;
289
290
291             // my vars (def)
292
293         // ctor
294         public Xcls_Box7(NewBranch _owner )
295         {
296             _this = _owner;
297             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
298
299             // my vars (dec)
300
301             // set gobject values
302             this.el.homogeneous = false;
303             var child_0 = new Xcls_Table8( _this );
304             child_0.ref();
305             this.el.pack_start (  child_0.el , false,false,0 );
306             var child_1 = new Xcls_scrolled_window( _this );
307             child_1.ref();
308             this.el.add (  child_1.el  );
309         }
310
311         // user defined functions
312     }
313     public class Xcls_Table8 : Object
314     {
315         public Gtk.Table el;
316         private NewBranch  _this;
317
318
319             // my vars (def)
320
321         // ctor
322         public Xcls_Table8(NewBranch _owner )
323         {
324             _this = _owner;
325             this.el = new Gtk.Table( 5, 5, true );
326
327             // my vars (dec)
328
329             // set gobject values
330             this.el.expand = false;
331             this.el.margin = 2;
332             this.el.column_spacing = 4;
333             this.el.vexpand = false;
334             var child_0 = new Xcls_Label9( _this );
335             child_0.ref();
336             this.el.attach_defaults (  child_0.el , 0,1,0,1 );
337             var child_1 = new Xcls_Label10( _this );
338             child_1.ref();
339             this.el.attach_defaults (  child_1.el , 1,2,0,1 );
340             var child_2 = new Xcls_projectsel( _this );
341             child_2.ref();
342             this.el.attach_defaults (  child_2.el , 0,1,1,2 );
343             var child_3 = new Xcls_ticketsel( _this );
344             child_3.ref();
345             this.el.attach_defaults (  child_3.el , 1,4,1,2 );
346             var child_4 = new Xcls_Button17( _this );
347             child_4.ref();
348             this.el.attach_defaults (  child_4.el , 4,5,1,2 );
349             var child_5 = new Xcls_Label18( _this );
350             child_5.ref();
351             this.el.attach_defaults (  child_5.el , 0,1,3,4 );
352             var child_6 = new Xcls_name( _this );
353             child_6.ref();
354             this.el.attach_defaults (  child_6.el , 0,4,4,5 );
355             var child_7 = new Xcls_createbtn( _this );
356             child_7.ref();
357             this.el.attach_defaults (  child_7.el , 4,5,4,5 );
358             var child_8 = new Xcls_Box21( _this );
359             child_8.ref();
360             this.el.attach_defaults (  child_8.el , 0,5,2,3 );
361         }
362
363         // user defined functions
364     }
365     public class Xcls_Label9 : Object
366     {
367         public Gtk.Label el;
368         private NewBranch  _this;
369
370
371             // my vars (def)
372
373         // ctor
374         public Xcls_Label9(NewBranch _owner )
375         {
376             _this = _owner;
377             this.el = new Gtk.Label( "Project" );
378
379             // my vars (dec)
380
381             // set gobject values
382             this.el.halign = Gtk.Align.START;
383             this.el.justify = Gtk.Justification.RIGHT;
384             this.el.visible = true;
385         }
386
387         // user defined functions
388     }
389
390     public class Xcls_Label10 : Object
391     {
392         public Gtk.Label el;
393         private NewBranch  _this;
394
395
396             // my vars (def)
397
398         // ctor
399         public Xcls_Label10(NewBranch _owner )
400         {
401             _this = _owner;
402             this.el = new Gtk.Label( "Ticket" );
403
404             // my vars (dec)
405
406             // set gobject values
407             this.el.halign = Gtk.Align.START;
408             this.el.visible = true;
409         }
410
411         // user defined functions
412     }
413
414     public class Xcls_projectsel : Object
415     {
416         public Gtk.ComboBox el;
417         private NewBranch  _this;
418
419
420             // my vars (def)
421         public bool loading;
422
423         // ctor
424         public Xcls_projectsel(NewBranch _owner )
425         {
426             _this = _owner;
427             _this.projectsel = this;
428             this.el = new Gtk.ComboBox.with_entry();
429
430             // my vars (dec)
431             this.loading = false;
432
433             // set gobject values
434             var child_0 = new Xcls_prcellrenderer( _this );
435             child_0.ref();
436             this.el.pack_start (  child_0.el , true );
437             var child_1 = new Xcls_prmodel( _this );
438             child_1.ref();
439             this.el.set_model (  child_1.el  );
440
441             // init method
442
443             this.el.set_entry_text_column(1);
444
445             //listeners
446             this.el.changed.connect( () => {
447                 if (this.loading) {
448                         return;
449                 }
450                 var project_id = this.selectedProjectId();
451                 _this.dbmodel.loadTickets(project_id);
452                 
453                 
454                 /*if (this.loading) {
455                         return;
456                 }
457                 var ticket_id = this.selectedTicketId();
458                 
459                 var name = RooTicket.singleton().usernameLocal();
460                 
461                 if (ticket_id == "" || ticket_id == null) {
462                 
463                         var dt = new  DateTime.now_local();
464                         _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
465                         return;
466                 }
467                 
468                 
469                 var ticket = RooTicket.singleton().getById(ticket_id);
470                
471                 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
472                 
473                 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
474                 */
475             });
476         }
477
478         // user defined functions
479         public string selectedProjectId () {
480                 Gtk.TreeIter iter;
481                 Value val1;
482          
483          
484                 this.el.get_active_iter (out iter);
485                 _this.prmodel.el.get_value (iter, 0, out val1);
486          
487         
488                 return  (string) val1;
489                 
490                 
491                 
492                 
493         }
494     }
495     public class Xcls_prcellrenderer : Object
496     {
497         public Gtk.CellRendererText el;
498         private NewBranch  _this;
499
500
501             // my vars (def)
502
503         // ctor
504         public Xcls_prcellrenderer(NewBranch _owner )
505         {
506             _this = _owner;
507             _this.prcellrenderer = this;
508             this.el = new Gtk.CellRendererText();
509
510             // my vars (dec)
511
512             // set gobject values
513         }
514
515         // user defined functions
516     }
517
518     public class Xcls_prmodel : Object
519     {
520         public Gtk.ListStore el;
521         private NewBranch  _this;
522
523
524             // my vars (def)
525
526         // ctor
527         public Xcls_prmodel(NewBranch _owner )
528         {
529             _this = _owner;
530             _this.prmodel = this;
531             this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
532
533             // my vars (dec)
534
535             // set gobject values
536         }
537
538         // user defined functions
539         public void loadProjects (string id) {
540         
541         
542             
543             _this.projectsel.loading = true;
544         
545             this.el.clear();                                    
546             Gtk.TreeIter iter;
547             var el = this.el;
548             
549             el.append(out iter);
550         
551             
552             el.set_value(iter, 0, "");
553             el.set_value(iter, 1, "-- select a project --");
554             if (id == "") {
555                     _this.projectsel.el.set_active_iter(iter);
556             }
557           
558             foreach(var project in RooProject.projects()) {
559             
560                 el.append(out iter);
561                 
562                 el.set_value(iter, 0, project.id);
563                 el.set_value(iter, 1,  project.name );
564                 if (id == project.id) {
565                            _this.projectsel.el.set_active_iter(iter);
566                     }   
567                 
568             }
569             
570             _this.projectsel.loading = false;
571              //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          
572                                              
573         }
574     }
575
576
577     public class Xcls_ticketsel : Object
578     {
579         public Gtk.ComboBox el;
580         private NewBranch  _this;
581
582
583             // my vars (def)
584         public bool loading;
585
586         // ctor
587         public Xcls_ticketsel(NewBranch _owner )
588         {
589             _this = _owner;
590             _this.ticketsel = this;
591             this.el = new Gtk.ComboBox.with_entry();
592
593             // my vars (dec)
594             this.loading = false;
595
596             // set gobject values
597             var child_0 = new Xcls_dbcellrenderer( _this );
598             child_0.ref();
599             this.el.pack_start (  child_0.el , true );
600             var child_1 = new Xcls_dbmodel( _this );
601             child_1.ref();
602             this.el.set_model (  child_1.el  );
603
604             // init method
605
606             //this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
607             this.el.set_entry_text_column(1);
608             this.el.get_child().set_sensitive(false);
609
610             //listeners
611             this.el.changed.connect( () => {
612                 if (this.loading) {
613                         return;
614                 }
615                 var ticket_id = this.selectedTicketId();
616                 
617                 var name = RooTicket.singleton().usernameLocal();
618                 
619                 this.el.get_child().get_style_context().remove_class("warning");
620                 if (ticket_id == "" || ticket_id == null) {
621                 
622                         var dt = new  DateTime.now_local();
623                         _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
624                         _this.view.loadTicket("");              
625                         
626                         this.el.get_child().get_style_context().add_class("warning");
627                         _this.createbtn.updateState();
628                         return;
629                 }
630                 
631                 
632                 var ticket = RooTicket.singleton().getById(ticket_id);
633                
634                 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
635                 _this.scrolled_window.el.show();
636                  
637                 _this.view.loadTicket(ticket.id);
638                 _this.createbtn.updateState();
639                 
640                 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
641             });
642         }
643
644         // user defined functions
645         public string selectedTicketId () {
646         Gtk.TreeIter iter;
647                 Value val1;
648          
649          
650                 this.el.get_active_iter (out iter);
651                 _this.dbmodel.el.get_value (iter, 0, out val1);
652          
653         
654                 return  (string) val1;
655                 
656                 
657                 
658                 
659         }
660     }
661     public class Xcls_dbcellrenderer : Object
662     {
663         public Gtk.CellRendererText el;
664         private NewBranch  _this;
665
666
667             // my vars (def)
668
669         // ctor
670         public Xcls_dbcellrenderer(NewBranch _owner )
671         {
672             _this = _owner;
673             _this.dbcellrenderer = this;
674             this.el = new Gtk.CellRendererText();
675
676             // my vars (dec)
677
678             // set gobject values
679         }
680
681         // user defined functions
682     }
683
684     public class Xcls_dbmodel : Object
685     {
686         public Gtk.ListStore el;
687         private NewBranch  _this;
688
689
690             // my vars (def)
691
692         // ctor
693         public Xcls_dbmodel(NewBranch _owner )
694         {
695             _this = _owner;
696             _this.dbmodel = this;
697             this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
698
699             // my vars (dec)
700
701             // set gobject values
702         }
703
704         // user defined functions
705         public void loadTickets (string project_id , string tid = "") {
706         
707         
708             
709             // fixme .. get project id from selection..
710             
711              RooTicket.singleton().loadTickets(
712                                 project_id,
713                                 _this.btn_not_me.el.active ? RooTicket.Who.ANYBODY :  RooTicket.Who.ME,
714                                  _this.btn_closed.el.active ? RooTicket.Status.ALL :  RooTicket.Status.ACTIVE
715                          );
716                 
717             _this.ticketsel.loading = true;
718         
719             this.el.clear();                                    
720             Gtk.TreeIter iter;
721             var el = this.el;
722             
723             el.append(out iter);
724         
725             
726             el.set_value(iter, 0, "");
727             el.set_value(iter, 1, "-- select a ticket --");
728             
729             _this.ticketsel.el.set_active_iter(iter);
730             var tickets = RooTicket.singleton().tickets;
731             foreach(var ticket in tickets) {
732             
733                 el.append(out iter);
734                 
735                 el.set_value(iter, 0, ticket.id);
736                 el.set_value(iter, 1, "#%s %s".printf( ticket.id, ticket.summary));
737                 
738                 if (ticket.id == tid) {
739                             _this.ticketsel.el.set_active_iter(iter);
740                 }
741                 
742             }
743             
744             _this.ticketsel.loading = false;
745              //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          
746                                              
747         }
748     }
749
750
751     public class Xcls_Button17 : Object
752     {
753         public Gtk.Button el;
754         private NewBranch  _this;
755
756
757             // my vars (def)
758
759         // ctor
760         public Xcls_Button17(NewBranch _owner )
761         {
762             _this = _owner;
763             this.el = new Gtk.Button();
764
765             // my vars (dec)
766
767             // set gobject values
768             this.el.expand = false;
769             this.el.label = "New Ticket";
770
771             //listeners
772             this.el.clicked.connect( () => {
773                 _this.el.response(-1);
774                 Ticket.singleton().show(_this.repo);
775             
776             });
777         }
778
779         // user defined functions
780     }
781
782     public class Xcls_Label18 : Object
783     {
784         public Gtk.Label el;
785         private NewBranch  _this;
786
787
788             // my vars (def)
789
790         // ctor
791         public Xcls_Label18(NewBranch _owner )
792         {
793             _this = _owner;
794             this.el = new Gtk.Label( "Use this as branch name" );
795
796             // my vars (dec)
797
798             // set gobject values
799             this.el.halign = Gtk.Align.START;
800             this.el.justify = Gtk.Justification.RIGHT;
801             this.el.xalign = 0.900000f;
802         }
803
804         // user defined functions
805     }
806
807     public class Xcls_name : Object
808     {
809         public Gtk.Entry el;
810         private NewBranch  _this;
811
812
813             // my vars (def)
814
815         // ctor
816         public Xcls_name(NewBranch _owner )
817         {
818             _this = _owner;
819             _this.name = this;
820             this.el = new Gtk.Entry();
821
822             // my vars (dec)
823
824             // set gobject values
825             this.el.visible = true;
826         }
827
828         // user defined functions
829     }
830
831     public class Xcls_createbtn : Object
832     {
833         public Gtk.Button el;
834         private NewBranch  _this;
835
836
837             // my vars (def)
838
839         // ctor
840         public Xcls_createbtn(NewBranch _owner )
841         {
842             _this = _owner;
843             _this.createbtn = this;
844             this.el = new Gtk.Button();
845
846             // my vars (dec)
847
848             // set gobject values
849             this.el.label = "Create Branch";
850
851             // init method
852
853             {
854                this.el.get_style_context().add_class("suggested-action");
855             }
856
857             //listeners
858             this.el.clicked.connect( () => {
859             
860                 GLib.debug("fire response = 1");
861                 
862                 var ticket_id = _this.ticketsel.selectedTicketId();
863                 
864                 if (ticket_id == "") {
865                         _this.ticketsel.el.get_child().get_style_context().add_class("warning");
866                         return;
867                 }
868                  
869                 _this.el.response(1);
870             });
871         }
872
873         // user defined functions
874         public void updateState () {
875         
876                 var ticket_id = _this.ticketsel.selectedTicketId();
877                 
878                 if (ticket_id == "") {
879                         this.el.set_sensitive(false);
880                         return;
881                 }
882          
883                 this.el.set_sensitive(true);
884          
885         }
886     }
887
888     public class Xcls_Box21 : Object
889     {
890         public Gtk.Box el;
891         private NewBranch  _this;
892
893
894             // my vars (def)
895
896         // ctor
897         public Xcls_Box21(NewBranch _owner )
898         {
899             _this = _owner;
900             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
901
902             // my vars (dec)
903
904             // set gobject values
905             var child_0 = new Xcls_btn_not_me( _this );
906             child_0.ref();
907             this.el.add (  child_0.el  );
908             var child_1 = new Xcls_btn_closed( _this );
909             child_1.ref();
910             this.el.add (  child_1.el  );
911             var child_2 = new Xcls_Label24( _this );
912             child_2.ref();
913             this.el.add (  child_2.el  );
914         }
915
916         // user defined functions
917     }
918     public class Xcls_btn_not_me : Object
919     {
920         public Gtk.CheckButton el;
921         private NewBranch  _this;
922
923
924             // my vars (def)
925
926         // ctor
927         public Xcls_btn_not_me(NewBranch _owner )
928         {
929             _this = _owner;
930             _this.btn_not_me = this;
931             this.el = new Gtk.CheckButton();
932
933             // my vars (dec)
934
935             // set gobject values
936             this.el.label = "Show tickets not assigned to me";
937
938             //listeners
939             this.el.toggled.connect( () => {
940                 var project_id = _this.projectsel.selectedProjectId();
941                 _this.dbmodel.loadTickets(project_id);  
942             });
943         }
944
945         // user defined functions
946     }
947
948     public class Xcls_btn_closed : Object
949     {
950         public Gtk.CheckButton el;
951         private NewBranch  _this;
952
953
954             // my vars (def)
955
956         // ctor
957         public Xcls_btn_closed(NewBranch _owner )
958         {
959             _this = _owner;
960             _this.btn_closed = this;
961             this.el = new Gtk.CheckButton();
962
963             // my vars (dec)
964
965             // set gobject values
966             this.el.label = "Show closed Tickets";
967
968             //listeners
969             this.el.toggled.connect( () => {
970                 var project_id = _this.projectsel.selectedProjectId();
971                 _this.dbmodel.loadTickets(project_id);  
972                  
973             });
974         }
975
976         // user defined functions
977     }
978
979     public class Xcls_Label24 : Object
980     {
981         public Gtk.Label el;
982         private NewBranch  _this;
983
984
985             // my vars (def)
986
987         // ctor
988         public Xcls_Label24(NewBranch _owner )
989         {
990             _this = _owner;
991             this.el = new Gtk.Label( "<a href=\"refresh\">Refresh Ticket list</a>" );
992
993             // my vars (dec)
994
995             // set gobject values
996             this.el.halign = Gtk.Align.END;
997             this.el.hexpand = true;
998             this.el.use_markup = true;
999
1000             //listeners
1001             this.el.activate_link.connect( (uri) => {
1002                 if (uri == "refresh") {
1003                         RooProject.reload();
1004                         var curproj = RooProject.getProjectByRepo(_this.repo);
1005                          _this.prmodel.loadProjects(curproj == null ? "": curproj.id);
1006             
1007                         _this.dbmodel.loadTickets(curproj == null ? "": curproj.id);            
1008                 }
1009                 return true;
1010             });
1011         }
1012
1013         // user defined functions
1014     }
1015
1016
1017
1018     public class Xcls_scrolled_window : Object
1019     {
1020         public Gtk.ScrolledWindow el;
1021         private NewBranch  _this;
1022
1023
1024             // my vars (def)
1025
1026         // ctor
1027         public Xcls_scrolled_window(NewBranch _owner )
1028         {
1029             _this = _owner;
1030             _this.scrolled_window = this;
1031             this.el = new Gtk.ScrolledWindow( null, null );
1032
1033             // my vars (dec)
1034
1035             // set gobject values
1036             this.el.height_request = 500;
1037             this.el.vexpand = true;
1038             var child_0 = new Xcls_view( _this );
1039             child_0.ref();
1040             this.el.add (  child_0.el  );
1041
1042             // init method
1043
1044             {
1045                 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1046             }
1047         }
1048
1049         // user defined functions
1050     }
1051     public class Xcls_view : Object
1052     {
1053         public WebKit.WebView el;
1054         private NewBranch  _this;
1055
1056
1057             // my vars (def)
1058
1059         // ctor
1060         public Xcls_view(NewBranch _owner )
1061         {
1062             _this = _owner;
1063             _this.view = this;
1064             this.el = new WebKit.WebView();
1065
1066             // my vars (dec)
1067
1068             // set gobject values
1069         }
1070
1071         // user defined functions
1072         public void loadTicket (string tid) {
1073                 int h,w;
1074                 _this.el.get_size(out w, out h);
1075                 
1076                 if (tid == "") {
1077                         _this.scrolled_window.el.hide();
1078                         _this.el.resize(w, 150);
1079                 } else {
1080                         _this.scrolled_window.el.show();
1081                         _this.el.resize(w, 800);
1082                 }
1083                 
1084                 var rs =  RooTicket.singleton();                
1085                 var uri = new WebKit.URIRequest("https://roojs.com/admin.php/MTrack/View/" + tid);
1086                 var hd = uri.get_http_headers();
1087                 var authCode = Base64.encode ("%s:%s".printf(rs.username, rs.password).data);
1088                 hd.append("Authorization", "Basic %s".printf(authCode));
1089                 
1090                  this.el.load_request(uri);
1091         }
1092     }
1093
1094
1095
1096     public class Xcls_Box27 : Object
1097     {
1098         public Gtk.Box el;
1099         private NewBranch  _this;
1100
1101
1102             // my vars (def)
1103
1104         // ctor
1105         public Xcls_Box27(NewBranch _owner )
1106         {
1107             _this = _owner;
1108             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1109
1110             // my vars (dec)
1111
1112             // set gobject values
1113             this.el.homogeneous = false;
1114         }
1115
1116         // user defined functions
1117     }
1118
1119     public class Xcls_Box28 : Object
1120     {
1121         public Gtk.Box el;
1122         private NewBranch  _this;
1123
1124
1125             // my vars (def)
1126
1127         // ctor
1128         public Xcls_Box28(NewBranch _owner )
1129         {
1130             _this = _owner;
1131             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1132
1133             // my vars (dec)
1134
1135             // set gobject values
1136             this.el.homogeneous = false;
1137         }
1138
1139         // user defined functions
1140     }
1141
1142
1143 }