{ "build_module" : "", "items" : [ { "# Gtk.Widget lastObj" : "null", "# JsRender.JsRender file" : "null", "# Xcls_MainWindow main_window" : "", "$ xns" : "Gtk", "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", "Gtk.SourceSearchContext searchcontext" : "", "bool hexpand" : true, "bool vexpand" : true, "id" : "GladeuiView", "int height" : 0, "int last_search_end" : 0, "int width" : 0, "items" : [ { "$ xns" : "Gtk", "items" : [ { "$ xns" : "Gtk", "* prop" : "child", "xtype" : "Box" }, { "$ xns" : "Gtk", "listeners" : { "pressed" : [ "(n_press, x, y) => {", "", "", "}", "" ] }, "xtype" : "GestureClick" } ], "xtype" : "Button" }, { "$ xns" : "Gtk", "* pack" : "add_controller", "xtype" : "GestureClick" }, { "$ xns" : "Gtk", "items" : [ { "$ xns" : "Gtk", "* prop" : "model", "items" : [ { "$ xns" : "Gtk", "* prop" : "model", "Gtk.TreeListModelCreateModelFunc create_func" : "() => { }", "bool autoexpand" : true, "bool passthrough" : true, "xtype" : "TreeListModel" } ], "xtype" : "SingleSelection" }, { "$ xns" : "Gtk", "string title" : "", "xtype" : "ColumnViewColumn" } ], "xtype" : "ColumnView" }, { "$ xns" : "Gtk", "* pack" : "pack_start,true,true,0", "id" : "notebook", "items" : [ { "$ xns" : "Gtk", "* pack" : false, "id" : "label_preview", "utf8 label" : "Preview", "xtype" : "Label" }, { "$ xns" : "Gtk", "* pack" : false, "id" : "label_code", "utf8 label" : "Preview Generated Code", "xtype" : "Label" }, { "# JsRender.JsRender file" : "null", "$ xns" : "Glade", "* ctor" : "_this.main_window == null ? null : new Glade.DesignView(_this.main_window.gladeproject)", "* init" : [ " ", "this.el.show();", "" ], "* pack" : false, "id" : "designview", "xtype" : "DesignView", "| 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();", "", " Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position?", "", " screenshot.save(filename,\"png\");", " return;", " ", " ", " ", "}", "" ], "| void test" : [ "() {", "", "}" ] }, { "$ xns" : "Gtk", "* init" : [ "{", " ", " 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 != \"\") {", "\t this.allow_node_scroll = false; ", "\t 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 , () => {", "\t this.allow_node_scroll = true;", "\t 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);", " ", " ", " ", " ", " ", " ", "}", " " ], "* pack" : "append_page,_this.label_code.el", "bool allow_node_scroll" : true, "bool loading" : true, "gboolean editable" : false, "gboolean show_line_marks" : true, "gboolean show_line_numbers" : true, "id" : "sourceview", "xtype" : "SourceView", "| 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;", "}", "" ], "| 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++) {", "\t\t msg += (msg.length > 0) ? \"\\n\" : \"\";", "\t\t msg += ar.get_string_element(i);", "\t }", " ", " ", " sbuf.create_source_mark(msg, type, iter);", " } );", " return ;", " ", " ", "", "", "}" ], "| 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);\t\t\t", " }", " //while (Gtk.events_pending()) {", " // Gtk.main_iteration();", " // }", " ", " this.loading = false; ", "}", "" ], "| void nodeSelected" : [ "(JsRender.Node? sel) {", " ", " ", " ", " // this is connected in widnowstate", " print(\"Roo-view - 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) {", "\t\t ", " \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);", "\t}", " ", " ", " ", " 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);", " ", " }", " ", " }", " ", "", "}", "" ] } ], "xtype" : "Notebook" } ], "listeners" : { "size_allocate" : [ "(aloc) => {", " ", " this.width = aloc.width;", " this.height =aloc.height;", "}", " " ] }, "xtype" : "Box", "| int search" : [ "(string txt) {", "\tthis.notebook.el.page = 1;", " \tvar s = new Gtk.SourceSearchSettings();", "\tvar buf = (Gtk.SourceBuffer) this.sourceview.el.get_buffer();", "\tthis.searchcontext = new Gtk.SourceSearchContext(buf,s);", "\tthis.searchcontext.set_highlight(true);", "\ts.set_search_text(txt);", "\t", "\tGtk.TextIter beg, st,en;", "\t ", "\tbuf.get_start_iter(out beg);", "\tthis.searchcontext.forward(beg, out st, out en);", "\tthis.last_search_end = 0;", "\treturn this.searchcontext.get_occurrences_count();", "", " ", "}", "" ], "| 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.designview.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, height); // this.el.position?", " screenshot.save(filename,\"png\");", " } catch (Error e) {", " ", " }", "", " ", " ", " ", "", "", " ", " ", "}", "" ], "| void forwardSearch" : [ "(bool change_focus) {", "", "\tif (this.searchcontext == null) {", "\t\treturn;", "\t}", "\tthis.notebook.el.page = 1;", "\tGtk.TextIter beg, st,en, stl;", "\t", "\tvar buf = this.sourceview.el.get_buffer();", "\tbuf.get_iter_at_offset(out beg, this.last_search_end);", "\tif (!this.searchcontext.forward(beg, out st, out en)) {", "\t\tthis.last_search_end = 0;", "\t} else { ", "\t\tthis.last_search_end = en.get_offset();", "\t\tif (change_focus) {", "\t\t\tthis.sourceview.el.grab_focus();\t", "\t\t}", "\t\tbuf.place_cursor(st);", "\t\tvar ln = st.get_line();", "\t\tbuf.get_iter_at_line(out stl,ln);", "\t\t ", "\t\tthis.sourceview.el.scroll_to_iter(stl, 0.0f, true, 0.0f, 0.5f);", "\t}", "", "}", "" ], "| void initGlade" : [ "() {", "\t _this.designview = new Xcls_designview( _this );", "\t ", "\t var box = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);", "\t ", "\t _this.notebook.el.append_page(box, _this.label_preview.el);", "\t Glade.App.set_window(this.main_window.el);", "\t// var pal = new Glade.Palette();", " //var ins = new Glade.Inspector();", "", "\t box.pack_start(_this.designview.el);", "\t// box.pack_start(pal);", "\t //box.pack_start(ins);", "\t // pal.show();", " // ins.show();", " _this.designview.el.show();", "\t box.show_all();\t ", "\t ", "} ", "" ], "| void loadFile" : [ "(JsRender.JsRender file)", "{", " ", "", " this.file = file;", " ", "", " // clear existing elements from project?", " ", " var p = this.designview.el.get_project();", " var li = p.get_objects().copy();", " // should remove all..", " for (var i =0; i < li.length(); i++) { ", " p.remove_object(li.nth_data(i)); ", " }", "", " if (file.tree == null) {", " return;", " }", "", "// print(\"%s\\n\",tf.tree.toJsonString());", "\tvar x = new JsRender.NodeToGlade((Project.Gtk) file.project, file.tree, null);", " Glade.App.set_window(_this.main_window.el); // see if setting it again forces it to go to the irght locations.", "\t ", "FileIOStream iostream;", "\tvar f = File.new_tmp (\"tpl-XXXXXX.glade\", out iostream);", "\tvar ostream = iostream.output_stream;", "\tvar dostream = new DataOutputStream (ostream);", "\tdostream.put_string (x.munge());", "\tthis.el.show();", "\t print(\"LOADING %s\\n\",f.get_path ());", " //p.load_from_file(f.get_path ());", " ", " p.load_from_file(\"/tmp/glade.xml\");", "", "}" ], "| void scroll_to_line" : [ "(int line) {", " this.notebook.el.page = 1;// code preview...", " ", " GLib.Timeout.add(500, () => {", " ", " ", "\t ", "\t ", "\t\t var buf = this.sourceview.el.get_buffer();", "\t ", "\t\tvar sbuf = (Gtk.SourceBuffer) buf;", "", "", "\t\tGtk.TextIter iter; ", "\t\tsbuf.get_iter_at_line(out iter, line);", "\t\tthis.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);", "\t\treturn false;", "\t}); ", "", " ", "}", "" ] } ], "modOrder" : "", "name" : "GladeuiView", "parent" : "", "path" : "/home/alan/gitlive/roobuilder/src/Builder4/GladeuiView.bjs", "permname" : "", "title" : "" }