{ "build_module" : "builder", "gen_extended" : false, "items" : [ { "# Project.Roo project" : "", "# bool done" : false, "$ xns" : "Gtk", "@ void buttonPressed" : "(string btn)", "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" }, { "# bool loading" : false, "$ xns" : "Gtk", "* pack" : "attach,1,1,1,1", "id" : "base_template", "items" : [ { "$ xns" : "Gtk", "* prop" : "model", "strings" : [ "{ ", "\t\"roo.builder.html\",", "\t\"bootstrap.builder.html\",", "\t\"bootstrap4.builder.html\",", "\t\"mailer.builder.html\"", "}" ], "xtype" : "StringList" } ], "listeners" : { "notify[\"selected\"]" : [ "() => {", "", " ", "\t// this get's called when we are filling in the data... ???", "\tif (this.loading) {", "\t\treturn;", "\t}", "\tvar sm = (Gtk.StringList) this.el.model;", "\t_this.project.base_template = sm.get_string(this.el.selected);", "\t\t", "\t\t print(\"\\nSET base template to %s\\n\", _this.project.base_template );", "\t\t// is_bjs = ((string)vfname) == \"bjs\";", "", "", " }" ] }, "xtype" : "DropDown" }, { "$ 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" }, { "# bool loading" : false, "$ xns" : "Gtk", "* pack" : "attach,1,3,1,1", "id" : "html_gen", "items" : [ { "$ xns" : "Gtk", "* prop" : "model", "strings" : [ "{ ", "\t\"Do not Generate\", // \"\"", "\t\"same directory as BJS file\", // bjs", "\t\"in templates subdirectory\" // tmeplate", " ", "} " ], "xtype" : "StringList" } ], "listeners" : { "notify[\"selected\"]" : [ "() => {", "", " ", "\t// this get's called when we are filling in the data... ???", "\tif (this.loading) {", "\t\treturn;", "\t}", "\tvar sm = (Gtk.StringList) this.el.model;", "\t_this.project.base_template = sm.get_string(this.el.selected);", "\t\t", "\t\t print(\"\\nSET base template to %s\\n\", _this.project.base_template );", "\t\t// is_bjs = ((string)vfname) == \"bjs\";", "", "", " }" ] }, "xtype" : "DropDown" } ], "n_columns" : 2, "n_rows" : 7, "uint row_spacing" : 2, "xtype" : "Grid" }, { "$ xns" : "Gtk", "label" : "HTML To insert at end of ", "xtype" : "Label" }, { "$ xns" : "Gtk", "bool vexpand" : true, "items" : [ { "$ xns" : "GtkSource", "* pack" : "set_child", "css_classes" : "{ \"code-editor\" }", "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" } ], "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", "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", "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();", " ", " ", " ", " ", "\tvar val = \"\";", "\tswitch (this.html_gen.el.selected) {", "\t\tcase 1: val = \"bjs\"; break;", "\t\tcase 2: val = \"template\"; break;", "\t}", " ", " _this.project.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 );", " ", " ", " var tv = 0;", " switch (this.project.html_gen) {", " \tcase \"bjs\": tv = 1; break;", " \tcase \"template\": tv = 2; break;", " }", " this.html_gen.el.selected = tv;", " ", " ", "", "\tvar sm = (Gtk.StringList) _this.base_template.el.model;", "\tthis.base_template.loading = true;", "\tthis.base_template.el.selected = Gtk.INVALID_LIST_POSITION;", "\tfor(var i=0;i< sm.get_n_items(); i++) {", "\t\tif (sm.get_string( i ) == this.project.base_template) {", "\t\t\tthis.base_template.el.selected = i;", "\t\t\tbreak;", "\t\t}", "\t}", " this.base_template.loading = false;", " //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" }