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