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