"build_module" : "builder",
"items" : [
{
- "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",
- "| 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}",
+ "listeners" : {
+ "size_allocate" : "(aloc) => {\n\n this.width = aloc.width;\n this.height =aloc.height;\n}\n "
+ },
+ "| void scroll_to_line" : "(int line) {\n this.notebook.el.page = 1;// code preview...\n \n GLib.Timeout.add(500, () => {\n \n \n\t \n\t \n\t\t var buf = this.sourceview.el.get_buffer();\n\t \n\t\tvar sbuf = (Gtk.SourceBuffer) buf;\n\n\n\t\tGtk.TextIter iter; \n\t\tsbuf.get_iter_at_line(out iter, line);\n\t\tthis.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);\n\t\treturn false;\n\t}); \n\n \n}\n",
+ "id" : "GtkView",
+ "# Gtk.Widget lastObj" : "null",
+ "| void createThumb" : "() {\n \n \n if (this.file == null) {\n return;\n }\n // only screenshot the gtk preview..\n if (this.notebook.el.page > 0 ) {\n return;\n }\n \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, height); // this.el.position?\n screenshot.save(filename,\"png\");\n } catch (Error e) {\n \n }\n\n \n return;\n \n \n \n \n \n // should we hold until it's printed...\n \n \n\n \n \n\n\n \n \n}\n",
+ "| void loadFile" : "(JsRender.JsRender file) \n{\n this.file = null;\n \n if (file.tree == null) {\n return;\n }\n this.notebook.el.page = 0;// gtk preview \n \n \n \n this.file = file; \n this.sourceview.loadFile();\n this.searchcontext = null;\n \n\n if (this.lastObj != null) {\n this.container.el.remove(this.lastObj);\n }\n \n // hide the compile view at present..\n \n \n var w = this.width;\n var h = this.height;\n \n print(\"ALLOC SET SIZES %d, %d\\n\", w,h); \n \n // set the container size min to 500/500 or 20 px less than max..\n w = int.max (w-20, 500);\n h = int.max (h-20, 500); \n \n print(\"SET SIZES %d, %d\\n\", w,h); \n _this.container.el.set_size_request(w,h);\n \n _this.view_layout.el.set_size(w,h); // should be baded on calc.. -- see update_scrolled.\n var rgba = Gdk.RGBA ();\n rgba.parse (\"#ccc\");\n _this.view_layout.el.override_background_color(Gtk.StateFlags.NORMAL, rgba);\n \n \n\tvar x = new JsRender.NodeToGtk(file.tree);\n var obj = x.munge() as Gtk.Widget;\n this.lastObj = null;\n\tif (obj == null) {\n \treturn;\n\t}\n\tthis.lastObj = obj;\n \n this.container.el.add(obj);\n obj.show_all();\n \n \n \n}\n ",
+ "int width" : 0,
+ "bool hexpand" : true,
+ "| int search" : "(string txt) {\n\tthis.notebook.el.page = 1;\n \tvar s = new Gtk.SourceSearchSettings();\n\tvar buf = (Gtk.SourceBuffer) this.sourceview.el.get_buffer();\n\tthis.searchcontext = new Gtk.SourceSearchContext(buf,s);\n\tthis.searchcontext.set_highlight(true);\n\ts.set_search_text(txt);\n\t\n\tGtk.TextIter beg, st,en;\n\t \n\tbuf.get_start_iter(out beg);\n\tthis.searchcontext.forward(beg, out st, out en);\n\tthis.last_search_end = 0;\n\treturn this.searchcontext.get_occurrences_count();\n\n \n}\n",
+ "int last_search_end" : 0,
+ "xtype" : "Box",
+ "Gtk.SourceSearchContext searchcontext" : "",
+ "# JsRender.JsRender file" : "null",
+ "int height" : 0,
"$ xns" : "Gtk",
"Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
+ "# Xcls_MainWindow main_window" : "",
+ "| void forwardSearch" : "() {\n\n\tif (this.searchcontext == null) {\n\t\treturn;\n\t}\n\tthis.notebook.el.page = 1;\n\tGtk.TextIter beg, st,en, stl;\n\t\n\tvar buf = this.sourceview.el.get_buffer();\n\tbuf.get_iter_at_offset(out beg, this.last_search_end);\n\tif (!this.searchcontext.forward(beg, out st, out en)) {\n\t\tthis.last_search_end = 0;\n\t} else { \n\t\tthis.last_search_end = en.get_offset();\n\t\n\t\tthis.sourceview.el.grab_focus();\n\t \n\t\tbuf.place_cursor(st);\n\t\tvar ln = st.get_line();\n\t\tbuf.get_iter_at_line(out stl,ln);\n\t\t \n\t\tthis.sourceview.el.scroll_to_iter(stl, 0.0f, true, 0.0f, 0.5f);\n\t}\n\n}\n",
"items" : [
{
- "id" : "viewbox",
- "* pack" : "pack1,true,true",
- "xtype" : "Box",
+ "id" : "notebook",
+ "* pack" : "pack_start,true,true,0",
+ "xtype" : "Notebook",
"$ xns" : "Gtk",
- "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
- "$ homogeneous" : false,
"items" : [
{
- "$ vexpand" : false,
- "$ height_request" : 20,
- "* pack" : "pack_start,false,true,0",
- "xtype" : "Box",
+ "id" : "label_preview",
+ "* pack" : false,
+ "xtype" : "Label",
"$ xns" : "Gtk",
- "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
- "$ homogeneous" : true,
+ "utf8 label" : "Preview"
+ },
+ {
+ "id" : "label_code",
+ "xtype" : "Label",
+ "* pack" : false,
+ "$ 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",
+ "| 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" : [
{
- "listeners" : {
- "clicked" : "( ) => {\n _this.view.renderJS( true);\n}"
- },
- "label" : "Redraw",
- "xtype" : "Button",
- "* pack" : "pack_start,false,false,0",
- "$ xns" : "Gtk"
+ "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"
+ }
+ ]
+ }
+ ]
},
{
- "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",
+ "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",
+ "$ xns" : "Gtk",
+ "items" : [
{
- "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" : "view_layout",
+ "xtype" : "Layout",
+ "* pack" : "add",
+ "$ xns" : "Gtk",
+ "items" : [
+ {
+ "id" : "container",
+ "* pack" : "put,10,10",
+ "xtype" : "Box",
+ "$ xns" : "Gtk",
+ "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL"
+ }
+ ]
}
]
},
{
- "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",
+ "* pack" : "append_page,_this.label_code.el",
"$ 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",
+ "gboolean show_line_marks" : true,
+ "id" : "sourceview",
+ "* init" : "{\n \n var description = Pango.FontDescription.from_string(\"monospace\");\n description.set_size(8000);\n this.el.override_font(description);\n\n this.loading = true;\n var buf = this.el.get_buffer();\n buf.notify.connect((ps) => {\n if (this.loading) {\n return;\n }\n if (ps.name != \"cursor-position\") {\n return;\n }\n print(\"cursor changed : %d\\n\", buf.cursor_position);\n Gtk.TextIter cpos;\n buf.get_iter_at_offset(out cpos, buf.cursor_position);\n \n var ln = cpos.get_line();\n \n var node = _this.file.lineToNode(ln);\n \n if (node == null) {\n print(\"can not find node\\n\");\n return;\n }\n var ltree = _this.main_window.windowstate.left_tree;\n var tp = ltree.model.treePathFromNode(node);\n print(\"got tree path %s\\n\", tp);\n if (tp != \"\") {\n\t this.allow_node_scroll = false; \n\t print(\"changing cursor on tree..\\n\");\n ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false);\n // scrolling is disabled... as node selection calls scroll 10ms after it changes.\n GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {\n\t this.allow_node_scroll = true;\n\t return false;\n });\n }\n \n // highlight the node..\n \n });\n \n \n \n var attrs = new Gtk.SourceMarkAttributes();\n var pink = Gdk.RGBA();\n pink.parse ( \"pink\");\n attrs.set_background ( pink);\n attrs.set_icon_name ( \"process-stop\"); \n attrs.query_tooltip_text.connect(( mark) => {\n //print(\"tooltip query? %s\\n\", mark.name);\n return mark.name;\n });\n \n this.el.set_mark_attributes (\"ERR\", attrs, 1);\n \n var wattrs = new Gtk.SourceMarkAttributes();\n var blue = Gdk.RGBA();\n blue.parse ( \"#ABF4EB\");\n wattrs.set_background ( blue);\n wattrs.set_icon_name ( \"process-stop\"); \n wattrs.query_tooltip_text.connect(( mark) => {\n //print(\"tooltip query? %s\\n\", mark.name);\n return mark.name;\n });\n \n this.el.set_mark_attributes (\"WARN\", wattrs, 1);\n \n \n \n var dattrs = new Gtk.SourceMarkAttributes();\n var purple = Gdk.RGBA();\n purple.parse ( \"#EEA9FF\");\n dattrs.set_background ( purple);\n dattrs.set_icon_name ( \"process-stop\"); \n dattrs.query_tooltip_text.connect(( mark) => {\n //print(\"tooltip query? %s\\n\", mark.name);\n return mark.name;\n });\n \n this.el.set_mark_attributes (\"DEPR\", dattrs, 1);\n \n \n var gattrs = new Gtk.SourceMarkAttributes();\n var grey = Gdk.RGBA();\n grey.parse ( \"#ccc\");\n gattrs.set_background ( grey);\n \n \n this.el.set_mark_attributes (\"grey\", gattrs, 1);\n \n \n \n \n \n \n}\n ",
+ "| void nodeSelected" : "(JsRender.Node? sel) {\n \n \n \n // this is connected in widnowstate\n print(\"node selected\\n\");\n var buf = this.el.get_buffer();\n \n var sbuf = (Gtk.SourceBuffer) buf;\n\n \n while(Gtk.events_pending()) {\n Gtk.main_iteration();\n }\n \n \n // clear all the marks..\n Gtk.TextIter start;\n Gtk.TextIter end; \n \n sbuf.get_bounds (out start, out end);\n sbuf.remove_source_marks (start, end, \"grey\");\n \n \n if (sel == null) {\n // no highlighting..\n return;\n }\n Gtk.TextIter iter; \n sbuf.get_iter_at_line(out iter, sel.line_start);\n \n \n Gtk.TextIter cur_iter;\n sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);\n \n //var cur_line = cur_iter.get_line();\n //if (cur_line > sel.line_start && cur_line < sel.line_end) {\n \n //} else {\n if (this.allow_node_scroll) {\n\t\t \n \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);\n\t}\n \n \n \n for (var i = 0; i < buf.get_line_count();i++) {\n if (i < sel.line_start || i > sel.line_end) {\n \n sbuf.get_iter_at_line(out iter, i);\n sbuf.create_source_mark(null, \"grey\", iter);\n \n }\n \n }\n \n\n}\n",
+ "bool loading" : true,
+ "| string toString" : "() {\n Gtk.TextIter s;\n Gtk.TextIter e;\n this.el.get_buffer().get_start_iter(out s);\n this.el.get_buffer().get_end_iter(out e);\n var ret = this.el.get_buffer().get_text(s,e,true);\n //print(\"TO STRING? \" + ret);\n return ret;\n}\n",
+ "| void loadFile" : "( ) {\n this.loading = true;\n var buf = this.el.get_buffer();\n buf.set_text(\"\",0);\n var sbuf = (Gtk.SourceBuffer) buf;\n\n \n\n if (_this.file == null || _this.file.xtype != \"Gtk\") {\n print(\"xtype != Gtk\");\n this.loading = false;\n return;\n }\n \n var valafn = \"\";\n try { \n var regex = new Regex(\"\\\\.bjs$\");\n \n \n valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");\n } catch (GLib.RegexError e) {\n this.loading = false;\n return;\n } \n \n\n if (!FileUtils.test(valafn,FileTest.IS_REGULAR) ) {\n print(\"File path has no errors\\n\");\n this.loading = false;\n return ;\n }\n \n string str;\n try {\n \n GLib.FileUtils.get_contents (valafn, out str);\n } catch (Error e) {\n this.loading = false;\n return ;\n }\n\n// print(\"setting str %d\\n\", str.length);\n buf.set_text(str, str.length);\n var lm = Gtk.SourceLanguageManager.get_default();\n \n //?? is javascript going to work as js?\n \n ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language));\n \n \n Gtk.TextIter start;\n Gtk.TextIter end; \n \n sbuf.get_bounds (out start, out end);\n sbuf.remove_source_marks (start, end, null); // remove all marks..\n \n \n if (_this.main_window.windowstate.last_compile_result != null) {\n var obj = _this.main_window.windowstate.last_compile_result;\n this.highlightErrorsJson(\"ERR\", obj);\n this.highlightErrorsJson(\"WARN\", obj);\n this.highlightErrorsJson(\"DEPR\", obj);\t\t\t\n }\n //while (Gtk.events_pending()) {\n // Gtk.main_iteration();\n // }\n \n this.loading = false; \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"
+ "xtype" : "SourceView",
+ "bool allow_node_scroll" : true,
+ "| void highlightErrorsJson" : " (string type, Json.Object obj) {\n Gtk.TextIter start;\n Gtk.TextIter end; \n \n var buf = this.el.get_buffer();\n var sbuf = (Gtk.SourceBuffer)buf;\n buf.get_bounds (out start, out end);\n \n sbuf.remove_source_marks (start, end, type);\n \n \n // we should highlight other types of errors..\n \n if (!obj.has_member(type)) {\n print(\"Return has no errors\\n\");\n return ;\n }\n var err = obj.get_object_member(type);\n \n if (_this.file == null) { \n return; // just in case the file has not loaded yet?\n }\n \n\n var valafn = \"\";\n try { \n var regex = new Regex(\"\\\\.bjs$\");\n \n \n valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");\n } catch (GLib.RegexError e) {\n return;\n } \n\n if (!err.has_member(valafn)) {\n print(\"File path has no errors\\n\");\n return ;\n }\n var lines = err.get_object_member(valafn);\n \n \n \n var tlines = buf.get_line_count () +1;\n \n lines.foreach_member((obj, line, node) => {\n \n Gtk.TextIter iter;\n // print(\"get inter\\n\");\n var eline = int.parse(line) -1 ;\n print(\"GOT ERROR on line %s -- converted to %d\\n\", line,eline);\n \n \n if (eline > tlines || eline < 0) {\n return;\n }\n sbuf.get_iter_at_line( out iter, eline);\n //print(\"mark line\\n\");\n var msg = type + \" on line: %d - %s\".printf(eline+1, valafn);\n var ar = lines.get_array_member(line);\n for (var i = 0 ; i < ar.get_length(); i++) {\n\t\t msg += (msg.length > 0) ? \"\\n\" : \"\";\n\t\t msg += ar.get_string_element(i);\n\t }\n \n \n sbuf.create_source_mark(msg, type, iter);\n } );\n return ;\n \n \n\n\n}",
+ "$ xns" : "Gtk",
+ "gboolean show_line_numbers" : true,
+ "gboolean editable" : false
}
]
}
]
- },
- {
- "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"
}
]
}
-static Xcls_WindowRooView _WindowRooView;
+static Xcls_GtkView _GtkView;
-public class Xcls_WindowRooView : Object
+public class Xcls_GtkView : Object
{
- public Gtk.Paned el;
- private Xcls_WindowRooView _this;
+ public Gtk.Box el;
+ private Xcls_GtkView _this;
- public static Xcls_WindowRooView singleton()
+ public static Xcls_GtkView singleton()
{
- if (_WindowRooView == null) {
- _WindowRooView= new Xcls_WindowRooView();
+ if (_GtkView == null) {
+ _GtkView= new Xcls_GtkView();
}
- return _WindowRooView;
+ return _GtkView;
}
+ 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;
// my vars (def)
+ public Gtk.Widget lastObj;
+ public int width;
+ public int last_search_end;
+ public Gtk.SourceSearchContext searchcontext;
public JsRender.JsRender file;
+ public int height;
+ public Xcls_MainWindow main_window;
// ctor
- public Xcls_WindowRooView()
+ public Xcls_GtkView()
{
_this = this;
- this.el = new Gtk.Paned( Gtk.Orientation.VERTICAL );
+ this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
// my vars (dec)
+ this.lastObj = null;
+ this.width = 0;
+ this.last_search_end = 0;
+ this.file = null;
+ this.height = 0;
// set gobject values
- var child_0 = new Xcls_viewbox( _this );
+ this.el.hexpand = true;
+ var child_0 = new Xcls_notebook( _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 );
+ this.el.pack_start ( child_0.el , true,true,0 );
+
+ //listeners
+ this.el.size_allocate.connect( (aloc) => {
+
+ this.width = aloc.width;
+ this.height =aloc.height;
+ });
}
// user defined functions
+ public void scroll_to_line (int line) {
+ this.notebook.el.page = 1;// code preview...
+
+ GLib.Timeout.add(500, () => {
+
+
+
+
+ var buf = this.sourceview.el.get_buffer();
+
+ var sbuf = (Gtk.SourceBuffer) buf;
+
+
+ Gtk.TextIter iter;
+ sbuf.get_iter_at_line(out iter, line);
+ this.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);
+ return false;
+ });
+
+
+ }
public void createThumb () {
if (this.file == null) {
return;
}
+ // only screenshot the gtk preview..
+ if (this.notebook.el.page > 0 ) {
+ 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
+ var height = win.get_height();
+ try {
+ Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position?
+ screenshot.save(filename,"png");
+ } catch (Error e) {
+
}
+
+ return;
+
+
+ // should we hold until it's printed...
+
+
+
+
+
+
+
+
}
- public void loadFile (JsRender.JsRender file)
+ public void loadFile (JsRender.JsRender file)
{
- this.file = file;
- this.view.renderJS(true);
+ this.file = null;
+
+ if (file.tree == null) {
+ return;
+ }
+ this.notebook.el.page = 0;// gtk preview
+
+
+
+ this.file = file;
+ this.sourceview.loadFile();
+ this.searchcontext = null;
+
+
+ if (this.lastObj != null) {
+ this.container.el.remove(this.lastObj);
+ }
+
+ // hide the compile view at present..
+
+
+ var w = this.width;
+ var h = this.height;
+
+ print("ALLOC SET SIZES %d, %d\n", w,h);
+
+ // set the container size min to 500/500 or 20 px less than max..
+ w = int.max (w-20, 500);
+ h = int.max (h-20, 500);
+
+ print("SET SIZES %d, %d\n", w,h);
+ _this.container.el.set_size_request(w,h);
+
+ _this.view_layout.el.set_size(w,h); // should be baded on calc.. -- see update_scrolled.
+ var rgba = Gdk.RGBA ();
+ rgba.parse ("#ccc");
+ _this.view_layout.el.override_background_color(Gtk.StateFlags.NORMAL, rgba);
+
+
+ var x = new JsRender.NodeToGtk(file.tree);
+ var obj = x.munge() as Gtk.Widget;
+ this.lastObj = null;
+ if (obj == null) {
+ return;
+ }
+ this.lastObj = obj;
+
+ this.container.el.add(obj);
+ obj.show_all();
+
+
+
+ }
+ public int search (string txt) {
+ this.notebook.el.page = 1;
+ var s = new Gtk.SourceSearchSettings();
+ var buf = (Gtk.SourceBuffer) this.sourceview.el.get_buffer();
+ this.searchcontext = new Gtk.SourceSearchContext(buf,s);
+ this.searchcontext.set_highlight(true);
+ s.set_search_text(txt);
+
+ Gtk.TextIter beg, st,en;
+
+ buf.get_start_iter(out beg);
+ this.searchcontext.forward(beg, out st, out en);
+ this.last_search_end = 0;
+ return this.searchcontext.get_occurrences_count();
+
+
+ }
+ public void forwardSearch () {
+
+ if (this.searchcontext == null) {
+ return;
+ }
+ this.notebook.el.page = 1;
+ Gtk.TextIter beg, st,en, stl;
+
+ var buf = this.sourceview.el.get_buffer();
+ buf.get_iter_at_offset(out beg, this.last_search_end);
+ if (!this.searchcontext.forward(beg, out st, out en)) {
+ this.last_search_end = 0;
+ } else {
+ this.last_search_end = en.get_offset();
+
+ this.sourceview.el.grab_focus();
+
+ buf.place_cursor(st);
+ var ln = st.get_line();
+ buf.get_iter_at_line(out stl,ln);
+
+ this.sourceview.el.scroll_to_iter(stl, 0.0f, true, 0.0f, 0.5f);
+ }
+
+ }
+ public class Xcls_notebook : Object
+ {
+ public Gtk.Notebook el;
+ private Xcls_GtkView _this;
+
+
+ // my vars (def)
+
+ // ctor
+ public Xcls_notebook(Xcls_GtkView _owner )
+ {
+ _this = _owner;
+ _this.notebook = this;
+ this.el = new Gtk.Notebook();
+
+ // my vars (dec)
+
+ // set gobject values
+ var child_0 = new Xcls_label_preview( _this );
+ child_0.ref();
+ var child_1 = new Xcls_label_code( _this );
+ child_1.ref();
+ var child_2 = new Xcls_WindowRooView( _this );
+ child_2.ref();
+ 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_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
+ }
+ public class Xcls_label_preview : Object
+ {
+ public Gtk.Label el;
+ private Xcls_GtkView _this;
+
+
+ // my vars (def)
+
+ // ctor
+ public Xcls_label_preview(Xcls_GtkView _owner )
+ {
+ _this = _owner;
+ _this.label_preview = this;
+ this.el = new Gtk.Label( "Preview" );
+
+ // my vars (dec)
+
+ // set gobject values
+ }
+
+ // user defined functions
+ }
+
+ public class Xcls_label_code : Object
+ {
+ public Gtk.Label el;
+ private Xcls_GtkView _this;
+
+
+ // my vars (def)
+
+ // ctor
+ public Xcls_label_code(Xcls_GtkView _owner )
+ {
+ _this = _owner;
+ _this.label_code = this;
+ this.el = new Gtk.Label( "Preview Generated Code" );
+
+ // my vars (dec)
+
+ // set gobject values
+ }
+
+ // user defined functions
}
- public void requestRedraw () {
- this.view.renderJS(false);
+
+ 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_WindowRooView _this;
+ private Xcls_GtkView _this;
// my vars (def)
// ctor
- public Xcls_viewbox(Xcls_WindowRooView _owner )
+ public Xcls_viewbox(Xcls_GtkView _owner )
{
_this = _owner;
_this.viewbox = this;
// set gobject values
this.el.homogeneous = false;
- var child_0 = new Xcls_Box3( _this );
+ 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 );
// user defined functions
}
- public class Xcls_Box3 : Object
+ public class Xcls_Box7 : Object
{
public Gtk.Box el;
- private Xcls_WindowRooView _this;
+ private Xcls_GtkView _this;
// my vars (def)
// ctor
- public Xcls_Box3(Xcls_WindowRooView _owner )
+ public Xcls_Box7(Xcls_GtkView _owner )
{
_this = _owner;
this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
this.el.homogeneous = true;
this.el.height_request = 20;
this.el.vexpand = false;
- var child_0 = new Xcls_Button4( _this );
+ 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_Button6( _this );
+ 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_Button4 : Object
+ public class Xcls_Button8 : Object
{
public Gtk.Button el;
- private Xcls_WindowRooView _this;
+ private Xcls_GtkView _this;
// my vars (def)
// ctor
- public Xcls_Button4(Xcls_WindowRooView _owner )
+ public Xcls_Button8(Xcls_GtkView _owner )
{
_this = _owner;
this.el = new Gtk.Button();
public class Xcls_AutoRedraw : Object
{
public Gtk.CheckButton el;
- private Xcls_WindowRooView _this;
+ private Xcls_GtkView _this;
// my vars (def)
// ctor
- public Xcls_AutoRedraw(Xcls_WindowRooView _owner )
+ public Xcls_AutoRedraw(Xcls_GtkView _owner )
{
_this = _owner;
_this.AutoRedraw = this;
// user defined functions
}
- public class Xcls_Button6 : Object
+ public class Xcls_Button10 : Object
{
public Gtk.Button el;
- private Xcls_WindowRooView _this;
+ private Xcls_GtkView _this;
// my vars (def)
// ctor
- public Xcls_Button6(Xcls_WindowRooView _owner )
+ public Xcls_Button10(Xcls_GtkView _owner )
{
_this = _owner;
this.el = new Gtk.Button();
public class Xcls_viewcontainer : Object
{
public Gtk.ScrolledWindow el;
- private Xcls_WindowRooView _this;
+ private Xcls_GtkView _this;
// my vars (def)
// ctor
- public Xcls_viewcontainer(Xcls_WindowRooView _owner )
+ public Xcls_viewcontainer(Xcls_GtkView _owner )
{
_this = _owner;
_this.viewcontainer = this;
public class Xcls_view : Object
{
public WebKit.WebView el;
- private Xcls_WindowRooView _this;
+ private Xcls_GtkView _this;
// my vars (def)
public bool pendingRedraw;
// ctor
- public Xcls_view(Xcls_WindowRooView _owner )
+ public Xcls_view(Xcls_GtkView _owner )
{
_this = _owner;
_this.view = this;
public class Xcls_inspectorcontainer : Object
{
public Gtk.ScrolledWindow el;
- private Xcls_WindowRooView _this;
+ private Xcls_GtkView _this;
// my vars (def)
// ctor
- public Xcls_inspectorcontainer(Xcls_WindowRooView _owner )
+ public Xcls_inspectorcontainer(Xcls_GtkView _owner )
{
_this = _owner;
_this.inspectorcontainer = this;
// user defined functions
}
+
+ public class Xcls_ScrolledWindow14 : Object
+ {
+ public Gtk.ScrolledWindow el;
+ private Xcls_GtkView _this;
+
+
+ // my vars (def)
+
+ // ctor
+ public Xcls_ScrolledWindow14(Xcls_GtkView _owner )
+ {
+ _this = _owner;
+ this.el = new Gtk.ScrolledWindow( null, null );
+
+ // my vars (dec)
+
+ // set gobject values
+ var child_0 = new Xcls_view_layout( _this );
+ child_0.ref();
+ this.el.add ( child_0.el );
+ }
+
+ // user defined functions
+ }
+ public class Xcls_view_layout : Object
+ {
+ public Gtk.Layout el;
+ private Xcls_GtkView _this;
+
+
+ // my vars (def)
+
+ // ctor
+ public Xcls_view_layout(Xcls_GtkView _owner )
+ {
+ _this = _owner;
+ _this.view_layout = this;
+ this.el = new Gtk.Layout( null, null );
+
+ // my vars (dec)
+
+ // set gobject values
+ var child_0 = new Xcls_container( _this );
+ child_0.ref();
+ this.el.put ( child_0.el , 10,10 );
+ }
+
+ // user defined functions
+ }
+ public class Xcls_container : Object
+ {
+ public Gtk.Box el;
+ private Xcls_GtkView _this;
+
+
+ // my vars (def)
+
+ // ctor
+ public Xcls_container(Xcls_GtkView _owner )
+ {
+ _this = _owner;
+ _this.container = this;
+ this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
+
+ // my vars (dec)
+
+ // set gobject values
+ }
+
+ // user defined functions
+ }
+
+
+
+ public class Xcls_ScrolledWindow17 : Object
+ {
+ public Gtk.ScrolledWindow el;
+ private Xcls_GtkView _this;
+
+
+ // my vars (def)
+
+ // ctor
+ public Xcls_ScrolledWindow17(Xcls_GtkView _owner )
+ {
+ _this = _owner;
+ this.el = new Gtk.ScrolledWindow( null, null );
+
+ // my vars (dec)
+
+ // set gobject values
+ var child_0 = new Xcls_sourceview( _this );
+ child_0.ref();
+ this.el.add ( child_0.el );
+ }
+
+ // user defined functions
+ }
+ public class Xcls_sourceview : Object
+ {
+ public Gtk.SourceView el;
+ private Xcls_GtkView _this;
+
+
+ // my vars (def)
+ public bool loading;
+ public bool allow_node_scroll;
+
+ // ctor
+ public Xcls_sourceview(Xcls_GtkView _owner )
+ {
+ _this = _owner;
+ _this.sourceview = this;
+ this.el = new Gtk.SourceView();
+
+ // my vars (dec)
+ this.loading = true;
+ this.allow_node_scroll = true;
+
+ // set gobject values
+ this.el.editable = false;
+ this.el.show_line_marks = true;
+ this.el.show_line_numbers = true;
+
+ // init method
+
+ {
+
+ var description = Pango.FontDescription.from_string("monospace");
+ description.set_size(8000);
+ this.el.override_font(description);
+
+ this.loading = true;
+ var buf = this.el.get_buffer();
+ buf.notify.connect((ps) => {
+ if (this.loading) {
+ return;
+ }
+ if (ps.name != "cursor-position") {
+ return;
+ }
+ print("cursor changed : %d\n", buf.cursor_position);
+ Gtk.TextIter cpos;
+ buf.get_iter_at_offset(out cpos, buf.cursor_position);
+
+ var ln = cpos.get_line();
+
+ var node = _this.file.lineToNode(ln);
+
+ if (node == null) {
+ print("can not find node\n");
+ return;
+ }
+ var ltree = _this.main_window.windowstate.left_tree;
+ var tp = ltree.model.treePathFromNode(node);
+ print("got tree path %s\n", tp);
+ if (tp != "") {
+ this.allow_node_scroll = false;
+ print("changing cursor on tree..\n");
+ ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false);
+ // scrolling is disabled... as node selection calls scroll 10ms after it changes.
+ GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {
+ this.allow_node_scroll = true;
+ return false;
+ });
+ }
+
+ // highlight the node..
+
+ });
+
+
+
+ var attrs = new Gtk.SourceMarkAttributes();
+ var pink = Gdk.RGBA();
+ pink.parse ( "pink");
+ attrs.set_background ( pink);
+ attrs.set_icon_name ( "process-stop");
+ attrs.query_tooltip_text.connect(( mark) => {
+ //print("tooltip query? %s\n", mark.name);
+ return mark.name;
+ });
+
+ this.el.set_mark_attributes ("ERR", attrs, 1);
+
+ var wattrs = new Gtk.SourceMarkAttributes();
+ var blue = Gdk.RGBA();
+ blue.parse ( "#ABF4EB");
+ wattrs.set_background ( blue);
+ wattrs.set_icon_name ( "process-stop");
+ wattrs.query_tooltip_text.connect(( mark) => {
+ //print("tooltip query? %s\n", mark.name);
+ return mark.name;
+ });
+
+ this.el.set_mark_attributes ("WARN", wattrs, 1);
+
+
+
+ var dattrs = new Gtk.SourceMarkAttributes();
+ var purple = Gdk.RGBA();
+ purple.parse ( "#EEA9FF");
+ dattrs.set_background ( purple);
+ dattrs.set_icon_name ( "process-stop");
+ dattrs.query_tooltip_text.connect(( mark) => {
+ //print("tooltip query? %s\n", mark.name);
+ return mark.name;
+ });
+
+ this.el.set_mark_attributes ("DEPR", dattrs, 1);
+
+
+ var gattrs = new Gtk.SourceMarkAttributes();
+ var grey = Gdk.RGBA();
+ grey.parse ( "#ccc");
+ gattrs.set_background ( grey);
+
+
+ this.el.set_mark_attributes ("grey", gattrs, 1);
+
+
+
+
+
+
+ }
+ }
+
+ // user defined functions
+ public void nodeSelected (JsRender.Node? sel) {
+
+
+
+ // this is connected in widnowstate
+ print("node selected\n");
+ var buf = this.el.get_buffer();
+
+ var sbuf = (Gtk.SourceBuffer) buf;
+
+
+ while(Gtk.events_pending()) {
+ Gtk.main_iteration();
+ }
+
+
+ // clear all the marks..
+ Gtk.TextIter start;
+ Gtk.TextIter end;
+
+ sbuf.get_bounds (out start, out end);
+ sbuf.remove_source_marks (start, end, "grey");
+
+
+ if (sel == null) {
+ // no highlighting..
+ return;
+ }
+ Gtk.TextIter iter;
+ sbuf.get_iter_at_line(out iter, sel.line_start);
+
+
+ Gtk.TextIter cur_iter;
+ sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);
+
+ //var cur_line = cur_iter.get_line();
+ //if (cur_line > sel.line_start && cur_line < sel.line_end) {
+
+ //} else {
+ if (this.allow_node_scroll) {
+
+ this.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);
+ }
+
+
+
+ for (var i = 0; i < buf.get_line_count();i++) {
+ if (i < sel.line_start || i > sel.line_end) {
+
+ sbuf.get_iter_at_line(out iter, i);
+ sbuf.create_source_mark(null, "grey", iter);
+
+ }
+
+ }
+
+
+ }
+ public string toString () {
+ Gtk.TextIter s;
+ Gtk.TextIter e;
+ this.el.get_buffer().get_start_iter(out s);
+ this.el.get_buffer().get_end_iter(out e);
+ var ret = this.el.get_buffer().get_text(s,e,true);
+ //print("TO STRING? " + ret);
+ return ret;
+ }
+ public void loadFile ( ) {
+ this.loading = true;
+ var buf = this.el.get_buffer();
+ buf.set_text("",0);
+ var sbuf = (Gtk.SourceBuffer) buf;
+
+
+
+ if (_this.file == null || _this.file.xtype != "Gtk") {
+ print("xtype != Gtk");
+ this.loading = false;
+ return;
+ }
+
+ var valafn = "";
+ try {
+ var regex = new Regex("\\.bjs$");
+
+
+ valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
+ } catch (GLib.RegexError e) {
+ this.loading = false;
+ return;
+ }
+
+
+ if (!FileUtils.test(valafn,FileTest.IS_REGULAR) ) {
+ print("File path has no errors\n");
+ this.loading = false;
+ return ;
+ }
+
+ string str;
+ try {
+
+ GLib.FileUtils.get_contents (valafn, out str);
+ } catch (Error e) {
+ this.loading = false;
+ return ;
+ }
+
+ // print("setting str %d\n", str.length);
+ buf.set_text(str, str.length);
+ var lm = Gtk.SourceLanguageManager.get_default();
+
+ //?? is javascript going to work as js?
+
+ ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language));
+
+
+ Gtk.TextIter start;
+ Gtk.TextIter end;
+
+ sbuf.get_bounds (out start, out end);
+ sbuf.remove_source_marks (start, end, null); // remove all marks..
+
+
+ if (_this.main_window.windowstate.last_compile_result != null) {
+ var obj = _this.main_window.windowstate.last_compile_result;
+ this.highlightErrorsJson("ERR", obj);
+ this.highlightErrorsJson("WARN", obj);
+ this.highlightErrorsJson("DEPR", obj);
+ }
+ //while (Gtk.events_pending()) {
+ // Gtk.main_iteration();
+ // }
+
+ this.loading = false;
+ }
+ public void highlightErrorsJson (string type, Json.Object obj) {
+ Gtk.TextIter start;
+ Gtk.TextIter end;
+
+ var buf = this.el.get_buffer();
+ var sbuf = (Gtk.SourceBuffer)buf;
+ buf.get_bounds (out start, out end);
+
+ sbuf.remove_source_marks (start, end, type);
+
+
+ // we should highlight other types of errors..
+
+ if (!obj.has_member(type)) {
+ print("Return has no errors\n");
+ return ;
+ }
+ var err = obj.get_object_member(type);
+
+ if (_this.file == null) {
+ return; // just in case the file has not loaded yet?
+ }
+
+
+ var valafn = "";
+ try {
+ var regex = new Regex("\\.bjs$");
+
+
+ valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
+ } catch (GLib.RegexError e) {
+ return;
+ }
+
+ if (!err.has_member(valafn)) {
+ print("File path has no errors\n");
+ return ;
+ }
+ var lines = err.get_object_member(valafn);
+
+
+
+ var tlines = buf.get_line_count () +1;
+
+ lines.foreach_member((obj, line, node) => {
+
+ Gtk.TextIter iter;
+ // print("get inter\n");
+ var eline = int.parse(line) -1 ;
+ print("GOT ERROR on line %s -- converted to %d\n", line,eline);
+
+
+ if (eline > tlines || eline < 0) {
+ return;
+ }
+ sbuf.get_iter_at_line( out iter, eline);
+ //print("mark line\n");
+ var msg = type + " on line: %d - %s".printf(eline+1, valafn);
+ var ar = lines.get_array_member(line);
+ for (var i = 0 ; i < ar.get_length(); i++) {
+ msg += (msg.length > 0) ? "\n" : "";
+ msg += ar.get_string_element(i);
+ }
+
+
+ sbuf.create_source_mark(msg, type, iter);
+ } );
+ return ;
+
+
+
+
+ }
+ }
+
+
+
}