{ "build_module" : "builder", "items" : [ { "$ xns" : "Gtk", "@ void complete" : "(string result)", "gboolean deletable" : true, "gboolean modal" : true, "gint default_height" : 500, "gint default_width" : 750, "id" : "DialogPluginWebkit", "items" : [ { "$ xns" : "Gtk", "* pack" : "get_content_area().append", "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", "bool homogeneous" : false, "items" : [ { "$ xns" : "Gtk", "* init" : [ " this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);", " ", "" ], "* pack" : "append", "bool hexpand" : true, "bool vexpand" : true, "items" : [ { "$ xns" : "WebKit", "* init" : [ " {", " // this may not work!?", " var settings = this.el.get_settings();", " settings.enable_write_console_messages_to_stdout = true;", " ", " var fs= new FakeServer(this.el);", " fs.ref();", " // this was an attempt to change the url perms.. did not work..", " // settings.enable_file_access_from_file_uris = true;", " // settings.enable_offline_web_application_cache - true;", " // settings.enable_universal_access_from_file_uris = true;", " ", " ", " ", " ", " ", "", " // FIXME - base url of script..", " // we need it so some of the database features work.", " this.el.load_html( \"Render not ready\" , ", " //fixme - should be a config option!", " // or should we catch stuff and fix it up..", " \"xhttp://localhost/roobuilder/\"", " );", " ", " ", " ", " ", "}", "" ], "* pack" : "set_child", "id" : "webview", "listeners" : { "script_dialog" : [ " (dialog) => {", " if (this.el == null) {", " return true;", " }", " ", " var msg = dialog.get_message();", " if (msg.length < 4) {", " return false;", " }", " if (msg.substring(0,4) != \"IPC:\") {", " return false;", " }", " var ar = msg.split(\":\", 3);", " if (ar.length < 3) {", " return false;", " }", " print(\"CMD: %s\\n\",ar[1]);", " print(\"ARGS: %s\\n\",ar[2]);", " switch(ar[1]) {", " ", " case \"SAVEHTML\":", " // print(\"%sw\",ar[2]);", " // _this.file.saveHTML(ar[2]);", " return true;", " ", " case \"OUT\":", " _this.result_json = ar[2];", " return true;", " ", " default:", " return true;", " }", " ", "}" ] }, "xtype" : "WebView" } ], "xtype" : "ScrolledWindow" } ], "xtype" : "Box" }, { "$ xns" : "Gtk", "* pack" : "add_action_widget,3", "label" : "Reload", "xtype" : "Button" }, { "$ xns" : "Gtk", "* pack" : "add_action_widget,0", "label" : "Cancel", "xtype" : "Button" }, { "$ xns" : "Gtk", "* pack" : "add_action_widget,1", "label" : "OK", "xtype" : "Button" } ], "listeners" : { "response" : [ "(response_id) => {", "", " \t\t ", "\t\t if (response_id == 1) { // OK...", "\t\t var loop = new MainLoop();", "\t\t // run toBJS to get the data... (calls back into alert handler)", "\t\t _this.result_json = \"\";", "\t\t this.webview.el.run_javascript.begin(\"Editor.\" + this.cls + \".panel.toBJS();\", null, (obj, res) => {", "\t\t try {", "\t\t this.webview.el.run_javascript.end(res);", "\t\t } catch(Error e) {", "\t\t ", "\t\t }", "\t\t loop.quit();", "\t\t });", "\t\t loop.run();", "\t\t _this.complete(_this.result_json);", "\t\t ", "\t\t ", "\t\t// print(\"LOOP END?\");", "\t\t // try and get the resopse...", "\t\t break;", "\t\t }", "\t\t if (response_id < 1) {", "\t\t this.el.hide();", "\t\t _this.complete(\"\");", "\t\t }", "\t\t // keep showing...?", " \t\t}", "" ] }, "string cls" : "", "string result_json" : "", "string tmpjs" : "", "utf8 title" : "Add / Edit Component", "xtype" : "Dialog", "| bool has_plugin" : [ "(string cls) {", "", " return GLib.FileUtils.test(", " BuilderApplication.configDirectory() + \"/resources/Editors/Editor.\" + cls + \".js\",", " GLib.FileTest.IS_REGULAR", " );", " ", "", "", "}", "" ], "| void showIt" : [ " // for result hook into complete", " ", " (Gtk.Window ?parent, Project.Project project, string cls, string tbl) {// JsRender.Node node) {", " ", " \tthis.cls = cls;", " ", " if (parent != null) {", " this.el.set_transient_for(parent);", " this.el.modal = true;", " }", " this.result_json = \"\";", " var db = project.roo_database;", " ", " this.el.show();", " ", " ", " ", " var runhtml = \"\\n\" ;", "", " print(runhtml);", " // fix to make sure they are the same..", " ", " // need to modify paths", "", " string inhtml;", " try {", " GLib.FileUtils.get_contents(", " BuilderApplication.configDirectory() + \"/resources/roo.builder.html\"", " , out inhtml);", " ", " } catch (Error e) {", " inhtml = \"\";", " }", " // fetch the json from the database...", " ", " //print(runhtml);", " ", " var html = inhtml.replace(\"\", runhtml + // + this.runhtml + ", " \"\" + ", " ", " ", " \"\");", " //print(\"LOAD HTML \" + html);", " ", " //var rootURL = _this.file.project.rootURL;", " ", " ", " ", " this.webview.el.load_html( html , ", " //fixme - should be a config option!", " \"xhttp://localhost/roobuilder/\"", " );", " ", " ", " ", " ", " ", "}", "" ] } ], "modOrder" : "", "name" : "DialogPluginWebkit", "parent" : "", "path" : "/home/alan/gitlive/roobuilder/src/Builder4/DialogPluginWebkit.bjs", "permname" : "", "title" : "" }