Fix #8019 - tidy up resource usage
[roobuilder] / src / Builder4 / WindowRooView.bjs
index 6c9452d..9ceb803 100644 (file)
             "    this.pendingRedraw = true;",
             "",
             "    var runhtml = \"<script type=\\\"text/javascript\\\">\\n\" ;",
-            "    string builderhtml;",
+            "    uint8[] builderhtml;",
             "    ",
             "    try {",
-            "        GLib.FileUtils.get_contents(BuilderApplication.configDirectory() + \"/resources/roo.builder.js\", out builderhtml);",
+            "        GLib. File.new_for_uri(\"resources:///html/roo.builder.js\").load_contents(null,  out   builderhtml, null);",
             "    } catch (Error e) {",
-            "        builderhtml = \"\";",
+            "        builderhtml = {};",
             "    }",
             "",
-            "    runhtml += builderhtml + \"\\n\";",
+            "    runhtml += (string) builderhtml + \"\\n\";",
             "    runhtml += \"</script>\\n\" ;",
             "",
             "    // fix to make sure they are the same..",
             "    this.runhtml = project.runhtml;",
             "    // need to modify paths",
             "",
-            "    string inhtml;",
+            "    uint8[] inhtml;",
             "    var base_template = project.base_template;",
+            "    var f = GLib. File.new_for_uri(\"resources:///html/\" + base_template);",
             "    ",
-            "    if (base_template.length > 0 && !FileUtils.test(",
-            "        BuilderApplication.configDirectory() + \"/resources/\" +  base_template, FileTest.EXISTS)  ",
-            "        ) {",
-            "           print(\"invalid base_template name - using default:  %s\\n\", base_template);",
-            "           base_template = \"\";",
+            "    if (base_template.length > 0 && !f.query_exists(null)) {",
+            "       ",
+            "           GLib.debug(\"invalid base_template name - using default:  %Scanner\", base_template);",
+            "           f = GLib. File.new_for_uri(\"resources:///html/roo.builder.html\");",
             "    ",
             "    }",
             "    try {",
-            "        GLib.FileUtils.get_contents(",
-            "            BuilderApplication.configDirectory() + \"/resources/\" + ",
-            "                (base_template.length > 0 ? base_template :  \"roo.builder.html\")",
-            "                , out inhtml);",
+            "\t    f.load_contents(null,  out inhtml, null);",
+            "         ",
             "    ",
             "    } catch (Error e) {",
-            "        inhtml = \"\";",
+            "        inhtml = {};",
             "    }    ",
             "    this.renderedData = js;",
             "",
             "    //this.runjs = js_src;",
             "    var fc =    FakeServerCache.factory_with_data(js_src);",
             "    this.runjs = fc.fname;",
+            "    var html  = (string) inhtml;",
+            "\thtml = html.replace(\"</head>\", runhtml + this.runhtml + ",
+            "        \"<script type=\\\"text/javascript\\\" src=\\\"xhttp://localhost\" + fc.fname + \"\\\"></script>\" +   ",
+            "          //  \"<script type=\\\"text/javascript\\\">\\n\" +",
+            "          //  js_src + \"\\n\" + ",
+            "          //  \"</script>\" + ",
+            "                    ",
+            "    \"</head>\");",
+            "    //print(\"LOAD HTML \" + html);",
+            "    ",
+            "     var rootURL = project.rootURL;",
+            "",
             "    ",
-            "        var html = inhtml.replace(\"</head>\", runhtml + this.runhtml + ",
-            "            \"<script type=\\\"text/javascript\\\" src=\\\"xhttp://localhost\" + fc.fname + \"\\\"></script>\" +   ",
-            "              //  \"<script type=\\\"text/javascript\\\">\\n\" +",
-            "              //  js_src + \"\\n\" + ",
-            "              //  \"</script>\" + ",
-            "                        ",
-            "        \"</head>\");",
-            "        //print(\"LOAD HTML \" + html);",
-            "        ",
-            "         var rootURL = project.rootURL;",
-            "   ",
-            "        ",
-            "        ",
-            "        this.el.load_html( html , ",
-            "            //fixme - should be a config option!",
-            "            (rootURL.length > 0 ? rootURL : \"xhttp://localhost/roobuilder/\")",
-            "        );",
-            "          this.initInspector();   ",
+            "    ",
+            "    this.el.load_html( html , ",
+            "        //fixme - should be a config option!",
+            "        (rootURL.length > 0 ? rootURL : \"xhttp://localhost/roobuilder/\")",
+            "    );",
+            "      this.initInspector();   ",
             "    // force the inspector...        ",
             "       //   this.initInspector();",
             "        ",
          "id" : "sourceviewscroll",
          "items" : [
           {
+           "# Gtk.CssProvider? css" : "null",
            "# JsRender.Node? node_selected" : "null",
            "# bool button_is_pressed" : false,
            "# bool key_is_pressed" : false,
            "# bool loading" : true,
+           "# bool show_line_marks" : true,
+           "# id" : "sourceview",
            "# int editable_start_pos" : "-1",
            "# string prop_selected" : "\"\"",
            "$ xns" : "GtkSource",
             ""
            ],
            "* pack" : "set_child",
-           "Gtk.CssProvider css" : "",
-           "gboolean editable" : false,
-           "gboolean show_line_marks" : true,
-           "gboolean show_line_numbers" : true,
-           "id" : "sourceview",
+           "bool editable" : false,
+           "bool show_line_numbers" : true,
            "items" : [
             {
              "$ xns" : "GtkSource",
             " ",
             ""
            ],
-           "Gtk.CssProvider css" : "",
+           "Gtk.CssProvider? css" : "null",
            "bool hexpand" : true,
            "id" : "search_entry",
            "items" : [