src/Builder4/WindowRooView.bjs
authorAlan Knowles <alan@roojs.com>
Wed, 3 Jun 2015 03:38:56 +0000 (11:38 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 3 Jun 2015 03:38:56 +0000 (11:38 +0800)
src/Builder4/WindowRooView.vala

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

index 7e436ad..e228acf 100644 (file)
        "$ xns" : "Gtk",
        "utf8 label" : "Preview Generated Code"
       },
+      {
+       "id" : "WindowRooView",
+       "| void createThumb" : "() {\n    \n    \n    if (this.file == null) {\n        return;\n    }\n    var filename = this.file.getIconFileName(false);\n    \n    var  win = this.el.get_parent_window();\n    var width = win.get_width();\n  //  var height = win.get_height();\n    try { \n        Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, this.el.position);\n        screenshot.save(filename,\"png\");\n    } catch(Error e) {\n        //noop\n    }\n\n      \n\n\n    \n     \n}\n",
+       "| void loadFile" : "(JsRender.JsRender file)\n{\n    this.file = file;\n    this.view.renderJS(true);\n}",
+       "* pack" : "add",
+       "xtype" : "Paned",
+       "# JsRender.JsRender file" : "",
+       "| void requestRedraw" : "() {\n    this.view.renderJS(false);\n}",
+       "$ xns" : "Gtk",
+       "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
+       "items" : [
+        {
+         "id" : "viewbox",
+         "* pack" : "pack1,true,true",
+         "xtype" : "Box",
+         "$ xns" : "Gtk",
+         "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
+         "$ homogeneous" : false,
+         "items" : [
+          {
+           "$ vexpand" : false,
+           "$ height_request" : 20,
+           "* pack" : "pack_start,false,true,0",
+           "xtype" : "Box",
+           "$ xns" : "Gtk",
+           "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
+           "$ homogeneous" : true,
+           "items" : [
+            {
+             "listeners" : {
+              "clicked" : "( ) => {\n    _this.view.renderJS(  true);\n}"
+             },
+             "label" : "Redraw",
+             "xtype" : "Button",
+             "* pack" : "pack_start,false,false,0",
+             "$ xns" : "Gtk"
+            },
+            {
+             "listeners" : {
+              "toggled" : " (state) => {\n    this.el.set_label(this.el.active  ? \"Auto Redraw On\" : \"Auto Redraw Off\");\n}"
+             },
+             "label" : "Auto Redraw On",
+             "id" : "AutoRedraw",
+             "$ active" : true,
+             "* pack" : "pack_start,false,false,0",
+             "xtype" : "CheckButton",
+             "$ xns" : "Gtk"
+            },
+            {
+             "listeners" : {
+              "clicked" : " () => {\n  _this.view.redraws = 99;\n    _this.view.el.web_context.clear_cache();  \n  //_this.view.renderJS(true);\n  FakeServerCache.clear();\n  _this.view.reInit();\n\n}"
+             },
+             "label" : "Full Redraw",
+             "xtype" : "Button",
+             "* pack" : "pack_start,false,false,0",
+             "$ xns" : "Gtk"
+            }
+           ]
+          },
+          {
+           "id" : "viewcontainer",
+           "* init" : "  this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n \n",
+           "$ shadow_type" : "Gtk.ShadowType.IN",
+           "* pack" : "pack_end,true,true,0",
+           "xtype" : "ScrolledWindow",
+           "$ xns" : "Gtk",
+           "items" : [
+            {
+             "listeners" : {
+              "script_dialog" : " (dialog) => {\n    if (this.el == null) {\n        return true;\n    }\n    \n     var msg = dialog.get_message();\n     if (msg.length < 4) {\n        return false;\n     }\n     if (msg.substring(0,4) != \"IPC:\") {\n         return false;\n     }\n     var ar = msg.split(\":\", 3);\n    if (ar.length < 3) {\n        return false;\n    }\n    switch(ar[1]) {\n        case \"SAVEHTML\":\n            _this.file.saveHTML(ar[2]);\n            return true;\n        default:\n            return false;\n    }\n    \n}",
+              "show" : "  ( ) => {\n    this.initInspector();;\n}",
+              "drag_drop" : "  ( ctx, x, y,time, ud) => {\n    return false;\n    /*\n\tprint(\"TARGET: drag-drop\");\n        var is_valid_drop_site = true;\n        \n         \n        Gtk.drag_get_data\n        (\n                w,         // will receive 'drag-data-received' signal \n                ctx,        /* represents the current state of the DnD \n                this.get('/Window').atoms[\"STRING\"],    /* the target type we want \n                time            /* time stamp \n        );\n                        \n                        \n                        /* No target offered by source => error \n                       \n\n\treturn  is_valid_drop_site;\n\t*/\n}",
+              "load_changed" : "(le) => {\n    if (le != WebKit.LoadEvent.FINISHED) {\n        return;\n    }\n    if (this.runjs.length < 1) {\n        return;\n    }\n  //  this.el.run_javascript(this.runjs, null);\n     FakeServerCache.remove(    this.runjs);\n    this.runjs = \"\";\n}"
+             },
+             "# string renderedData" : "\"\"",
+             "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   print(\"reInit?\");\n         // if this happens destroy the webkit..\n         // recreate it..\n     this.el.stop_loading();\n         \n     if (_this.viewbox.el.get_parent() == null) {\n        return;\n     }\n         \n         \n    _this.viewbox.el.remove(_this.viewcontainer.el);\n    _this.el.remove(_this.inspectorcontainer.el);        \n         \n         // destory seems to cause problems.\n         //this.el.destroy();\n        //_this.viewcontainer.el.destroy();\n         //_this.inspectorcontainer.el.destroy();\n     var  inv =new Xcls_inspectorcontainer(_this);\n      inv.ref();\n      _this.el.pack2(inv.el,true,true);\n      \n      \n     this.el = null;         \n     var nv =new Xcls_viewcontainer(_this);\n     nv.ref();\n     _this.viewbox.el.pack_end(nv.el,true,true,0);\n         \n         \n     inv.el.show_all();\n     nv.el.show_all();\n         //while(Gtk.events_pending ()) Gtk.main_iteration ();\n         //_this.view.renderJS(true); \n     _this.view.refreshRequired  = true;\n}\n",
+             "* pack" : "add",
+             "redraws" : 0,
+             "xtype" : "WebView",
+             "# WebKit.WebInspector inspector" : "",
+             "# string runjs" : "\"\"",
+             "# 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    try {\n        GLib.FileUtils.get_contents(BuilderApplication.configDirectory() + \"/resources/roo.builder.js\", out builderhtml);\n    } catch (Error e) {\n        builderhtml = \"\";\n    }\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    try {\n        GLib.FileUtils.get_contents(\n            BuilderApplication.configDirectory() + \"/resources/\" + \n                (base_template.length > 0 ? base_template :  \"roo.builder.html\")\n                , out inhtml);\n    \n    } catch (Error e) {\n        inhtml = \"\";\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\n    //this.runjs = js_src;\n    var fc =    FakeServerCache.factory_with_data(js_src);\n    this.runjs = fc.fname;\n    \n        var html = inhtml.replace(\"</head>\", runhtml + this.runhtml + \n            \"<script type=\\\"text/javascript\\\" src=\\\"xhttp://localhost\" + fc.fname + \"\\\"></script>\" +   \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                                                                                                                                                                                                                        ",
+             "$ xns" : "WebKit",
+             "| void initInspector" : "() {\n    \n   /* if (this.inspector == this.el.get_inspector()) {\n        this.inspector.show();\n        this.inspector.open_window();        \n        print(\"init inspecter called, and inspector is the same as existing\\n\");\n        return;\n    }\n    print(\"new inspector?\\n\");\n*/\n    this.inspector = this.el.get_inspector();\n    this.inspector.ref();\n    \n    // got a new inspector...\n        \n    this.inspector.open_window.connect(() => {\n         this.inspector = this.el.get_inspector();\n        print(\"inspector attach\\n\");\n        var wv = this.inspector.get_web_view();\n        if (wv != null) {\n            print(\"got inspector web view\\n\");\n            \n            var cn = _this.inspectorcontainer.el.get_child();\n            if (cn != null) {\n                 _this.inspectorcontainer.el.remove(cn);\n             }\n            \n            _this.inspectorcontainer.el.add(wv);\n            wv.show();\n        } else {\n            //this.inspector.close();\n            \n            //this.inspector = null;\n           \n \n        }\n        return true;\n       \n    });\n    /*\n    this.inspector.closed.connect(() => {\n         print(\"inspector closed?!?\");\n         // if this happens destroy the webkit..\n         // recreate it..\n         this.el.stop_loading();\n         \n         if (_this.viewbox.el.get_parent() == null) {\n            return;\n         }\n         \n         \n        _this.viewbox.el.remove(_this.viewcontainer.el);\n        _this.el.remove(_this.inspectorcontainer.el);        \n         \n         // destory seems to cause problems.\n         //this.el.destroy();\n        //_this.viewcontainer.el.destroy();\n         //_this.inspectorcontainer.el.destroy();\n\n         this.el = null;         \n         var nv =new Xcls_viewcontainer(_this);\n         nv.ref();\n         _this.viewbox.el.pack_end(nv.el,true,true,0);\n         \n          var  inv =new Xcls_inspectorcontainer(_this);\n          inv.ref();\n          _this.el.pack2(inv.el,true,true);\n         \n         inv.el.show_all();\n         nv.el.show_all();\n         //while(Gtk.events_pending ()) Gtk.main_iteration ();\n         //_this.view.renderJS(true); \n         _this.view.refreshRequired  = true;\n       \n    }); \n    */\n    \n    this.inspector.show();\n}\n",
+             "# GLib.DateTime lastRedraw" : "null",
+             "# string runhtml" : "\"\"",
+             "# bool pendingRedraw" : false,
+             "| void renderJS" : "(bool force) {\n\n    // this is the public redraw call..\n    // we refresh in a loop privately..\n    var autodraw = _this.AutoRedraw.el.active;\n    if (!autodraw && !force) {\n        print(\"Skipping redraw - no force, and autodraw off\");\n        return;\n    }\n     \n    this.refreshRequired  = true;\n}\n"
+            }
+           ]
+          }
+         ]
+        },
+        {
+         "id" : "inspectorcontainer",
+         "* init" : "  this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n \n",
+         "$ shadow_type" : "Gtk.ShadowType.IN",
+         "xtype" : "ScrolledWindow",
+         "* pack" : "pack2,true,true",
+         "$ xns" : "Gtk"
+        }
+       ]
+      },
       {
        "* pack" : "append_page,_this.label_preview.el",
        "xtype" : "ScrolledWindow",
index 527cf9e..2b7aa89 100644 (file)
@@ -15,6 +15,12 @@ public class Xcls_GtkView : Object
     public Xcls_notebook notebook;
     public Xcls_label_preview label_preview;
     public Xcls_label_code label_code;
+    public Xcls_WindowRooView WindowRooView;
+    public Xcls_viewbox viewbox;
+    public Xcls_AutoRedraw AutoRedraw;
+    public Xcls_viewcontainer viewcontainer;
+    public Xcls_view view;
+    public Xcls_inspectorcontainer inspectorcontainer;
     public Xcls_view_layout view_layout;
     public Xcls_container container;
     public Xcls_sourceview sourceview;
@@ -238,12 +244,15 @@ public class Xcls_GtkView : Object
             child_0.ref();
             var child_1 = new Xcls_label_code( _this );
             child_1.ref();
-            var child_2 = new Xcls_ScrolledWindow5( _this );
+            var child_2 = new Xcls_WindowRooView( _this );
             child_2.ref();
-            this.el.append_page (  child_2.el , _this.label_preview.el );
-            var child_3 = new Xcls_ScrolledWindow8( _this );
+            this.el.add (  child_2.el  );
+            var child_3 = new Xcls_ScrolledWindow14( _this );
             child_3.ref();
-            this.el.append_page (  child_3.el , _this.label_code.el );
+            this.el.append_page (  child_3.el , _this.label_preview.el );
+            var child_4 = new Xcls_ScrolledWindow17( _this );
+            child_4.ref();
+            this.el.append_page (  child_4.el , _this.label_code.el );
         }
 
         // user defined functions
