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