src/Builder4/WindowRooView.bjs
authorAlan Knowles <alan@roojs.com>
Wed, 15 Apr 2015 05:50:19 +0000 (13:50 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 15 Apr 2015 05:50:19 +0000 (13:50 +0800)
src/Builder4/WindowRooView.vala

src/Builder4/WindowRooView.bjs
src/Builder4/WindowRooView.vala

index 220ad9f..9af14cc 100644 (file)
          "id" : "view",
          "# bool refreshRequired" : false,
          "* init" : " {\n    // this may not work!?\n    var settings =  this.el.get_settings();\n    settings.enable_developer_extras = true;\n    \n    \n    var fs= new FakeServer(this.el);\n    fs.ref();\n    // this was an attempt to change the url perms.. did not work..\n    // settings.enable_file_access_from_file_uris = true;\n    // settings.enable_offline_web_application_cache - true;\n    // settings.enable_universal_access_from_file_uris = true;\n   \n     \n    \n    \n    \n\n     // FIXME - base url of script..\n     // we need it so some of the database features work.\n    this.el.load_html( \"Render not ready\" , \n            //fixme - should be a config option!\n            // or should we catch stuff and fix it up..\n            \"http://localhost/app.Builder/\"\n    );\n        \n        \n   //this.el.open('file:///' + __script_path__ + '/../builder.html');\n    /*\n    Gtk.drag_dest_set\n    (\n            this.el,              //\n            Gtk.DestDefaults.MOTION  | Gtk.DestDefaults.HIGHLIGHT,\n            null,            // list of targets\n            Gdk.DragAction.COPY         // what to do with data after dropped \n    );\n                            \n   // print(\"RB: TARGETS : \" + LeftTree.atoms[\"STRING\"]);\n    Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);\n    */\n    GLib.Timeout.add_seconds(1,  ()  =>{\n         //print(\"run refresh?\");\n         if (this.el == null) {\n            return false;\n         }\n         this.runRefresh(); \n         return true;\n     });\n    \n    \n}\n",
+         "| void reInit" : "() {\n\n}\n",
          "* pack" : "add",
          "redraws" : 0,
          "xtype" : "WebView",
-         "void reInit" : "() {\n\n}\n",
          "# WebKit.WebInspector inspector" : "",
          "# int redraws" : 0,
          "| void runRefresh" : " () \n{\n    // this is run every 2 seconds from the init..\n\n  \n    \n    if (!this.refreshRequired) {\n       // print(\"no refresh required\");\n        return;\n    }\n\n    if (this.lastRedraw != null) {\n       // do not redraw if last redraw was less that 5 seconds ago.\n       if ((int64)(new DateTime.now_local()).difference(this.lastRedraw) < 5000 ) {\n            return;\n        }\n    }\n    \n    if (_this.file == null) {\n        return;\n    }\n    \n    \n     this.refreshRequired = false;\n   //  print(\"HTML RENDERING\");\n     \n     \n     //this.get('/BottomPane').el.show();\n     //this.get('/BottomPane').el.set_current_page(2);// webkit inspector\n    _this.file.webkit_page_id  = this.el.get_page_id();\n    \n    var js = _this.file.toSourcePreview();\n\n    if (js.length < 1) {\n        print(\"no data\");\n        return;\n    }\n//    var  data = js[0];\n    this.redraws++;\n  \n    var project = _this.file.project;  \n\n     //print (project.fn);\n     // set it to non-empty.\n     \n//     runhtml = runhtml.length ?  runhtml : '<script type=\"text/javascript\"></script>'; \n\n\n//   this.runhtml  = this.runhtml || '';\n \n \n    // then we need to reload the browser using\n    // load_html_string..\n\n    // then trigger a redraw once it's loaded..\n    this.pendingRedraw = true;\n\n    var runhtml = \"<script type=\\\"text/javascript\\\">\\n\" ;\n    string builderhtml;\n    \n    \n    GLib.FileUtils.get_contents(BuilderApplication.configDirectory() + \"/resources/roo.builder.js\", out builderhtml);\n\n    runhtml += builderhtml + \"\\n\";\n    runhtml += \"</script>\\n\" ;\n\n    // fix to make sure they are the same..\n    this.runhtml = project.runhtml;\n    // need to modify paths\n\n    string inhtml;\n    var base_template = _this.file.project.base_template;\n    \n    if (base_template.length > 0 && !FileUtils.test(\n        BuilderApplication.configDirectory() + \"/resources/\" +  base_template, FileTest.EXISTS)  \n        ) {\n           print(\"invalid base_template name - using default:  %s\\n\", base_template);\n           base_template = \"\";\n    \n    }\n    \n    GLib.FileUtils.get_contents(\n        BuilderApplication.configDirectory() + \"/resources/\" + \n            (base_template.length > 0 ? base_template :  \"roo.builder.html\")\n            , out inhtml);\n    \n    \n    this.renderedData = js;\n\n\n    string js_src = js + \"\\n\" +\n\t\"Roo.onReady(function() {\\n\" +\n\t\"if (\" + _this.file.name +\".show) \" +  _this.file.name +\".show({});\\n\" +\n\t\"Roo.XComponent.build();\\n\" +\n\t\"});\\n\";\n\t\n   // print(\"render js: \" + js);\n    //if (!this.ready) {\n  //      console.log('not loaded yet');\n    //}\n    this.lastRedraw = new DateTime.now_local();\n\n        var html = inhtml.replace(\"</head>\", runhtml + this.runhtml + \n        \n                \"<script type=\\\"text/javascript\\\">\\n\" +\n                js_src + \"\\n\" + \n                \"</script>\" + \n                        \n        \"</head>\");\n        //print(\"LOAD HTML \" + html);\n        \n         var rootURL = _this.file.project.rootURL;\n   \n        \n        \n        this.el.load_html( html , \n            //fixme - should be a config option!\n            (rootURL.length > 0 ? rootURL : \"xhttp://localhost/app.Builder.js/\")\n        );\n        \n    // force the inspector...        \n          this.initInspector();\n        \n        // - no need for this, the builder javascript will call it when build is complete\n        //GLib.Timeout.add_seconds(1, () => {\n        //    this.el.run_javascript(\"Builder.saveHTML()\",null);\n        //    return false;\n        //});\n//     print( \"before render\" +    this.lastRedraw);\n//    print( \"after render\" +    (new Date()));\n    \n}\n                                                                                                                                                                                                                        ",
index c650a75..3dfd49e 100644 (file)
@@ -303,7 +303,6 @@ public class Xcls_WindowRooView : Object
             // my vars (def)
         public string renderedData;
         public bool refreshRequired;
-        public void reInit;
         public WebKit.WebInspector inspector;
         public int redraws;
         public GLib.DateTime lastRedraw;
@@ -320,10 +319,6 @@ public class Xcls_WindowRooView : Object
             // my vars (dec)
             this.renderedData = "";
             this.refreshRequired = false;
-            this.reInit = () {
-
-}
-;
             this.redraws = 0;
             this.lastRedraw = null;
             this.runhtml = "";
@@ -439,6 +434,9 @@ public class Xcls_WindowRooView : Object
         }
 
         // user defined functions 
+        public void reInit () {
+        
+        }
         public void runRefresh () 
         {
             // this is run every 2 seconds from the init..