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