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