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 "// print(\"setting str %d\\n\", str.length);",
345 " buf.set_text(str, str.length);",
346 " var lm = GtkSource.LanguageManager.get_default();",
348 " //?? is javascript going to work as js?",
350 " ((GtkSource.Buffer)(buf)) .set_language(lm.get_language(_this.file.language));",
353 " _this.main_window.windowstate.updateErrorMarksAll(); ",
354 " // restore the cursor position?",
355 " // after reloading the contents.",
356 " GLib.Timeout.add(500, () => {",
357 "\t\t_this.buffer.in_cursor_change = true;",
358 " print(\"RESORTING cursor to = %d\\n\", cpos);",
359 "\t\tGtk.TextIter cpos_iter;",
360 "\t\tbuf.get_iter_at_offset(out cpos_iter, cpos);",
361 "\t\tbuf.place_cursor(cpos_iter); ",
363 "\t\tthis.el.get_vadjustment().set_value(vadj_pos);;",
364 "\t\t_this.buffer.in_cursor_change = false;",
368 "\t\t//_this.buffer.checkSyntax();",
373 " this.loading = false; ",
377 "| void nodeSelected" : [
378 "(JsRender.Node? sel, bool scroll) {",
381 " if (this.loading) {",
384 " // this is connected in widnowstate",
385 " print(\"Roo-view - node selected\\n\");",
386 " var buf = this.el.get_buffer();",
388 " var sbuf = (GtkSource.Buffer) buf;",
394 " // clear all the marks..",
395 " Gtk.TextIter start;",
396 " Gtk.TextIter end; ",
398 " sbuf.get_bounds (out start, out end);",
399 " sbuf.remove_source_marks (start, end, \"grey\");",
401 " this.node_selected = sel;",
402 " if (sel == null) {",
403 " // no highlighting..",
406 " Gtk.TextIter iter; ",
407 " sbuf.get_iter_at_line(out iter, sel.line_start);",
410 " Gtk.TextIter cur_iter;",
411 " sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);",
414 " if (!_this.buffer.in_cursor_change) {",
416 " \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
421 " for (var i = 0; i < buf.get_line_count();i++) {",
422 " if (i < sel.line_start || i > sel.line_end) {",
424 " sbuf.get_iter_at_line(out iter, i);",
425 " sbuf.create_source_mark(null, \"grey\", iter);",
437 "xtype" : "ScrolledWindow"
441 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
442 "bool homogeneous" : false,
443 "bool vexpand" : false,
450 "this.css = new Gtk.CssProvider();",
452 "this.css.load_from_string(\"",
453 "\t#gtkview-search-entry { font: 10px monospace ;}\"",
456 "Gtk.StyleContext.add_provider_for_display(",
457 "\tthis.el.get_display(),",
459 "\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
465 "Gtk.CssProvider css" : "",
466 "bool hexpand" : true,
467 "id" : "search_entry",
473 "(keyval, keycode, state) => {",
475 "\tif (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
476 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
477 "\t\t_this.forwardSearch(true);",
482 " \tif (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {",
483 "\t\t_this.forwardSearch(true);",
489 " // print(event.key.keyval)",
496 "xtype" : "EventControllerKey"
503 "\t_this.search(_this.search_entry.el.text);",
504 "\t _this.search_results.updateResults();",
506 "\tGLib.Timeout.add_seconds(1,() => {",
507 "\t\t _this.search_results.updateResults();",
508 "\t\t return false;",
516 "string name" : "gtkview-search-entry",
517 "string placeholder_text" : "Press enter to search",
518 "uint search_delay" : 3,
519 "xtype" : "SearchEntry",
520 "| void forwardSearch" : [
521 "(bool change_focus) {",
524 "\t_this.forwardSearch(change_focus);",
528 "\tswitch(_this.windowstate.state) {",
529 "\t\tcase WindowState.State.CODEONLY:",
530 "\t\t//case WindowState.State.CODE:",
531 "\t\t\t// search the code being edited..",
532 "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);",
535 "\t\tcase WindowState.State.PREVIEW:",
536 "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
537 "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);",
539 "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);",
552 "id" : "search_results",
553 "int margin_end" : 4,
554 "int margin_start" : 4,
555 "string label" : "No Results",
557 "| void updateResults" : [
559 "\tthis.el.visible = true;",
561 "\tvar res = _this.searchcontext.get_occurrences_count();",
563 "\t\t_this.search_results.el.label = \"??? Matches\";\t\t",
567 "\t_this.nextBtn.el.sensitive = false;",
568 "\t_this.backBtn.el.sensitive = false;\t",
571 "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
572 "\t\t_this.nextBtn.el.sensitive = true;",
573 "\t\t_this.backBtn.el.sensitive = true;",
576 "\t_this.search_results.el.label = \"No Matches\";",
583 "bool always_show_image" : true,
584 "bool sensitive" : false,
589 "_this.forwardSearch(true);",
596 "string icon_name" : "go-down",
601 "bool always_show_image" : true,
602 "bool sensitive" : false,
608 "_this.backSearch(true);",
614 "string icon_name" : "go-up",
619 "bool always_show_arrow" : true,
620 "bool always_show_image" : true,
624 "* ctor" : "new Gtk.PopoverMenu.from_model(null)",
625 "* prop" : "popover",
626 "id" : "search_settings",
630 "* pack" : "set_child",
631 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
636 "id" : "case_sensitive",
637 "string label" : "Case Sensitive",
638 "xtype" : "CheckButton"
643 "string label" : "Regex",
644 "xtype" : "CheckButton"
649 "string label" : "Multi-line (add \\n)",
650 "xtype" : "CheckButton"
656 "xtype" : "PopoverMenu"
659 "string icon_name" : "emblem-system",
660 "xtype" : "MenuButton"
675 "\tthis.notebook.el.page = 1;",
679 "\tvar s = new GtkSource.SearchSettings();",
680 "\ts.case_sensitive = _this.case_sensitive.el.active;",
681 "\ts.regex_enabled = _this.regex.el.active;\t",
682 "\ts.wrap_around = false;",
684 "\tthis.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);",
685 "\tthis.searchcontext.set_highlight(true);",
686 "\tvar txt = in_txt;",
688 "\tif (_this.multiline.el.active) {",
689 "\t\ttxt = in_txt.replace(\"\\\\n\", \"\\n\");",
692 "\ts.set_search_text(txt);",
693 "\tGtk.TextIter beg, st,en;",
694 "\tbool has_wrapped_around;",
695 "\tthis.buffer.el.get_start_iter(out beg);",
696 "\tthis.searchcontext.forward(beg, out st, out en, out has_wrapped_around);",
697 "\tthis.last_search_end = 0;",
699 "\treturn this.searchcontext.get_occurrences_count();",
707 "| void backSearch" : [
708 "(bool change_focus) {",
710 "\tif (this.searchcontext == null) {",
714 "\tGtk.TextIter beg, st,en;",
715 "\tbool has_wrapped_around;",
716 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );",
718 "\tif (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {",
720 "\t\tthis.last_search_end = 0;",
723 "\tthis.last_search_end = en.get_offset();",
724 "\tif (change_focus) {",
725 "\t\tthis.sourceview.el.grab_focus();",
727 "\tthis.buffer.el.place_cursor(st);",
728 "\tthis.sourceview.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
729 "\tvar ln = st.get_line();",
730 "\tthis.highlightNodeAtLine(ln);",
735 "| void createThumb" : [
739 " if (this.file == null) {",
742 " // only screenshot the gtk preview..",
743 " if (this.notebook.el.page > 0 ) {",
748 " \tthis.file.widgetToIcon(this.container.el); ",
757 " // should we hold until it's printed...",
765 "| void forwardSearch" : [
766 "(bool change_focus) {",
768 "\tif (this.searchcontext == null) {",
771 "\tthis.notebook.el.page = 1;",
772 "\tGtk.TextIter beg, st,en;",
773 "\tbool has_wrapped_around;",
774 "\tvar buf = this.sourceview.el.get_buffer();",
775 "\tbuf.get_iter_at_offset(out beg, this.last_search_end);",
776 "\tif (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {",
777 "\t\tthis.last_search_end = 0;",
780 "\tthis.last_search_end = en.get_offset();",
781 "\tif (change_focus) {",
782 "\t\tthis.sourceview.el.grab_focus();",
784 "\tbuf.place_cursor(st);",
788 "\tthis.sourceview.el.scroll_to_iter(st, 0.0f, true, 0.0f, 0.5f);",
791 "\tvar ln = st.get_line();",
793 "\tthis.highlightNodeAtLine(ln);",
797 "| void highlightNodeAtLine" : [
800 "\t// this is done from clicking on the editor..",
802 "\t// highlight node...",
805 " var node = _this.file.lineToNode(ln+1);",
807 " if (node == null) {",
808 " //print(\"can not find node\\n\");",
811 " var prop = node.lineToProp(ln+1);",
812 " print(\"prop : %s\", prop == null ? \"???\" : prop.name);",
815 " // ---------- this selects the tree's node...",
817 " var ltree = _this.main_window.windowstate.left_tree;",
818 " ltree.model.selectNode(node);",
819 " //var tp = ltree.model.treePathFromNode(node);",
821 " //print(\"got tree path %s\\n\", tp);",
822 " //if (tp == \"\") {",
825 " //_this.sourceview.allow_node_scroll = false; /// block node scrolling..",
828 " //print(\"changing cursor on tree..\\n\");",
832 " // let's try allowing editing on the methods.",
833 " // a little klunky at present..",
834 "\t_this.sourceview.prop_selected = \"\";",
836 " if (prop != null) {",
837 "\t\t//see if we can find it..",
838 "\t\tvar kv = prop.split(\":\");",
839 "\t\tif (kv[0] == \"p\") {",
841 " \t\t//var k = prop.get_key(kv[1]);",
842 " \t\t// fixme -- need to determine if it's an editable property...",
843 " \t\t_this.sourceview.prop_selected = prop;",
845 "\t\t} else if (kv[0] == \"l\") {",
846 "\t\t\t _this.sourceview.prop_selected = prop;",
851 " //ltree.view.setCursor(tp, \"editor\");",
852 " // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); ",
853 " _this.sourceview.nodeSelected(node,false);",
855 " // scrolling is disabled... as node selection calls scroll 10ms after it changes.",
856 " // GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {",
857 "\t // this.allow_node_scroll = true;",
858 "\t // return false;",
875 "| void loadFile" : [
876 "(JsRender.JsRender file) ",
878 " this.file = null;",
880 " if (file.tree == null) {",
883 " this.notebook.el.page = 0;// gtk preview ",
887 " this.file = file; ",
888 " this.sourceview.loadFile();",
889 " this.searchcontext = null;",
892 " if (this.lastObj != null) {",
893 " this.container.el.remove(this.lastObj);",
896 " // hide the compile view at present..",
899 " var w = this.el.get_width();",
900 " var h = this.el.get_height();",
902 " print(\"ALLOC SET SIZES %d, %d\\n\", w,h); ",
904 " // set the container size min to 500/500 or 20 px less than max..",
905 " w = int.max (w-20, 500);",
906 " h = int.max (h-20, 500); ",
908 " print(\"SET SIZES %d, %d\\n\", w,h); ",
909 " _this.container.el.set_size_request(w,h);",
911 " _this.view_layout.el.set_size_request(w,h); ",
912 " // should be baded on calc.. -- see update_scrolled.",
914 " var fc = this.container.el.get_first_child();",
915 " if (fc != null) {",
916 " \t\tthis.container.el.remove(fc);",
919 " \t\tvar xmlstr = JsRender.NodeToGlade.mungeFile( file);",
920 " \t\tvar builder = new Gtk.Builder.from_string (xmlstr, xmlstr.length);",
921 " \t\tvar obj = (Gtk.Widget) builder.get_object(\"w\"+ file.tree.oid.to_string());",
922 " \t\t this.container.el.append(obj);",
924 " this.createThumb();",
928 "\tvar x = new JsRender.NodeToGtk((Project.Gtk) file.project, file.tree);",
929 " var obj = x.munge() as Gtk.Widget;",
930 " this.lastObj = null;",
931 "\tif (obj == null) {",
934 "\tthis.lastObj = obj;",
936 " this.container.el.append(obj);",
944 "| void scroll_to_line" : [
946 " // code preview...",
948 " GLib.Timeout.add(100, () => {",
951 "\t this.notebook.el.set_current_page(1);",
953 "\t\t var buf = this.sourceview.el.get_buffer();",
955 "\t\tvar sbuf = (GtkSource.Buffer) buf;",
958 "\t\tGtk.TextIter iter; ",
959 "\t\tsbuf.get_iter_at_line(out iter, line);",
960 "\t\tthis.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
968 "| void updateErrorMarks" : [
969 "(string category) {",
973 "\tvar buf = _this.buffer.el;",
974 "\tGtk.TextIter start;",
975 "\tGtk.TextIter end; ",
976 "\tbuf.get_bounds (out start, out end);",
978 "\tbuf.remove_source_marks (start, end, category);",
980 "\tGLib.debug(\"highlight errors\");\t\t ",
982 "\t // we should highlight other types of errors..",
987 "\tif (_this.file == null) {",
988 "\t\tGLib.debug(\"file is null?\");",
992 "\tvar ar = this.file.getErrors(category);",
993 "\tif (ar == null || ar.get_n_items() < 1) {",
994 "\t\tGLib.debug(\"higjlight %s has no errors\", category);",
1002 "\tvar tlines = buf.get_line_count () +1;",
1006 "\tfor (var i = 0; i < ar.get_n_items();i++) {",
1007 "\t\tvar err = (Palete.CompileError) ar.get_item(i);",
1009 "\t Gtk.TextIter iter;",
1010 "// print(\"get inter\\n\");",
1011 "\t var eline = err.line + 1;",
1012 "\t GLib.debug(\"GOT ERROR on line %d -- converted to %d \",",
1013 "\t \terr.line ,eline);",
1016 "\t if (eline > tlines || eline < 0) {",
1021 "\t buf.get_iter_at_line( out iter, eline);",
1024 "\t\tvar msg = \"Line: %d %s : %s\".printf(eline+1, err.category, err.msg);",
1025 "\t buf.create_source_mark( msg, err.category, iter);",
1026 "\t GLib.debug(\"set line %d to %s\", eline, msg);",
1027 "\t //this.marks.set(eline, msg);",