1 static Xcls_RooProjectSettings _RooProjectSettings;
3 public class Xcls_RooProjectSettings : Object
6 private Xcls_RooProjectSettings _this;
8 public static Xcls_RooProjectSettings singleton()
10 if (_RooProjectSettings == null) {
11 _RooProjectSettings= new Xcls_RooProjectSettings();
13 return _RooProjectSettings;
15 public Xcls_label_global label_global;
16 public Xcls_label_database label_database;
17 public Xcls_grid grid;
18 public Xcls_path path;
19 public Xcls_base_template base_template;
20 public Xcls_base_template_cellrenderer base_template_cellrenderer;
21 public Xcls_base_template_model base_template_model;
22 public Xcls_rootURL rootURL;
23 public Xcls_filetype filetype;
24 public Xcls_ftdbcellrenderer ftdbcellrenderer;
25 public Xcls_ftdbmodel ftdbmodel;
26 public Xcls_view view;
27 public Xcls_database_DBTYPE database_DBTYPE;
28 public Xcls_database_DBNAME database_DBNAME;
29 public Xcls_database_DBUSERNAME database_DBUSERNAME;
30 public Xcls_database_DBPASSWORD database_DBPASSWORD;
31 public Xcls_database_ERROR database_ERROR;
34 public signal void buttonPressed (string btn);
35 public Project.Project project;
38 public Xcls_RooProjectSettings()
41 this.el = new Gtk.Popover( null );
46 this.el.border_width = 0;
48 this.el.position = Gtk.PositionType.RIGHT;
49 var child_0 = new Xcls_Box2( _this );
51 this.el.add ( child_0.el );
54 // user defined functions
55 public void show (Gtk.Widget btn, Project.Project project) {
56 _this.project = project;
57 _this.path.el.label = project.firstPath();
58 // get the active project.
59 var lm = Gtk.SourceLanguageManager.get_default();
61 ((Gtk.SourceBuffer)(_this.view.el.get_buffer())) .set_language(
62 lm.get_language("html")
66 //project.runhtml = project.runhtml || '';
67 _this.view.el.get_buffer().set_text(project.runhtml);
70 _this.rootURL.el.set_text( _this.project.rootURL );
73 _this.base_template_model.loadData();
75 var js = _this.project;
76 _this.database_DBTYPE.el.set_text( js.get_string_member("DBTYPE") );
77 _this.database_DBNAME.el.set_text( js.get_string_member("DBNAME") );
78 _this.database_DBUSERNAME.el.set_text( js.get_string_member("DBUSERNAME") );
79 _this.database_DBPASSWORD.el.set_text( js.get_string_member("DBPASSWORD") );
81 //console.log('show all');
82 this.el.set_modal(true);
83 this.el.set_relative_to(btn);
85 this.el.set_position(Gtk.PositionType.RIGHT);
88 print("SHOWALL - POPIP\n");
90 this.el.set_size_request(800,500);
91 this.view.el.grab_focus();
97 var buf = _this.view.el.get_buffer();
100 buf.get_start_iter(out s);
101 buf.get_end_iter(out e);
102 _this.project.runhtml = buf.get_text(s,e,true);
104 _this.project.rootURL = _this.rootURL.el.get_text();
105 // set by event changed...
106 //_this.project.base_template = _this.base_template.el.get_text();
108 var js = _this.project.json_project_data;
109 js.set_string_member("DBTYPE", _this.database_DBTYPE.el.get_text());
110 js.set_string_member("DBNAME", _this.database_DBNAME.el.get_text());
111 js.set_string_member("DBUSERNAME", _this.database_DBUSERNAME.el.get_text());
112 js.set_string_member("DBPASSWORD", _this.database_DBPASSWORD.el.get_text());
113 // _this.project.set_string_member("DBHOST", _this.DBTYPE.el.get_text());
115 // need to re-init the database
117 _this.project.initRooDatabase();
121 public class Xcls_Box2 : Object
124 private Xcls_RooProjectSettings _this;
130 public Xcls_Box2(Xcls_RooProjectSettings _owner )
133 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
137 // set gobject values
138 this.el.homogeneous = false;
139 this.el.border_width = 5;
140 var child_0 = new Xcls_Notebook3( _this );
142 this.el.pack_start ( child_0.el , true,true,0 );
143 var child_1 = new Xcls_Box34( _this );
145 this.el.pack_end ( child_1.el , false,false,0 );
148 // user defined functions
150 public class Xcls_Notebook3 : Object
152 public Gtk.Notebook el;
153 private Xcls_RooProjectSettings _this;
159 public Xcls_Notebook3(Xcls_RooProjectSettings _owner )
162 this.el = new Gtk.Notebook();
166 // set gobject values
167 var child_0 = new Xcls_label_global( _this );
169 var child_1 = new Xcls_label_database( _this );
171 var child_2 = new Xcls_Box6( _this );
173 this.el.append_page ( child_2.el , _this.label_global.el );
174 var child_3 = new Xcls_Box23( _this );
176 this.el.append_page ( child_3.el , _this.label_database.el );
179 // user defined functions
181 public class Xcls_label_global : Object
184 private Xcls_RooProjectSettings _this;
190 public Xcls_label_global(Xcls_RooProjectSettings _owner )
193 _this.label_global = this;
194 this.el = new Gtk.Label( "Global" );
198 // set gobject values
201 // user defined functions
204 public class Xcls_label_database : Object
207 private Xcls_RooProjectSettings _this;
213 public Xcls_label_database(Xcls_RooProjectSettings _owner )
216 _this.label_database = this;
217 this.el = new Gtk.Label( "Database" );
221 // set gobject values
224 // user defined functions
227 public class Xcls_Box6 : Object
230 private Xcls_RooProjectSettings _this;
236 public Xcls_Box6(Xcls_RooProjectSettings _owner )
239 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
243 // set gobject values
244 this.el.homogeneous = false;
245 var child_0 = new Xcls_grid( _this );
247 this.el.pack_start ( child_0.el , false,false,4 );
248 var child_1 = new Xcls_Label20( _this );
250 this.el.pack_start ( child_1.el , false,false,0 );
251 var child_2 = new Xcls_ScrolledWindow21( _this );
253 this.el.pack_start ( child_2.el , true,true,0 );
256 // user defined functions
258 public class Xcls_grid : Object
261 private Xcls_RooProjectSettings _this;
267 public Xcls_grid(Xcls_RooProjectSettings _owner )
271 this.el = new Gtk.Grid();
275 // set gobject values
276 this.el.margin_right = 4;
277 this.el.margin_left = 4;
278 this.el.row_spacing = 2;
279 var child_0 = new Xcls_Label8( _this );
281 this.el.attach ( child_0.el , 0,0,1,1 );
282 var child_1 = new Xcls_path( _this );
284 this.el.attach ( child_1.el , 1,0,1,1 );
285 var child_2 = new Xcls_Label10( _this );
287 this.el.attach ( child_2.el , 0,1,1,1 );
288 var child_3 = new Xcls_base_template( _this );
290 this.el.attach ( child_3.el , 1,1,1,1 );
291 var child_4 = new Xcls_Label14( _this );
293 this.el.attach ( child_4.el , 0,2,1,1 );
294 var child_5 = new Xcls_rootURL( _this );
296 this.el.attach ( child_5.el , 1,2,1,1 );
297 var child_6 = new Xcls_Label16( _this );
299 this.el.attach ( child_6.el , 0,1,1,1 );
300 var child_7 = new Xcls_filetype( _this );
302 this.el.attach ( child_7.el , 1,0,1,1 );
305 // user defined functions
307 public class Xcls_Label8 : Object
310 private Xcls_RooProjectSettings _this;
316 public Xcls_Label8(Xcls_RooProjectSettings _owner )
319 this.el = new Gtk.Label( "Filename" );
323 // set gobject values
328 // user defined functions
331 public class Xcls_path : Object
334 private Xcls_RooProjectSettings _this;
340 public Xcls_path(Xcls_RooProjectSettings _owner )
344 this.el = new Gtk.Label( "filename" );
348 // set gobject values
353 // user defined functions
356 public class Xcls_Label10 : Object
359 private Xcls_RooProjectSettings _this;
365 public Xcls_Label10(Xcls_RooProjectSettings _owner )
368 this.el = new Gtk.Label( "HTML template file" );
372 // set gobject values
376 // user defined functions
379 public class Xcls_base_template : Object
381 public Gtk.ComboBox el;
382 private Xcls_RooProjectSettings _this;
389 public Xcls_base_template(Xcls_RooProjectSettings _owner )
392 _this.base_template = this;
393 this.el = new Gtk.ComboBox();
396 this.loading = false;
398 // set gobject values
399 var child_0 = new Xcls_base_template_cellrenderer( _this );
401 this.el.pack_start ( child_0.el , true );
402 var child_1 = new Xcls_base_template_model( _this );
404 this.el.set_model ( child_1.el );
408 this.el.add_attribute(_this.base_template_cellrenderer.el , "markup", 0 );
411 this.el.changed.connect( () => {
414 // this get's called when we are filling in the data... ???
420 if (this.el.get_active_iter(out iter)) {
422 _this.base_template_model.el.get_value (iter, 0, out vfname);
423 _this.project.base_template = ((string)vfname) ;
425 print("\nSET base template to %s\n", _this.project.base_template );
426 // is_bjs = ((string)vfname) == "bjs";
430 // directory is only available for non-bjs
437 // user defined functions
439 public class Xcls_base_template_cellrenderer : Object
441 public Gtk.CellRendererText el;
442 private Xcls_RooProjectSettings _this;
448 public Xcls_base_template_cellrenderer(Xcls_RooProjectSettings _owner )
451 _this.base_template_cellrenderer = this;
452 this.el = new Gtk.CellRendererText();
456 // set gobject values
459 // user defined functions
462 public class Xcls_base_template_model : Object
464 public Gtk.ListStore el;
465 private Xcls_RooProjectSettings _this;
471 public Xcls_base_template_model(Xcls_RooProjectSettings _owner )
474 _this.base_template_model = this;
475 this.el = new Gtk.ListStore( 1, typeof(string) );
479 // set gobject values
482 // user defined functions
483 public void loadData () {
484 _this.base_template.loading = true;
490 /// el.append(out iter);
494 el.set_value(iter, 0, "roo.builder.html");
495 _this.base_template.el.set_active_iter(iter);
496 if (_this.project.base_template == "roo.builder.html") {
497 _this.base_template.el.set_active_iter(iter);
501 el.set_value(iter, 0, "bootstrap.builder.html");
503 print("\ncur template = %s\n", _this.project.base_template);
505 if (_this.project.base_template == "bootstrap.builder.html") {
506 _this.base_template.el.set_active_iter(iter);
510 el.set_value(iter, 0, "mailer.builder.html");
512 if (_this.project.base_template == "mailer.builder.html") {
513 _this.base_template.el.set_active_iter(iter);
515 _this.base_template.loading = false;
521 public class Xcls_Label14 : Object
524 private Xcls_RooProjectSettings _this;
530 public Xcls_Label14(Xcls_RooProjectSettings _owner )
533 this.el = new Gtk.Label( "root URL" );
537 // set gobject values
541 // user defined functions
544 public class Xcls_rootURL : Object
547 private Xcls_RooProjectSettings _this;
553 public Xcls_rootURL(Xcls_RooProjectSettings _owner )
556 _this.rootURL = this;
557 this.el = new Gtk.Entry();
561 // set gobject values
564 // user defined functions
567 public class Xcls_Label16 : Object
570 private Xcls_RooProjectSettings _this;
576 public Xcls_Label16(Xcls_RooProjectSettings _owner )
579 this.el = new Gtk.Label( "Generate HTML in" );
583 // set gobject values
587 // user defined functions
590 public class Xcls_filetype : Object
592 public Gtk.ComboBox el;
593 private Xcls_RooProjectSettings _this;
599 public Xcls_filetype(Xcls_RooProjectSettings _owner )
602 _this.filetype = this;
603 this.el = new Gtk.ComboBox();
607 // set gobject values
608 var child_0 = new Xcls_ftdbcellrenderer( _this );
610 this.el.pack_start ( child_0.el , true );
611 var child_1 = new Xcls_ftdbmodel( _this );
613 this.el.set_model ( child_1.el );
617 this.el.add_attribute(_this.ftdbcellrenderer.el , "markup", 1 );
620 this.el.changed.connect( () => {
623 if (this.el.get_active_iter(out iter)) {
625 _this.ftdbmodel.el.get_value (iter, 0, out vfname);
626 is_bjs = ((string)vfname) == "bjs";
630 // directory is only available for non-bjs
631 this.showhide(is_bjs);
637 // user defined functions
638 public void showhide (bool is_bjs) {
639 for (var i = 2; i < 9;i++) {
640 var el = _this.grid.el.get_child_at(0,i);
642 var showhide= is_bjs;
644 showhide = !showhide;
652 el = _this.grid.el.get_child_at(1,i);
659 // load up the directories
660 //??? why can we not create bjs files in other directories??
661 if (!is_bjs && _this.file.path.length < 1) {
662 _this.dirmodel.loadData();
670 public class Xcls_ftdbcellrenderer : Object
672 public Gtk.CellRendererText el;
673 private Xcls_RooProjectSettings _this;
679 public Xcls_ftdbcellrenderer(Xcls_RooProjectSettings _owner )
682 _this.ftdbcellrenderer = this;
683 this.el = new Gtk.CellRendererText();
687 // set gobject values
690 // user defined functions
693 public class Xcls_ftdbmodel : Object
695 public Gtk.ListStore el;
696 private Xcls_RooProjectSettings _this;
702 public Xcls_ftdbmodel(Xcls_RooProjectSettings _owner )
705 _this.ftdbmodel = this;
706 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
710 // set gobject values
713 // user defined functions
714 public void loadData (string cur) {
719 /// el.append(out iter);
722 // el.set_value(iter, 0, "");
723 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
728 el.set_value(iter, 0, "bjs");
729 el.set_value(iter, 1, "User Interface File (bjs)");
730 _this.filetype.el.set_active_iter(iter);
734 el.set_value(iter, 0, "vala");
735 el.set_value(iter, 1, "Vala");
737 _this.filetype.el.set_active_iter(iter);
744 el.set_value(iter, 0, "js");
745 el.set_value(iter, 1, "Javascript");
748 _this.filetype.el.set_active_iter(iter);
753 el.set_value(iter, 0, "css");
754 el.set_value(iter, 1, "CSS");
757 _this.filetype.el.set_active_iter(iter);
765 public class Xcls_Label20 : Object
768 private Xcls_RooProjectSettings _this;
774 public Xcls_Label20(Xcls_RooProjectSettings _owner )
777 this.el = new Gtk.Label( "HTML To insert at end of <HEAD>" );
781 // set gobject values
784 // user defined functions
787 public class Xcls_ScrolledWindow21 : Object
789 public Gtk.ScrolledWindow el;
790 private Xcls_RooProjectSettings _this;
796 public Xcls_ScrolledWindow21(Xcls_RooProjectSettings _owner )
799 this.el = new Gtk.ScrolledWindow( null, null );
803 // set gobject values
804 var child_0 = new Xcls_view( _this );
806 this.el.add ( child_0.el );
809 // user defined functions
811 public class Xcls_view : Object
813 public Gtk.SourceView el;
814 private Xcls_RooProjectSettings _this;
820 public Xcls_view(Xcls_RooProjectSettings _owner )
824 this.el = new Gtk.SourceView();
830 var description = Pango.FontDescription.from_string("monospace");
831 description.set_size(9000);
832 this.el.override_font(description);
835 this.el.key_release_event.connect( ( event) =>{
836 if (event.keyval != 115) {
840 if ( (event.state & Gdk.ModifierType.CONTROL_MASK ) < 1 ) {
843 var buf = this.el.get_buffer();
846 buf.get_start_iter(out s);
847 buf.get_end_iter(out e);
848 _this.project.runhtml = buf.get_text(s,e,true);
851 _this.buttonPressed("save");
858 // user defined functions
863 public class Xcls_Box23 : Object
866 private Xcls_RooProjectSettings _this;
872 public Xcls_Box23(Xcls_RooProjectSettings _owner )
875 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
879 // set gobject values
880 this.el.homogeneous = false;
881 var child_0 = new Xcls_Label24( _this );
883 this.el.pack_start ( child_0.el , false,false,0 );
884 var child_1 = new Xcls_database_DBTYPE( _this );
886 this.el.pack_start ( child_1.el , false,false,0 );
887 var child_2 = new Xcls_Label26( _this );
889 this.el.pack_start ( child_2.el , false,false,0 );
890 var child_3 = new Xcls_database_DBNAME( _this );
892 this.el.pack_start ( child_3.el , false,false,0 );
893 var child_4 = new Xcls_Label28( _this );
895 this.el.pack_start ( child_4.el , false,false,0 );
896 var child_5 = new Xcls_database_DBUSERNAME( _this );
898 this.el.pack_start ( child_5.el , false,false,0 );
899 var child_6 = new Xcls_Label30( _this );
901 this.el.pack_start ( child_6.el , false,false,0 );
902 var child_7 = new Xcls_database_DBPASSWORD( _this );
904 this.el.pack_start ( child_7.el , false,false,0 );
905 var child_8 = new Xcls_Button32( _this );
907 this.el.pack_start ( child_8.el , false,false,0 );
908 var child_9 = new Xcls_database_ERROR( _this );
910 this.el.pack_start ( child_9.el , false,false,0 );
913 // user defined functions
915 public class Xcls_Label24 : Object
918 private Xcls_RooProjectSettings _this;
924 public Xcls_Label24(Xcls_RooProjectSettings _owner )
927 this.el = new Gtk.Label( "Type (eg. MySQL or PostgreSQL)" );
931 // set gobject values
935 // user defined functions
938 public class Xcls_database_DBTYPE : Object
941 private Xcls_RooProjectSettings _this;
947 public Xcls_database_DBTYPE(Xcls_RooProjectSettings _owner )
950 _this.database_DBTYPE = this;
951 this.el = new Gtk.Entry();
955 // set gobject values
958 this.el.key_press_event.connect( (ev) => {
960 if (ev.keyval == Gdk.Key.Tab) {
961 _this.database_DBNAME.el.grab_focus();
970 // user defined functions
973 public class Xcls_Label26 : Object
976 private Xcls_RooProjectSettings _this;
982 public Xcls_Label26(Xcls_RooProjectSettings _owner )
985 this.el = new Gtk.Label( "Name" );
989 // set gobject values
993 // user defined functions
996 public class Xcls_database_DBNAME : Object
999 private Xcls_RooProjectSettings _this;
1005 public Xcls_database_DBNAME(Xcls_RooProjectSettings _owner )
1008 _this.database_DBNAME = this;
1009 this.el = new Gtk.Entry();
1013 // set gobject values
1016 this.el.key_press_event.connect( (ev) => {
1018 if (ev.keyval == Gdk.Key.Tab) {
1019 _this.database_DBUSERNAME.el.grab_focus();
1028 // user defined functions
1031 public class Xcls_Label28 : Object
1033 public Gtk.Label el;
1034 private Xcls_RooProjectSettings _this;
1040 public Xcls_Label28(Xcls_RooProjectSettings _owner )
1043 this.el = new Gtk.Label( "Username" );
1047 // set gobject values
1048 this.el.xalign = 0f;
1051 // user defined functions
1054 public class Xcls_database_DBUSERNAME : Object
1056 public Gtk.Entry el;
1057 private Xcls_RooProjectSettings _this;
1063 public Xcls_database_DBUSERNAME(Xcls_RooProjectSettings _owner )
1066 _this.database_DBUSERNAME = this;
1067 this.el = new Gtk.Entry();
1071 // set gobject values
1074 this.el.key_press_event.connect( (ev) => {
1076 if (ev.keyval == Gdk.Key.Tab) {
1077 _this.database_DBPASSWORD.el.grab_focus();
1086 // user defined functions
1089 public class Xcls_Label30 : Object
1091 public Gtk.Label el;
1092 private Xcls_RooProjectSettings _this;
1098 public Xcls_Label30(Xcls_RooProjectSettings _owner )
1101 this.el = new Gtk.Label( "Password" );
1105 // set gobject values
1106 this.el.xalign = 0f;
1109 // user defined functions
1112 public class Xcls_database_DBPASSWORD : Object
1114 public Gtk.Entry el;
1115 private Xcls_RooProjectSettings _this;
1121 public Xcls_database_DBPASSWORD(Xcls_RooProjectSettings _owner )
1124 _this.database_DBPASSWORD = this;
1125 this.el = new Gtk.Entry();
1129 // set gobject values
1132 // user defined functions
1135 public class Xcls_Button32 : Object
1137 public Gtk.Button el;
1138 private Xcls_RooProjectSettings _this;
1144 public Xcls_Button32(Xcls_RooProjectSettings _owner )
1147 this.el = new Gtk.Button();
1151 // set gobject values
1152 this.el.label = "Check Connection";
1155 this.el.clicked.connect( () => {
1158 _this.database_ERROR.el.label = "";
1161 // assumes localhost...
1162 cnc = Gda.Connection.open_from_string (
1163 _this.database_DBTYPE.el.get_text(),
1164 "DB_NAME=" + _this.database_DBNAME.el.get_text(),
1165 "USERNAME=" + _this.database_DBUSERNAME.el.get_text() +
1166 ";PASSWORD=" + _this.database_DBPASSWORD.el.get_text(),
1167 Gda.ConnectionOptions.NONE
1169 //} catch (Gda.ConnectionError ce) {
1170 // _this.database_ERROR.el.label = ce.message;
1171 } catch(Gda.ConnectionError ue) {
1172 _this.database_ERROR.el.label = ue.message;
1174 } catch(Gda.ConfigError ue) {
1175 _this.database_ERROR.el.label = ue.message;
1178 _this.database_ERROR.el.label = "Connection Succeeded";
1183 // user defined functions
1186 public class Xcls_database_ERROR : Object
1188 public Gtk.Label el;
1189 private Xcls_RooProjectSettings _this;
1195 public Xcls_database_ERROR(Xcls_RooProjectSettings _owner )
1198 _this.database_ERROR = this;
1199 this.el = new Gtk.Label( " " );
1203 // set gobject values
1205 this.el.xalign = 0f;
1208 // user defined functions
1213 public class Xcls_Box34 : Object
1216 private Xcls_RooProjectSettings _this;
1222 public Xcls_Box34(Xcls_RooProjectSettings _owner )
1225 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1229 // set gobject values
1230 this.el.homogeneous = true;
1231 this.el.expand = false;
1232 this.el.vexpand = false;
1233 var child_0 = new Xcls_Button35( _this );
1235 this.el.add ( child_0.el );
1236 var child_1 = new Xcls_Button36( _this );
1238 this.el.add ( child_1.el );
1241 // user defined functions
1243 public class Xcls_Button35 : Object
1245 public Gtk.Button el;
1246 private Xcls_RooProjectSettings _this;
1252 public Xcls_Button35(Xcls_RooProjectSettings _owner )
1255 this.el = new Gtk.Button();
1259 // set gobject values
1260 this.el.label = "Apply";
1263 this.el.button_press_event.connect( () => {
1266 _this.buttonPressed("apply");
1271 // user defined functions
1274 public class Xcls_Button36 : Object
1276 public Gtk.Button el;
1277 private Xcls_RooProjectSettings _this;
1283 public Xcls_Button36(Xcls_RooProjectSettings _owner )
1286 this.el = new Gtk.Button();
1290 // set gobject values
1291 this.el.label = "Save";
1294 this.el.button_press_event.connect( () => {
1297 _this.buttonPressed("save");
1302 // user defined functions