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