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