src/Builder4/ProjectSettings.bjs
[app.Builder.js] / src / Builder4 / ProjectSettings.vala
1 static Xcls_ProjectSettings  _ProjectSettings;
2
3 public class Xcls_ProjectSettings : Object 
4 {
5     public Gtk.VBox el;
6     private Xcls_ProjectSettings  _this;
7
8     public static Xcls_ProjectSettings singleton()
9     {
10         if (_ProjectSettings == null) {
11             _ProjectSettings= new Xcls_ProjectSettings();
12         }
13         return _ProjectSettings;
14     }
15     public Xcls_label_global label_global;
16     public Xcls_label_database label_database;
17     public Xcls_path path;
18     public Xcls_base_template base_template;
19     public Xcls_rootURL rootURL;
20     public Xcls_view view;
21     public Xcls_database_DBTYPE database_DBTYPE;
22     public Xcls_database_DBNAME database_DBNAME;
23     public Xcls_database_DBUSERNAME database_DBUSERNAME;
24     public Xcls_database_DBPASSWORD database_DBPASSWORD;
25     public Xcls_database_ERROR database_ERROR;
26
27         // my vars (def)
28     public signal void buttonPressed (string btn);
29     public Project.Project project;
30
31     // ctor 
32     public Xcls_ProjectSettings()
33     {
34         _this = this;
35         this.el = new Gtk.VBox( false, 0 );
36
37         // my vars (dec)
38
39         // set gobject values
40         this.el.border_width = 5;
41         var child_0 = new Xcls_HBox2( _this );
42         child_0.ref();
43         this.el.pack_start (  child_0.el , false,false,0 );
44         var child_1 = new Xcls_Notebook5( _this );
45         child_1.ref();
46         this.el.pack_end (  child_1.el , true,true,0 );
47     }
48
49     // user defined functions 
50     public void show (Project.Project project) {
51         _this.project = project;
52         _this.path.el.label = project.firstPath();
53         // get the active project.
54          var lm = Gtk.SourceLanguageManager.get_default();
55                     
56         ((Gtk.SourceBuffer)(_this.view.el.get_buffer())) .set_language(
57         
58             lm.get_language("html"));
59       
60         //print (project.fn);
61         //project.runhtml = project.runhtml || '';
62         _this.view.el.get_buffer().set_text(project.runhtml);
63         
64            
65         _this.rootURL.el.set_text( _this.project.rootURL );
66         _this.base_template.el.set_text(_this.project.base_template);    
67        
68         
69         //this.el.show_all();
70     }
71     public void save ()
72     {
73        var buf =    _this.view.el.get_buffer();
74        Gtk.TextIter s;
75          Gtk.TextIter e;
76         buf.get_start_iter(out s);
77         buf.get_end_iter(out e);
78           _this.project.runhtml = buf.get_text(s,e,true);
79           
80         _this.project.rootURL = _this.rootURL.el.get_text();
81         _this.project.base_template = _this.base_template.el.get_text();    
82         
83         
84     }
85     public class Xcls_HBox2 : Object 
86     {
87         public Gtk.HBox el;
88         private Xcls_ProjectSettings  _this;
89
90
91             // my vars (def)
92
93         // ctor 
94         public Xcls_HBox2(Xcls_ProjectSettings _owner )
95         {
96             _this = _owner;
97             this.el = new Gtk.HBox( true, 0 );
98
99             // my vars (dec)
100
101             // set gobject values
102             this.el.expand = false;
103             this.el.vexpand = false;
104             var child_0 = new Xcls_Button3( _this );
105             child_0.ref();
106             this.el.add (  child_0.el  );
107             var child_1 = new Xcls_Button4( _this );
108             child_1.ref();
109             this.el.add (  child_1.el  );
110         }
111
112         // user defined functions 
113     }
114     public class Xcls_Button3 : Object 
115     {
116         public Gtk.Button el;
117         private Xcls_ProjectSettings  _this;
118
119
120             // my vars (def)
121
122         // ctor 
123         public Xcls_Button3(Xcls_ProjectSettings _owner )
124         {
125             _this = _owner;
126             this.el = new Gtk.Button();
127
128             // my vars (dec)
129
130             // set gobject values
131             this.el.label = "Apply";
132
133             // listeners 
134             this.el.button_press_event.connect( () => {
135                 _this.save();
136                       
137                 _this.buttonPressed("apply");
138                     return false;
139             });
140         }
141
142         // user defined functions 
143     }
144     public class Xcls_Button4 : Object 
145     {
146         public Gtk.Button el;
147         private Xcls_ProjectSettings  _this;
148
149
150             // my vars (def)
151
152         // ctor 
153         public Xcls_Button4(Xcls_ProjectSettings _owner )
154         {
155             _this = _owner;
156             this.el = new Gtk.Button();
157
158             // my vars (dec)
159
160             // set gobject values
161             this.el.label = "Save";
162
163             // listeners 
164             this.el.button_press_event.connect( () => {
165                    _this.save();
166                       
167                 _this.buttonPressed("save");
168                     return false;
169             });
170         }
171
172         // user defined functions 
173     }
174     public class Xcls_Notebook5 : Object 
175     {
176         public Gtk.Notebook el;
177         private Xcls_ProjectSettings  _this;
178
179
180             // my vars (def)
181
182         // ctor 
183         public Xcls_Notebook5(Xcls_ProjectSettings _owner )
184         {
185             _this = _owner;
186             this.el = new Gtk.Notebook();
187
188             // my vars (dec)
189
190             // set gobject values
191             var child_0 = new Xcls_label_global( _this );
192             child_0.ref();
193             var child_1 = new Xcls_label_database( _this );
194             child_1.ref();
195             var child_2 = new Xcls_VBox8( _this );
196             child_2.ref();
197             this.el.append_page (  child_2.el , _this.label_global.el );
198             var child_3 = new Xcls_VBox19( _this );
199             child_3.ref();
200             this.el.append_page (  child_3.el , _this.label_database.el );
201         }
202
203         // user defined functions 
204     }
205     public class Xcls_label_global : Object 
206     {
207         public Gtk.Label el;
208         private Xcls_ProjectSettings  _this;
209
210
211             // my vars (def)
212
213         // ctor 
214         public Xcls_label_global(Xcls_ProjectSettings _owner )
215         {
216             _this = _owner;
217             _this.label_global = this;
218             this.el = new Gtk.Label( "Global" );
219
220             // my vars (dec)
221
222             // set gobject values
223         }
224
225         // user defined functions 
226     }
227     public class Xcls_label_database : Object 
228     {
229         public Gtk.Label el;
230         private Xcls_ProjectSettings  _this;
231
232
233             // my vars (def)
234
235         // ctor 
236         public Xcls_label_database(Xcls_ProjectSettings _owner )
237         {
238             _this = _owner;
239             _this.label_database = this;
240             this.el = new Gtk.Label( "Database" );
241
242             // my vars (dec)
243
244             // set gobject values
245         }
246
247         // user defined functions 
248     }
249     public class Xcls_VBox8 : Object 
250     {
251         public Gtk.VBox el;
252         private Xcls_ProjectSettings  _this;
253
254
255             // my vars (def)
256
257         // ctor 
258         public Xcls_VBox8(Xcls_ProjectSettings _owner )
259         {
260             _this = _owner;
261             this.el = new Gtk.VBox( false, 0 );
262
263             // my vars (dec)
264
265             // set gobject values
266             var child_0 = new Xcls_path( _this );
267             child_0.ref();
268             this.el.pack_start (  child_0.el , false,false,0 );
269             var child_1 = new Xcls_HBox10( _this );
270             child_1.ref();
271             this.el.pack_start (  child_1.el , false,false,0 );
272             var child_2 = new Xcls_HBox13( _this );
273             child_2.ref();
274             this.el.pack_start (  child_2.el , false,false,0 );
275             var child_3 = new Xcls_Label16( _this );
276             child_3.ref();
277             this.el.pack_start (  child_3.el , false,false,0 );
278             var child_4 = new Xcls_ScrolledWindow17( _this );
279             child_4.ref();
280             this.el.pack_start (  child_4.el , true,true,0 );
281         }
282
283         // user defined functions 
284     }
285     public class Xcls_path : Object 
286     {
287         public Gtk.Label el;
288         private Xcls_ProjectSettings  _this;
289
290
291             // my vars (def)
292
293         // ctor 
294         public Xcls_path(Xcls_ProjectSettings _owner )
295         {
296             _this = _owner;
297             _this.path = this;
298             this.el = new Gtk.Label( "filename" );
299
300             // my vars (dec)
301
302             // set gobject values
303             this.el.margin = 3;
304             this.el.xalign = 0f;
305         }
306
307         // user defined functions 
308     }
309     public class Xcls_HBox10 : Object 
310     {
311         public Gtk.HBox el;
312         private Xcls_ProjectSettings  _this;
313
314
315             // my vars (def)
316
317         // ctor 
318         public Xcls_HBox10(Xcls_ProjectSettings _owner )
319         {
320             _this = _owner;
321             this.el = new Gtk.HBox( false, 0 );
322
323             // my vars (dec)
324
325             // set gobject values
326             this.el.expand = false;
327             var child_0 = new Xcls_Label11( _this );
328             child_0.ref();
329             this.el.pack_start (  child_0.el , false,false,0 );
330             var child_1 = new Xcls_base_template( _this );
331             child_1.ref();
332             this.el.add (  child_1.el  );
333         }
334
335         // user defined functions 
336     }
337     public class Xcls_Label11 : Object 
338     {
339         public Gtk.Label el;
340         private Xcls_ProjectSettings  _this;
341
342
343             // my vars (def)
344
345         // ctor 
346         public Xcls_Label11(Xcls_ProjectSettings _owner )
347         {
348             _this = _owner;
349             this.el = new Gtk.Label( "HTML template file" );
350
351             // my vars (dec)
352
353             // set gobject values
354             this.el.margin = 3;
355         }
356
357         // user defined functions 
358     }
359     public class Xcls_base_template : Object 
360     {
361         public Gtk.Entry el;
362         private Xcls_ProjectSettings  _this;
363
364
365             // my vars (def)
366
367         // ctor 
368         public Xcls_base_template(Xcls_ProjectSettings _owner )
369         {
370             _this = _owner;
371             _this.base_template = this;
372             this.el = new Gtk.Entry();
373
374             // my vars (dec)
375
376             // set gobject values
377         }
378
379         // user defined functions 
380     }
381     public class Xcls_HBox13 : Object 
382     {
383         public Gtk.HBox el;
384         private Xcls_ProjectSettings  _this;
385
386
387             // my vars (def)
388
389         // ctor 
390         public Xcls_HBox13(Xcls_ProjectSettings _owner )
391         {
392             _this = _owner;
393             this.el = new Gtk.HBox( false, 0 );
394
395             // my vars (dec)
396
397             // set gobject values
398             this.el.expand = false;
399             var child_0 = new Xcls_Label14( _this );
400             child_0.ref();
401             this.el.pack_start (  child_0.el , false,false,0 );
402             var child_1 = new Xcls_rootURL( _this );
403             child_1.ref();
404             this.el.add (  child_1.el  );
405         }
406
407         // user defined functions 
408     }
409     public class Xcls_Label14 : Object 
410     {
411         public Gtk.Label el;
412         private Xcls_ProjectSettings  _this;
413
414
415             // my vars (def)
416
417         // ctor 
418         public Xcls_Label14(Xcls_ProjectSettings _owner )
419         {
420             _this = _owner;
421             this.el = new Gtk.Label( "root URL" );
422
423             // my vars (dec)
424
425             // set gobject values
426             this.el.margin = 3;
427         }
428
429         // user defined functions 
430     }
431     public class Xcls_rootURL : Object 
432     {
433         public Gtk.Entry el;
434         private Xcls_ProjectSettings  _this;
435
436
437             // my vars (def)
438
439         // ctor 
440         public Xcls_rootURL(Xcls_ProjectSettings _owner )
441         {
442             _this = _owner;
443             _this.rootURL = this;
444             this.el = new Gtk.Entry();
445
446             // my vars (dec)
447
448             // set gobject values
449         }
450
451         // user defined functions 
452     }
453     public class Xcls_Label16 : Object 
454     {
455         public Gtk.Label el;
456         private Xcls_ProjectSettings  _this;
457
458
459             // my vars (def)
460
461         // ctor 
462         public Xcls_Label16(Xcls_ProjectSettings _owner )
463         {
464             _this = _owner;
465             this.el = new Gtk.Label( "HTML To insert at end of <HEAD>" );
466
467             // my vars (dec)
468
469             // set gobject values
470         }
471
472         // user defined functions 
473     }
474     public class Xcls_ScrolledWindow17 : Object 
475     {
476         public Gtk.ScrolledWindow el;
477         private Xcls_ProjectSettings  _this;
478
479
480             // my vars (def)
481
482         // ctor 
483         public Xcls_ScrolledWindow17(Xcls_ProjectSettings _owner )
484         {
485             _this = _owner;
486             this.el = new Gtk.ScrolledWindow( null, null );
487
488             // my vars (dec)
489
490             // set gobject values
491             var child_0 = new Xcls_view( _this );
492             child_0.ref();
493             this.el.add (  child_0.el  );
494         }
495
496         // user defined functions 
497     }
498     public class Xcls_view : Object 
499     {
500         public Gtk.SourceView el;
501         private Xcls_ProjectSettings  _this;
502
503
504             // my vars (def)
505
506         // ctor 
507         public Xcls_view(Xcls_ProjectSettings _owner )
508         {
509             _this = _owner;
510             _this.view = this;
511             this.el = new Gtk.SourceView();
512
513             // my vars (dec)
514
515             // set gobject values
516
517             // init method 
518
519             var description =   Pango.FontDescription.from_string("monospace");
520                 description.set_size(9000);
521                 this.el.override_font(description);
522
523             // listeners 
524             this.el.key_release_event.connect( ( event) =>{
525                 if (event.keyval != 115) {
526                     return false;
527                      
528                 }
529                 if   ( (event.state & Gdk.ModifierType.CONTROL_MASK ) < 1 ) {
530                     return false;
531                 }
532                  var buf =    this.el.get_buffer();
533                 Gtk.TextIter s;
534                 Gtk.TextIter e;
535                 buf.get_start_iter(out s);
536                 buf.get_end_iter(out e);
537                 _this.project.runhtml = buf.get_text(s,e,true);
538                 
539                       
540                 _this.buttonPressed("save");
541                  
542                 return false;
543                      
544             });
545         }
546
547         // user defined functions 
548     }
549     public class Xcls_VBox19 : Object 
550     {
551         public Gtk.VBox el;
552         private Xcls_ProjectSettings  _this;
553
554
555             // my vars (def)
556
557         // ctor 
558         public Xcls_VBox19(Xcls_ProjectSettings _owner )
559         {
560             _this = _owner;
561             this.el = new Gtk.VBox( false, 0 );
562
563             // my vars (dec)
564
565             // set gobject values
566             var child_0 = new Xcls_Label20( _this );
567             child_0.ref();
568             this.el.pack_start (  child_0.el , false,false,0 );
569             var child_1 = new Xcls_database_DBTYPE( _this );
570             child_1.ref();
571             this.el.pack_start (  child_1.el , false,false,0 );
572             var child_2 = new Xcls_Label22( _this );
573             child_2.ref();
574             this.el.pack_start (  child_2.el , false,false,0 );
575             var child_3 = new Xcls_database_DBNAME( _this );
576             child_3.ref();
577             this.el.pack_start (  child_3.el , false,false,0 );
578             var child_4 = new Xcls_Label24( _this );
579             child_4.ref();
580             this.el.pack_start (  child_4.el , false,false,0 );
581             var child_5 = new Xcls_database_DBUSERNAME( _this );
582             child_5.ref();
583             this.el.pack_start (  child_5.el , false,false,0 );
584             var child_6 = new Xcls_Label26( _this );
585             child_6.ref();
586             this.el.pack_start (  child_6.el , false,false,0 );
587             var child_7 = new Xcls_database_DBPASSWORD( _this );
588             child_7.ref();
589             this.el.pack_start (  child_7.el , false,false,0 );
590             var child_8 = new Xcls_Button28( _this );
591             child_8.ref();
592             this.el.pack_start (  child_8.el , false,false,0 );
593             var child_9 = new Xcls_database_ERROR( _this );
594             child_9.ref();
595             this.el.pack_start (  child_9.el , false,false,0 );
596         }
597
598         // user defined functions 
599     }
600     public class Xcls_Label20 : Object 
601     {
602         public Gtk.Label el;
603         private Xcls_ProjectSettings  _this;
604
605
606             // my vars (def)
607
608         // ctor 
609         public Xcls_Label20(Xcls_ProjectSettings _owner )
610         {
611             _this = _owner;
612             this.el = new Gtk.Label( "Type (eg. MySQL or PostgreSQL)" );
613
614             // my vars (dec)
615
616             // set gobject values
617             this.el.xalign = 0f;
618         }
619
620         // user defined functions 
621     }
622     public class Xcls_database_DBTYPE : Object 
623     {
624         public Gtk.Entry el;
625         private Xcls_ProjectSettings  _this;
626
627
628             // my vars (def)
629
630         // ctor 
631         public Xcls_database_DBTYPE(Xcls_ProjectSettings _owner )
632         {
633             _this = _owner;
634             _this.database_DBTYPE = this;
635             this.el = new Gtk.Entry();
636
637             // my vars (dec)
638
639             // set gobject values
640         }
641
642         // user defined functions 
643     }
644     public class Xcls_Label22 : Object 
645     {
646         public Gtk.Label el;
647         private Xcls_ProjectSettings  _this;
648
649
650             // my vars (def)
651
652         // ctor 
653         public Xcls_Label22(Xcls_ProjectSettings _owner )
654         {
655             _this = _owner;
656             this.el = new Gtk.Label( "Name" );
657
658             // my vars (dec)
659
660             // set gobject values
661             this.el.xalign = 0f;
662         }
663
664         // user defined functions 
665     }
666     public class Xcls_database_DBNAME : Object 
667     {
668         public Gtk.Entry el;
669         private Xcls_ProjectSettings  _this;
670
671
672             // my vars (def)
673
674         // ctor 
675         public Xcls_database_DBNAME(Xcls_ProjectSettings _owner )
676         {
677             _this = _owner;
678             _this.database_DBNAME = this;
679             this.el = new Gtk.Entry();
680
681             // my vars (dec)
682
683             // set gobject values
684         }
685
686         // user defined functions 
687     }
688     public class Xcls_Label24 : Object 
689     {
690         public Gtk.Label el;
691         private Xcls_ProjectSettings  _this;
692
693
694             // my vars (def)
695
696         // ctor 
697         public Xcls_Label24(Xcls_ProjectSettings _owner )
698         {
699             _this = _owner;
700             this.el = new Gtk.Label( "Username" );
701
702             // my vars (dec)
703
704             // set gobject values
705             this.el.xalign = 0f;
706         }
707
708         // user defined functions 
709     }
710     public class Xcls_database_DBUSERNAME : Object 
711     {
712         public Gtk.Entry el;
713         private Xcls_ProjectSettings  _this;
714
715
716             // my vars (def)
717
718         // ctor 
719         public Xcls_database_DBUSERNAME(Xcls_ProjectSettings _owner )
720         {
721             _this = _owner;
722             _this.database_DBUSERNAME = this;
723             this.el = new Gtk.Entry();
724
725             // my vars (dec)
726
727             // set gobject values
728         }
729
730         // user defined functions 
731     }
732     public class Xcls_Label26 : Object 
733     {
734         public Gtk.Label el;
735         private Xcls_ProjectSettings  _this;
736
737
738             // my vars (def)
739
740         // ctor 
741         public Xcls_Label26(Xcls_ProjectSettings _owner )
742         {
743             _this = _owner;
744             this.el = new Gtk.Label( "Password" );
745
746             // my vars (dec)
747
748             // set gobject values
749             this.el.xalign = 0f;
750         }
751
752         // user defined functions 
753     }
754     public class Xcls_database_DBPASSWORD : Object 
755     {
756         public Gtk.Entry el;
757         private Xcls_ProjectSettings  _this;
758
759
760             // my vars (def)
761
762         // ctor 
763         public Xcls_database_DBPASSWORD(Xcls_ProjectSettings _owner )
764         {
765             _this = _owner;
766             _this.database_DBPASSWORD = this;
767             this.el = new Gtk.Entry();
768
769             // my vars (dec)
770
771             // set gobject values
772         }
773
774         // user defined functions 
775     }
776     public class Xcls_Button28 : Object 
777     {
778         public Gtk.Button el;
779         private Xcls_ProjectSettings  _this;
780
781
782             // my vars (def)
783
784         // ctor 
785         public Xcls_Button28(Xcls_ProjectSettings _owner )
786         {
787             _this = _owner;
788             this.el = new Gtk.Button();
789
790             // my vars (dec)
791
792             // set gobject values
793             this.el.label = "Check Connection";
794
795             // listeners 
796             this.el.clicked.connect( () => {
797             
798             
799               _this.database_ERROR.el.label    = "";
800                 Gda.Connection cnc;
801                 try {
802                     // assumes localhost...
803                      cnc = Gda.Connection.open_from_string (
804                                 _this.database_DBTYPE.el.get_text(),
805                                 "DB_NAME=" + _this.database_DBNAME.el.get_text(), 
806                                 "USERNAME=" + _this.database_DBUSERNAME.el.get_text() + 
807                                 ";PASSWORD=" + _this.database_DBPASSWORD.el.get_text(),
808                                 Gda.ConnectionOptions.NONE
809                         );
810                //} catch (Gda.ConnectionError ce) { 
811                //   _this.database_ERROR.el.label = ce.message;        
812                } catch(Error ue) {
813                   _this.database_ERROR.el.label = ue.message;
814                     return;
815                }
816               _this.database_ERROR.el.label = "Connection Succeeded";
817                cnc.close();
818             });
819         }
820
821         // user defined functions 
822     }
823     public class Xcls_database_ERROR : Object 
824     {
825         public Gtk.Label el;
826         private Xcls_ProjectSettings  _this;
827
828
829             // my vars (def)
830
831         // ctor 
832         public Xcls_database_ERROR(Xcls_ProjectSettings _owner )
833         {
834             _this = _owner;
835             _this.database_ERROR = this;
836             this.el = new Gtk.Label( " " );
837
838             // my vars (dec)
839
840             // set gobject values
841             this.el.margin = 3;
842             this.el.xalign = 0f;
843         }
844
845         // user defined functions 
846     }
847 }