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