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