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,5,1,1 );
271             var child_12 = new Xcls_Label19( _this );
272             child_12.ref();
273             this.el.attach (  child_12.el , 0,6,1,1 );
274             var child_13 = new Xcls_modOrder( _this );
275             child_13.ref();
276             this.el.attach (  child_13.el , 1,6,1,1 );
277             var child_14 = new Xcls_Label21( _this );
278             child_14.ref();
279             this.el.attach (  child_14.el , 0,7,1,1 );
280             var child_15 = new Xcls_build_module( _this );
281             child_15.ref();
282             this.el.attach (  child_15.el , 1,7,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             //listeners
342             this.el.changed.connect( () => {
343                 Gtk.TreeIter iter;
344                 if (!this.el.get_active_iter(out iter)) {
345                         return;
346                 }
347                 
348             
349             
350             });
351         }
352
353         // user defined functions
354     }
355     public class Xcls_ftdbcellrenderer : Object
356     {
357         public Gtk.CellRendererText el;
358         private Xcls_PopoverFileDetails  _this;
359
360
361             // my vars (def)
362
363         // ctor
364         public Xcls_ftdbcellrenderer(Xcls_PopoverFileDetails _owner )
365         {
366             _this = _owner;
367             _this.ftdbcellrenderer = this;
368             this.el = new Gtk.CellRendererText();
369
370             // my vars (dec)
371
372             // set gobject values
373         }
374
375         // user defined functions
376     }
377
378     public class Xcls_ftdbmodel : Object
379     {
380         public Gtk.ListStore el;
381         private Xcls_PopoverFileDetails  _this;
382
383
384             // my vars (def)
385
386         // ctor
387         public Xcls_ftdbmodel(Xcls_PopoverFileDetails _owner )
388         {
389             _this = _owner;
390             _this.ftdbmodel = this;
391             this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
392
393             // my vars (dec)
394
395             // set gobject values
396         }
397
398         // user defined functions
399         public void loadData (string cur) {
400             this.el.clear();                                    
401             Gtk.TreeIter iter;
402             var el = this.el;
403             
404            /// el.append(out iter);
405             
406              
407            // el.set_value(iter, 0, "");
408            // el.set_value(iter, 1, "aaa  - Just add Element - aaa");
409         
410             el.append(out iter);
411         
412             
413             el.set_value(iter, 0, "bjs");
414             el.set_value(iter, 1, "User Interface File (bjs)");
415             _this.filetype.el.set_active_iter(iter);
416         
417             el.append(out iter);
418             
419             el.set_value(iter, 0, "vala");
420             el.set_value(iter, 1, "Vala");
421                 if (cur == "vala") {
422                     _this.filetype.el.set_active_iter(iter);
423             }
424         
425         
426         
427             el.append(out iter);
428             
429             el.set_value(iter, 0, "js");
430             el.set_value(iter, 1, "Javascript");
431         
432                 if (cur == "js") {
433                     _this.filetype.el.set_active_iter(iter);
434             }
435         
436             el.append(out iter);
437             
438             el.set_value(iter, 0, "css");
439             el.set_value(iter, 1, "CSS");
440         
441                 if (cur == "css") {
442                     _this.filetype.el.set_active_iter(iter);
443             }
444                                              
445         }
446     }
447
448
449     public class Xcls_Label9 : Object
450     {
451         public Gtk.Label el;
452         private Xcls_PopoverFileDetails  _this;
453
454
455             // my vars (def)
456
457         // ctor
458         public Xcls_Label9(Xcls_PopoverFileDetails _owner )
459         {
460             _this = _owner;
461             this.el = new Gtk.Label( "Component Name" );
462
463             // my vars (dec)
464
465             // set gobject values
466             this.el.justify = Gtk.Justification.RIGHT;
467             this.el.xalign = 0.900000f;
468         }
469
470         // user defined functions
471     }
472
473     public class Xcls_name : Object
474     {
475         public Gtk.Entry el;
476         private Xcls_PopoverFileDetails  _this;
477
478
479             // my vars (def)
480
481         // ctor
482         public Xcls_name(Xcls_PopoverFileDetails _owner )
483         {
484             _this = _owner;
485             _this.name = this;
486             this.el = new Gtk.Entry();
487
488             // my vars (dec)
489
490             // set gobject values
491             this.el.visible = true;
492         }
493
494         // user defined functions
495     }
496
497     public class Xcls_Label11 : Object
498     {
499         public Gtk.Label el;
500         private Xcls_PopoverFileDetails  _this;
501
502
503             // my vars (def)
504
505         // ctor
506         public Xcls_Label11(Xcls_PopoverFileDetails _owner )
507         {
508             _this = _owner;
509             this.el = new Gtk.Label( "Title" );
510
511             // my vars (dec)
512
513             // set gobject values
514             this.el.justify = Gtk.Justification.RIGHT;
515             this.el.xalign = 0.900000f;
516             this.el.visible = true;
517         }
518
519         // user defined functions
520     }
521
522     public class Xcls_title : Object
523     {
524         public Gtk.Entry el;
525         private Xcls_PopoverFileDetails  _this;
526
527
528             // my vars (def)
529
530         // ctor
531         public Xcls_title(Xcls_PopoverFileDetails _owner )
532         {
533             _this = _owner;
534             _this.title = this;
535             this.el = new Gtk.Entry();
536
537             // my vars (dec)
538
539             // set gobject values
540             this.el.visible = true;
541         }
542
543         // user defined functions
544     }
545
546     public class Xcls_Label13 : Object
547     {
548         public Gtk.Label el;
549         private Xcls_PopoverFileDetails  _this;
550
551
552             // my vars (def)
553
554         // ctor
555         public Xcls_Label13(Xcls_PopoverFileDetails _owner )
556         {
557             _this = _owner;
558             this.el = new Gtk.Label( "Region" );
559
560             // my vars (dec)
561
562             // set gobject values
563             this.el.justify = Gtk.Justification.RIGHT;
564             this.el.xalign = 0.900000f;
565             this.el.tooltip_text = "center, north, south, east, west";
566             this.el.visible = true;
567         }
568
569         // user defined functions
570     }
571
572     public class Xcls_region : Object
573     {
574         public Gtk.Entry el;
575         private Xcls_PopoverFileDetails  _this;
576
577
578             // my vars (def)
579
580         // ctor
581         public Xcls_region(Xcls_PopoverFileDetails _owner )
582         {
583             _this = _owner;
584             _this.region = this;
585             this.el = new Gtk.Entry();
586
587             // my vars (dec)
588
589             // set gobject values
590             this.el.visible = true;
591         }
592
593         // user defined functions
594     }
595
596     public class Xcls_Label15 : Object
597     {
598         public Gtk.Label el;
599         private Xcls_PopoverFileDetails  _this;
600
601
602             // my vars (def)
603
604         // ctor
605         public Xcls_Label15(Xcls_PopoverFileDetails _owner )
606         {
607             _this = _owner;
608             this.el = new Gtk.Label( "Parent Name" );
609
610             // my vars (dec)
611
612             // set gobject values
613             this.el.justify = Gtk.Justification.RIGHT;
614             this.el.xalign = 0.900000f;
615             this.el.visible = true;
616         }
617
618         // user defined functions
619     }
620
621     public class Xcls_parent : Object
622     {
623         public Gtk.Entry el;
624         private Xcls_PopoverFileDetails  _this;
625
626
627             // my vars (def)
628
629         // ctor
630         public Xcls_parent(Xcls_PopoverFileDetails _owner )
631         {
632             _this = _owner;
633             _this.parent = this;
634             this.el = new Gtk.Entry();
635
636             // my vars (dec)
637
638             // set gobject values
639             this.el.visible = true;
640         }
641
642         // user defined functions
643     }
644
645     public class Xcls_Label17 : Object
646     {
647         public Gtk.Label el;
648         private Xcls_PopoverFileDetails  _this;
649
650
651             // my vars (def)
652
653         // ctor
654         public Xcls_Label17(Xcls_PopoverFileDetails _owner )
655         {
656             _this = _owner;
657             this.el = new Gtk.Label( "Permission Name" );
658
659             // my vars (dec)
660
661             // set gobject values
662             this.el.justify = Gtk.Justification.RIGHT;
663             this.el.xalign = 0.900000f;
664             this.el.visible = true;
665         }
666
667         // user defined functions
668     }
669
670     public class Xcls_permname : Object
671     {
672         public Gtk.Entry el;
673         private Xcls_PopoverFileDetails  _this;
674
675
676             // my vars (def)
677
678         // ctor
679         public Xcls_permname(Xcls_PopoverFileDetails _owner )
680         {
681             _this = _owner;
682             _this.permname = this;
683             this.el = new Gtk.Entry();
684
685             // my vars (dec)
686
687             // set gobject values
688             this.el.visible = true;
689         }
690
691         // user defined functions
692     }
693
694     public class Xcls_Label19 : Object
695     {
696         public Gtk.Label el;
697         private Xcls_PopoverFileDetails  _this;
698
699
700             // my vars (def)
701
702         // ctor
703         public Xcls_Label19(Xcls_PopoverFileDetails _owner )
704         {
705             _this = _owner;
706             this.el = new Gtk.Label( "Order (for tabs)" );
707
708             // my vars (dec)
709
710             // set gobject values
711             this.el.justify = Gtk.Justification.RIGHT;
712             this.el.xalign = 0.900000f;
713             this.el.visible = true;
714         }
715
716         // user defined functions
717     }
718
719     public class Xcls_modOrder : Object
720     {
721         public Gtk.Entry el;
722         private Xcls_PopoverFileDetails  _this;
723
724
725             // my vars (def)
726
727         // ctor
728         public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
729         {
730             _this = _owner;
731             _this.modOrder = this;
732             this.el = new Gtk.Entry();
733
734             // my vars (dec)
735
736             // set gobject values
737             this.el.visible = true;
738         }
739
740         // user defined functions
741     }
742
743     public class Xcls_Label21 : Object
744     {
745         public Gtk.Label el;
746         private Xcls_PopoverFileDetails  _this;
747
748
749             // my vars (def)
750
751         // ctor
752         public Xcls_Label21(Xcls_PopoverFileDetails _owner )
753         {
754             _this = _owner;
755             this.el = new Gtk.Label( "Module to build (Vala only)" );
756
757             // my vars (dec)
758
759             // set gobject values
760             this.el.justify = Gtk.Justification.RIGHT;
761             this.el.xalign = 0.900000f;
762             this.el.visible = true;
763         }
764
765         // user defined functions
766     }
767
768     public class Xcls_build_module : Object
769     {
770         public Gtk.ComboBox el;
771         private Xcls_PopoverFileDetails  _this;
772
773
774             // my vars (def)
775
776         // ctor
777         public Xcls_build_module(Xcls_PopoverFileDetails _owner )
778         {
779             _this = _owner;
780             _this.build_module = this;
781             this.el = new Gtk.ComboBox();
782
783             // my vars (dec)
784
785             // set gobject values
786             var child_0 = new Xcls_dbcellrenderer( _this );
787             child_0.ref();
788             this.el.pack_start (  child_0.el , true );
789             var child_1 = new Xcls_dbmodel( _this );
790             child_1.ref();
791             this.el.set_model (  child_1.el  );
792
793             // init method
794
795             this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
796         }
797
798         // user defined functions
799     }
800     public class Xcls_dbcellrenderer : Object
801     {
802         public Gtk.CellRendererText el;
803         private Xcls_PopoverFileDetails  _this;
804
805
806             // my vars (def)
807
808         // ctor
809         public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
810         {
811             _this = _owner;
812             _this.dbcellrenderer = this;
813             this.el = new Gtk.CellRendererText();
814
815             // my vars (dec)
816
817             // set gobject values
818         }
819
820         // user defined functions
821     }
822
823     public class Xcls_dbmodel : Object
824     {
825         public Gtk.ListStore el;
826         private Xcls_PopoverFileDetails  _this;
827
828
829             // my vars (def)
830
831         // ctor
832         public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
833         {
834             _this = _owner;
835             _this.dbmodel = this;
836             this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
837
838             // my vars (dec)
839
840             // set gobject values
841         }
842
843         // user defined functions
844         public void loadData (Gee.ArrayList<string> data, string cur) {
845             this.el.clear();                                    
846             Gtk.TreeIter iter;
847             var el = this.el;
848             
849            /// el.append(out iter);
850             
851              
852            // el.set_value(iter, 0, "");
853            // el.set_value(iter, 1, "aaa  - Just add Element - aaa");
854         
855             el.append(out iter);
856         
857             
858             el.set_value(iter, 0, "");
859             el.set_value(iter, 1, "-- select a module --");
860             _this.build_module.el.set_active_iter(iter);
861             
862             for (var i = 0; i < data.size;i++) {
863             
864         
865                 el.append(out iter);
866                 
867                 el.set_value(iter, 0, data.get(i));
868                 el.set_value(iter, 1, data.get(i));
869                 
870                 if (data.get(i) == cur) {
871                     _this.build_module.el.set_active_iter(iter);
872                 }
873                 
874             }
875              this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          
876                                              
877         }
878     }
879
880
881
882     public class Xcls_HButtonBox25 : Object
883     {
884         public Gtk.HButtonBox el;
885         private Xcls_PopoverFileDetails  _this;
886
887
888             // my vars (def)
889
890         // ctor
891         public Xcls_HButtonBox25(Xcls_PopoverFileDetails _owner )
892         {
893             _this = _owner;
894             this.el = new Gtk.HButtonBox();
895
896             // my vars (dec)
897
898             // set gobject values
899             this.el.margin_right = 4;
900             this.el.margin_left = 4;
901             this.el.margin_bottom = 4;
902             var child_0 = new Xcls_Button26( _this );
903             child_0.ref();
904             this.el.add (  child_0.el  );
905             var child_1 = new Xcls_save_btn( _this );
906             child_1.ref();
907             this.el.add (  child_1.el  );
908         }
909
910         // user defined functions
911     }
912     public class Xcls_Button26 : Object
913     {
914         public Gtk.Button el;
915         private Xcls_PopoverFileDetails  _this;
916
917
918             // my vars (def)
919
920         // ctor
921         public Xcls_Button26(Xcls_PopoverFileDetails _owner )
922         {
923             _this = _owner;
924             this.el = new Gtk.Button();
925
926             // my vars (dec)
927
928             // set gobject values
929             this.el.label = "Cancel";
930
931             //listeners
932             this.el.clicked.connect( () => { 
933             
934               _this.done = true;
935                 _this.el.hide(); 
936             });
937         }
938
939         // user defined functions
940     }
941
942     public class Xcls_save_btn : Object
943     {
944         public Gtk.Button el;
945         private Xcls_PopoverFileDetails  _this;
946
947
948             // my vars (def)
949
950         // ctor
951         public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
952         {
953             _this = _owner;
954             _this.save_btn = this;
955             this.el = new Gtk.Button();
956
957             // my vars (dec)
958
959             // set gobject values
960             this.el.label = "Save";
961
962             //listeners
963             this.el.clicked.connect( ( ) =>  { 
964             
965              
966             
967             
968                 if (_this.name.el.get_text().length  < 1) {
969                     StandardErrorDialog.show(
970                         _this.mainwindow.el,
971                         "You have to set Component name "
972                     );
973                      
974                     return;
975                 }
976                 // what does this do?
977                 
978                 var isNew = _this.file.name.length  > 0 ? false : true;
979                 /*
980                 if (!isNew && this.file.name != _this.name.el.get_text()) {
981                     Xcls_StandardErrorDialog.singleton().show(
982                         this.el,
983                         "Sorry changing names does not work yet. "
984                     );
985                      
986                     return;
987                 }
988                 */
989                  
990                 
991               
992                 // FIXME - this may be more complicated...
993                 //for (var i in this.def) {
994                 //    this.file[i] =  this.get(i).el.get_text();
995                 //}
996             
997                 if (!isNew) {
998                     try {
999                          _this.updateFileFromEntry();
1000                      } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
1001                           Xcls_StandardErrorDialog.singleton().show(
1002                             _this.mainwindow.el,
1003                             "The name you used already exists "
1004                         );
1005                         return;
1006                          
1007                      }
1008             
1009                       _this.done = true;
1010                     _this.file.save();
1011                     _this.el.hide();
1012                     return;
1013                 }
1014                 var fn = _this.name.el.get_text();
1015                 var dir = _this.project.firstPath();
1016                
1017                 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
1018                     Xcls_StandardErrorDialog.singleton().show(
1019                         _this.mainwindow.el,
1020                         "That file already exists"
1021                     ); 
1022                     return;
1023                 }
1024                
1025                var f =  JsRender.JsRender.factory(
1026                         _this.file.project.xtype,  
1027                         _this.file.project, 
1028                         dir + "/" + fn + ".bjs");
1029             
1030                 _this.file = f;
1031                 
1032             
1033                 
1034                 _this.updateFileFromEntry();
1035                 _this.file.loaded = true;
1036                 _this.file.save();
1037                 _this.file.project.addFile(_this.file);
1038                 
1039              
1040                 // what about .js ?
1041                _this.done = true;
1042                 _this.el.hide();
1043             
1044                 
1045                 
1046                 _this.success(_this.project, _this.file);
1047                
1048             });
1049         }
1050
1051         // user defined functions
1052     }
1053
1054
1055
1056 }