{
- "name" : "RooProjectSettings",
- "parent" : "",
- "title" : "",
- "path" : "/home/alan/gitlive/roobuilder/src/Builder4/RooProjectSettings.bjs",
- "permname" : "",
- "modOrder" : "",
"build_module" : "builder",
+ "gen_extended" : false,
"items" : [
- ]
+ {
+ "$ xns" : "Gtk",
+ "@ void buttonPressed" : "(string btn)",
+ "Gtk.PositionType position" : "Gtk.PositionType.RIGHT",
+ "Project.Roo project" : "",
+ "bool autohide" : false,
+ "bool done" : false,
+ "bool modal" : true,
+ "id" : "RooProjectSettings",
+ "items" : [
+ {
+ "$ homogeneous" : false,
+ "$ xns" : "Gtk",
+ "* pack" : "set_child",
+ "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
+ "border_width" : 5,
+ "items" : [
+ {
+ "$ xns" : "Gtk",
+ "items" : [
+ {
+ "$ xns" : "Gtk",
+ "* pack" : false,
+ "id" : "label_global",
+ "utf8 label" : "Global",
+ "xtype" : "Label"
+ },
+ {
+ "$ xns" : "Gtk",
+ "* pack" : false,
+ "id" : "label_database",
+ "utf8 label" : "Database",
+ "xtype" : "Label"
+ },
+ {
+ "$ xns" : "Gtk",
+ "* pack" : "append_page,_this.label_global.el",
+ "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
+ "gboolean homogeneous" : false,
+ "items" : [
+ {
+ "$ homogeneous" : true,
+ "$ xns" : "Gtk",
+ "id" : "grid",
+ "int margin_end" : 4,
+ "int margin_start" : 4,
+ "items" : [
+ {
+ "$ xns" : "Gtk",
+ "* pack" : "attach,0,0,1,1",
+ "int margin_bottom" : 3,
+ "int margin_end" : 3,
+ "int margin_start" : 3,
+ "int margin_top" : 3,
+ "label" : "Filename",
+ "xalign" : 0,
+ "xtype" : "Label"
+ },
+ {
+ "$ xns" : "Gtk",
+ "* pack" : "attach,1,0,1,1",
+ "id" : "path",
+ "int margin_bottom" : 3,
+ "int margin_end" : 3,
+ "int margin_start" : 3,
+ "int margin_top" : 3,
+ "label" : "filename",
+ "xalign" : 0,
+ "xtype" : "Label"
+ },
+ {
+ "$ xns" : "Gtk",
+ "* pack" : "attach,0,1,1,1",
+ "int margin_bottom" : 3,
+ "int margin_end" : 3,
+ "int margin_start" : 3,
+ "int margin_top" : 3,
+ "label" : "HTML template file",
+ "xtype" : "Label"
+ },
+ {
+ "$ xns" : "Gtk",
+ "* init" : "this.el.add_attribute(_this.base_template_cellrenderer.el , \"markup\", 0 );",
+ "* pack" : "attach,1,1,1,1",
+ "bool loading" : false,
+ "id" : "base_template",
+ "items" : [
+ {
+ "$ xns" : "Gtk",
+ "* pack" : "pack_start,true",
+ "id" : "base_template_cellrenderer",
+ "xtype" : "CellRendererText"
+ },
+ {
+ "$ columns" : "typeof(string)",
+ "$ xns" : "Gtk",
+ "* pack" : "set_model",
+ "id" : "base_template_model",
+ "n_columns" : 1,
+ "xtype" : "ListStore",
+ "| void loadData" : [
+ " () {",
+ "\t_this.base_template.loading = true;",
+ " ",
+ " this.el.clear(); ",
+ " Gtk.TreeIter iter;",
+ " var el = this.el;",
+ " ",
+ " /// el.append(out iter);",
+ " ",
+ " ",
+ " el.append(out iter);",
+ " el.set_value(iter, 0, \"roo.builder.html\");",
+ " _this.base_template.el.set_active_iter(iter);",
+ "\tif (_this.project.base_template == \"roo.builder.html\") {",
+ "\t _this.base_template.el.set_active_iter(iter);",
+ " }",
+ "",
+ " el.append(out iter);",
+ " el.set_value(iter, 0, \"bootstrap.builder.html\");",
+ " ",
+ "\tprint(\"\\ncur template = %s\\n\", _this.project.base_template);",
+ " ",
+ " if (_this.project.base_template == \"bootstrap.builder.html\") {",
+ "\t _this.base_template.el.set_active_iter(iter);",
+ " }",
+ "\t el.append(out iter);",
+ " el.set_value(iter, 0, \"bootstrap4.builder.html\");",
+ " if (_this.project.base_template == \"bootstrap4.builder.html\") {",
+ "\t _this.base_template.el.set_active_iter(iter);",
+ " }",
+ " ",
+ "",
+ "\tel.append(out iter);",
+ " el.set_value(iter, 0, \"mailer.builder.html\");",
+ "",
+ "\tif (_this.project.base_template == \"mailer.builder.html\") {",
+ "\t _this.base_template.el.set_active_iter(iter);",
+ " }",
+ "\t_this.base_template.loading = false;",
+ " ",
+ "}",
+ ""
+ ]
+ }
+ ],
+ "listeners" : {
+ "changed" : [
+ "() => {",
+ "\tGtk.TreeIter iter;",
+ " ",
+ "\t// this get's called when we are filling in the data... ???",
+ "\tif (this.loading) {",
+ "\t\treturn;",
+ "\t}",
+ "\t",
+ " ",
+ "\tif (this.el.get_active_iter(out iter)) {",
+ "\t\tValue vfname;",
+ "\t\t_this.base_template_model.el.get_value (iter, 0, out vfname);",
+ "\t\t_this.project.base_template = ((string)vfname) ;",
+ "\t\t",
+ "\t\t print(\"\\nSET base template to %s\\n\", _this.project.base_template );",
+ "\t\t// is_bjs = ((string)vfname) == \"bjs\";",
+ "\t}",
+ " ",
+ " ",
+ " // directory is only available for non-bjs ",
+ " ",
+ "",
+ "",
+ "}",
+ ""
+ ]
+ },
+ "xtype" : "ComboBox"
+ },
+ {
+ "$ xns" : "Gtk",
+ "* pack" : "attach,0,2,1,1",
+ "int margin_bottom" : 3,
+ "int margin_end" : 3,
+ "int margin_start" : 3,
+ "int margin_top" : 3,
+ "label" : "root URL",
+ "xtype" : "Label"
+ },
+ {
+ "$ xns" : "Gtk",
+ "* pack" : "attach,1,2,1,1",
+ "id" : "rootURL",
+ "xtype" : "Entry"
+ },
+ {
+ "$ xns" : "Gtk",
+ "* pack" : "attach,0,3,1,1",
+ "label" : "Generate HTML in",
+ "xtype" : "Label"
+ },
+ {
+ "$ xns" : "Gtk",
+ "* init" : "this.el.add_attribute(_this.html_gen_cellrenderer.el , \"markup\", 1 );",
+ "* pack" : "attach,1,3,1,1",
+ "id" : "html_gen",
+ "items" : [
+ {
+ "$ xns" : "Gtk",
+ "* pack" : "pack_start,true",
+ "id" : "html_gen_cellrenderer",
+ "xtype" : "CellRendererText"
+ },
+ {
+ "$ columns" : "typeof(string),typeof(string)",
+ "$ xns" : "Gtk",
+ "* pack" : "set_model",
+ "id" : "html_gen_model",
+ "n_columns" : 2,
+ "xtype" : "ListStore",
+ "| void loadData" : [
+ " (string cur) {",
+ " this.el.clear(); ",
+ " Gtk.TreeIter iter;",
+ " var el = this.el;",
+ " ",
+ " ",
+ " el.append(out iter);",
+ "",
+ " ",
+ " el.set_value(iter, 0, \"\");",
+ " el.set_value(iter, 1, \"Do not Generate\");",
+ " _this.html_gen.el.set_active_iter(iter);",
+ "",
+ " el.append(out iter);",
+ " ",
+ " el.set_value(iter, 0, \"bjs\");",
+ " el.set_value(iter, 1, \"same directory as BJS file\");",
+ "\tif (cur == \"bjs\") {",
+ "\t _this.html_gen.el.set_active_iter(iter);",
+ " }",
+ "",
+ "",
+ "",
+ " el.append(out iter);",
+ " ",
+ " el.set_value(iter, 0, \"templates\");",
+ " el.set_value(iter, 1, \"in templates subdirectory\");",
+ "",
+ "\tif (cur == \"template\") {",
+ "\t _this.html_gen.el.set_active_iter(iter);",
+ " }",
+ "",
+ " ",
+ "}",
+ ""
+ ]
+ }
+ ],
+ "xtype" : "ComboBox"
+ }
+ ],
+ "n_columns" : 2,
+ "n_rows" : 7,
+ "uint row_spacing" : 2,
+ "xtype" : "Grid"
+ },
+ {
+ "$ xns" : "Gtk",
+ "label" : "HTML To insert at end of <HEAD>",
+ "xtype" : "Label"
+ },
+ {
+ "$ xns" : "Gtk",
+ "bool vexpand" : true,
+ "items" : [
+ {
+ "$ xns" : "GtkSource",
+ "* init" : [
+ " ",
+ " ",
+ "this.css = new Gtk.CssProvider();",
+ " ",
+ "\tthis.css.load_from_string(",
+ "\t\"#roo-project-settings-view{ font: 10px monospace;}\"",
+ ");",
+ " ",
+ "//this.el.get_style_context().add_provider(this.css,Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);",
+ " ",
+ " Gtk.StyleContext.add_provider_for_display(",
+ "\t Gdk.Display.get_default(), ",
+ "\t this.css,",
+ "\t Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
+ " );"
+ ],
+ "* pack" : "set_child",
+ "Gtk.CssProvider css" : "",
+ "id" : "view",
+ "items" : [
+ {
+ "$ xns" : "Gtk",
+ "listeners" : {
+ "key_released" : [
+ "(keyval, keycode, state) => {",
+ "",
+ "",
+ " if (keyval != 115) {",
+ " return;",
+ " ",
+ " }",
+ " if ( (state & Gdk.ModifierType.CONTROL_MASK ) < 1 ) {",
+ " return;",
+ " }",
+ " var buf = _this.view.el.get_buffer();",
+ " Gtk.TextIter s;",
+ " Gtk.TextIter e;",
+ " buf.get_start_iter(out s);",
+ " buf.get_end_iter(out e);",
+ " _this.project.runhtml = buf.get_text(s,e,true);",
+ " ",
+ " ",
+ " _this.buttonPressed(\"save\");",
+ " ",
+ " ",
+ "",
+ "}",
+ ""
+ ]
+ },
+ "xtype" : "EventControllerKey"
+ }
+ ],
+ "string name" : "roo-project-settings-view",
+ "xtype" : "View"
+ }
+ ],
+ "xtype" : "ScrolledWindow"
+ }
+ ],
+ "xtype" : "Box"
+ },
+ {
+ "$ xns" : "Gtk",
+ "* pack" : "append_page,_this.label_database.el",
+ "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
+ "gboolean homogeneous" : false,
+ "items" : [
+ {
+ "$ xns" : "Gtk",
+ "label" : "Type (eg. MySQL or PostgreSQL)",
+ "xalign" : 0,
+ "xtype" : "Label"
+ },
+ {
+ "$ xns" : "Gtk",
+ "id" : "database_DBTYPE",
+ "items" : [
+ {
+ "$ xns" : "Gtk",
+ "listeners" : {
+ "key_pressed" : [
+ "(keyval, keycode, state) => {",
+ " if (keyval == Gdk.Key.Tab) {",
+ " _this.database_DBNAME.el.grab_focus();",
+ " return true;",
+ " }",
+ "",
+ "",
+ "\treturn false;",
+ "}",
+ ""
+ ]
+ },
+ "xtype" : "EventControllerKey"
+ }
+ ],
+ "xtype" : "Entry"
+ },
+ {
+ "$ xns" : "Gtk",
+ "label" : "Name",
+ "xalign" : 0,
+ "xtype" : "Label"
+ },
+ {
+ "$ xns" : "Gtk",
+ "id" : "database_DBNAME",
+ "items" : [
+ {
+ "$ xns" : "Gtk",
+ "listeners" : {
+ "key_pressed" : [
+ "(keyval, keycode, state) => {",
+ " if (keyval == Gdk.Key.Tab) {",
+ " _this.database_DBUSERNAME.el.grab_focus();",
+ " return true;",
+ " }",
+ "",
+ "",
+ "\treturn false;",
+ "\t ",
+ "}",
+ ""
+ ]
+ },
+ "xtype" : "EventControllerKey"
+ }
+ ],
+ "xtype" : "Entry"
+ },
+ {
+ "$ xns" : "Gtk",
+ "label" : "Username",
+ "xalign" : 0,
+ "xtype" : "Label"
+ },
+ {
+ "$ xns" : "Gtk",
+ "id" : "database_DBUSERNAME",
+ "items" : [
+ {
+ "$ xns" : "Gtk",
+ "listeners" : {
+ "key_pressed" : [
+ "(keyval, keycode, state) => {",
+ " if (keyval == Gdk.Key.Tab) {",
+ " _this.database_DBPASSWORD.el.grab_focus();",
+ " return true;",
+ " }",
+ "",
+ "",
+ "\treturn false;",
+ "\t ",
+ "",
+ "}",
+ ""
+ ]
+ },
+ "xtype" : "EventControllerKey"
+ }
+ ],
+ "xtype" : "Entry"
+ },
+ {
+ "$ xns" : "Gtk",
+ "label" : "Password",
+ "xalign" : 0,
+ "xtype" : "Label"
+ },
+ {
+ "$ xns" : "Gtk",
+ "id" : "database_DBPASSWORD",
+ "xtype" : "Entry"
+ },
+ {
+ "$ xns" : "Gtk",
+ "listeners" : {
+ "clicked" : [
+ "() => {",
+ "",
+ "",
+ " _this.database_ERROR.el.label = \"\";",
+ " /*",
+ " Gda.Connection cnc;",
+ " try {",
+ " // assumes localhost...",
+ " cnc = Gda.Connection.open_from_string (",
+ "\t\t\t_this.database_DBTYPE.el.get_text(),",
+ "\t\t\t\"DB_NAME=\" + _this.database_DBNAME.el.get_text(), ",
+ "\t\t\t\"USERNAME=\" + _this.database_DBUSERNAME.el.get_text() + ",
+ "\t\t\t\";PASSWORD=\" + _this.database_DBPASSWORD.el.get_text(),",
+ "\t\t\tGda.ConnectionOptions.NONE",
+ "\t\t);",
+ " //} catch (Gda.ConnectionError ce) { ",
+ " // _this.database_ERROR.el.label = ce.message; ",
+ " } catch(GLib.Error ue) {",
+ " _this.database_ERROR.el.label = ue.message;",
+ " return;",
+ " } ",
+ " _this.database_ERROR.el.label = \"Connection Succeeded\";",
+ " cnc.close();",
+ " */",
+ "}"
+ ]
+ },
+ "utf8 label" : "Check Connection",
+ "xtype" : "Button"
+ },
+ {
+ "$ xns" : "Gtk",
+ "id" : "database_ERROR",
+ "label" : " ",
+ "xalign" : 0,
+ "xtype" : "Label"
+ }
+ ],
+ "xtype" : "Box"
+ }
+ ],
+ "xtype" : "Notebook"
+ }
+ ],
+ "xtype" : "Box"
+ },
+ {
+ "$ xns" : "Gtk",
+ "* prop" : "titlebar",
+ "bool show_title_buttons" : false,
+ "items" : [
+ {
+ "$ xns" : "Gtk",
+ "* pack" : "pack_start",
+ "listeners" : {
+ "clicked" : [
+ "() => { ",
+ "",
+ " _this.done = true;",
+ " _this.el.hide(); ",
+ "}"
+ ]
+ },
+ "string label" : "Cancel",
+ "xtype" : "Button"
+ },
+ {
+ "$ xns" : "Gtk",
+ "* pack" : "pack_end",
+ "css_classes" : "{ \"suggested-action\" }",
+ "listeners" : {
+ "clicked" : [
+ "( ) => { ",
+ "",
+ " ",
+ " _this.buttonPressed(\"save\");",
+ " ",
+ "\t// what about .js ?",
+ " _this.done = true;",
+ "\t_this.el.hide();",
+ "",
+ "// hopefull this will work with bjs files..",
+ "\t",
+ " ",
+ " ",
+ "}"
+ ]
+ },
+ "string label" : "Save",
+ "xtype" : "Button"
+ }
+ ],
+ "xtype" : "HeaderBar"
+ }
+ ],
+ "string title" : "Edit Project settings",
+ "uint border_width" : 0,
+ "xtype" : "Window",
+ "| void save" : [
+ "() {",
+ " var buf = _this.view.el.get_buffer();",
+ " Gtk.TextIter s;",
+ " Gtk.TextIter e;",
+ " buf.get_start_iter(out s);",
+ " buf.get_end_iter(out e);",
+ "\t_this.project.runhtml = buf.get_text(s,e,true);",
+ " ",
+ " _this.project.rootURL = _this.rootURL.el.get_text();",
+ " ",
+ " ",
+ " Gtk.TreeIter iter;",
+ " Value html_gen_val;",
+ " _this.html_gen.el.get_active_iter(out iter);",
+ " _this.html_gen_model.el.get_value (iter, 0, out html_gen_val);",
+ " ",
+ " _this.project.html_gen = (string)html_gen_val;",
+ " ",
+ " // set by event changed...",
+ " //_this.project.base_template = _this.base_template.el.get_text(); ",
+ " ",
+ " var js = _this.project;",
+ " js.DBTYPE = _this.database_DBTYPE.el.get_text();",
+ " js.DBNAME= _this.database_DBNAME.el.get_text();",
+ " js.DBUSERNAME= _this.database_DBUSERNAME.el.get_text();",
+ " js.DBPASSWORD= _this.database_DBPASSWORD.el.get_text();",
+ "// _this.project.set_string_member(\"DBHOST\", _this.DBTYPE.el.get_text()); ",
+ " ",
+ " // need to re-init the database ",
+ " \tjs.save();",
+ " _this.project.initDatabase();",
+ " ",
+ " ",
+ "}"
+ ],
+ "| void show" : [
+ " (Gtk.Window pwin, Project.Roo project) {",
+ " _this.done = false;",
+ " ",
+ " _this.project = project;",
+ " _this.path.el.label = project.path;",
+ " // get the active project.",
+ " var lm = GtkSource.LanguageManager.get_default();",
+ " ",
+ " ((GtkSource.Buffer)(_this.view.el.get_buffer())) .set_language(",
+ " lm.get_language(\"html\")",
+ " );",
+ " ",
+ " //print (project.fn);",
+ " //project.runhtml = project.runhtml || '';",
+ " _this.view.el.get_buffer().set_text(project.runhtml);",
+ " ",
+ " ",
+ " _this.rootURL.el.set_text( _this.project.rootURL );",
+ " ",
+ " _this.html_gen_model.loadData(_this.project.html_gen);",
+ "",
+ " _this.base_template_model.loadData();",
+ " ",
+ " //var js = _this.project;",
+ " _this.database_DBTYPE.el.set_text( _this.project.DBTYPE );",
+ " _this.database_DBNAME.el.set_text( _this.project.DBNAME );",
+ " _this.database_DBUSERNAME.el.set_text( _this.project.DBUSERNAME );",
+ " _this.database_DBPASSWORD.el.set_text( _this.project.DBPASSWORD );",
+ " ",
+ " \t//console.log('show all');",
+ "",
+ "\t",
+ " this.el.set_transient_for(pwin);",
+ "\t// window + header?",
+ "\t print(\"SHOWALL - POPIP\\n\");",
+ "\tthis.el.show();",
+ "\tthis.el.set_size_request(800,600);",
+ "\tthis.view.el.grab_focus();",
+ "\t",
+ " ",
+ " //this.el.show_all();",
+ "}",
+ ""
+ ]
+ }
+ ],
+ "name" : "RooProjectSettings"
}
\ No newline at end of file