@@ -294,7 +303,706 @@ public class Xcls_GtkView : Object
         // user defined functions
     }
 
-    public class Xcls_ScrolledWindow5 : Object
+    public class Xcls_WindowRooView : Object
+    {
+        public Gtk.Paned el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+        public JsRender.JsRender file;
+
+        // ctor
+        public Xcls_WindowRooView(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            _this.WindowRooView = this;
+            this.el = new Gtk.Paned( Gtk.Orientation.VERTICAL );
+
+            // my vars (dec)
+
+            // set gobject values
+            var child_0 = new Xcls_viewbox( _this );
+            child_0.ref();
+            this.el.pack1 (  child_0.el , true,true );
+            var child_1 = new Xcls_inspectorcontainer( _this );
+            child_1.ref();
+            this.el.pack2 (  child_1.el , true,true );
+        }
+
+        // user defined functions
+        public void createThumb () {
+            
+            
+            if (this.file == null) {
+                return;
+            }
+            var filename = this.file.getIconFileName(false);
+            
+            var  win = this.el.get_parent_window();
+            var width = win.get_width();
+          //  var height = win.get_height();
+            try { 
+                Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, this.el.position);
+                screenshot.save(filename,"png");
+            } catch(Error e) {
+                //noop
+            }
+        
+              
+        
+        
+            
+             
+        }
+        public void loadFile (JsRender.JsRender file)
+        {
+            this.file = file;
+            this.view.renderJS(true);
+        }
+        public void requestRedraw () {
+            this.view.renderJS(false);
+        }
+    }
+    public class Xcls_viewbox : Object
+    {
+        public Gtk.Box el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_viewbox(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            _this.viewbox = this;
+            this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.homogeneous = false;
+            var child_0 = new Xcls_Box7( _this );
+            child_0.ref();
+            this.el.pack_start (  child_0.el , false,true,0 );
+            var child_1 = new Xcls_viewcontainer( _this );
+            child_1.ref();
+            this.el.pack_end (  child_1.el , true,true,0 );
+        }
+
+        // user defined functions
+    }
+    public class Xcls_Box7 : Object
+    {
+        public Gtk.Box el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_Box7(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.homogeneous = true;
+            this.el.height_request = 20;
+            this.el.vexpand = false;
+            var child_0 = new Xcls_Button8( _this );
+            child_0.ref();
+            this.el.pack_start (  child_0.el , false,false,0 );
+            var child_1 = new Xcls_AutoRedraw( _this );
+            child_1.ref();
+            this.el.pack_start (  child_1.el , false,false,0 );
+            var child_2 = new Xcls_Button10( _this );
+            child_2.ref();
+            this.el.pack_start (  child_2.el , false,false,0 );
+        }
+
+        // user defined functions
+    }
+    public class Xcls_Button8 : Object
+    {
+        public Gtk.Button el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_Button8(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.Button();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.label = "Redraw";
+
+            //listeners
+            this.el.clicked.connect( ( ) => {
+                _this.view.renderJS(  true);
+            });
+        }
+
+        // user defined functions
+    }
+
+    public class Xcls_AutoRedraw : Object
+    {
+        public Gtk.CheckButton el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_AutoRedraw(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            _this.AutoRedraw = this;
+            this.el = new Gtk.CheckButton();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.active = true;
+            this.el.label = "Auto Redraw On";
+
+            //listeners
+            this.el.toggled.connect( (state) => {
+                this.el.set_label(this.el.active  ? "Auto Redraw On" : "Auto Redraw Off");
+            });
+        }
+
+        // user defined functions
+    }
+
+    public class Xcls_Button10 : Object
+    {
+        public Gtk.Button el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_Button10(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.Button();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.label = "Full Redraw";
+
+            //listeners
+            this.el.clicked.connect( () => {
+              _this.view.redraws = 99;
+                _this.view.el.web_context.clear_cache();  
+              //_this.view.renderJS(true);
+              FakeServerCache.clear();
+              _this.view.reInit();
+            
+            });
+        }
+
+        // user defined functions
+    }
+
+
+    public class Xcls_viewcontainer : Object
+    {
+        public Gtk.ScrolledWindow el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_viewcontainer(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            _this.viewcontainer = this;
+            this.el = new Gtk.ScrolledWindow( null, null );
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.shadow_type = Gtk.ShadowType.IN;
+            var child_0 = new Xcls_view( _this );
+            child_0.ref();
+            this.el.add (  child_0.el  );
+
+            // init method
+
+            this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
+        }
+
+        // user defined functions
+    }
+    public class Xcls_view : Object
+    {
+        public WebKit.WebView el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+        public string renderedData;
+        public bool refreshRequired;
+        public WebKit.WebInspector inspector;
+        public string runjs;
+        public int redraws;
+        public GLib.DateTime lastRedraw;
+        public string runhtml;
+        public bool pendingRedraw;
+
+        // ctor
+        public Xcls_view(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            _this.view = this;
+            this.el = new WebKit.WebView();
+
+            // my vars (dec)
+            this.renderedData = "";
+            this.refreshRequired = false;
+            this.runjs = "";
+            this.redraws = 0;
+            this.lastRedraw = null;
+            this.runhtml = "";
+            this.pendingRedraw = false;
+
+            // set gobject values
+
+            // init method
+
+            {
+                // this may not work!?
+                var settings =  this.el.get_settings();
+                settings.enable_developer_extras = 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..
+                        "http://localhost/app.Builder/"
+                );
+                    
+                    
+               //this.el.open('file:///' + __script_path__ + '/../builder.html');
+                /*
+                Gtk.drag_dest_set
+                (
+                        this.el,              //
+                        Gtk.DestDefaults.MOTION  | Gtk.DestDefaults.HIGHLIGHT,
+                        null,            // list of targets
+                        Gdk.DragAction.COPY         // what to do with data after dropped 
+                );
+                                        
+               // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
+                Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
+                */
+                GLib.Timeout.add_seconds(1,  ()  =>{
+                     //print("run refresh?");
+                     if (this.el == null) {
+                        return false;
+                     }
+                     this.runRefresh(); 
+                     return true;
+                 });
+                
+                
+            }
+
+            //listeners
+            this.el.script_dialog.connect( (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;
+                }
+                switch(ar[1]) {
+                    case "SAVEHTML":
+                        _this.file.saveHTML(ar[2]);
+                        return true;
+                    default:
+                        return false;
+                }
+                
+            });
+            this.el.show.connect( ( ) => {
+                this.initInspector();;
+            });
+            this.el.drag_drop.connect( ( ctx, x, y,time, ud) => {
+                return false;
+                /*
+               print("TARGET: drag-drop");
+                    var is_valid_drop_site = true;
+                    
+                     
+                    Gtk.drag_get_data
+                    (
+                            w,         // will receive 'drag-data-received' signal 
+                            ctx,        /* represents the current state of the DnD 
+                            this.get('/Window').atoms["STRING"],    /* the target type we want 
+                            time            /* time stamp 
+                    );
+                                    
+                                    
+                                    /* No target offered by source => error 
+                                   
+            
+               return  is_valid_drop_site;
+               */
+            });
+            this.el.load_changed.connect( (le) => {
+                if (le != WebKit.LoadEvent.FINISHED) {
+                    return;
+                }
+                if (this.runjs.length < 1) {
+                    return;
+                }
+              //  this.el.run_javascript(this.runjs, null);
+                 FakeServerCache.remove(    this.runjs);
+                this.runjs = "";
+            });
+        }
+
+        // user defined functions
+        public void reInit () {
+           print("reInit?");
+                 // if this happens destroy the webkit..
+                 // recreate it..
+             this.el.stop_loading();
+                 
+             if (_this.viewbox.el.get_parent() == null) {
+                return;
+             }
+                 
+                 
+            _this.viewbox.el.remove(_this.viewcontainer.el);
+            _this.el.remove(_this.inspectorcontainer.el);        
+                 
+                 // destory seems to cause problems.
+                 //this.el.destroy();
+                //_this.viewcontainer.el.destroy();
+                 //_this.inspectorcontainer.el.destroy();
+             var  inv =new Xcls_inspectorcontainer(_this);
+              inv.ref();
+              _this.el.pack2(inv.el,true,true);
+              
+              
+             this.el = null;         
+             var nv =new Xcls_viewcontainer(_this);
+             nv.ref();
+             _this.viewbox.el.pack_end(nv.el,true,true,0);
+                 
+                 
+             inv.el.show_all();
+             nv.el.show_all();
+                 //while(Gtk.events_pending ()) Gtk.main_iteration ();
+                 //_this.view.renderJS(true); 
+             _this.view.refreshRequired  = true;
+        }
+        public void runRefresh () 
+        {
+            // this is run every 2 seconds from the init..
+        
+          
+            
+            if (!this.refreshRequired) {
+               // print("no refresh required");
+                return;
+            }
+        
+            if (this.lastRedraw != null) {
+               // do not redraw if last redraw was less that 5 seconds ago.
+               if ((int64)(new DateTime.now_local()).difference(this.lastRedraw) < 5000 ) {
+                    return;
+                }
+            }
+            
+            if (_this.file == null) {
+                return;
+            }
+            
+            
+             this.refreshRequired = false;
+           //  print("HTML RENDERING");
+             
+             
+             //this.get('/BottomPane').el.show();
+             //this.get('/BottomPane').el.set_current_page(2);// webkit inspector
+            _this.file.webkit_page_id  = this.el.get_page_id();
+            
+            var js = _this.file.toSourcePreview();
+        
+            if (js.length < 1) {
+                print("no data");
+                return;
+            }
+        //    var  data = js[0];
+            this.redraws++;
+          
+            var project = _this.file.project;  
+        
+             //print (project.fn);
+             // set it to non-empty.
+             
+        //     runhtml = runhtml.length ?  runhtml : '<script type="text/javascript"></script>'; 
+        
+        
+        //   this.runhtml  = this.runhtml || '';
+         
+         
+            // then we need to reload the browser using
+            // load_html_string..
+        
+            // then trigger a redraw once it's loaded..
+            this.pendingRedraw = true;
+        
+            var runhtml = "<script type=\"text/javascript\">\n" ;
+            string builderhtml;
+            
+            try {
+                GLib.FileUtils.get_contents(BuilderApplication.configDirectory() + "/resources/roo.builder.js", out builderhtml);
+            } catch (Error e) {
+                builderhtml = "";
+            }
+        
+            runhtml += builderhtml + "\n";
+            runhtml += "</script>\n" ;
+        
+            // fix to make sure they are the same..
+            this.runhtml = project.runhtml;
+            // need to modify paths
+        
+            string inhtml;
+            var base_template = _this.file.project.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 = "";
+            
+            }
+            try {
+                GLib.FileUtils.get_contents(
+                    BuilderApplication.configDirectory() + "/resources/" + 
+                        (base_template.length > 0 ? base_template :  "roo.builder.html")
+                        , out inhtml);
+            
+            } catch (Error e) {
+                inhtml = "";
+            }    
+            this.renderedData = js;
+        
+        
+            string js_src = js + "\n" +
+               "Roo.onReady(function() {\n" +
+               "if (" + _this.file.name +".show) " +  _this.file.name +".show({});\n" +
+               "Roo.XComponent.build();\n" +
+               "});\n";
+               
+           // print("render js: " + js);
+            //if (!this.ready) {
+          //      console.log('not loaded yet');
+            //}
+            this.lastRedraw = new DateTime.now_local();
+        
+        
+            //this.runjs = js_src;
+            var fc =    FakeServerCache.factory_with_data(js_src);
+            this.runjs = fc.fname;
+            
+                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 = _this.file.project.rootURL;
+           
+                
+                
+                this.el.load_html( html , 
+                    //fixme - should be a config option!
+                    (rootURL.length > 0 ? rootURL : "xhttp://localhost/app.Builder.js/")
+                );
+                
+            // force the inspector...        
+               //   this.initInspector();
+                
+                // - no need for this, the builder javascript will call it when build is complete
+                //GLib.Timeout.add_seconds(1, () => {
+                //    this.el.run_javascript("Builder.saveHTML()",null);
+                //    return false;
+                //});
+        //     print( "before render" +    this.lastRedraw);
+        //    print( "after render" +    (new Date()));
+            
+        }
+        public void initInspector () {
+            
+           /* if (this.inspector == this.el.get_inspector()) {
+                this.inspector.show();
+                this.inspector.open_window();        
+                print("init inspecter called, and inspector is the same as existing\n");
+                return;
+            }
+            print("new inspector?\n");
+        */
+            this.inspector = this.el.get_inspector();
+            this.inspector.ref();
+            
+            // got a new inspector...
+                
+            this.inspector.open_window.connect(() => {
+                 this.inspector = this.el.get_inspector();
+                print("inspector attach\n");
+                var wv = this.inspector.get_web_view();
+                if (wv != null) {
+                    print("got inspector web view\n");
+                    
+                    var cn = _this.inspectorcontainer.el.get_child();
+                    if (cn != null) {
+                         _this.inspectorcontainer.el.remove(cn);
+                     }
+                    
+                    _this.inspectorcontainer.el.add(wv);
+                    wv.show();
+                } else {
+                    //this.inspector.close();
+                    
+                    //this.inspector = null;
+                   
+         
+                }
+                return true;
+               
+            });
+            /*
+            this.inspector.closed.connect(() => {
+                 print("inspector closed?!?");
+                 // if this happens destroy the webkit..
+                 // recreate it..
+                 this.el.stop_loading();
+                 
+                 if (_this.viewbox.el.get_parent() == null) {
+                    return;
+                 }
+                 
+                 
+                _this.viewbox.el.remove(_this.viewcontainer.el);
+                _this.el.remove(_this.inspectorcontainer.el);        
+                 
+                 // destory seems to cause problems.
+                 //this.el.destroy();
+                //_this.viewcontainer.el.destroy();
+                 //_this.inspectorcontainer.el.destroy();
+        
+                 this.el = null;         
+                 var nv =new Xcls_viewcontainer(_this);
+                 nv.ref();
+                 _this.viewbox.el.pack_end(nv.el,true,true,0);
+                 
+                  var  inv =new Xcls_inspectorcontainer(_this);
+                  inv.ref();
+                  _this.el.pack2(inv.el,true,true);
+                 
+                 inv.el.show_all();
+                 nv.el.show_all();
+                 //while(Gtk.events_pending ()) Gtk.main_iteration ();
+                 //_this.view.renderJS(true); 
+                 _this.view.refreshRequired  = true;
+               
+            }); 
+            */
+            
+            this.inspector.show();
+        }
+        public void renderJS (bool force) {
+        
+            // this is the public redraw call..
+            // we refresh in a loop privately..
+            var autodraw = _this.AutoRedraw.el.active;
+            if (!autodraw && !force) {
+                print("Skipping redraw - no force, and autodraw off");
+                return;
+            }
+             
+            this.refreshRequired  = true;
+        }
+    }
+
+
+
+    public class Xcls_inspectorcontainer : Object
+    {
+        public Gtk.ScrolledWindow el;
+        private Xcls_GtkView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_inspectorcontainer(Xcls_GtkView _owner )
+        {
+            _this = _owner;
+            _this.inspectorcontainer = this;
+            this.el = new Gtk.ScrolledWindow( null, null );
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.shadow_type = Gtk.ShadowType.IN;
+
+            // init method
+
+            this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
+        }
+
+        // user defined functions
+    }
+
+
+    public class Xcls_ScrolledWindow14 : Object
     {
         public Gtk.ScrolledWindow el;
         private Xcls_GtkView  _this;
@@ -303,7 +1011,7 @@ public class Xcls_GtkView : Object
             // my vars (def)
 
         // ctor
-        public Xcls_ScrolledWindow5(Xcls_GtkView _owner )
+        public Xcls_ScrolledWindow14(Xcls_GtkView _owner )
         {
             _this = _owner;
             this.el = new Gtk.ScrolledWindow( null, null );
@@ -368,7 +1076,7 @@ public class Xcls_GtkView : Object
 
 
 
-    public class Xcls_ScrolledWindow8 : Object
+    public class Xcls_ScrolledWindow17 : Object
     {
         public Gtk.ScrolledWindow el;
         private Xcls_GtkView  _this;
@@ -377,7 +1085,7 @@ public class Xcls_GtkView : Object
             // my vars (def)
 
         // ctor
-        public Xcls_ScrolledWindow8(Xcls_GtkView _owner )
+        public Xcls_ScrolledWindow17(Xcls_GtkView _owner )
         {
             _this = _owner;
             this.el = new Gtk.ScrolledWindow( null, null );