1 static Xcls_ProjectSettings _ProjectSettings;
3 public class Xcls_ProjectSettings : Object
6 private Xcls_ProjectSettings _this;
8 public static Xcls_ProjectSettings singleton()
10 if (_ProjectSettings == null) {
11 _ProjectSettings= new Xcls_ProjectSettings();
13 return _ProjectSettings;
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;
28 public signal void buttonPressed (string btn);
29 public Project.Project project;
32 public Xcls_ProjectSettings()
35 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
40 this.el.homogeneous = false;
41 this.el.border_width = 5;
42 var child_0 = new Xcls_Box2( _this );
44 this.el.pack_start ( child_0.el , false,false,0 );
45 var child_1 = new Xcls_Notebook5( _this );
47 this.el.pack_end ( child_1.el , true,true,0 );
50 // user defined functions
51 public void show (Project.Project project) {
52 _this.project = project;
53 _this.path.el.label = project.firstPath();
54 // get the active project.
55 var lm = Gtk.SourceLanguageManager.get_default();
57 ((Gtk.SourceBuffer)(_this.view.el.get_buffer())) .set_language(
59 lm.get_language("html"));
62 //project.runhtml = project.runhtml || '';
63 _this.view.el.get_buffer().set_text(project.runhtml);
66 _this.rootURL.el.set_text( _this.project.rootURL );
67 _this.base_template.el.set_text(_this.project.base_template);
68 var js = _this.project;
69 _this.database_DBTYPE.el.set_text( js.get_string_member("DBTYPE") );
70 _this.database_DBNAME.el.set_text( js.get_string_member("DBNAME") );
71 _this.database_DBUSERNAME.el.set_text( js.get_string_member("DBUSERNAME") );
72 _this.database_DBPASSWORD.el.set_text( js.get_string_member("DBPASSWORD") );
77 var buf = _this.view.el.get_buffer();
80 buf.get_start_iter(out s);
81 buf.get_end_iter(out e);
82 _this.project.runhtml = buf.get_text(s,e,true);
84 _this.project.rootURL = _this.rootURL.el.get_text();
85 _this.project.base_template = _this.base_template.el.get_text();
87 var js = _this.project.json_project_data;
88 js.set_string_member("DBTYPE", _this.database_DBTYPE.el.get_text());
89 js.set_string_member("DBNAME", _this.database_DBNAME.el.get_text());
90 js.set_string_member("DBUSERNAME", _this.database_DBUSERNAME.el.get_text());
91 js.set_string_member("DBPASSWORD", _this.database_DBPASSWORD.el.get_text());
92 // _this.project.set_string_member("DBHOST", _this.DBTYPE.el.get_text());
94 // need to re-init the database
96 _this.project.initRooDatabase();
100 public class Xcls_Box2 : Object
103 private Xcls_ProjectSettings _this;
109 public Xcls_Box2(Xcls_ProjectSettings _owner )
112 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
116 // set gobject values
117 this.el.homogeneous = true;
118 this.el.expand = false;
119 this.el.vexpand = false;
120 var child_0 = new Xcls_Button3( _this );
122 this.el.add ( child_0.el );
123 var child_1 = new Xcls_Button4( _this );
125 this.el.add ( child_1.el );
128 // user defined functions
130 public class Xcls_Button3 : Object
132 public Gtk.Button el;
133 private Xcls_ProjectSettings _this;
139 public Xcls_Button3(Xcls_ProjectSettings _owner )
142 this.el = new Gtk.Button();
146 // set gobject values
147 this.el.label = "Apply";
150 this.el.button_press_event.connect( () => {
153 _this.buttonPressed("apply");
158 // user defined functions
160 public class Xcls_Button4 : Object
162 public Gtk.Button el;
163 private Xcls_ProjectSettings _this;
169 public Xcls_Button4(Xcls_ProjectSettings _owner )
172 this.el = new Gtk.Button();
176 // set gobject values
177 this.el.label = "Save";
180 this.el.button_press_event.connect( () => {
183 _this.buttonPressed("save");
188 // user defined functions
190 public class Xcls_Notebook5 : Object
192 public Gtk.Notebook el;
193 private Xcls_ProjectSettings _this;
199 public Xcls_Notebook5(Xcls_ProjectSettings _owner )
202 this.el = new Gtk.Notebook();
206 // set gobject values
207 var child_0 = new Xcls_label_global( _this );
209 var child_1 = new Xcls_label_database( _this );
211 var child_2 = new Xcls_Box8( _this );
213 this.el.append_page ( child_2.el , _this.label_global.el );
214 var child_3 = new Xcls_Box19( _this );
216 this.el.append_page ( child_3.el , _this.label_database.el );
219 // user defined functions
221 public class Xcls_label_global : Object
224 private Xcls_ProjectSettings _this;
230 public Xcls_label_global(Xcls_ProjectSettings _owner )
233 _this.label_global = this;
234 this.el = new Gtk.Label( "Global" );
238 // set gobject values
241 // user defined functions
243 public class Xcls_label_database : Object
246 private Xcls_ProjectSettings _this;
252 public Xcls_label_database(Xcls_ProjectSettings _owner )
255 _this.label_database = this;
256 this.el = new Gtk.Label( "Database" );
260 // set gobject values
263 // user defined functions
265 public class Xcls_Box8 : Object
268 private Xcls_ProjectSettings _this;
274 public Xcls_Box8(Xcls_ProjectSettings _owner )
277 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
281 // set gobject values
282 this.el.homogeneous = false;
283 var child_0 = new Xcls_path( _this );
285 this.el.pack_start ( child_0.el , false,false,0 );
286 var child_1 = new Xcls_Box10( _this );
288 this.el.pack_start ( child_1.el , false,false,0 );
289 var child_2 = new Xcls_Box13( _this );
291 this.el.pack_start ( child_2.el , false,false,0 );
292 var child_3 = new Xcls_Label16( _this );
294 this.el.pack_start ( child_3.el , false,false,0 );
295 var child_4 = new Xcls_ScrolledWindow17( _this );
297 this.el.pack_start ( child_4.el , true,true,0 );
300 // user defined functions
302 public class Xcls_path : Object
305 private Xcls_ProjectSettings _this;
311 public Xcls_path(Xcls_ProjectSettings _owner )
315 this.el = new Gtk.Label( "filename" );
319 // set gobject values
324 // user defined functions
326 public class Xcls_Box10 : Object
329 private Xcls_ProjectSettings _this;
335 public Xcls_Box10(Xcls_ProjectSettings _owner )
338 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
342 // set gobject values
343 this.el.homogeneous = false;
344 this.el.expand = false;
345 var child_0 = new Xcls_Label11( _this );
347 this.el.pack_start ( child_0.el , false,false,0 );
348 var child_1 = new Xcls_base_template( _this );
350 this.el.add ( child_1.el );
353 // user defined functions
355 public class Xcls_Label11 : Object
358 private Xcls_ProjectSettings _this;
364 public Xcls_Label11(Xcls_ProjectSettings _owner )
367 this.el = new Gtk.Label( "HTML template file" );
371 // set gobject values
375 // user defined functions
377 public class Xcls_base_template : Object
380 private Xcls_ProjectSettings _this;
386 public Xcls_base_template(Xcls_ProjectSettings _owner )
389 _this.base_template = this;
390 this.el = new Gtk.Entry();
394 // set gobject values
397 // user defined functions
399 public class Xcls_Box13 : Object
402 private Xcls_ProjectSettings _this;
408 public Xcls_Box13(Xcls_ProjectSettings _owner )
411 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
415 // set gobject values
416 this.el.homogeneous = false;
417 this.el.expand = false;
418 var child_0 = new Xcls_Label14( _this );
420 this.el.pack_start ( child_0.el , false,false,0 );
421 var child_1 = new Xcls_rootURL( _this );
423 this.el.add ( child_1.el );
426 // user defined functions
428 public class Xcls_Label14 : Object
431 private Xcls_ProjectSettings _this;
437 public Xcls_Label14(Xcls_ProjectSettings _owner )
440 this.el = new Gtk.Label( "root URL" );
444 // set gobject values
448 // user defined functions
450 public class Xcls_rootURL : Object
453 private Xcls_ProjectSettings _this;
459 public Xcls_rootURL(Xcls_ProjectSettings _owner )
462 _this.rootURL = this;
463 this.el = new Gtk.Entry();
467 // set gobject values
470 // user defined functions
472 public class Xcls_Label16 : Object
475 private Xcls_ProjectSettings _this;
481 public Xcls_Label16(Xcls_ProjectSettings _owner )
484 this.el = new Gtk.Label( "HTML To insert at end of <HEAD>" );
488 // set gobject values
491 // user defined functions
493 public class Xcls_ScrolledWindow17 : Object
495 public Gtk.ScrolledWindow el;
496 private Xcls_ProjectSettings _this;
502 public Xcls_ScrolledWindow17(Xcls_ProjectSettings _owner )
505 this.el = new Gtk.ScrolledWindow( null, null );
509 // set gobject values
510 var child_0 = new Xcls_view( _this );
512 this.el.add ( child_0.el );
515 // user defined functions
517 public class Xcls_view : Object
519 public Gtk.SourceView el;
520 private Xcls_ProjectSettings _this;
526 public Xcls_view(Xcls_ProjectSettings _owner )
530 this.el = new Gtk.SourceView();
536 var description = Pango.FontDescription.from_string("monospace");
537 description.set_size(9000);
538 this.el.override_font(description);
541 this.el.key_release_event.connect( ( event) =>{
542 if (event.keyval != 115) {
546 if ( (event.state & Gdk.ModifierType.CONTROL_MASK ) < 1 ) {
549 var buf = this.el.get_buffer();
552 buf.get_start_iter(out s);
553 buf.get_end_iter(out e);
554 _this.project.runhtml = buf.get_text(s,e,true);
557 _this.buttonPressed("save");
564 // user defined functions
566 public class Xcls_Box19 : Object
569 private Xcls_ProjectSettings _this;
575 public Xcls_Box19(Xcls_ProjectSettings _owner )
578 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
582 // set gobject values
583 this.el.homogeneous = false;
584 var child_0 = new Xcls_Label20( _this );
586 this.el.pack_start ( child_0.el , false,false,0 );
587 var child_1 = new Xcls_database_DBTYPE( _this );
589 this.el.pack_start ( child_1.el , false,false,0 );
590 var child_2 = new Xcls_Label22( _this );
592 this.el.pack_start ( child_2.el , false,false,0 );
593 var child_3 = new Xcls_database_DBNAME( _this );
595 this.el.pack_start ( child_3.el , false,false,0 );
596 var child_4 = new Xcls_Label24( _this );
598 this.el.pack_start ( child_4.el , false,false,0 );
599 var child_5 = new Xcls_database_DBUSERNAME( _this );
601 this.el.pack_start ( child_5.el , false,false,0 );
602 var child_6 = new Xcls_Label26( _this );
604 this.el.pack_start ( child_6.el , false,false,0 );
605 var child_7 = new Xcls_database_DBPASSWORD( _this );
607 this.el.pack_start ( child_7.el , false,false,0 );
608 var child_8 = new Xcls_Button28( _this );
610 this.el.pack_start ( child_8.el , false,false,0 );
611 var child_9 = new Xcls_database_ERROR( _this );
613 this.el.pack_start ( child_9.el , false,false,0 );
616 // user defined functions
618 public class Xcls_Label20 : Object
621 private Xcls_ProjectSettings _this;
627 public Xcls_Label20(Xcls_ProjectSettings _owner )
630 this.el = new Gtk.Label( "Type (eg. MySQL or PostgreSQL)" );
634 // set gobject values
638 // user defined functions
640 public class Xcls_database_DBTYPE : Object
643 private Xcls_ProjectSettings _this;
649 public Xcls_database_DBTYPE(Xcls_ProjectSettings _owner )
652 _this.database_DBTYPE = this;
653 this.el = new Gtk.Entry();
657 // set gobject values
660 this.el.key_press_event.connect( (ev) => {
662 if (ev.keyval == Gdk.Key.Tab) {
663 _this.database_DBNAME.el.grab_focus();
672 // user defined functions
674 public class Xcls_Label22 : Object
677 private Xcls_ProjectSettings _this;
683 public Xcls_Label22(Xcls_ProjectSettings _owner )
686 this.el = new Gtk.Label( "Name" );
690 // set gobject values
694 // user defined functions
696 public class Xcls_database_DBNAME : Object
699 private Xcls_ProjectSettings _this;
705 public Xcls_database_DBNAME(Xcls_ProjectSettings _owner )
708 _this.database_DBNAME = this;
709 this.el = new Gtk.Entry();
713 // set gobject values
716 this.el.key_press_event.connect( (ev) => {
718 if (ev.keyval == Gdk.Key.Tab) {
719 _this.database_DBUSERNAME.el.grab_focus();
728 // user defined functions
730 public class Xcls_Label24 : Object
733 private Xcls_ProjectSettings _this;
739 public Xcls_Label24(Xcls_ProjectSettings _owner )
742 this.el = new Gtk.Label( "Username" );
746 // set gobject values
750 // user defined functions
752 public class Xcls_database_DBUSERNAME : Object
755 private Xcls_ProjectSettings _this;
761 public Xcls_database_DBUSERNAME(Xcls_ProjectSettings _owner )
764 _this.database_DBUSERNAME = this;
765 this.el = new Gtk.Entry();
769 // set gobject values
772 this.el.key_press_event.connect( (ev) => {
774 if (ev.keyval == Gdk.Key.Tab) {
775 _this.database_DBPASSWORD.el.grab_focus();
784 // user defined functions
786 public class Xcls_Label26 : Object
789 private Xcls_ProjectSettings _this;
795 public Xcls_Label26(Xcls_ProjectSettings _owner )
798 this.el = new Gtk.Label( "Password" );
802 // set gobject values
806 // user defined functions
808 public class Xcls_database_DBPASSWORD : Object
811 private Xcls_ProjectSettings _this;
817 public Xcls_database_DBPASSWORD(Xcls_ProjectSettings _owner )
820 _this.database_DBPASSWORD = this;
821 this.el = new Gtk.Entry();
825 // set gobject values
828 // user defined functions
830 public class Xcls_Button28 : Object
832 public Gtk.Button el;
833 private Xcls_ProjectSettings _this;
839 public Xcls_Button28(Xcls_ProjectSettings _owner )
842 this.el = new Gtk.Button();
846 // set gobject values
847 this.el.label = "Check Connection";
850 this.el.clicked.connect( () => {
853 _this.database_ERROR.el.label = "";
856 // assumes localhost...
857 cnc = Gda.Connection.open_from_string (
858 _this.database_DBTYPE.el.get_text(),
859 "DB_NAME=" + _this.database_DBNAME.el.get_text(),
860 "USERNAME=" + _this.database_DBUSERNAME.el.get_text() +
861 ";PASSWORD=" + _this.database_DBPASSWORD.el.get_text(),
862 Gda.ConnectionOptions.NONE
864 //} catch (Gda.ConnectionError ce) {
865 // _this.database_ERROR.el.label = ce.message;
866 } catch(Gda.ConnectionError ue) {
867 _this.database_ERROR.el.label = ue.message;
869 } catch(Gda.ConfigError ue) {
870 _this.database_ERROR.el.label = ue.message;
873 _this.database_ERROR.el.label = "Connection Succeeded";
878 // user defined functions
880 public class Xcls_database_ERROR : Object
883 private Xcls_ProjectSettings _this;
889 public Xcls_database_ERROR(Xcls_ProjectSettings _owner )
892 _this.database_ERROR = this;
893 this.el = new Gtk.Label( " " );
897 // set gobject values
902 // user defined functions