2 "build_module" : "builder",
3 "gen_extended" : false,
6 "# Gtk.Widget lastObj" : "null",
7 "# GtkSource.SearchContext searchcontext" : "",
8 "# JsRender.JsRender file" : "null",
9 "# Xcls_MainWindow main_window" : "",
14 "\tthis.css = new Gtk.CssProvider();",
16 "\tthis.css.load_from_string(",
17 "\t\t\"#gtkview-view-layout { background-color: #ccc; }\"",
20 "\tGtk.StyleContext.add_provider_for_display(",
21 "\t\tthis.el.get_display(),",
23 "\t\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
30 "Gtk.CssProvider css" : "",
31 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
32 "bool hexpand" : true,
33 "bool vexpand" : true,
35 "int last_search_end" : 0,
39 "Gtk.Overflow overflow" : "Gtk.Overflow.VISIBLE",
45 "id" : "label_preview",
46 "utf8 label" : "Preview",
53 "utf8 label" : "Preview Generated Code",
58 "* pack" : "append_page,_this.label_preview.el",
62 "* pack" : "set_child",
67 "* pack" : "put,10,10",
68 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
73 "string name" : "gtkview-view-layout",
77 "xtype" : "ScrolledWindow"
81 "* pack" : "append_page,_this.label_code.el",
82 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
87 "bool vexpand" : true,
88 "id" : "sourceviewscroll",
91 "# JsRender.Node? node_selected" : "",
92 "# string prop_selected" : "\"\"",
93 "$ xns" : "GtkSource",
98 " \tthis.css = new Gtk.CssProvider();",
100 "\tthis.css.load_from_string(\"#gtkview-view { font: 10px monospace ;}\");",
102 "\tGtk.StyleContext.add_provider_for_display(",
103 "\t\tthis.el.get_display(),",
105 "\t\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
109 " this.loading = true;",
113 " var attrs = new GtkSource.MarkAttributes();",
114 " var pink = Gdk.RGBA();",
115 " pink.parse ( \"pink\");",
116 " attrs.set_background ( pink);",
117 " attrs.set_icon_name ( \"process-stop\"); ",
118 " attrs.query_tooltip_text.connect(( mark) => {",
119 " //print(\"tooltip query? %s\\n\", mark.name);",
120 " return mark.name;",
123 " this.el.set_mark_attributes (\"ERR\", attrs, 1);",
125 " var wattrs = new GtkSource.MarkAttributes();",
126 " var blue = Gdk.RGBA();",
127 " blue.parse ( \"#ABF4EB\");",
128 " wattrs.set_background ( blue);",
129 " wattrs.set_icon_name ( \"process-stop\"); ",
130 " wattrs.query_tooltip_text.connect(( mark) => {",
131 " //print(\"tooltip query? %s\\n\", mark.name);",
132 " return mark.name;",
135 " this.el.set_mark_attributes (\"WARN\", wattrs, 1);",
139 " var dattrs = new GtkSource.MarkAttributes();",
140 " var purple = Gdk.RGBA();",
141 " purple.parse ( \"#EEA9FF\");",
142 " dattrs.set_background ( purple);",
143 " dattrs.set_icon_name ( \"process-stop\"); ",
144 " dattrs.query_tooltip_text.connect(( mark) => {",
145 " //print(\"tooltip query? %s\\n\", mark.name);",
146 " return mark.name;",
149 " this.el.set_mark_attributes (\"DEPR\", dattrs, 1);",
152 " var gattrs = new GtkSource.MarkAttributes();",
153 " var grey = Gdk.RGBA();",
154 " grey.parse ( \"#ccc\");",
155 " gattrs.set_background ( grey);",
158 " this.el.set_mark_attributes (\"grey\", gattrs, 1);",
168 "* pack" : "set_child",
169 "Gtk.CssProvider css" : "",
170 "bool allow_node_scroll" : true,
171 "bool loading" : true,
172 "gboolean editable" : false,
173 "gboolean show_line_marks" : true,
174 "gboolean show_line_numbers" : true,
178 "$ xns" : "GtkSource",
179 "* pack" : "set_buffer",
180 "bool dirty" : false,
182 "int error_line" : "-1",
184 "notify[\"cursor_position\"]" : [
188 " if (_this.sourceview.loading) {",
192 " GLib.debug(\"cursor changed : %d\", this.el.cursor_position);",
193 " Gtk.TextIter cpos;",
194 " this.el.get_iter_at_offset(out cpos, this.el.cursor_position);",
196 " var ln = cpos.get_line();",
198 " var node = _this.file.lineToNode(ln);",
200 " if (node == null) {",
201 " print(\"can not find node\\n\");",
204 " _this.sourceview.loading = true;",
205 " var ltree = _this.main_window.windowstate.left_tree;",
206 " ltree.model.selectNode(node);",
207 " _this.sourceview.loading = false;",
209 " //print(\"got tree path %s\\n\", tp);",
210 " //if (tp != \"\") {",
211 " // this.allow_node_scroll = false; ",
212 " // print(\"changing cursor on tree..\\n\");",
213 " //ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false);",
214 " // scrolling is disabled... as node selection calls scroll 10ms after it changes.",
215 " ///GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {",
216 " // this.allow_node_scroll = true;",
221 " // highlight the node..",
234 "(keyval, keycode, state) => {",
238 "\t if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
239 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
240 "\t\t_this.forwardSearch(true);",
243 " if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
244 "\t GLib.debug(\"SAVE: ctrl-f pressed\");",
245 "\t\t_this.search_entry.el.grab_focus();",
254 "xtype" : "EventControllerKey"
259 "(x, y, keyboard_tooltip, tooltip) => {",
261 "\t//GLib.debug(\"query tooltip\");",
262 "\tGtk.TextIter iter;",
265 "\tvar yoff = (int) _this.sourceviewscroll.el.vadjustment.value;",
267 "\tthis.el.get_iter_at_position (out iter, out trailing, x, y + yoff);",
269 "\tvar l = iter.get_line();",
270 "\t// GLib.debug(\"query tooltip line %d\", (int) l);",
271 "\tvar marks = _this.buffer.el.get_source_marks_at_line(l, \"ERR\");",
272 "\tif (marks.is_empty()) {",
273 "\t\tmarks = _this.buffer.el.get_source_marks_at_line(l, \"WARN\");",
275 "\tif (marks.is_empty()) {",
276 "\t\tmarks = _this.buffer.el.get_source_marks_at_line(l, \"DEPR\");",
279 "\t// GLib.debug(\"query tooltip line marks %d\", (int) marks.length());",
281 "\tmarks.@foreach((m) => { ",
282 "\t\t//GLib.debug(\"got mark %s\", m.name);",
283 "\t\tstr += (str.length > 0 ? \"\\n\" : \"\") + m.name;",
286 "\t// true if there is a mark..",
287 "\ttooltip.set_text( str);",
288 "\treturn str.length > 0 ? true : false;",
294 "string name" : "gtkview-view",
296 "| string toString" : [
300 " this.el.get_buffer().get_start_iter(out s);",
301 " this.el.get_buffer().get_end_iter(out e);",
302 " var ret = this.el.get_buffer().get_text(s,e,true);",
303 " //print(\"TO STRING? \" + ret);",
308 "| void loadFile" : [
310 " this.loading = true;",
311 " var buf = this.el.get_buffer();",
312 " buf.set_text(\"\",0);",
313 " var sbuf = (GtkSource.Buffer) buf;",
317 " if (_this.file == null || _this.file.xtype != \"Gtk\") {",
318 " print(\"xtype != Gtk\");",
319 " this.loading = false;",
323 " var valafn = \"\";",
325 " var regex = new Regex(\"\\\\.bjs$\");",
328 " valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");",
329 " } catch (GLib.RegexError e) {",
330 " this.loading = false;",
335 " if (!FileUtils.test(valafn,FileTest.IS_REGULAR) ) {",
336 " print(\"File path has no errors\\n\");",
337 " this.loading = false;",
344 " GLib.FileUtils.get_contents (valafn, out str);",
345 " } catch (Error e) {",
346 " this.loading = false;",
350 "// print(\"setting str %d\\n\", str.length);",
351 " buf.set_text(str, str.length);",
352 " var lm = GtkSource.LanguageManager.get_default();",
354 " //?? is javascript going to work as js?",
356 " ((GtkSource.Buffer)(buf)) .set_language(lm.get_language(_this.file.language));",
359 " _this.main_window.windowstate.updateErrorMarksAll(); ",
363 " this.loading = false; ",
367 "| void nodeSelected" : [
368 "(JsRender.Node? sel, bool scroll) {",
371 " if (this.loading) {",
374 " // this is connected in widnowstate",
375 " print(\"Roo-view - node selected\\n\");",
376 " var buf = this.el.get_buffer();",
378 " var sbuf = (GtkSource.Buffer) buf;",
381 " // while(Gtk.events_pending()) {",
382 " // Gtk.main_iteration();",
386 " // clear all the marks..",
387 " Gtk.TextIter start;",
388 " Gtk.TextIter end; ",
390 " sbuf.get_bounds (out start, out end);",
391 " sbuf.remove_source_marks (start, end, \"grey\");",
393 " this.node_selected = sel;",
394 " if (sel == null) {",
395 " // no highlighting..",
398 " Gtk.TextIter iter; ",
399 " sbuf.get_iter_at_line(out iter, sel.line_start);",
402 " Gtk.TextIter cur_iter;",
403 " sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);",
405 " //var cur_line = cur_iter.get_line();",
406 " //if (cur_line > sel.line_start && cur_line < sel.line_end) {",
409 " if (this.allow_node_scroll) {",
411 " \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
416 " for (var i = 0; i < buf.get_line_count();i++) {",
417 " if (i < sel.line_start || i > sel.line_end) {",
419 " sbuf.get_iter_at_line(out iter, i);",
420 " sbuf.create_source_mark(null, \"grey\", iter);",
432 "xtype" : "ScrolledWindow"
436 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
437 "bool homogeneous" : false,
438 "bool vexpand" : false,
445 "this.css = new Gtk.CssProvider();",
447 "this.css.load_from_string(\"",
448 "\t#gtkview-search-entry { font: 10px monospace ;}\"",
451 "Gtk.StyleContext.add_provider_for_display(",
452 "\tthis.el.get_display(),",
454 "\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
460 "Gtk.CssProvider css" : "",
461 "bool hexpand" : true,
462 "id" : "search_entry",
468 "(keyval, keycode, state) => {",
470 "\tif (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
471 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
472 "\t\t_this.forwardSearch(true);",
477 " \tif (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {",
478 "\t\t_this.forwardSearch(true);",
484 " // print(event.key.keyval)",
491 "xtype" : "EventControllerKey"
498 "\t_this.search(_this.search_entry.el.text);",
499 "\t _this.search_results.updateResults();",
501 "\tGLib.Timeout.add_seconds(1,() => {",
502 "\t\t _this.search_results.updateResults();",
503 "\t\t return false;",
511 "string name" : "gtkview-search-entry",
512 "string placeholder_text" : "Press enter to search",
513 "uint search_delay" : 3,
514 "xtype" : "SearchEntry",
515 "| void forwardSearch" : [
516 "(bool change_focus) {",
519 "\t_this.forwardSearch(change_focus);",
523 "\tswitch(_this.windowstate.state) {",
524 "\t\tcase WindowState.State.CODEONLY:",
525 "\t\t//case WindowState.State.CODE:",
526 "\t\t\t// search the code being edited..",
527 "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);",
530 "\t\tcase WindowState.State.PREVIEW:",
531 "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
532 "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);",
534 "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);",
547 "id" : "search_results",
548 "int margin_end" : 4,
549 "int margin_start" : 4,
550 "string label" : "No Results",
552 "| void updateResults" : [
554 "\tthis.el.visible = true;",
556 "\tvar res = _this.searchcontext.get_occurrences_count();",
558 "\t\t_this.search_results.el.label = \"??? Matches\";\t\t",
562 "\t_this.nextBtn.el.sensitive = false;",
563 "\t_this.backBtn.el.sensitive = false;\t",
566 "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
567 "\t\t_this.nextBtn.el.sensitive = true;",
568 "\t\t_this.backBtn.el.sensitive = true;",
571 "\t_this.search_results.el.label = \"No Matches\";",
578 "bool always_show_image" : true,
579 "bool sensitive" : false,
584 "_this.forwardSearch(true);",
591 "string icon_name" : "go-down",
596 "bool always_show_image" : true,
597 "bool sensitive" : false,
603 "_this.backSearch(true);",
609 "string icon_name" : "go-up",
614 "bool always_show_arrow" : true,
615 "bool always_show_image" : true,
619 "* ctor" : "new Gtk.PopoverMenu.from_model(null)",
620 "* prop" : "popover",
621 "id" : "search_settings",
625 "* pack" : "set_child",
626 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
631 "id" : "case_sensitive",
632 "string label" : "Case Sensitive",
633 "xtype" : "CheckButton"
638 "string label" : "Regex",
639 "xtype" : "CheckButton"
644 "string label" : "Multi-line (add \\n)",
645 "xtype" : "CheckButton"
651 "xtype" : "PopoverMenu"
654 "string icon_name" : "emblem-system",
655 "xtype" : "MenuButton"
670 "\tthis.notebook.el.page = 1;",
674 "\tvar s = new GtkSource.SearchSettings();",
675 "\ts.case_sensitive = _this.case_sensitive.el.active;",
676 "\ts.regex_enabled = _this.regex.el.active;\t",
677 "\ts.wrap_around = false;",
679 "\tthis.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);",
680 "\tthis.searchcontext.set_highlight(true);",
681 "\tvar txt = in_txt;",
683 "\tif (_this.multiline.el.active) {",
684 "\t\ttxt = in_txt.replace(\"\\\\n\", \"\\n\");",
687 "\ts.set_search_text(txt);",
688 "\tGtk.TextIter beg, st,en;",
689 "\tbool has_wrapped_around;",
690 "\tthis.buffer.el.get_start_iter(out beg);",
691 "\tthis.searchcontext.forward(beg, out st, out en, out has_wrapped_around);",
692 "\tthis.last_search_end = 0;",
694 "\treturn this.searchcontext.get_occurrences_count();",
702 "| void backSearch" : [
703 "(bool change_focus) {",
705 "\tif (this.searchcontext == null) {",
709 "\tGtk.TextIter beg, st,en;",
710 "\tbool has_wrapped_around;",
711 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );",
713 "\tif (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {",
715 "\t\tthis.last_search_end = 0;",
718 "\tthis.last_search_end = en.get_offset();",
719 "\tif (change_focus) {",
720 "\t\tthis.sourceview.el.grab_focus();",
722 "\tthis.buffer.el.place_cursor(st);",
723 "\tthis.sourceview.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
724 "\tvar ln = st.get_line();",
725 "\tthis.highlightNodeAtLine(ln);",
730 "| void createThumb" : [
734 " if (this.file == null) {",
737 " // only screenshot the gtk preview..",
738 " if (this.notebook.el.page > 0 ) {",
743 " \tthis.file.widgetToIcon(this.container.el); ",
752 " // should we hold until it's printed...",
760 "| void forwardSearch" : [
761 "(bool change_focus) {",
763 "\tif (this.searchcontext == null) {",
766 "\tthis.notebook.el.page = 1;",
767 "\tGtk.TextIter beg, st,en;",
768 "\tbool has_wrapped_around;",
769 "\tvar buf = this.sourceview.el.get_buffer();",
770 "\tbuf.get_iter_at_offset(out beg, this.last_search_end);",
771 "\tif (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {",
772 "\t\tthis.last_search_end = 0;",
775 "\tthis.last_search_end = en.get_offset();",
776 "\tif (change_focus) {",
777 "\t\tthis.sourceview.el.grab_focus();",
779 "\tbuf.place_cursor(st);",
783 "\tthis.sourceview.el.scroll_to_iter(st, 0.0f, true, 0.0f, 0.5f);",
786 "\tvar ln = st.get_line();",
788 "\tthis.highlightNodeAtLine(ln);",
792 "| void highlightNodeAtLine" : [
795 "\t// this is done from clicking on the editor..",
797 "\t// highlight node...",
800 " var node = _this.file.lineToNode(ln+1);",
802 " if (node == null) {",
803 " //print(\"can not find node\\n\");",
806 " var prop = node.lineToProp(ln+1);",
807 " print(\"prop : %s\", prop == null ? \"???\" : prop.name);",
810 " // ---------- this selects the tree's node...",
812 " var ltree = _this.main_window.windowstate.left_tree;",
813 " ltree.model.selectNode(node);",
814 " //var tp = ltree.model.treePathFromNode(node);",
816 " //print(\"got tree path %s\\n\", tp);",
817 " //if (tp == \"\") {",
820 " //_this.sourceview.allow_node_scroll = false; /// block node scrolling..",
823 " //print(\"changing cursor on tree..\\n\");",
827 " // let's try allowing editing on the methods.",
828 " // a little klunky at present..",
829 "\t_this.sourceview.prop_selected = \"\";",
831 " if (prop != null) {",
832 "\t\t//see if we can find it..",
833 "\t\tvar kv = prop.split(\":\");",
834 "\t\tif (kv[0] == \"p\") {",
836 " \t\t//var k = prop.get_key(kv[1]);",
837 " \t\t// fixme -- need to determine if it's an editable property...",
838 " \t\t_this.sourceview.prop_selected = prop;",
840 "\t\t} else if (kv[0] == \"l\") {",
841 "\t\t\t _this.sourceview.prop_selected = prop;",
846 " //ltree.view.setCursor(tp, \"editor\");",
847 " // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); ",
848 " _this.sourceview.nodeSelected(node,false);",
850 " // scrolling is disabled... as node selection calls scroll 10ms after it changes.",
851 " // GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {",
852 "\t // this.allow_node_scroll = true;",
853 "\t // return false;",
870 "| void loadFile" : [
871 "(JsRender.JsRender file) ",
873 " this.file = null;",
875 " if (file.tree == null) {",
878 " this.notebook.el.page = 0;// gtk preview ",
882 " this.file = file; ",
883 " this.sourceview.loadFile();",
884 " this.searchcontext = null;",
887 " if (this.lastObj != null) {",
888 " this.container.el.remove(this.lastObj);",
891 " // hide the compile view at present..",
894 " var w = this.el.get_width();",
895 " var h = this.el.get_height();",
897 " print(\"ALLOC SET SIZES %d, %d\\n\", w,h); ",
899 " // set the container size min to 500/500 or 20 px less than max..",
900 " w = int.max (w-20, 500);",
901 " h = int.max (h-20, 500); ",
903 " print(\"SET SIZES %d, %d\\n\", w,h); ",
904 " _this.container.el.set_size_request(w,h);",
906 " _this.view_layout.el.set_size_request(w,h); ",
907 " // should be baded on calc.. -- see update_scrolled.",
909 " var fc = this.container.el.get_first_child();",
910 " if (fc != null) {",
911 " \t\tthis.container.el.remove(fc);",
914 " \t\tvar xmlstr = JsRender.NodeToGlade.mungeFile( file);",
915 " \t\tvar builder = new Gtk.Builder.from_string (xmlstr, xmlstr.length);",
916 " \t\tvar obj = (Gtk.Widget) builder.get_object(\"w\"+ file.tree.oid.to_string());",
917 " \t\t this.container.el.append(obj);",
919 " this.createThumb();",
923 "\tvar x = new JsRender.NodeToGtk((Project.Gtk) file.project, file.tree);",
924 " var obj = x.munge() as Gtk.Widget;",
925 " this.lastObj = null;",
926 "\tif (obj == null) {",
929 "\tthis.lastObj = obj;",
931 " this.container.el.append(obj);",
939 "| void scroll_to_line" : [
941 " // code preview...",
943 " GLib.Timeout.add(100, () => {",
946 "\t this.notebook.el.set_current_page(1);",
948 "\t\t var buf = this.sourceview.el.get_buffer();",
950 "\t\tvar sbuf = (GtkSource.Buffer) buf;",
953 "\t\tGtk.TextIter iter; ",
954 "\t\tsbuf.get_iter_at_line(out iter, line);",
955 "\t\tthis.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
963 "| void updateErrorMarks" : [
964 "(string category) {",
968 "\tvar buf = _this.buffer.el;",
969 "\tGtk.TextIter start;",
970 "\tGtk.TextIter end; ",
971 "\tbuf.get_bounds (out start, out end);",
973 "\tbuf.remove_source_marks (start, end, category);",
975 "\tGLib.debug(\"highlight errors\");\t\t ",
977 "\t // we should highlight other types of errors..",
982 "\tif (_this.file == null) {",
983 "\t\tGLib.debug(\"file is null?\");",
987 "\tvar ar = this.file.getErrors(category);",
988 "\tif (ar == null || ar.get_n_items() < 1) {",
989 "\t\tGLib.debug(\"higjlight %s has no errors\", category);",
999 "\tvar tlines = buf.get_line_count () +1;",
1003 "\tfor (var i = 0; i < ar.get_n_items();i++) {",
1004 "\t\tvar err = (Palete.CompileError) ar.get_item(i);",
1006 "\t Gtk.TextIter iter;",
1007 "// print(\"get inter\\n\");",
1008 "\t var eline = err.line - offset;",
1009 "\t GLib.debug(\"GOT ERROR on line %d -- converted to %d (offset = %d)\",",
1010 "\t \terr.line ,eline, offset);",
1013 "\t if (eline > tlines || eline < 0) {",
1018 "\t buf.get_iter_at_line( out iter, eline);",
1021 "\t\tvar msg = \"Line: %d %s : %s\".printf(eline+1, err.category, err.msg);",
1022 "\t buf.create_source_mark( msg, err.category, iter);",
1023 "\t GLib.debug(\"set line %d to %s\", eline, msg);",
1024 "\t //this.marks.set(eline, msg);",