Sample/Window.bjs
authorAlan Knowles <alan@akbkhome.com>
Fri, 11 Jun 2010 02:07:49 +0000 (10:07 +0800)
committerAlan Knowles <alan@akbkhome.com>
Fri, 11 Jun 2010 02:07:49 +0000 (10:07 +0800)
Sample/Window.bjs

index c3a1ed6..492d8e2 100644 (file)
                                                                                             "id": "view",
                                                                                             "pack": "add",
                                                                                             "xtype": "WebView",
-                                                                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    // this may not work!?\n    this.el.get_settings().enable_developer_extras = true;\n    var _this = _this;\n    var insp = this.el.get_inspector();\n    insp.signal.inspect_web_view.connect(function(wi, pg) {\n        return _this.get('/BottomPane.inspector').el;\n    //create_inspector_cb\n    });\n    \n    insp.signal.show_window.connect(function(wi, pg) {\n     //inspector_show_window_cb\n    });\n    \n    this.el.open('file:///' + __script_path__ + '/../builder.html');\n                          \n    Gtk.drag_dest_set\n    (\n            this.el,              /* widget that will accept a drop */\n            Gtk.DestDefaults.MOTION  | Gtk.DestDefaults.HIGHLIGHT,\n            null,            /* lists of target to support */\n            0,              /* size of list */\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",
+                                                                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    // this may not work!?\n    this.el.get_settings().enable_developer_extras = true;\n    var _this = this;\n    var insp = this.el.get_inspector();\n    insp.signal.inspect_web_view.connect(function(wi, pg) {\n        return _this.get('/BottomPane.inspector').el;\n    //create_inspector_cb\n    });\n    \n    insp.signal.show_window.connect(function(wi, pg) {\n     //inspector_show_window_cb\n    });\n    \n    this.el.open('file:///' + __script_path__ + '/../builder.html');\n                          \n    Gtk.drag_dest_set\n    (\n            this.el,              /* widget that will accept a drop */\n            Gtk.DestDefaults.MOTION  | Gtk.DestDefaults.HIGHLIGHT,\n            null,            /* lists of target to support */\n            0,              /* size of list */\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",
                                                                                             "|renderJS": "function(data) {\n    print(\"HTML RENDERING\");\n    /// prevent looping..\n    //if (this.pendingRedraw) {\n    //   print(\"pending redraw active?!\");\n     //   return;\n    //}\n    \n    \n    if (!this.get('/Window.LeftTree').getActiveFile()) {\n        return;\n    }\n    \n    var project = this.get('/Window.LeftTree').getActiveFile().project;\n    //print (project.fn);\n    \n    project.runhtml  = project.runhtml || '';\n    \n\n    this.runhtml  = this.runhtml || '';\n    \n    if (project.runhtml != this.runhtml) {\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        this.runhtml = project.runhtml;\n        \n        var html = imports.File.File.read(__script_path__ + '/../builder.html');\n        html = html.replace('</head>', this.runhtml + '</head>');\n        print(\"LOAD HTML \" + html);\n        this.el.load_html_string( html , 'file:///' + __script_path__ + '/../builder.html');\n        // should trigger load_finished!\n        return;\n    \n    }\n    \n    this.pendingRedraw = false;    \n     \n    \n    this.renderedData = data;\n    var str = JSON.stringify(data) ;\n    \n    if (!this.ready) {\n        console.log('not loaded yet');\n    }\n    //Seed.print(\"RENDER:\" + str);\n    //imports.File.File.write('/tmp/builder.debug.js', \"Builder.render(\" + JSON.stringify(data) + \");\");\n \n    this.el.execute_script(\"Builder.render(\" + JSON.stringify(data) + \");\");\n}\n",
                                                                                             "|xns": "WebKit"
                                                                                         }