src/Builder4/PopoverFileDetails.bjs
[app.Builder.js] / src / Builder4 / PopoverFileDetails.vala
1 static Xcls_PopoverFileDetails  _PopoverFileDetails;
2
3 public class Xcls_PopoverFileDetails : Object
4 {
5     public Gtk.Popover el;
6     private Xcls_PopoverFileDetails  _this;
7
8     public static Xcls_PopoverFileDetails singleton()
9     {
10         if (_PopoverFileDetails == null) {
11             _PopoverFileDetails= new Xcls_PopoverFileDetails();
12         }
13         return _PopoverFileDetails;
14     }
15     public Xcls_grid grid;
16     public Xcls_filetypelbl filetypelbl;
17     public Xcls_filetype filetype;
18     public Xcls_ftdbcellrenderer ftdbcellrenderer;
19     public Xcls_ftdbmodel ftdbmodel;
20     public Xcls_name name;
21     public Xcls_title title;
22     public Xcls_region region;
23     public Xcls_parent parent;
24     public Xcls_permname permname;
25     public Xcls_modOrder modOrder;
26     public Xcls_build_module build_module;
27     public Xcls_dbcellrenderer dbcellrenderer;
28     public Xcls_dbmodel dbmodel;
29     public Xcls_build_module build_module;
30     public Xcls_dbcellrenderer dbcellrenderer;
31     public Xcls_dbmodel dbmodel;
32     public Xcls_save_btn save_btn;
33
34         // my vars (def)
35     public signal void success (Project.Project pr, JsRender.JsRender file);
36     public bool done;
37     public Project.Project project;
38     public JsRender.JsRender file;
39     public Xcls_MainWindow mainwindow;
40
41     // ctor
42     public Xcls_PopoverFileDetails()
43     {
44         _this = this;
45         this.el = new Gtk.Popover( null );
46
47         // my vars (dec)
48         this.done = false;
49         this.file = null;
50         this.mainwindow = null;
51
52         // set gobject values
53         this.el.border_width = 0;
54         this.el.modal = true;
55         this.el.position = Gtk.PositionType.RIGHT;
56         var child_0 = new Xcls_Box2( _this );
57         child_0.ref();
58         this.el.add (  child_0.el  );
59
60         //listeners
61         this.el.closed.connect( () => {
62           if (!this.done) {
63             _this.el.show();
64           
65           }
66         });
67     }
68
69     // user defined functions
70     public   void updateFileFromEntry () {
71     
72             _this.file.title = _this.title.el.get_text();
73             _this.file.region = _this.region.el.get_text();            
74             _this.file.parent = _this.parent.el.get_text();                        
75             _this.file.permname = _this.permname.el.get_text();                                    
76             _this.file.modOrder = _this.modOrder.el.get_text();
77             
78             if (_this.file.name.length  > 0 && _this.file.name != _this.name.el.get_text()) {
79                 _this.file.renameTo(_this.name.el.get_text());
80             }
81             // store the module...
82             _this.file.build_module = "";        
83              Gtk.TreeIter iter; 
84             if (_this.build_module.el.get_active_iter (out iter)) {
85                  Value vfname;
86                  this.dbmodel.el.get_value (iter, 0, out vfname);
87                  if (((string)vfname).length > 0) {
88                      _this.file.build_module = (string)vfname;
89                  }
90         
91             }
92             
93             
94     
95                                                         
96     }
97     public void show (JsRender.JsRender c, Gtk.Widget btn) 
98     {
99         this.project = c.project;
100         this.done = false;
101         
102         
103         //if (!this.el) {
104             //this.init();
105          //}
106         
107         _this.name.el.set_text(c.name);
108         _this.title.el.set_text(c.title);
109         _this.parent.el.set_text(c.parent);    
110         _this.region.el.set_text(c.region);
111         _this.modOrder.el.set_text(c.modOrder);
112          _this.permname.el.set_text(c.permname);
113         
114         
115         
116         
117         
118         
119         
120         if (c.path.length > 0) {
121                  
122             this.save_btn.el.set_label("Save");
123         } else {
124             this.save_btn.el.set_label("Create");
125             
126            
127         }
128         
129          var ar = new Gee.ArrayList<string>();
130          _this.dbmodel.loadData(ar,"");
131         // load the modules... if relivant..
132         if (this.project.xtype == "Gtk") {
133             var p = (Project.Gtk)c.project;
134               var cg = p.compilegroups;
135     
136             var iter = cg.map_iterator();
137            while(iter.next()) {
138                 var key = iter.get_key();
139                 if (key == "_default_") {
140                     continue;
141                 }
142                 ar.add(key);
143             };
144             _this.dbmodel.loadData(ar, c.build_module);
145     
146         }
147         
148          
149         _this.file = c;
150         //console.log('show all');
151        this.el.set_modal(true);
152         this.el.set_relative_to(btn);
153     
154         this.el.set_position(Gtk.PositionType.RIGHT);
155         
156         // window + header?
157          print("SHOWALL - POPIP\n");
158         this.el.show_all();
159         this.name.el.grab_focus();
160         
161         
162         
163         if (c.path.length > 0) {
164                 _this.filetype.el.hide();
165                 _this.filetypelbl.el.hide();
166      
167         } else {
168             
169             _this.ftdbmodel.loadData("bjs"); // fixme - need to determine type..
170             _this.filetype.el.show();
171             _this.filetypelbl.el.show();
172         }
173         
174         
175         //this.success = c.success;
176         
177         
178     }
179     public class Xcls_Box2 : Object
180     {
181         public Gtk.Box el;
182         private Xcls_PopoverFileDetails  _this;
183
184
185             // my vars (def)
186
187         // ctor
188         public Xcls_Box2(Xcls_PopoverFileDetails _owner )
189         {
190             _this = _owner;
191             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
192
193             // my vars (dec)
194
195             // set gobject values
196             this.el.homogeneous = false;
197             var child_0 = new Xcls_HeaderBar3( _this );
198             child_0.ref();
199             this.el.pack_start (  child_0.el , false,true,0 );
200             var child_1 = new Xcls_grid( _this );
201             child_1.ref();
202             this.el.pack_start (  child_1.el , false,false,4 );
203             var child_2 = new Xcls_Label29( _this );
204             child_2.ref();
205             this.el.attach (  child_2.el , 0,7,1,1 );
206             var child_3 = new Xcls_HButtonBox30( _this );
207             child_3.ref();
208             this.el.pack_end (  child_3.el , false,true,0 );
209         }
210
211         // user defined functions
212     }
213     public class Xcls_HeaderBar3 : Object
214     {
215         public Gtk.HeaderBar el;
216         private Xcls_PopoverFileDetails  _this;
217
218
219             // my vars (def)
220
221         // ctor
222         public Xcls_HeaderBar3(Xcls_PopoverFileDetails _owner )
223         {
224             _this = _owner;
225             this.el = new Gtk.HeaderBar();
226
227             // my vars (dec)
228
229             // set gobject values
230             this.el.title = "Add / Edit File";
231         }
232
233         // user defined functions
234     }
235
236     public class Xcls_grid : Object
237     {
238         public Gtk.Grid el;
239         private Xcls_PopoverFileDetails  _this;
240
241
242             // my vars (def)
243
244         // ctor
245         public Xcls_grid(Xcls_PopoverFileDetails _owner )
246         {
247             _this = _owner;
248             _this.grid = this;
249             this.el = new Gtk.Grid();
250
251             // my vars (dec)
252
253             // set gobject values
254             this.el.margin_right = 4;
255             this.el.margin_left = 4;
256             this.el.row_spacing = 2;
257             var child_0 = new Xcls_filetypelbl( _this );
258             child_0.ref();
259             this.el.attach (  child_0.el , 0,0,1,1 );
260             var child_1 = new Xcls_filetype( _this );
261             child_1.ref();
262             this.el.attach (  child_1.el , 1,0,1,1 );
263             var child_2 = new Xcls_Label9( _this );
264             child_2.ref();
265             this.el.attach (  child_2.el , 0,1,1,1 );
266             var child_3 = new Xcls_name( _this );
267             child_3.ref();
268             this.el.attach (  child_3.el , 1,1,1,1 );
269             var child_4 = new Xcls_Label11( _this );
270             child_4.ref();
271             this.el.attach (  child_4.el , 0,2,1,1 );
272             var child_5 = new Xcls_title( _this );
273             child_5.ref();
274             this.el.attach (  child_5.el , 1,2,1,1 );
275             var child_6 = new Xcls_Label13( _this );
276             child_6.ref();
277             this.el.attach (  child_6.el , 0,3,1,1 );
278             var child_7 = new Xcls_region( _this );
279             child_7.ref();
280             this.el.attach (  child_7.el , 1,3,1,1 );
281             var child_8 = new Xcls_Label15( _this );
282             child_8.ref();
283             this.el.attach (  child_8.el , 0,4,1,1 );
284             var child_9 = new Xcls_parent( _this );
285             child_9.ref();
286             this.el.attach (  child_9.el , 1,4,1,1 );
287             var child_10 = new Xcls_Label17( _this );
288             child_10.ref();
289             this.el.attach (  child_10.el , 0,5,1,1 );
290             var child_11 = new Xcls_permname( _this );
291             child_11.ref();
292             this.el.attach (  child_11.el , 1,5,1,1 );
293             var child_12 = new Xcls_Label19( _this );
294             child_12.ref();
295             this.el.attach (  child_12.el , 0,6,1,1 );
296             var child_13 = new Xcls_modOrder( _this );
297             child_13.ref();
298             this.el.attach (  child_13.el , 1,6,1,1 );
299             var child_14 = new Xcls_Label21( _this );
300             child_14.ref();
301             this.el.attach (  child_14.el , 0,7,1,1 );
302             var child_15 = new Xcls_build_module( _this );
303             child_15.ref();
304             this.el.attach (  child_15.el , 1,7,1,1 );
305             var child_16 = new Xcls_Label25( _this );
306             child_16.ref();
307             this.el.attach (  child_16.el , 0,8 );
308             var child_17 = new Xcls_build_module( _this );
309             child_17.ref();
310             this.el.attach (  child_17.el , 1,8 );
311         }
312
313         // user defined functions
314     }
315     public class Xcls_filetypelbl : Object
316     {
317         public Gtk.Label el;
318         private Xcls_PopoverFileDetails  _this;
319
320
321             // my vars (def)
322
323         // ctor
324         public Xcls_filetypelbl(Xcls_PopoverFileDetails _owner )
325         {
326             _this = _owner;
327             _this.filetypelbl = this;
328             this.el = new Gtk.Label( "File type" );
329
330             // my vars (dec)
331
332             // set gobject values
333             this.el.justify = Gtk.Justification.RIGHT;
334             this.el.xalign = 0.900000f;
335         }
336
337         // user defined functions
338     }
339
340     public class Xcls_filetype : Object
341     {
342         public Gtk.ComboBox el;
343         private Xcls_PopoverFileDetails  _this;
344
345
346             // my vars (def)
347
348         // ctor
349         public Xcls_filetype(Xcls_PopoverFileDetails _owner )
350         {
351             _this = _owner;
352             _this.filetype = this;
353             this.el = new Gtk.ComboBox();
354
355             // my vars (dec)
356
357             // set gobject values
358             var child_0 = new Xcls_ftdbcellrenderer( _this );
359             child_0.ref();
360             this.el.pack_start (  child_0.el , true );
361             var child_1 = new Xcls_ftdbmodel( _this );
362             child_1.ref();
363             this.el.set_model (  child_1.el  );
364
365             // init method
366
367             this.el.add_attribute(_this.ftdbcellrenderer.el , "markup", 1 );
368
369             //listeners
370             this.el.changed.connect( () => {
371                 Gtk.TreeIter iter;
372                 bool is_bjs = true;
373                 if (this.el.get_active_iter(out iter)) {
374                         Value vfname;
375                         _this.ftdbmodel.el.get_value (iter, 0, out vfname);
376                          is_bjs = ((string)vfname) == "bjs";
377                 }
378                 
379                for (var i = 2; i < 8;i++) {
380                         var el = _this.grid.el.get_child_at(0,i);
381                         if (is_bjs) {
382                            el.show();
383                         } else {
384                                 el.hide();
385                         }
386                          el = _this.grid.el.get_child_at(1,i);
387                         if (is_bjs) {
388                            el.show();
389                         } else {
390                                 el.hide();
391                         }     
392                 }
393                  
394                  
395             
396             
397             });
398         }
399
400         // user defined functions
401     }
402     public class Xcls_ftdbcellrenderer : Object
403     {
404         public Gtk.CellRendererText el;
405         private Xcls_PopoverFileDetails  _this;
406
407
408             // my vars (def)
409
410         // ctor
411         public Xcls_ftdbcellrenderer(Xcls_PopoverFileDetails _owner )
412         {
413             _this = _owner;
414             _this.ftdbcellrenderer = this;
415             this.el = new Gtk.CellRendererText();
416
417             // my vars (dec)
418
419             // set gobject values
420         }
421
422         // user defined functions
423     }
424
425     public class Xcls_ftdbmodel : Object
426     {
427         public Gtk.ListStore el;
428         private Xcls_PopoverFileDetails  _this;
429
430
431             // my vars (def)
432
433         // ctor
434         public Xcls_ftdbmodel(Xcls_PopoverFileDetails _owner )
435         {
436             _this = _owner;
437             _this.ftdbmodel = this;
438             this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
439
440             // my vars (dec)
441
442             // set gobject values
443         }
444
445         // user defined functions
446         public void loadData (string cur) {
447             this.el.clear();                                    
448             Gtk.TreeIter iter;
449             var el = this.el;
450             
451            /// el.append(out iter);
452             
453              
454            // el.set_value(iter, 0, "");
455            // el.set_value(iter, 1, "aaa  - Just add Element - aaa");
456         
457             el.append(out iter);
458         
459             
460             el.set_value(iter, 0, "bjs");
461             el.set_value(iter, 1, "User Interface File (bjs)");
462             _this.filetype.el.set_active_iter(iter);
463         
464             el.append(out iter);
465             
466             el.set_value(iter, 0, "vala");
467             el.set_value(iter, 1, "Vala");
468                 if (cur == "vala") {
469                     _this.filetype.el.set_active_iter(iter);
470             }
471         
472         
473         
474             el.append(out iter);
475             
476             el.set_value(iter, 0, "js");
477             el.set_value(iter, 1, "Javascript");
478         
479                 if (cur == "js") {
480                     _this.filetype.el.set_active_iter(iter);
481             }
482         
483             el.append(out iter);
484             
485             el.set_value(iter, 0, "css");
486             el.set_value(iter, 1, "CSS");
487         
488                 if (cur == "css") {
489                     _this.filetype.el.set_active_iter(iter);
490             }
491                                              
492         }
493     }
494
495
496     public class Xcls_Label9 : Object
497     {
498         public Gtk.Label el;
499         private Xcls_PopoverFileDetails  _this;
500
501
502             // my vars (def)
503
504         // ctor
505         public Xcls_Label9(Xcls_PopoverFileDetails _owner )
506         {
507             _this = _owner;
508             this.el = new Gtk.Label( "Component Name" );
509
510             // my vars (dec)
511
512             // set gobject values
513             this.el.justify = Gtk.Justification.RIGHT;
514             this.el.xalign = 0.900000f;
515         }
516
517         // user defined functions
518     }
519
520     public class Xcls_name : Object
521     {
522         public Gtk.Entry el;
523         private Xcls_PopoverFileDetails  _this;
524
525
526             // my vars (def)
527
528         // ctor
529         public Xcls_name(Xcls_PopoverFileDetails _owner )
530         {
531             _this = _owner;
532             _this.name = this;
533             this.el = new Gtk.Entry();
534
535             // my vars (dec)
536
537             // set gobject values
538             this.el.visible = true;
539         }
540
541         // user defined functions
542     }
543
544     public class Xcls_Label11 : Object
545     {
546         public Gtk.Label el;
547         private Xcls_PopoverFileDetails  _this;
548
549
550             // my vars (def)
551
552         // ctor
553         public Xcls_Label11(Xcls_PopoverFileDetails _owner )
554         {
555             _this = _owner;
556             this.el = new Gtk.Label( "Title" );
557
558             // my vars (dec)
559
560             // set gobject values
561             this.el.justify = Gtk.Justification.RIGHT;
562             this.el.xalign = 0.900000f;
563             this.el.visible = true;
564         }
565
566         // user defined functions
567     }
568
569     public class Xcls_title : Object
570     {
571         public Gtk.Entry el;
572         private Xcls_PopoverFileDetails  _this;
573
574
575             // my vars (def)
576
577         // ctor
578         public Xcls_title(Xcls_PopoverFileDetails _owner )
579         {
580             _this = _owner;
581             _this.title = this;
582             this.el = new Gtk.Entry();
583
584             // my vars (dec)
585
586             // set gobject values
587             this.el.visible = true;
588         }
589
590         // user defined functions
591     }
592
593     public class Xcls_Label13 : Object
594     {
595         public Gtk.Label el;
596         private Xcls_PopoverFileDetails  _this;
597
598
599             // my vars (def)
600
601         // ctor
602         public Xcls_Label13(Xcls_PopoverFileDetails _owner )
603         {
604             _this = _owner;
605             this.el = new Gtk.Label( "Region" );
606
607             // my vars (dec)
608
609             // set gobject values
610             this.el.justify = Gtk.Justification.RIGHT;
611             this.el.xalign = 0.900000f;
612             this.el.tooltip_text = "center, north, south, east, west";
613             this.el.visible = true;
614         }
615
616         // user defined functions
617     }
618
619     public class Xcls_region : Object
620     {
621         public Gtk.Entry el;
622         private Xcls_PopoverFileDetails  _this;
623
624
625             // my vars (def)
626
627         // ctor
628         public Xcls_region(Xcls_PopoverFileDetails _owner )
629         {
630             _this = _owner;
631             _this.region = this;
632             this.el = new Gtk.Entry();
633
634             // my vars (dec)
635
636             // set gobject values
637             this.el.visible = true;
638         }
639
640         // user defined functions
641     }
642
643     public class Xcls_Label15 : Object
644     {
645         public Gtk.Label el;
646         private Xcls_PopoverFileDetails  _this;
647
648
649             // my vars (def)
650
651         // ctor
652         public Xcls_Label15(Xcls_PopoverFileDetails _owner )
653         {
654             _this = _owner;
655             this.el = new Gtk.Label( "Parent Name" );
656
657             // my vars (dec)
658
659             // set gobject values
660             this.el.justify = Gtk.Justification.RIGHT;
661             this.el.xalign = 0.900000f;
662             this.el.visible = true;
663         }
664
665         // user defined functions
666     }
667
668     public class Xcls_parent : Object
669     {
670         public Gtk.Entry el;
671         private Xcls_PopoverFileDetails  _this;
672
673
674             // my vars (def)
675
676         // ctor
677         public Xcls_parent(Xcls_PopoverFileDetails _owner )
678         {
679             _this = _owner;
680             _this.parent = this;
681             this.el = new Gtk.Entry();
682
683             // my vars (dec)
684
685             // set gobject values
686             this.el.visible = true;
687         }
688
689         // user defined functions
690     }
691
692     public class Xcls_Label17 : Object
693     {
694         public Gtk.Label el;
695         private Xcls_PopoverFileDetails  _this;
696
697
698             // my vars (def)
699
700         // ctor
701         public Xcls_Label17(Xcls_PopoverFileDetails _owner )
702         {
703             _this = _owner;
704             this.el = new Gtk.Label( "Permission Name" );
705
706             // my vars (dec)
707
708             // set gobject values
709             this.el.justify = Gtk.Justification.RIGHT;
710             this.el.xalign = 0.900000f;
711             this.el.visible = true;
712         }
713
714         // user defined functions
715     }
716
717     public class Xcls_permname : Object
718     {
719         public Gtk.Entry el;
720         private Xcls_PopoverFileDetails  _this;
721
722
723             // my vars (def)
724
725         // ctor
726         public Xcls_permname(Xcls_PopoverFileDetails _owner )
727         {
728             _this = _owner;
729             _this.permname = this;
730             this.el = new Gtk.Entry();
731
732             // my vars (dec)
733
734             // set gobject values
735             this.el.visible = true;
736         }
737
738         // user defined functions
739     }
740
741     public class Xcls_Label19 : Object
742     {
743         public Gtk.Label el;
744         private Xcls_PopoverFileDetails  _this;
745
746
747             // my vars (def)
748
749         // ctor
750         public Xcls_Label19(Xcls_PopoverFileDetails _owner )
751         {
752             _this = _owner;
753             this.el = new Gtk.Label( "Order (for tabs)" );
754
755             // my vars (dec)
756
757             // set gobject values
758             this.el.justify = Gtk.Justification.RIGHT;
759             this.el.xalign = 0.900000f;
760             this.el.visible = true;
761         }
762
763         // user defined functions
764     }
765
766     public class Xcls_modOrder : Object
767     {
768         public Gtk.Entry el;
769         private Xcls_PopoverFileDetails  _this;
770
771
772             // my vars (def)
773
774         // ctor
775         public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
776         {
777             _this = _owner;
778             _this.modOrder = this;
779             this.el = new Gtk.Entry();
780
781             // my vars (dec)
782
783             // set gobject values
784             this.el.visible = true;
785         }
786
787         // user defined functions
788     }
789
790     public class Xcls_Label21 : Object
791     {
792         public Gtk.Label el;
793         private Xcls_PopoverFileDetails  _this;
794
795
796             // my vars (def)
797
798         // ctor
799         public Xcls_Label21(Xcls_PopoverFileDetails _owner )
800         {
801             _this = _owner;
802             this.el = new Gtk.Label( "Module to build (Vala only)" );
803
804             // my vars (dec)
805
806             // set gobject values
807             this.el.justify = Gtk.Justification.RIGHT;
808             this.el.xalign = 0.900000f;
809             this.el.visible = true;
810         }
811
812         // user defined functions
813     }
814
815     public class Xcls_build_module : Object
816     {
817         public Gtk.ComboBox el;
818         private Xcls_PopoverFileDetails  _this;
819
820
821             // my vars (def)
822
823         // ctor
824         public Xcls_build_module(Xcls_PopoverFileDetails _owner )
825         {
826             _this = _owner;
827             _this.build_module = this;
828             this.el = new Gtk.ComboBox();
829
830             // my vars (dec)
831
832             // set gobject values
833             var child_0 = new Xcls_dbcellrenderer( _this );
834             child_0.ref();
835             this.el.pack_start (  child_0.el , true );
836             var child_1 = new Xcls_dbmodel( _this );
837             child_1.ref();
838             this.el.set_model (  child_1.el  );
839
840             // init method
841
842             this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
843         }
844
845         // user defined functions
846     }
847     public class Xcls_dbcellrenderer : Object
848     {
849         public Gtk.CellRendererText el;
850         private Xcls_PopoverFileDetails  _this;
851
852
853             // my vars (def)
854
855         // ctor
856         public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
857         {
858             _this = _owner;
859             _this.dbcellrenderer = this;
860             this.el = new Gtk.CellRendererText();
861
862             // my vars (dec)
863
864             // set gobject values
865         }
866
867         // user defined functions
868     }
869
870     public class Xcls_dbmodel : Object
871     {
872         public Gtk.ListStore el;
873         private Xcls_PopoverFileDetails  _this;
874
875
876             // my vars (def)
877
878         // ctor
879         public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
880         {
881             _this = _owner;
882             _this.dbmodel = this;
883             this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
884
885             // my vars (dec)
886
887             // set gobject values
888         }
889
890         // user defined functions
891         public void loadData (Gee.ArrayList<string> data, string cur) {
892             this.el.clear();                                    
893             Gtk.TreeIter iter;
894             var el = this.el;
895             
896            /// el.append(out iter);
897             
898              
899            // el.set_value(iter, 0, "");
900            // el.set_value(iter, 1, "aaa  - Just add Element - aaa");
901         
902             el.append(out iter);
903         
904             
905             el.set_value(iter, 0, "");
906             el.set_value(iter, 1, "-- select a module --");
907             _this.build_module.el.set_active_iter(iter);
908             
909             for (var i = 0; i < data.size;i++) {
910             
911         
912                 el.append(out iter);
913                 
914                 el.set_value(iter, 0, data.get(i));
915                 el.set_value(iter, 1, data.get(i));
916                 
917                 if (data.get(i) == cur) {
918                     _this.build_module.el.set_active_iter(iter);
919                 }
920                 
921             }
922              this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          
923                                              
924         }
925     }
926
927
928     public class Xcls_Label25 : Object
929     {
930         public Gtk.Label el;
931         private Xcls_PopoverFileDetails  _this;
932
933
934             // my vars (def)
935
936         // ctor
937         public Xcls_Label25(Xcls_PopoverFileDetails _owner )
938         {
939             _this = _owner;
940             this.el = new Gtk.Label( "Directory" );
941
942             // my vars (dec)
943
944             // set gobject values
945             this.el.justify = Gtk.Justification.RIGHT;
946             this.el.xalign = 0.900000f;
947             this.el.visible = true;
948         }
949
950         // user defined functions
951     }
952
953     public class Xcls_build_module : Object
954     {
955         public Gtk.ComboBox el;
956         private Xcls_PopoverFileDetails  _this;
957
958
959             // my vars (def)
960
961         // ctor
962         public Xcls_build_module(Xcls_PopoverFileDetails _owner )
963         {
964             _this = _owner;
965             _this.build_module = this;
966             this.el = new Gtk.ComboBox();
967
968             // my vars (dec)
969
970             // set gobject values
971             var child_0 = new Xcls_dbcellrenderer( _this );
972             child_0.ref();
973             this.el.pack_start (  child_0.el , true );
974             var child_1 = new Xcls_dbmodel( _this );
975             child_1.ref();
976             this.el.set_model (  child_1.el  );
977
978             // init method
979
980             this.el.add_attribute(_this.dircellrenderer.el , "markup", 1 );
981         }
982
983         // user defined functions
984     }
985     public class Xcls_dbcellrenderer : Object
986     {
987         public Gtk.CellRendererText el;
988         private Xcls_PopoverFileDetails  _this;
989
990
991             // my vars (def)
992
993         // ctor
994         public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
995         {
996             _this = _owner;
997             _this.dbcellrenderer = this;
998             this.el = new Gtk.CellRendererText();
999
1000             // my vars (dec)
1001
1002             // set gobject values
1003         }
1004
1005         // user defined functions
1006     }
1007
1008     public class Xcls_dbmodel : Object
1009     {
1010         public Gtk.ListStore el;
1011         private Xcls_PopoverFileDetails  _this;
1012
1013
1014             // my vars (def)
1015
1016         // ctor
1017         public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
1018         {
1019             _this = _owner;
1020             _this.dbmodel = this;
1021             this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
1022
1023             // my vars (dec)
1024
1025             // set gobject values
1026         }
1027
1028         // user defined functions
1029         public void loadData (Gee.ArrayList<string> data, string cur) {
1030             this.el.clear();                                    
1031             Gtk.TreeIter iter;
1032             var el = this.el;
1033             
1034            /// el.append(out iter);
1035             
1036              
1037            // el.set_value(iter, 0, "");
1038            // el.set_value(iter, 1, "aaa  - Just add Element - aaa");
1039         
1040             el.append(out iter);
1041         
1042             
1043             el.set_value(iter, 0, "");
1044             el.set_value(iter, 1, "-- select a module --");
1045             _this.build_module.el.set_active_iter(iter);
1046             
1047             for (var i = 0; i < data.size;i++) {
1048             
1049         
1050                 el.append(out iter);
1051                 
1052                 el.set_value(iter, 0, data.get(i));
1053                 el.set_value(iter, 1, data.get(i));
1054                 
1055                 if (data.get(i) == cur) {
1056                     _this.build_module.el.set_active_iter(iter);
1057                 }
1058                 
1059             }
1060              this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          
1061                                              
1062         }
1063     }
1064
1065
1066
1067     public class Xcls_Label29 : Object
1068     {
1069         public Gtk.Label el;
1070         private Xcls_PopoverFileDetails  _this;
1071
1072
1073             // my vars (def)
1074
1075         // ctor
1076         public Xcls_Label29(Xcls_PopoverFileDetails _owner )
1077         {
1078             _this = _owner;
1079             this.el = new Gtk.Label( "Module to build (Vala only)" );
1080
1081             // my vars (dec)
1082
1083             // set gobject values
1084             this.el.justify = Gtk.Justification.RIGHT;
1085             this.el.xalign = 0.900000f;
1086             this.el.visible = true;
1087         }
1088
1089         // user defined functions
1090     }
1091
1092     public class Xcls_HButtonBox30 : Object
1093     {
1094         public Gtk.HButtonBox el;
1095         private Xcls_PopoverFileDetails  _this;
1096
1097
1098             // my vars (def)
1099
1100         // ctor
1101         public Xcls_HButtonBox30(Xcls_PopoverFileDetails _owner )
1102         {
1103             _this = _owner;
1104             this.el = new Gtk.HButtonBox();
1105
1106             // my vars (dec)
1107
1108             // set gobject values
1109             this.el.margin_right = 4;
1110             this.el.margin_left = 4;
1111             this.el.margin_bottom = 4;
1112             var child_0 = new Xcls_Button31( _this );
1113             child_0.ref();
1114             this.el.add (  child_0.el  );
1115             var child_1 = new Xcls_save_btn( _this );
1116             child_1.ref();
1117             this.el.add (  child_1.el  );
1118         }
1119
1120         // user defined functions
1121     }
1122     public class Xcls_Button31 : Object
1123     {
1124         public Gtk.Button el;
1125         private Xcls_PopoverFileDetails  _this;
1126
1127
1128             // my vars (def)
1129
1130         // ctor
1131         public Xcls_Button31(Xcls_PopoverFileDetails _owner )
1132         {
1133             _this = _owner;
1134             this.el = new Gtk.Button();
1135
1136             // my vars (dec)
1137
1138             // set gobject values
1139             this.el.label = "Cancel";
1140
1141             //listeners
1142             this.el.clicked.connect( () => { 
1143             
1144               _this.done = true;
1145                 _this.el.hide(); 
1146             });
1147         }
1148
1149         // user defined functions
1150     }
1151
1152     public class Xcls_save_btn : Object
1153     {
1154         public Gtk.Button el;
1155         private Xcls_PopoverFileDetails  _this;
1156
1157
1158             // my vars (def)
1159
1160         // ctor
1161         public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
1162         {
1163             _this = _owner;
1164             _this.save_btn = this;
1165             this.el = new Gtk.Button();
1166
1167             // my vars (dec)
1168
1169             // set gobject values
1170             this.el.label = "Save";
1171
1172             //listeners
1173             this.el.clicked.connect( ( ) =>  { 
1174             
1175              
1176             
1177             
1178                 if (_this.name.el.get_text().length  < 1) {
1179                     StandardErrorDialog.show(
1180                         _this.mainwindow.el,
1181                         "You have to set Component name "
1182                     );
1183                      
1184                     return;
1185                 }
1186                 // what does this do?
1187                 
1188                 var isNew = _this.file.name.length  > 0 ? false : true;
1189                 /*
1190                 if (!isNew && this.file.name != _this.name.el.get_text()) {
1191                     Xcls_StandardErrorDialog.singleton().show(
1192                         this.el,
1193                         "Sorry changing names does not work yet. "
1194                     );
1195                      
1196                     return;
1197                 }
1198                 */
1199                  
1200                 
1201               
1202                 // FIXME - this may be more complicated...
1203                 //for (var i in this.def) {
1204                 //    this.file[i] =  this.get(i).el.get_text();
1205                 //}
1206             
1207                 if (!isNew) {
1208                     try {
1209                          _this.updateFileFromEntry();
1210                      } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
1211                           Xcls_StandardErrorDialog.singleton().show(
1212                             _this.mainwindow.el,
1213                             "The name you used already exists "
1214                         );
1215                         return;
1216                          
1217                      }
1218             
1219                       _this.done = true;
1220                     _this.file.save();
1221                     _this.el.hide();
1222                     return;
1223                 }
1224                 
1225                 // ---------------- NEW FILES...
1226                 
1227                 var fn = _this.name.el.get_text();
1228                 var dir = _this.project.firstPath();   // fixme.. should be based on a pulldown?
1229                 
1230                 var targetfile = dir + "/" + fn;
1231                 
1232                 // strip the file type off the end..
1233                 Gtk.TreeIter iter;
1234             
1235                 if (!_this.filetype.el.get_active_iter(out iter)) {
1236                         // should not happen...
1237                         // so we are jut going to return without 
1238                         StandardErrorDialog.show(
1239                         _this.mainwindow.el,
1240                         "You must select a file type. "
1241                     );
1242                 }
1243                 Value ftypename;
1244                 _this.ftdbmodel.el.get_value (iter, 0, out ftypename);
1245                 var ext = ((string)ftypename);
1246                 
1247                 var rx = new GLib.Regex("\\." + ext + "$",GLib.RegexCompileFlags.CASELESS);
1248                 targetfile = rx.replace(targetfile, targetfile.length, 0, ""); 
1249                
1250                 if (GLib.FileUtils.test(targetfile + "." + ext, GLib.FileTest.EXISTS)) {
1251                     Xcls_StandardErrorDialog.singleton().show(
1252                         _this.mainwindow.el,
1253                         "That file already exists"
1254                     ); 
1255                     return;
1256                 }
1257                
1258                var f =  JsRender.JsRender.factory(
1259                         ext == "bjs" ? _this.file.project.xtype : "PlainFile",  
1260                         _this.file.project, 
1261                         targetfile + "." + ext);
1262             
1263                 _this.file = f;
1264                 
1265             
1266                 
1267                 _this.updateFileFromEntry();
1268                 _this.file.loaded = true;
1269                 _this.file.save();
1270                 if (ext == "bjs") {
1271                         _this.file.project.addFile(_this.file);
1272                 }
1273                 
1274              
1275                 // what about .js ?
1276                _this.done = true;
1277                 _this.el.hide();
1278             
1279             // hopefull this will work with bjs files..
1280                 
1281                 _this.success(_this.project, _this.file);
1282                
1283             });
1284         }
1285
1286         // user defined functions
1287     }
1288
1289
1290
1291 }