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