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