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