5 "# Gtk.Widget lastObj" : "null",
6 "# JsRender.JsRender file" : "null",
7 "# Xcls_MainWindow main_window" : "",
9 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
10 "Gtk.SourceSearchContext searchcontext" : "",
11 "bool hexpand" : true,
12 "bool vexpand" : true,
15 "int last_search_end" : 0,
20 "* pack" : "pack_start,true,true,0",
26 "id" : "label_preview",
27 "utf8 label" : "Preview",
34 "utf8 label" : "Preview Generated Code",
38 "# JsRender.JsRender file" : "null",
40 "* ctor" : "_this.main_window == null ? null : new Glade.DesignView(_this.main_window.gladeproject)",
48 "xtype" : "DesignView",
49 "| void createThumb" : [
53 " if (this.file == null) {",
56 " var filename = this.file.getIconFileName(false);",
58 " var win = this.el.get_parent_window();",
59 " var width = win.get_width();",
60 " var height = win.get_height();",
62 " Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position?",
64 " screenshot.save(filename,\"png\");",
83 " var description = Pango.FontDescription.from_string(\"monospace\");",
84 " description.set_size(8000);",
85 " this.el.override_font(description);",
87 " this.loading = true;",
88 " var buf = this.el.get_buffer();",
89 " buf.notify.connect((ps) => {",
90 " if (this.loading) {",
93 " if (ps.name != \"cursor-position\") {",
96 " print(\"cursor changed : %d\\n\", buf.cursor_position);",
97 " Gtk.TextIter cpos;",
98 " buf.get_iter_at_offset(out cpos, buf.cursor_position);",
100 " var ln = cpos.get_line();",
102 " var node = _this.file.lineToNode(ln);",
104 " if (node == null) {",
105 " print(\"can not find node\\n\");",
108 " var ltree = _this.main_window.windowstate.left_tree;",
109 " var tp = ltree.model.treePathFromNode(node);",
110 " print(\"got tree path %s\\n\", tp);",
111 " if (tp != \"\") {",
112 "\t this.allow_node_scroll = false; ",
113 "\t print(\"changing cursor on tree..\\n\");",
114 " ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false);",
115 " // scrolling is disabled... as node selection calls scroll 10ms after it changes.",
116 " GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {",
117 "\t this.allow_node_scroll = true;",
122 " // highlight the node..",
128 " var attrs = new Gtk.SourceMarkAttributes();",
129 " var pink = Gdk.RGBA();",
130 " pink.parse ( \"pink\");",
131 " attrs.set_background ( pink);",
132 " attrs.set_icon_name ( \"process-stop\"); ",
133 " attrs.query_tooltip_text.connect(( mark) => {",
134 " //print(\"tooltip query? %s\\n\", mark.name);",
135 " return mark.name;",
138 " this.el.set_mark_attributes (\"ERR\", attrs, 1);",
140 " var wattrs = new Gtk.SourceMarkAttributes();",
141 " var blue = Gdk.RGBA();",
142 " blue.parse ( \"#ABF4EB\");",
143 " wattrs.set_background ( blue);",
144 " wattrs.set_icon_name ( \"process-stop\"); ",
145 " wattrs.query_tooltip_text.connect(( mark) => {",
146 " //print(\"tooltip query? %s\\n\", mark.name);",
147 " return mark.name;",
150 " this.el.set_mark_attributes (\"WARN\", wattrs, 1);",
154 " var dattrs = new Gtk.SourceMarkAttributes();",
155 " var purple = Gdk.RGBA();",
156 " purple.parse ( \"#EEA9FF\");",
157 " dattrs.set_background ( purple);",
158 " dattrs.set_icon_name ( \"process-stop\"); ",
159 " dattrs.query_tooltip_text.connect(( mark) => {",
160 " //print(\"tooltip query? %s\\n\", mark.name);",
161 " return mark.name;",
164 " this.el.set_mark_attributes (\"DEPR\", dattrs, 1);",
167 " var gattrs = new Gtk.SourceMarkAttributes();",
168 " var grey = Gdk.RGBA();",
169 " grey.parse ( \"#ccc\");",
170 " gattrs.set_background ( grey);",
173 " this.el.set_mark_attributes (\"grey\", gattrs, 1);",
183 "* pack" : "append_page,_this.label_code.el",
184 "bool allow_node_scroll" : true,
185 "bool loading" : true,
186 "gboolean editable" : false,
187 "gboolean show_line_marks" : true,
188 "gboolean show_line_numbers" : true,
190 "xtype" : "SourceView",
191 "| string toString" : [
195 " this.el.get_buffer().get_start_iter(out s);",
196 " this.el.get_buffer().get_end_iter(out e);",
197 " var ret = this.el.get_buffer().get_text(s,e,true);",
198 " //print(\"TO STRING? \" + ret);",
203 "| void highlightErrorsJson" : [
204 " (string type, Json.Object obj) {",
205 " Gtk.TextIter start;",
206 " Gtk.TextIter end; ",
208 " var buf = this.el.get_buffer();",
209 " var sbuf = (Gtk.SourceBuffer)buf;",
210 " buf.get_bounds (out start, out end);",
212 " sbuf.remove_source_marks (start, end, type);",
215 " // we should highlight other types of errors..",
217 " if (!obj.has_member(type)) {",
218 " print(\"Return has no errors\\n\");",
221 " var err = obj.get_object_member(type);",
223 " if (_this.file == null) { ",
224 " return; // just in case the file has not loaded yet?",
228 " var valafn = \"\";",
230 " var regex = new Regex(\"\\\\.bjs$\");",
233 " valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");",
234 " } catch (GLib.RegexError e) {",
238 " if (!err.has_member(valafn)) {",
239 " print(\"File path has no errors\\n\");",
242 " var lines = err.get_object_member(valafn);",
246 " var tlines = buf.get_line_count () +1;",
248 " lines.foreach_member((obj, line, node) => {",
250 " Gtk.TextIter iter;",
251 " // print(\"get inter\\n\");",
252 " var eline = int.parse(line) -1 ;",
253 " print(\"GOT ERROR on line %s -- converted to %d\\n\", line,eline);",
256 " if (eline > tlines || eline < 0) {",
259 " sbuf.get_iter_at_line( out iter, eline);",
260 " //print(\"mark line\\n\");",
261 " var msg = type + \" on line: %d - %s\".printf(eline+1, valafn);",
262 " var ar = lines.get_array_member(line);",
263 " for (var i = 0 ; i < ar.get_length(); i++) {",
264 "\t\t msg += (msg.length > 0) ? \"\\n\" : \"\";",
265 "\t\t msg += ar.get_string_element(i);",
269 " sbuf.create_source_mark(msg, type, iter);",
278 "| void loadFile" : [
282 " this.loading = true;",
283 " var buf = this.el.get_buffer();",
284 " buf.set_text(\"\",0);",
285 " var sbuf = (Gtk.SourceBuffer) buf;",
289 " if (_this.file == null || _this.file.xtype != \"Gtk\") {",
290 " print(\"xtype != Gtk\");",
291 " this.loading = false;",
295 " var valafn = \"\";",
297 " var regex = new Regex(\"\\\\.bjs$\");",
300 " valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");",
301 " } catch (GLib.RegexError e) {",
302 " this.loading = false;",
307 " if (!FileUtils.test(valafn,FileTest.IS_REGULAR) ) {",
308 " print(\"File path has no errors\\n\");",
309 " this.loading = false;",
316 " GLib.FileUtils.get_contents (valafn, out str);",
317 " } catch (Error e) {",
318 " this.loading = false;",
322 "// print(\"setting str %d\\n\", str.length);",
323 " buf.set_text(str, str.length);",
324 " var lm = Gtk.SourceLanguageManager.get_default();",
326 " //?? is javascript going to work as js?",
328 " ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language));",
331 " Gtk.TextIter start;",
332 " Gtk.TextIter end; ",
334 " sbuf.get_bounds (out start, out end);",
335 " sbuf.remove_source_marks (start, end, null); // remove all marks..",
338 " if (_this.main_window.windowstate.last_compile_result != null) {",
339 " var obj = _this.main_window.windowstate.last_compile_result;",
340 " this.highlightErrorsJson(\"ERR\", obj);",
341 " this.highlightErrorsJson(\"WARN\", obj);",
342 " this.highlightErrorsJson(\"DEPR\", obj);\t\t\t",
344 " //while (Gtk.events_pending()) {",
345 " // Gtk.main_iteration();",
348 " this.loading = false; ",
352 "| void nodeSelected" : [
353 "(JsRender.Node? sel) {",
357 " // this is connected in widnowstate",
358 " print(\"Roo-view - node selected\\n\");",
359 " var buf = this.el.get_buffer();",
361 " var sbuf = (Gtk.SourceBuffer) buf;",
364 " while(Gtk.events_pending()) {",
365 " Gtk.main_iteration();",
369 " // clear all the marks..",
370 " Gtk.TextIter start;",
371 " Gtk.TextIter end; ",
373 " sbuf.get_bounds (out start, out end);",
374 " sbuf.remove_source_marks (start, end, \"grey\");",
377 " if (sel == null) {",
378 " // no highlighting..",
381 " Gtk.TextIter iter; ",
382 " sbuf.get_iter_at_line(out iter, sel.line_start);",
385 " Gtk.TextIter cur_iter;",
386 " sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);",
388 " //var cur_line = cur_iter.get_line();",
389 " //if (cur_line > sel.line_start && cur_line < sel.line_end) {",
392 " if (this.allow_node_scroll) {",
394 " \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
399 " for (var i = 0; i < buf.get_line_count();i++) {",
400 " if (i < sel.line_start || i > sel.line_end) {",
402 " sbuf.get_iter_at_line(out iter, i);",
403 " sbuf.create_source_mark(null, \"grey\", iter);",
422 " this.width = aloc.width;",
423 " this.height =aloc.height;",
431 "\tthis.notebook.el.page = 1;",
432 " \tvar s = new Gtk.SourceSearchSettings();",
433 "\tvar buf = (Gtk.SourceBuffer) this.sourceview.el.get_buffer();",
434 "\tthis.searchcontext = new Gtk.SourceSearchContext(buf,s);",
435 "\tthis.searchcontext.set_highlight(true);",
436 "\ts.set_search_text(txt);",
438 "\tGtk.TextIter beg, st,en;",
440 "\tbuf.get_start_iter(out beg);",
441 "\tthis.searchcontext.forward(beg, out st, out en);",
442 "\tthis.last_search_end = 0;",
443 "\treturn this.searchcontext.get_occurrences_count();",
449 "| void createThumb" : [
453 " if (this.file == null) {",
456 " // only screenshot the gtk preview..",
457 " if (this.notebook.el.page > 0 ) {",
462 " var filename = this.file.getIconFileName(false);",
464 " var win = this.designview.el.get_parent_window();",
465 " var width = win.get_width();",
466 " var height = win.get_height();",
468 " Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position?",
469 " screenshot.save(filename,\"png\");",
470 " } catch (Error e) {",
481 " // should we hold until it's printed...",
494 "| void forwardSearch" : [
495 "(bool change_focus) {",
497 "\tif (this.searchcontext == null) {",
500 "\tthis.notebook.el.page = 1;",
501 "\tGtk.TextIter beg, st,en, stl;",
503 "\tvar buf = this.sourceview.el.get_buffer();",
504 "\tbuf.get_iter_at_offset(out beg, this.last_search_end);",
505 "\tif (!this.searchcontext.forward(beg, out st, out en)) {",
506 "\t\tthis.last_search_end = 0;",
508 "\t\tthis.last_search_end = en.get_offset();",
509 "\t\tif (change_focus) {",
510 "\t\t\tthis.sourceview.el.grab_focus();\t",
512 "\t\tbuf.place_cursor(st);",
513 "\t\tvar ln = st.get_line();",
514 "\t\tbuf.get_iter_at_line(out stl,ln);",
516 "\t\tthis.sourceview.el.scroll_to_iter(stl, 0.0f, true, 0.0f, 0.5f);",
522 "| void initGlade" : [
524 "\t _this.designview = new Xcls_designview( _this );",
526 "\t var box = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
528 "\t _this.notebook.el.append_page(box, _this.label_preview.el);",
529 "\t Glade.App.set_window(this.main_window.el);",
530 "\t// var pal = new Glade.Palette();",
531 " //var ins = new Glade.Inspector();",
533 "\t box.pack_start(_this.designview.el);",
534 "\t// box.pack_start(pal);",
535 "\t //box.pack_start(ins);",
538 " _this.designview.el.show();",
539 "\t box.show_all();\t ",
544 "| void loadFile" : [
545 "(JsRender.JsRender file)",
549 " this.file = file;",
552 " // clear existing elements from project?",
554 " var p = this.designview.el.get_project();",
555 " var li = p.get_objects().copy();",
556 " // should remove all..",
557 " for (var i =0; i < li.length(); i++) { ",
558 " p.remove_object(li.nth_data(i)); ",
561 " if (file.tree == null) {",
565 "// print(\"%s\\n\",tf.tree.toJsonString());",
566 "\tvar x = new JsRender.NodeToGlade((Project.Gtk) file.project, file.tree, null);",
567 " Glade.App.set_window(_this.main_window.el); // see if setting it again forces it to go to the irght locations.",
569 "FileIOStream iostream;",
570 "\tvar f = File.new_tmp (\"tpl-XXXXXX.glade\", out iostream);",
571 "\tvar ostream = iostream.output_stream;",
572 "\tvar dostream = new DataOutputStream (ostream);",
573 "\tdostream.put_string (x.munge());",
575 "\t print(\"LOADING %s\\n\",f.get_path ());",
576 " //p.load_from_file(f.get_path ());",
578 " p.load_from_file(\"/tmp/glade.xml\");",
582 "| void scroll_to_line" : [
584 " this.notebook.el.page = 1;// code preview...",
586 " GLib.Timeout.add(500, () => {",
591 "\t\t var buf = this.sourceview.el.get_buffer();",
593 "\t\tvar sbuf = (Gtk.SourceBuffer) buf;",
596 "\t\tGtk.TextIter iter; ",
597 "\t\tsbuf.get_iter_at_line(out iter, line);",
598 "\t\tthis.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
609 "name" : "GladeuiView",
611 "path" : "/home/alan/gitlive/roobuilder/src/Builder4/GladeuiView.bjs",