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,
30 "(n_press, x, y) => {",
37 "xtype" : "GestureClick"
44 "* pack" : "add_controller",
45 "xtype" : "GestureClick"
57 "Gtk.TreeListModelCreateModelFunc create_func" : "() => { }",
58 "bool autoexpand" : true,
59 "bool passthrough" : true,
60 "xtype" : "TreeListModel"
63 "xtype" : "SingleSelection"
68 "xtype" : "ColumnViewColumn"
71 "xtype" : "ColumnView"
75 "* pack" : "pack_start,true,true,0",
81 "id" : "label_preview",
82 "utf8 label" : "Preview",
89 "utf8 label" : "Preview Generated Code",
93 "# JsRender.JsRender file" : "null",
95 "* ctor" : "_this.main_window == null ? null : new Glade.DesignView(_this.main_window.gladeproject)",
103 "xtype" : "DesignView",
104 "| void createThumb" : [
108 " if (this.file == null) {",
111 " var filename = this.file.getIconFileName(false);",
113 " var win = this.el.get_parent_window();",
114 " var width = win.get_width();",
115 " var height = win.get_height();",
117 " Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position?",
119 " screenshot.save(filename,\"png\");",
138 " var description = Pango.FontDescription.from_string(\"monospace\");",
139 " description.set_size(8000);",
140 " this.el.override_font(description);",
142 " this.loading = true;",
143 " var buf = this.el.get_buffer();",
144 " buf.notify.connect((ps) => {",
145 " if (this.loading) {",
148 " if (ps.name != \"cursor-position\") {",
151 " print(\"cursor changed : %d\\n\", buf.cursor_position);",
152 " Gtk.TextIter cpos;",
153 " buf.get_iter_at_offset(out cpos, buf.cursor_position);",
155 " var ln = cpos.get_line();",
157 " var node = _this.file.lineToNode(ln);",
159 " if (node == null) {",
160 " print(\"can not find node\\n\");",
163 " var ltree = _this.main_window.windowstate.left_tree;",
164 " var tp = ltree.model.treePathFromNode(node);",
165 " print(\"got tree path %s\\n\", tp);",
166 " if (tp != \"\") {",
167 "\t this.allow_node_scroll = false; ",
168 "\t print(\"changing cursor on tree..\\n\");",
169 " ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false);",
170 " // scrolling is disabled... as node selection calls scroll 10ms after it changes.",
171 " GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {",
172 "\t this.allow_node_scroll = true;",
177 " // highlight the node..",
183 " var attrs = new Gtk.SourceMarkAttributes();",
184 " var pink = Gdk.RGBA();",
185 " pink.parse ( \"pink\");",
186 " attrs.set_background ( pink);",
187 " attrs.set_icon_name ( \"process-stop\"); ",
188 " attrs.query_tooltip_text.connect(( mark) => {",
189 " //print(\"tooltip query? %s\\n\", mark.name);",
190 " return mark.name;",
193 " this.el.set_mark_attributes (\"ERR\", attrs, 1);",
195 " var wattrs = new Gtk.SourceMarkAttributes();",
196 " var blue = Gdk.RGBA();",
197 " blue.parse ( \"#ABF4EB\");",
198 " wattrs.set_background ( blue);",
199 " wattrs.set_icon_name ( \"process-stop\"); ",
200 " wattrs.query_tooltip_text.connect(( mark) => {",
201 " //print(\"tooltip query? %s\\n\", mark.name);",
202 " return mark.name;",
205 " this.el.set_mark_attributes (\"WARN\", wattrs, 1);",
209 " var dattrs = new Gtk.SourceMarkAttributes();",
210 " var purple = Gdk.RGBA();",
211 " purple.parse ( \"#EEA9FF\");",
212 " dattrs.set_background ( purple);",
213 " dattrs.set_icon_name ( \"process-stop\"); ",
214 " dattrs.query_tooltip_text.connect(( mark) => {",
215 " //print(\"tooltip query? %s\\n\", mark.name);",
216 " return mark.name;",
219 " this.el.set_mark_attributes (\"DEPR\", dattrs, 1);",
222 " var gattrs = new Gtk.SourceMarkAttributes();",
223 " var grey = Gdk.RGBA();",
224 " grey.parse ( \"#ccc\");",
225 " gattrs.set_background ( grey);",
228 " this.el.set_mark_attributes (\"grey\", gattrs, 1);",
238 "* pack" : "append_page,_this.label_code.el",
239 "bool allow_node_scroll" : true,
240 "bool loading" : true,
241 "gboolean editable" : false,
242 "gboolean show_line_marks" : true,
243 "gboolean show_line_numbers" : true,
245 "xtype" : "SourceView",
246 "| string toString" : [
250 " this.el.get_buffer().get_start_iter(out s);",
251 " this.el.get_buffer().get_end_iter(out e);",
252 " var ret = this.el.get_buffer().get_text(s,e,true);",
253 " //print(\"TO STRING? \" + ret);",
258 "| void highlightErrorsJson" : [
259 " (string type, Json.Object obj) {",
260 " Gtk.TextIter start;",
261 " Gtk.TextIter end; ",
263 " var buf = this.el.get_buffer();",
264 " var sbuf = (Gtk.SourceBuffer)buf;",
265 " buf.get_bounds (out start, out end);",
267 " sbuf.remove_source_marks (start, end, type);",
270 " // we should highlight other types of errors..",
272 " if (!obj.has_member(type)) {",
273 " print(\"Return has no errors\\n\");",
276 " var err = obj.get_object_member(type);",
278 " if (_this.file == null) { ",
279 " return; // just in case the file has not loaded yet?",
283 " var valafn = \"\";",
285 " var regex = new Regex(\"\\\\.bjs$\");",
288 " valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");",
289 " } catch (GLib.RegexError e) {",
293 " if (!err.has_member(valafn)) {",
294 " print(\"File path has no errors\\n\");",
297 " var lines = err.get_object_member(valafn);",
301 " var tlines = buf.get_line_count () +1;",
303 " lines.foreach_member((obj, line, node) => {",
305 " Gtk.TextIter iter;",
306 " // print(\"get inter\\n\");",
307 " var eline = int.parse(line) -1 ;",
308 " print(\"GOT ERROR on line %s -- converted to %d\\n\", line,eline);",
311 " if (eline > tlines || eline < 0) {",
314 " sbuf.get_iter_at_line( out iter, eline);",
315 " //print(\"mark line\\n\");",
316 " var msg = type + \" on line: %d - %s\".printf(eline+1, valafn);",
317 " var ar = lines.get_array_member(line);",
318 " for (var i = 0 ; i < ar.get_length(); i++) {",
319 "\t\t msg += (msg.length > 0) ? \"\\n\" : \"\";",
320 "\t\t msg += ar.get_string_element(i);",
324 " sbuf.create_source_mark(msg, type, iter);",
333 "| void loadFile" : [
337 " this.loading = true;",
338 " var buf = this.el.get_buffer();",
339 " buf.set_text(\"\",0);",
340 " var sbuf = (Gtk.SourceBuffer) buf;",
344 " if (_this.file == null || _this.file.xtype != \"Gtk\") {",
345 " print(\"xtype != Gtk\");",
346 " this.loading = false;",
350 " var valafn = \"\";",
352 " var regex = new Regex(\"\\\\.bjs$\");",
355 " valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");",
356 " } catch (GLib.RegexError e) {",
357 " this.loading = false;",
362 " if (!FileUtils.test(valafn,FileTest.IS_REGULAR) ) {",
363 " print(\"File path has no errors\\n\");",
364 " this.loading = false;",
371 " GLib.FileUtils.get_contents (valafn, out str);",
372 " } catch (Error e) {",
373 " this.loading = false;",
377 "// print(\"setting str %d\\n\", str.length);",
378 " buf.set_text(str, str.length);",
379 " var lm = Gtk.SourceLanguageManager.get_default();",
381 " //?? is javascript going to work as js?",
383 " ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language));",
386 " Gtk.TextIter start;",
387 " Gtk.TextIter end; ",
389 " sbuf.get_bounds (out start, out end);",
390 " sbuf.remove_source_marks (start, end, null); // remove all marks..",
393 " if (_this.main_window.windowstate.last_compile_result != null) {",
394 " var obj = _this.main_window.windowstate.last_compile_result;",
395 " this.highlightErrorsJson(\"ERR\", obj);",
396 " this.highlightErrorsJson(\"WARN\", obj);",
397 " this.highlightErrorsJson(\"DEPR\", obj);\t\t\t",
399 " //while (Gtk.events_pending()) {",
400 " // Gtk.main_iteration();",
403 " this.loading = false; ",
407 "| void nodeSelected" : [
408 "(JsRender.Node? sel) {",
412 " // this is connected in widnowstate",
413 " print(\"Roo-view - node selected\\n\");",
414 " var buf = this.el.get_buffer();",
416 " var sbuf = (Gtk.SourceBuffer) buf;",
419 " while(Gtk.events_pending()) {",
420 " Gtk.main_iteration();",
424 " // clear all the marks..",
425 " Gtk.TextIter start;",
426 " Gtk.TextIter end; ",
428 " sbuf.get_bounds (out start, out end);",
429 " sbuf.remove_source_marks (start, end, \"grey\");",
432 " if (sel == null) {",
433 " // no highlighting..",
436 " Gtk.TextIter iter; ",
437 " sbuf.get_iter_at_line(out iter, sel.line_start);",
440 " Gtk.TextIter cur_iter;",
441 " sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);",
443 " //var cur_line = cur_iter.get_line();",
444 " //if (cur_line > sel.line_start && cur_line < sel.line_end) {",
447 " if (this.allow_node_scroll) {",
449 " \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
454 " for (var i = 0; i < buf.get_line_count();i++) {",
455 " if (i < sel.line_start || i > sel.line_end) {",
457 " sbuf.get_iter_at_line(out iter, i);",
458 " sbuf.create_source_mark(null, \"grey\", iter);",
477 " this.width = aloc.width;",
478 " this.height =aloc.height;",
486 "\tthis.notebook.el.page = 1;",
487 " \tvar s = new Gtk.SourceSearchSettings();",
488 "\tvar buf = (Gtk.SourceBuffer) this.sourceview.el.get_buffer();",
489 "\tthis.searchcontext = new Gtk.SourceSearchContext(buf,s);",
490 "\tthis.searchcontext.set_highlight(true);",
491 "\ts.set_search_text(txt);",
493 "\tGtk.TextIter beg, st,en;",
495 "\tbuf.get_start_iter(out beg);",
496 "\tthis.searchcontext.forward(beg, out st, out en);",
497 "\tthis.last_search_end = 0;",
498 "\treturn this.searchcontext.get_occurrences_count();",
504 "| void createThumb" : [
508 " if (this.file == null) {",
511 " // only screenshot the gtk preview..",
512 " if (this.notebook.el.page > 0 ) {",
517 " var filename = this.file.getIconFileName(false);",
519 " var win = this.designview.el.get_parent_window();",
520 " var width = win.get_width();",
521 " var height = win.get_height();",
523 " Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position?",
524 " screenshot.save(filename,\"png\");",
525 " } catch (Error e) {",
539 "| void forwardSearch" : [
540 "(bool change_focus) {",
542 "\tif (this.searchcontext == null) {",
545 "\tthis.notebook.el.page = 1;",
546 "\tGtk.TextIter beg, st,en, stl;",
548 "\tvar buf = this.sourceview.el.get_buffer();",
549 "\tbuf.get_iter_at_offset(out beg, this.last_search_end);",
550 "\tif (!this.searchcontext.forward(beg, out st, out en)) {",
551 "\t\tthis.last_search_end = 0;",
553 "\t\tthis.last_search_end = en.get_offset();",
554 "\t\tif (change_focus) {",
555 "\t\t\tthis.sourceview.el.grab_focus();\t",
557 "\t\tbuf.place_cursor(st);",
558 "\t\tvar ln = st.get_line();",
559 "\t\tbuf.get_iter_at_line(out stl,ln);",
561 "\t\tthis.sourceview.el.scroll_to_iter(stl, 0.0f, true, 0.0f, 0.5f);",
567 "| void initGlade" : [
569 "\t _this.designview = new Xcls_designview( _this );",
571 "\t var box = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
573 "\t _this.notebook.el.append_page(box, _this.label_preview.el);",
574 "\t Glade.App.set_window(this.main_window.el);",
575 "\t// var pal = new Glade.Palette();",
576 " //var ins = new Glade.Inspector();",
578 "\t box.pack_start(_this.designview.el);",
579 "\t// box.pack_start(pal);",
580 "\t //box.pack_start(ins);",
583 " _this.designview.el.show();",
584 "\t box.show_all();\t ",
589 "| void loadFile" : [
590 "(JsRender.JsRender file)",
594 " this.file = file;",
597 " // clear existing elements from project?",
599 " var p = this.designview.el.get_project();",
600 " var li = p.get_objects().copy();",
601 " // should remove all..",
602 " for (var i =0; i < li.length(); i++) { ",
603 " p.remove_object(li.nth_data(i)); ",
606 " if (file.tree == null) {",
610 "// print(\"%s\\n\",tf.tree.toJsonString());",
611 "\tvar x = new JsRender.NodeToGlade((Project.Gtk) file.project, file.tree, null);",
612 " Glade.App.set_window(_this.main_window.el); // see if setting it again forces it to go to the irght locations.",
614 "FileIOStream iostream;",
615 "\tvar f = File.new_tmp (\"tpl-XXXXXX.glade\", out iostream);",
616 "\tvar ostream = iostream.output_stream;",
617 "\tvar dostream = new DataOutputStream (ostream);",
618 "\tdostream.put_string (x.munge());",
620 "\t print(\"LOADING %s\\n\",f.get_path ());",
621 " //p.load_from_file(f.get_path ());",
623 " p.load_from_file(\"/tmp/glade.xml\");",
627 "| void scroll_to_line" : [
629 " this.notebook.el.page = 1;// code preview...",
631 " GLib.Timeout.add(500, () => {",
636 "\t\t var buf = this.sourceview.el.get_buffer();",
638 "\t\tvar sbuf = (Gtk.SourceBuffer) buf;",
641 "\t\tGtk.TextIter iter; ",
642 "\t\tsbuf.get_iter_at_line(out iter, line);",
643 "\t\tthis.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
654 "name" : "GladeuiView",
656 "path" : "/home/alan/gitlive/roobuilder/src/Builder4/GladeuiView.bjs",