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 loading" : false,
171 "bool zallow_node_scroll" : 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,
181 "bool in_cursor_change" : false,
183 "int error_line" : "-1",
184 "int last_line" : "-1",
188 "GLib.debug(\"cursor moved called\");",
191 " \tif (this.in_cursor_change ) {",
192 " GLib.debug(\"cursor changed : %d [ignoring nested call)\", this.el.cursor_position);",
196 " GLib.debug(\"cursor changed : %d\", this.el.cursor_position);",
197 " Gtk.TextIter cpos;",
198 " this.el.get_iter_at_offset(out cpos, this.el.cursor_position);",
200 " var ln = cpos.get_line();",
201 " if (this.last_line == ln ){",
204 "\tthis.last_line = ln;",
205 " var node = _this.file.lineToNode(ln);",
207 " if (node == null) {",
208 " print(\"can not find node\\n\");",
211 " this.in_cursor_change = true;",
212 " var ltree = _this.main_window.windowstate.left_tree;",
213 " ltree.model.selectNode(node);",
214 " this.in_cursor_change = false;",
225 "(keyval, keycode, state) => {",
229 "\t if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
230 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
231 "\t\t_this.forwardSearch(true);",
234 " if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
235 "\t GLib.debug(\"SAVE: ctrl-f pressed\");",
236 "\t\t_this.search_entry.el.grab_focus();",
245 "xtype" : "EventControllerKey"
250 "(x, y, keyboard_tooltip, tooltip) => {",
252 "\t//GLib.debug(\"query tooltip\");",
253 "\tGtk.TextIter iter;",
256 "\tvar yoff = (int) _this.sourceviewscroll.el.vadjustment.value;",
258 "\tthis.el.get_iter_at_position (out iter, out trailing, x, y + yoff);",
260 "\tvar l = iter.get_line();",
261 "\t// GLib.debug(\"query tooltip line %d\", (int) l);",
262 "\tvar marks = _this.buffer.el.get_source_marks_at_line(l, \"ERR\");",
263 "\tif (marks.is_empty()) {",
264 "\t\tmarks = _this.buffer.el.get_source_marks_at_line(l, \"WARN\");",
266 "\tif (marks.is_empty()) {",
267 "\t\tmarks = _this.buffer.el.get_source_marks_at_line(l, \"DEPR\");",
270 "\t// GLib.debug(\"query tooltip line marks %d\", (int) marks.length());",
272 "\tmarks.@foreach((m) => { ",
273 "\t\t//GLib.debug(\"got mark %s\", m.name);",
274 "\t\tstr += (str.length > 0 ? \"\\n\" : \"\") + m.name;",
277 "\t// true if there is a mark..",
278 "\ttooltip.set_text( str);",
279 "\treturn str.length > 0 ? true : false;",
285 "string name" : "gtkview-view",
286 "uint tab_width" : 4,
288 "| string toString" : [
292 " this.el.get_buffer().get_start_iter(out s);",
293 " this.el.get_buffer().get_end_iter(out e);",
294 " var ret = this.el.get_buffer().get_text(s,e,true);",
295 " //print(\"TO STRING? \" + ret);",
300 "| void loadFile" : [
302 " this.loading = true;",
303 " var buf = this.el.get_buffer();",
304 " buf.set_text(\"\",0);",
305 " var sbuf = (GtkSource.Buffer) buf;",
306 "\tvar cpos = buf.cursor_position;",
308 " \tprint(\"BEFORE LOAD cursor = %d\\n\", cpos);",
309 " var vadj_pos = this.el.get_vadjustment().get_value();",
311 " if (_this.file == null || _this.file.xtype != \"Gtk\") {",
312 " print(\"xtype != Gtk\");",
313 " this.loading = false;",
317 " var valafn = \"\";",
319 " var regex = new Regex(\"\\\\.bjs$\");",
322 " valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");",
323 " } catch (GLib.RegexError e) {",
324 " this.loading = false;",
329 " if (!FileUtils.test(valafn,FileTest.IS_REGULAR) ) {",
330 " print(\"File path has no errors\\n\");",
331 " this.loading = false;",
338 " GLib.FileUtils.get_contents (valafn, out str);",
339 " } catch (Error e) {",
340 " this.loading = false;",
344 " var str = _this.file.toSource();",
346 "// print(\"setting str %d\\n\", str.length);",
347 " buf.set_text(str, str.length);",
348 " var lm = GtkSource.LanguageManager.get_default();",
350 " //?? is javascript going to work as js?",
352 " ((GtkSource.Buffer)(buf)) .set_language(lm.get_language(_this.file.language));",
355 " _this.main_window.windowstate.updateErrorMarksAll(); ",
356 " // restore the cursor position?",
357 " // after reloading the contents.",
358 " GLib.Timeout.add(500, () => {",
359 "\t\t_this.buffer.in_cursor_change = true;",
360 " print(\"RESORTING cursor to = %d\\n\", cpos);",
361 "\t\tGtk.TextIter cpos_iter;",
362 "\t\tbuf.get_iter_at_offset(out cpos_iter, cpos);",
363 "\t\tbuf.place_cursor(cpos_iter); ",
365 "\t\tthis.el.get_vadjustment().set_value(vadj_pos);;",
366 "\t\t_this.buffer.in_cursor_change = false;",
370 "\t\t//_this.buffer.checkSyntax();",
375 " this.loading = false; ",
379 "| void nodeSelected" : [
380 "(JsRender.Node? sel, bool scroll) {",
383 " if (this.loading) {",
386 " // this is connected in widnowstate",
387 " print(\"Roo-view - node selected\\n\");",
388 " var buf = this.el.get_buffer();",
390 " var sbuf = (GtkSource.Buffer) buf;",
396 " // clear all the marks..",
397 " Gtk.TextIter start;",
398 " Gtk.TextIter end; ",
400 " sbuf.get_bounds (out start, out end);",
401 " sbuf.remove_source_marks (start, end, \"grey\");",
403 " this.node_selected = sel;",
404 " if (sel == null) {",
405 " // no highlighting..",
408 " Gtk.TextIter iter; ",
409 " sbuf.get_iter_at_line(out iter, sel.line_start);",
412 " Gtk.TextIter cur_iter;",
413 " sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);",
416 " if (!_this.buffer.in_cursor_change) {",
418 " \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
423 " for (var i = 0; i < buf.get_line_count();i++) {",
424 " if (i < sel.line_start || i > sel.line_end) {",
426 " sbuf.get_iter_at_line(out iter, i);",
427 " sbuf.create_source_mark(null, \"grey\", iter);",
439 "xtype" : "ScrolledWindow"
443 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
444 "bool homogeneous" : false,
445 "bool vexpand" : false,
452 "this.css = new Gtk.CssProvider();",
454 "this.css.load_from_string(\"",
455 "\t#gtkview-search-entry { font: 10px monospace ;}\"",
458 "Gtk.StyleContext.add_provider_for_display(",
459 "\tthis.el.get_display(),",
461 "\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
467 "Gtk.CssProvider css" : "",
468 "bool hexpand" : true,
469 "id" : "search_entry",
475 "(keyval, keycode, state) => {",
477 "\tif (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
478 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
479 "\t\t_this.forwardSearch(true);",
484 " \tif (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {",
485 "\t\t_this.forwardSearch(true);",
491 " // print(event.key.keyval)",
498 "xtype" : "EventControllerKey"
505 "\t_this.search(_this.search_entry.el.text);",
506 "\t _this.search_results.updateResults();",
508 "\tGLib.Timeout.add_seconds(1,() => {",
509 "\t\t _this.search_results.updateResults();",
510 "\t\t return false;",
518 "string name" : "gtkview-search-entry",
519 "string placeholder_text" : "Press enter to search",
520 "uint search_delay" : 3,
521 "xtype" : "SearchEntry",
522 "| void forwardSearch" : [
523 "(bool change_focus) {",
526 "\t_this.forwardSearch(change_focus);",
530 "\tswitch(_this.windowstate.state) {",
531 "\t\tcase WindowState.State.CODEONLY:",
532 "\t\t//case WindowState.State.CODE:",
533 "\t\t\t// search the code being edited..",
534 "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);",
537 "\t\tcase WindowState.State.PREVIEW:",
538 "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
539 "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);",
541 "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);",
554 "id" : "search_results",
555 "int margin_end" : 4,
556 "int margin_start" : 4,
557 "string label" : "No Results",
559 "| void updateResults" : [
561 "\tthis.el.visible = true;",
563 "\tvar res = _this.searchcontext.get_occurrences_count();",
565 "\t\t_this.search_results.el.label = \"??? Matches\";\t\t",
569 "\t_this.nextBtn.el.sensitive = false;",
570 "\t_this.backBtn.el.sensitive = false;\t",
573 "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
574 "\t\t_this.nextBtn.el.sensitive = true;",
575 "\t\t_this.backBtn.el.sensitive = true;",
578 "\t_this.search_results.el.label = \"No Matches\";",
585 "bool always_show_image" : true,
586 "bool sensitive" : false,
591 "_this.forwardSearch(true);",
598 "string icon_name" : "go-down",
603 "bool always_show_image" : true,
604 "bool sensitive" : false,
610 "_this.backSearch(true);",
616 "string icon_name" : "go-up",
621 "bool always_show_arrow" : true,
622 "bool always_show_image" : true,
626 "* ctor" : "new Gtk.PopoverMenu.from_model(null)",
627 "* prop" : "popover",
628 "id" : "search_settings",
632 "* pack" : "set_child",
633 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
638 "id" : "case_sensitive",
639 "string label" : "Case Sensitive",
640 "xtype" : "CheckButton"
645 "string label" : "Regex",
646 "xtype" : "CheckButton"
651 "string label" : "Multi-line (add \\n)",
652 "xtype" : "CheckButton"
658 "xtype" : "PopoverMenu"
661 "string icon_name" : "emblem-system",
662 "xtype" : "MenuButton"
677 "\tthis.notebook.el.page = 1;",
681 "\tvar s = new GtkSource.SearchSettings();",
682 "\ts.case_sensitive = _this.case_sensitive.el.active;",
683 "\ts.regex_enabled = _this.regex.el.active;\t",
684 "\ts.wrap_around = false;",
686 "\tthis.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);",
687 "\tthis.searchcontext.set_highlight(true);",
688 "\tvar txt = in_txt;",
690 "\tif (_this.multiline.el.active) {",
691 "\t\ttxt = in_txt.replace(\"\\\\n\", \"\\n\");",
694 "\ts.set_search_text(txt);",
695 "\tGtk.TextIter beg, st,en;",
696 "\tbool has_wrapped_around;",
697 "\tthis.buffer.el.get_start_iter(out beg);",
698 "\tthis.searchcontext.forward(beg, out st, out en, out has_wrapped_around);",
699 "\tthis.last_search_end = 0;",
701 "\treturn this.searchcontext.get_occurrences_count();",
709 "| void backSearch" : [
710 "(bool change_focus) {",
712 "\tif (this.searchcontext == null) {",
716 "\tGtk.TextIter beg, st,en;",
717 "\tbool has_wrapped_around;",
718 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );",
720 "\tif (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {",
722 "\t\tthis.last_search_end = 0;",
725 "\tthis.last_search_end = en.get_offset();",
726 "\tif (change_focus) {",
727 "\t\tthis.sourceview.el.grab_focus();",
729 "\tthis.buffer.el.place_cursor(st);",
730 "\tthis.sourceview.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
731 "\tvar ln = st.get_line();",
732 "\tthis.highlightNodeAtLine(ln);",
737 "| void createThumb" : [
741 " if (this.file == null) {",
744 " // only screenshot the gtk preview..",
745 " if (this.notebook.el.page > 0 ) {",
750 " \tthis.file.widgetToIcon(this.container.el); ",
759 " // should we hold until it's printed...",
767 "| void forwardSearch" : [
768 "(bool change_focus) {",
770 "\tif (this.searchcontext == null) {",
773 "\tthis.notebook.el.page = 1;",
774 "\tGtk.TextIter beg, st,en;",
775 "\tbool has_wrapped_around;",
776 "\tvar buf = this.sourceview.el.get_buffer();",
777 "\tbuf.get_iter_at_offset(out beg, this.last_search_end);",
778 "\tif (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {",
779 "\t\tthis.last_search_end = 0;",
782 "\tthis.last_search_end = en.get_offset();",
783 "\tif (change_focus) {",
784 "\t\tthis.sourceview.el.grab_focus();",
786 "\tbuf.place_cursor(st);",
790 "\tthis.sourceview.el.scroll_to_iter(st, 0.0f, true, 0.0f, 0.5f);",
793 "\tvar ln = st.get_line();",
795 "\tthis.highlightNodeAtLine(ln);",
799 "| void highlightNodeAtLine" : [
802 "\t// this is done from clicking on the editor..",
804 "\t// highlight node...",
807 " var node = _this.file.lineToNode(ln+1);",
809 " if (node == null) {",
810 " //print(\"can not find node\\n\");",
813 " var prop = node.lineToProp(ln+1);",
814 " print(\"prop : %s\", prop == null ? \"???\" : prop.name);",
817 " // ---------- this selects the tree's node...",
819 " var ltree = _this.main_window.windowstate.left_tree;",
820 " ltree.model.selectNode(node);",
821 " //var tp = ltree.model.treePathFromNode(node);",
823 " //print(\"got tree path %s\\n\", tp);",
824 " //if (tp == \"\") {",
827 " //_this.sourceview.allow_node_scroll = false; /// block node scrolling..",
830 " //print(\"changing cursor on tree..\\n\");",
834 " // let's try allowing editing on the methods.",
835 " // a little klunky at present..",
836 "\t_this.sourceview.prop_selected = \"\";",
838 " if (prop != null) {",
839 "\t\t//see if we can find it..",
840 "\t\tvar kv = prop.split(\":\");",
841 "\t\tif (kv[0] == \"p\") {",
843 " \t\t//var k = prop.get_key(kv[1]);",
844 " \t\t// fixme -- need to determine if it's an editable property...",
845 " \t\t_this.sourceview.prop_selected = prop;",
847 "\t\t} else if (kv[0] == \"l\") {",
848 "\t\t\t _this.sourceview.prop_selected = prop;",
853 " //ltree.view.setCursor(tp, \"editor\");",
854 " // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); ",
855 " _this.sourceview.nodeSelected(node,false);",
857 " // scrolling is disabled... as node selection calls scroll 10ms after it changes.",
858 " // GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {",
859 "\t // this.allow_node_scroll = true;",
860 "\t // return false;",
877 "| void loadFile" : [
878 "(JsRender.JsRender file) ",
880 " this.file = null;",
882 " if (file.tree == null) {",
885 " this.notebook.el.page = 0;// gtk preview ",
889 " this.file = file; ",
890 " this.sourceview.loadFile();",
891 " this.searchcontext = null;",
894 " if (this.lastObj != null) {",
895 " this.container.el.remove(this.lastObj);",
898 " // hide the compile view at present..",
901 " var w = this.el.get_width();",
902 " var h = this.el.get_height();",
904 " print(\"ALLOC SET SIZES %d, %d\\n\", w,h); ",
906 " // set the container size min to 500/500 or 20 px less than max..",
907 " w = int.max (w-20, 500);",
908 " h = int.max (h-20, 500); ",
910 " print(\"SET SIZES %d, %d\\n\", w,h); ",
911 " _this.container.el.set_size_request(w,h);",
913 " _this.view_layout.el.set_size_request(w,h); ",
914 " // should be baded on calc.. -- see update_scrolled.",
916 " var fc = this.container.el.get_first_child();",
917 " if (fc != null) {",
918 " \t\tthis.container.el.remove(fc);",
921 " \t\tvar xmlstr = JsRender.NodeToGlade.mungeFile( file);",
922 " \t\tvar builder = new Gtk.Builder.from_string (xmlstr, xmlstr.length);",
923 " \t\tvar obj = (Gtk.Widget) builder.get_object(\"w\"+ file.tree.oid.to_string());",
924 " \t\t this.container.el.append(obj);",
926 " this.createThumb();",
930 "\tvar x = new JsRender.NodeToGtk((Project.Gtk) file.project, file.tree);",
931 " var obj = x.munge() as Gtk.Widget;",
932 " this.lastObj = null;",
933 "\tif (obj == null) {",
936 "\tthis.lastObj = obj;",
938 " this.container.el.append(obj);",
946 "| void scroll_to_line" : [
948 " // code preview...",
950 " GLib.Timeout.add(100, () => {",
953 "\t this.notebook.el.set_current_page(1);",
955 "\t\t var buf = this.sourceview.el.get_buffer();",
957 "\t\tvar sbuf = (GtkSource.Buffer) buf;",
960 "\t\tGtk.TextIter iter; ",
961 "\t\tsbuf.get_iter_at_line(out iter, line);",
962 "\t\tthis.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
970 "| void updateErrorMarks" : [
971 "(string category) {",
975 "\tvar buf = _this.buffer.el;",
976 "\tGtk.TextIter start;",
977 "\tGtk.TextIter end; ",
978 "\tbuf.get_bounds (out start, out end);",
980 "\tbuf.remove_source_marks (start, end, category);",
982 "\tGLib.debug(\"highlight errors\");\t\t ",
984 "\t // we should highlight other types of errors..",
989 "\tif (_this.file == null) {",
990 "\t\tGLib.debug(\"file is null?\");",
994 "\tvar ar = this.file.getErrors(category);",
995 "\tif (ar == null || ar.get_n_items() < 1) {",
996 "\t\tGLib.debug(\"higjlight %s has no errors\", category);",
1004 "\tvar tlines = buf.get_line_count () +1;",
1008 "\tfor (var i = 0; i < ar.get_n_items();i++) {",
1009 "\t\tvar err = (Palete.CompileError) ar.get_item(i);",
1011 "\t Gtk.TextIter iter;",
1012 "// print(\"get inter\\n\");",
1013 "\t var eline = err.line + 1;",
1014 "\t GLib.debug(\"GOT ERROR on line %d -- converted to %d \",",
1015 "\t \terr.line ,eline);",
1018 "\t if (eline > tlines || eline < 0) {",
1023 "\t buf.get_iter_at_line( out iter, eline);",
1026 "\t\tvar msg = \"Line: %d %s : %s\".printf(eline+1, err.category, err.msg);",
1027 "\t buf.create_source_mark( msg, err.category, iter);",
1028 "\t GLib.debug(\"set line %d to %s\", eline, msg);",
1029 "\t //this.marks.set(eline, msg);",