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