1 static Xcls_GtkView _GtkView;
3 public class Xcls_GtkView : Object
6 private Xcls_GtkView _this;
8 public static Xcls_GtkView singleton()
10 if (_GtkView == null) {
11 _GtkView= new Xcls_GtkView();
15 public Xcls_notebook notebook;
16 public Xcls_label_preview label_preview;
17 public Xcls_label_code label_code;
18 public Xcls_view_layout view_layout;
19 public Xcls_container container;
20 public Xcls_sourceviewscroll sourceviewscroll;
21 public Xcls_sourceview sourceview;
22 public Xcls_buffer buffer;
23 public Xcls_keystate keystate;
24 public Xcls_search_entry search_entry;
25 public Xcls_search_results search_results;
26 public Xcls_nextBtn nextBtn;
27 public Xcls_backBtn backBtn;
28 public Xcls_search_settings search_settings;
29 public Xcls_case_sensitive case_sensitive;
30 public Xcls_regex regex;
31 public Xcls_multiline multiline;
34 public Gtk.Widget lastObj;
35 public Xcls_MainWindow main_window;
36 public int last_error_counter;
37 public int last_search_end;
38 public GtkSource.SearchContext searchcontext;
39 public JsRender.JsRender file;
45 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
49 this.last_error_counter = 0;
50 this.last_search_end = 0;
54 this.el.hexpand = true;
55 this.el.vexpand = true;
56 new Xcls_notebook( _this );
57 this.el.append( _this.notebook.el );
60 // user defined functions
61 public void loadFile (JsRender.JsRender file)
65 if (file.tree == null) {
68 this.last_error_counter = -1;
69 this.notebook.el.page = 0;// gtk preview
74 this.sourceview.loadFile();
76 this.searchcontext = null;
77 this.last_error_counter = -1;
78 this.updateErrorMarks();
79 if (this.lastObj != null) {
80 this.container.el.remove(this.lastObj);
83 // hide the compile view at present..
86 var w = this.el.get_width();
87 var h = this.el.get_height();
89 print("ALLOC SET SIZES %d, %d\n", w,h);
91 // set the container size min to 500/500 or 20 px less than max..
92 w = int.max (w-20, 500);
93 h = int.max (h-20, 500);
95 print("SET SIZES %d, %d\n", w,h);
96 _this.container.el.set_size_request(w,h);
98 _this.view_layout.el.set_size_request(w,h);
99 // should be baded on calc.. -- see update_scrolled.
101 var fc = this.container.el.get_first_child();
103 this.container.el.remove(fc);
106 var xmlstr = JsRender.NodeToGlade.mungeFile( file);
107 var builder = new Gtk.Builder();
109 if (!builder.add_from_string(xmlstr, xmlstr.length)) {
112 } catch(GLib.Error e) {
113 GLib.debug(e.message);
118 var obj = (Gtk.Widget) builder.get_object("w"+ file.tree.oid.to_string());
119 this.container.el.append(obj);
127 public void highlightNodeAtLine (int ln) {
129 // this is done from clicking on the editor..
134 var node = _this.file.lineToNode(ln+1);
137 //print("can not find node\n");
140 var prop = node.lineToProp(ln+1);
141 print("prop : %s", prop == null ? "???" : prop.name);
144 // ---------- this selects the tree's node...
146 var ltree = _this.main_window.windowstate.left_tree;
147 ltree.model.selectNode(node);
148 //var tp = ltree.model.treePathFromNode(node);
150 //print("got tree path %s\n", tp);
154 //_this.sourceview.allow_node_scroll = false; /// block node scrolling..
157 //print("changing cursor on tree..\n");
161 // let's try allowing editing on the methods.
162 // a little klunky at present..
163 _this.sourceview.prop_selected = "";
166 //see if we can find it..
167 var kv = prop.split(":");
170 //var k = prop.get_key(kv[1]);
171 // fixme -- need to determine if it's an editable property...
172 _this.sourceview.prop_selected = prop;
174 } else if (kv[0] == "l") {
175 _this.sourceview.prop_selected = prop;
180 //ltree.view.setCursor(tp, "editor");
181 // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false);
182 _this.sourceview.nodeSelected(node,false);
184 // scrolling is disabled... as node selection calls scroll 10ms after it changes.
185 // GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {
186 // this.allow_node_scroll = true;
202 public void forwardSearch (bool change_focus) {
204 if (this.searchcontext == null) {
207 this.notebook.el.page = 1;
208 Gtk.TextIter beg, st,en;
209 bool has_wrapped_around;
210 var buf = this.sourceview.el.get_buffer();
211 buf.get_iter_at_offset(out beg, this.last_search_end);
212 if (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {
213 this.last_search_end = 0;
216 this.last_search_end = en.get_offset();
218 this.sourceview.el.grab_focus();
220 buf.place_cursor(st);
224 this.sourceview.el.scroll_to_iter(st, 0.0f, true, 0.0f, 0.5f);
227 var ln = st.get_line();
229 this.highlightNodeAtLine(ln);
231 public void backSearch (bool change_focus) {
233 if (this.searchcontext == null) {
237 Gtk.TextIter beg, st,en;
238 bool has_wrapped_around;
239 this.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );
241 if (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {
243 this.last_search_end = 0;
246 this.last_search_end = en.get_offset();
248 this.sourceview.el.grab_focus();
250 this.buffer.el.place_cursor(st);
251 this.sourceview.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);
252 var ln = st.get_line();
253 this.highlightNodeAtLine(ln);
256 public int search (string in_txt) {
257 this.notebook.el.page = 1;
261 var s = new GtkSource.SearchSettings();
262 s.case_sensitive = _this.case_sensitive.el.active;
263 s.regex_enabled = _this.regex.el.active;
264 s.wrap_around = false;
266 this.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);
267 this.searchcontext.set_highlight(true);
270 if (_this.multiline.el.active) {
271 txt = in_txt.replace("\\n", "\n");
274 s.set_search_text(txt);
275 Gtk.TextIter beg, st,en;
276 bool has_wrapped_around;
277 this.buffer.el.get_start_iter(out beg);
278 this.searchcontext.forward(beg, out st, out en, out has_wrapped_around);
279 this.last_search_end = 0;
281 return this.searchcontext.get_occurrences_count();
287 public void createThumb () {
290 if (this.file == null) {
293 // only screenshot the gtk preview..
294 if (this.notebook.el.page > 0 ) {
299 this.file.widgetToIcon(this.container.el);
308 // should we hold until it's printed...
314 public void updateErrorMarks () {
318 var buf = _this.buffer.el;
321 buf.get_bounds (out start, out end);
325 //GLib.debug("highlight errors");
327 // we should highlight other types of errors..
332 if (_this.file == null) {
333 GLib.debug("file is null?");
337 var ar = this.file.getErrors();
339 buf.remove_tag_by_name ("ERR", start, end);
340 buf.remove_tag_by_name ("WARN", start, end);
341 buf.remove_tag_by_name ("DEPR", start, end);
342 buf.remove_source_marks (start, end, "ERR");
343 buf.remove_source_marks (start, end, "WARN");
344 buf.remove_source_marks (start, end, "DEPR");
345 this.last_error_counter = file.error_counter ;
346 //GLib.debug("higjlight has no errors");
349 if (this.last_error_counter == file.error_counter) {
357 var tlines = buf.get_line_count () +1;
361 buf.remove_source_marks (start, end, "ERR");
362 buf.remove_source_marks (start, end, "WARN");
363 buf.remove_source_marks (start, end, "DEPR");
364 buf.remove_tag_by_name ("ERR", start, end);
365 buf.remove_tag_by_name ("WARN", start, end);
366 buf.remove_tag_by_name ("DEPR", start, end);
367 foreach(var diag in ar) {
371 // print("get inter\n");
372 var eline = (int)diag.range.start.line ;
373 var eline_to = (int)diag.range.end.line;
374 if (eline > tlines || eline < 0) {
379 buf.get_iter_at_line( out iter, eline);
381 buf.get_iter_at_line_offset( out start,
382 eline, (int)diag.range.start.character);
383 buf.get_iter_at_line_offset( out end,
384 eline_to, (int)diag.range.end.character);
386 buf.apply_tag_by_name(diag.category, start, end);
389 var msg = "Line: %d %s : %s".printf(eline+1, diag.category, diag.message);
390 buf.create_source_mark( msg, diag.category, iter);
391 GLib.debug("set line %d to %s", eline, msg);
392 //this.marks.set(eline, msg);
394 this.last_error_counter = file.error_counter ;
401 public void scroll_to_line (int line) {
404 GLib.Timeout.add(100, () => {
407 this.notebook.el.set_current_page(1);
409 var buf = this.sourceview.el.get_buffer();
411 var sbuf = (GtkSource.Buffer) buf;
415 sbuf.get_iter_at_line(out iter, line);
416 this.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);
422 public class Xcls_notebook : Object
424 public Gtk.Notebook el;
425 private Xcls_GtkView _this;
431 public Xcls_notebook(Xcls_GtkView _owner )
434 _this.notebook = this;
435 this.el = new Gtk.Notebook();
439 // set gobject values
440 this.el.overflow = Gtk.Overflow.VISIBLE;
441 new Xcls_label_preview( _this );
442 new Xcls_label_code( _this );
443 var child_3 = new Xcls_ScrolledWindow4( _this );
445 this.el.append_page ( child_3.el , _this.label_preview.el );
446 var child_4 = new Xcls_Box7( _this );
448 this.el.append_page ( child_4.el , _this.label_code.el );
451 // user defined functions
453 public class Xcls_label_preview : Object
456 private Xcls_GtkView _this;
462 public Xcls_label_preview(Xcls_GtkView _owner )
465 _this.label_preview = this;
466 this.el = new Gtk.Label( "Preview" );
470 // set gobject values
473 // user defined functions
476 public class Xcls_label_code : Object
479 private Xcls_GtkView _this;
485 public Xcls_label_code(Xcls_GtkView _owner )
488 _this.label_code = this;
489 this.el = new Gtk.Label( "Preview Generated Code" );
493 // set gobject values
496 // user defined functions
499 public class Xcls_ScrolledWindow4 : Object
501 public Gtk.ScrolledWindow el;
502 private Xcls_GtkView _this;
508 public Xcls_ScrolledWindow4(Xcls_GtkView _owner )
511 this.el = new Gtk.ScrolledWindow();
515 // set gobject values
516 new Xcls_view_layout( _this );
517 this.el.set_child ( _this.view_layout.el );
520 // user defined functions
522 public class Xcls_view_layout : Object
525 private Xcls_GtkView _this;
531 public Xcls_view_layout(Xcls_GtkView _owner )
534 _this.view_layout = this;
535 this.el = new Gtk.Fixed();
539 // set gobject values
540 this.el.name = "gtkview-view-layout";
541 new Xcls_container( _this );
542 this.el.put ( _this.container.el , 10,10 );
545 // user defined functions
547 public class Xcls_container : Object
550 private Xcls_GtkView _this;
556 public Xcls_container(Xcls_GtkView _owner )
559 _this.container = this;
560 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
564 // set gobject values
567 // user defined functions
572 public class Xcls_Box7 : Object
575 private Xcls_GtkView _this;
581 public Xcls_Box7(Xcls_GtkView _owner )
584 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
588 // set gobject values
589 new Xcls_sourceviewscroll( _this );
590 this.el.append( _this.sourceviewscroll.el );
591 var child_2 = new Xcls_Box13( _this );
593 this.el.append( child_2.el );
596 // user defined functions
598 public class Xcls_sourceviewscroll : Object
600 public Gtk.ScrolledWindow el;
601 private Xcls_GtkView _this;
607 public Xcls_sourceviewscroll(Xcls_GtkView _owner )
610 _this.sourceviewscroll = this;
611 this.el = new Gtk.ScrolledWindow();
615 // set gobject values
616 this.el.vexpand = true;
617 new Xcls_sourceview( _this );
618 this.el.set_child ( _this.sourceview.el );
621 // user defined functions
623 public class Xcls_sourceview : Object
625 public GtkSource.View el;
626 private Xcls_GtkView _this;
631 public string prop_selected;
632 public JsRender.Node? node_selected;
635 public Xcls_sourceview(Xcls_GtkView _owner )
638 _this.sourceview = this;
639 this.el = new GtkSource.View();
642 this.loading = false;
643 this.prop_selected = "\"\"";
645 // set gobject values
646 this.el.name = "gtkview-view";
647 this.el.editable = false;
648 this.el.show_line_marks = true;
649 this.el.show_line_numbers = true;
650 this.el.css_classes = { "code-editor" };
651 this.el.tab_width = 4;
652 new Xcls_buffer( _this );
653 this.el.set_buffer ( _this.buffer.el );
654 new Xcls_keystate( _this );
655 this.el.add_controller( _this.keystate.el );
656 var child_3 = new Xcls_EventControllerScroll12( _this );
658 this.el.add_controller( child_3.el );
668 var attrs = new GtkSource.MarkAttributes();
669 attrs.set_icon_name ( "process-stop");
670 attrs.query_tooltip_text.connect(( mark) => {
671 //print("tooltip query? %s\n", mark.name);
675 this.el.set_mark_attributes ("ERR", attrs, 1);
677 var wattrs = new GtkSource.MarkAttributes();
678 wattrs.set_icon_name ( "process-stop");
679 wattrs.query_tooltip_text.connect(( mark) => {
680 //print("tooltip query? %s\n", mark.name);
684 this.el.set_mark_attributes ("WARN", wattrs, 1);
688 var dattrs = new GtkSource.MarkAttributes();
689 dattrs.set_icon_name ( "process-stop");
690 dattrs.query_tooltip_text.connect(( mark) => {
691 //print("tooltip query? %s\n", mark.name);
695 this.el.set_mark_attributes ("DEPR", dattrs, 1);
698 var gattrs = new GtkSource.MarkAttributes();
699 var grey = Gdk.RGBA();
700 grey.parse ( "#ccc");
701 gattrs.set_background ( grey);
704 this.el.set_mark_attributes ("grey", gattrs, 1);
714 this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
716 //GLib.debug("query tooltip");
720 var yoff = (int) _this.sourceviewscroll.el.vadjustment.value;
722 this.el.get_iter_at_position (out iter, out trailing, x, y + yoff);
724 var l = iter.get_line();
725 // GLib.debug("query tooltip line %d", (int) l);
726 var marks = _this.buffer.el.get_source_marks_at_line(l, "ERR");
727 if (marks.is_empty()) {
728 marks = _this.buffer.el.get_source_marks_at_line(l, "WARN");
730 if (marks.is_empty()) {
731 marks = _this.buffer.el.get_source_marks_at_line(l, "DEPR");
734 // GLib.debug("query tooltip line marks %d", (int) marks.length());
736 marks.@foreach((m) => {
737 //GLib.debug("got mark %s", m.name);
738 str += (str.length > 0 ? "\n" : "") + m.name;
741 // true if there is a mark..
742 tooltip.set_text( str);
743 return str.length > 0 ? true : false;
748 // user defined functions
749 public void loadFile ( ) {
751 var buf = this.el.get_buffer();
754 var cpos = buf.cursor_position;
756 print("BEFORE LOAD cursor = %d\n", cpos);
757 var vadj_pos = this.el.get_vadjustment().get_value();
759 if (_this.file == null || _this.file.xtype != "Gtk") {
760 print("xtype != Gtk");
761 this.loading = false;
767 var regex = new Regex("\\.bjs$");
770 valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
771 } catch (GLib.RegexError e) {
772 this.loading = false;
777 if (!FileUtils.test(valafn,FileTest.IS_REGULAR) ) {
778 print("File path has no errors\n");
779 this.loading = false;
786 GLib.FileUtils.get_contents (valafn, out str);
788 this.loading = false;
792 var str = _this.file.toSource();
794 // print("setting str %d\n", str.length);
795 buf.set_text(str, str.length);
796 var lm = GtkSource.LanguageManager.get_default();
798 //?? is javascript going to work as js?
800 ((GtkSource.Buffer)(buf)) .set_language(lm.get_language(_this.file.language));
803 _this.main_window.windowstate.updateErrorMarksAll();
804 // restore the cursor position?
805 // after reloading the contents.
806 GLib.Timeout.add(500, () => {
807 _this.buffer.in_cursor_change = true;
808 print("RESORTING cursor to = %d\n", cpos);
809 Gtk.TextIter cpos_iter;
810 buf.get_iter_at_offset(out cpos_iter, cpos);
811 buf.place_cursor(cpos_iter);
813 this.el.get_vadjustment().set_value(vadj_pos);;
814 _this.buffer.in_cursor_change = false;
818 //_this.buffer.checkSyntax();
823 this.loading = false;
825 public void nodeSelected (JsRender.Node? sel, bool scroll) {
831 // this is connected in widnowstate
832 print("Roo-view - node selected\n");
833 var buf = this.el.get_buffer();
835 var sbuf = (GtkSource.Buffer) buf;
841 // clear all the marks..
845 sbuf.get_bounds (out start, out end);
846 sbuf.remove_source_marks (start, end, "grey");
848 this.node_selected = sel;
854 sbuf.get_iter_at_line(out iter, sel.line_start);
857 Gtk.TextIter cur_iter;
858 sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);
861 if (!_this.buffer.in_cursor_change) {
863 this.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);
868 for (var i = 0; i < buf.get_line_count();i++) {
869 if (i < sel.line_start || i > sel.line_end) {
871 sbuf.get_iter_at_line(out iter, i);
872 sbuf.create_source_mark(null, "grey", iter);
880 public string toString () {
883 this.el.get_buffer().get_start_iter(out s);
884 this.el.get_buffer().get_end_iter(out e);
885 var ret = this.el.get_buffer().get_text(s,e,true);
886 //print("TO STRING? " + ret);
890 public class Xcls_buffer : Object
892 public GtkSource.Buffer el;
893 private Xcls_GtkView _this;
897 public int error_line;
898 public bool in_cursor_change;
900 public int last_line;
903 public Xcls_buffer(Xcls_GtkView _owner )
907 this.el = new GtkSource.Buffer( null );
910 this.error_line = -1;
911 this.in_cursor_change = false;
915 // set gobject values
920 buf.create_tag ("bold", "weight", Pango.Weight.BOLD);
921 buf.create_tag ("type", "weight", Pango.Weight.BOLD, "foreground", "#204a87");
922 buf.create_tag ("keyword", "weight", Pango.Weight.BOLD, "foreground", "#a40000");
923 buf.create_tag ("text", "weight", Pango.Weight.NORMAL, "foreground", "#729fcf");
924 buf.create_tag ("number", "weight", Pango.Weight.BOLD, "foreground", "#ad7fa8");
925 buf.create_tag ("method", "weight", Pango.Weight.BOLD, "foreground", "#729fcf");
926 buf.create_tag ("property", "weight", Pango.Weight.BOLD, "foreground", "#BC1F51");
927 buf.create_tag ("variable", "weight", Pango.Weight.BOLD, "foreground", "#A518B5");
930 buf.create_tag ("ERR", "weight", Pango.Weight.BOLD, "background", "pink");
931 buf.create_tag ("WARN", "weight", Pango.Weight.BOLD, "background", "#ABF4EB");
932 buf.create_tag ("DEPR", "weight", Pango.Weight.BOLD, "background", "#EEA9FF");
935 this.el.cursor_moved.connect( ( ) => {
936 GLib.debug("cursor moved called");
939 if (this.in_cursor_change ) {
940 GLib.debug("cursor changed : %d [ignoring nested call)", this.el.cursor_position);
944 GLib.debug("cursor changed : %d", this.el.cursor_position);
946 this.el.get_iter_at_offset(out cpos, this.el.cursor_position);
948 var ln = cpos.get_line();
949 if (this.last_line == ln ){
953 var node = _this.file.lineToNode(ln);
956 print("can not find node\n");
959 this.in_cursor_change = true;
960 var ltree = _this.main_window.windowstate.left_tree;
961 ltree.model.selectNode(node);
962 this.in_cursor_change = false;
966 // user defined functions
969 public class Xcls_keystate : Object
971 public Gtk.EventControllerKey el;
972 private Xcls_GtkView _this;
976 public bool is_control;
979 public Xcls_keystate(Xcls_GtkView _owner )
982 _this.keystate = this;
983 this.el = new Gtk.EventControllerKey();
986 this.is_control = false;
988 // set gobject values
991 this.el.key_released.connect( (keyval, keycode, state) => {
993 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
994 this.is_control = false;
997 this.el.key_pressed.connect( (keyval, keycode, state) => {
999 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1000 this.is_control = true;
1003 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1004 GLib.debug("SAVE: ctrl-g pressed");
1005 _this.forwardSearch(true);
1008 if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1009 GLib.debug("SAVE: ctrl-f pressed");
1010 _this.search_entry.el.grab_focus();
1018 // user defined functions
1021 public class Xcls_EventControllerScroll12 : Object
1023 public Gtk.EventControllerScroll el;
1024 private Xcls_GtkView _this;
1028 public double distance;
1031 public Xcls_EventControllerScroll12(Xcls_GtkView _owner )
1034 this.el = new Gtk.EventControllerScroll( Gtk.EventControllerScrollFlags.VERTICAL );
1037 this.distance = 0.0f;
1039 // set gobject values
1042 this.el.scroll.connect( (dx, dy) => {
1043 if (!_this.keystate.is_control) {
1046 //GLib.debug("scroll %f", dy);
1048 this.distance += dy;
1049 if (this.distance < -1) {
1050 BuilderApplication.settings.editor_font_size ++;
1053 if (this.distance > 1) {
1054 BuilderApplication.settings.editor_font_size --;
1062 // user defined functions
1067 public class Xcls_Box13 : Object
1070 private Xcls_GtkView _this;
1076 public Xcls_Box13(Xcls_GtkView _owner )
1079 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1083 // set gobject values
1084 this.el.homogeneous = false;
1085 this.el.vexpand = false;
1086 new Xcls_search_entry( _this );
1087 this.el.append( _this.search_entry.el );
1088 new Xcls_search_results( _this );
1089 this.el.append( _this.search_results.el );
1090 new Xcls_nextBtn( _this );
1091 this.el.append( _this.nextBtn.el );
1092 new Xcls_backBtn( _this );
1093 this.el.append( _this.backBtn.el );
1094 var child_5 = new Xcls_MenuButton19( _this );
1096 this.el.append( child_5.el );
1099 // user defined functions
1101 public class Xcls_search_entry : Object
1103 public Gtk.SearchEntry el;
1104 private Xcls_GtkView _this;
1108 public Gtk.CssProvider css;
1111 public Xcls_search_entry(Xcls_GtkView _owner )
1114 _this.search_entry = this;
1115 this.el = new Gtk.SearchEntry();
1119 // set gobject values
1120 this.el.name = "gtkview-search-entry";
1121 this.el.hexpand = true;
1122 this.el.placeholder_text = "Press enter to search";
1123 this.el.search_delay = 3;
1124 var child_1 = new Xcls_EventControllerKey15( _this );
1126 this.el.add_controller( child_1.el );
1129 this.el.search_changed.connect( () => {
1131 _this.search(_this.search_entry.el.text);
1132 _this.search_results.updateResults();
1134 GLib.Timeout.add_seconds(1,() => {
1135 _this.search_results.updateResults();
1144 // user defined functions
1145 public void forwardSearch (bool change_focus) {
1148 _this.forwardSearch(change_focus);
1152 switch(_this.windowstate.state) {
1153 case WindowState.State.CODEONLY:
1154 //case WindowState.State.CODE:
1155 // search the code being edited..
1156 _this.windowstate.code_editor_tab.forwardSearch(change_focus);
1159 case WindowState.State.PREVIEW:
1160 if (_this.windowstate.file.xtype == "Gtk") {
1161 _this.windowstate.window_gladeview.forwardSearch(change_focus);
1163 _this.windowstate.window_rooview.forwardSearch(change_focus);
1172 public class Xcls_EventControllerKey15 : Object
1174 public Gtk.EventControllerKey el;
1175 private Xcls_GtkView _this;
1181 public Xcls_EventControllerKey15(Xcls_GtkView _owner )
1184 this.el = new Gtk.EventControllerKey();
1188 // set gobject values
1191 this.el.key_pressed.connect( (keyval, keycode, state) => {
1193 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1194 GLib.debug("SAVE: ctrl-g pressed");
1195 _this.forwardSearch(true);
1200 if (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {
1201 _this.forwardSearch(true);
1207 // print(event.key.keyval)
1213 // user defined functions
1217 public class Xcls_search_results : Object
1219 public Gtk.Label el;
1220 private Xcls_GtkView _this;
1226 public Xcls_search_results(Xcls_GtkView _owner )
1229 _this.search_results = this;
1230 this.el = new Gtk.Label( "No Results" );
1234 // set gobject values
1235 this.el.margin_end = 4;
1236 this.el.margin_start = 4;
1239 // user defined functions
1240 public void updateResults () {
1241 this.el.visible = true;
1243 var res = _this.searchcontext.get_occurrences_count();
1245 _this.search_results.el.label = "??? Matches";
1249 _this.nextBtn.el.sensitive = false;
1250 _this.backBtn.el.sensitive = false;
1253 _this.search_results.el.label = "%d Matches".printf(res);
1254 _this.nextBtn.el.sensitive = true;
1255 _this.backBtn.el.sensitive = true;
1258 _this.search_results.el.label = "No Matches";
1263 public class Xcls_nextBtn : Object
1265 public Gtk.Button el;
1266 private Xcls_GtkView _this;
1270 public bool always_show_image;
1273 public Xcls_nextBtn(Xcls_GtkView _owner )
1276 _this.nextBtn = this;
1277 this.el = new Gtk.Button();
1280 this.always_show_image = true;
1282 // set gobject values
1283 this.el.icon_name = "go-down";
1284 this.el.sensitive = false;
1287 this.el.clicked.connect( ( ) => {
1288 _this.forwardSearch(true);
1294 // user defined functions
1297 public class Xcls_backBtn : Object
1299 public Gtk.Button el;
1300 private Xcls_GtkView _this;
1304 public bool always_show_image;
1307 public Xcls_backBtn(Xcls_GtkView _owner )
1310 _this.backBtn = this;
1311 this.el = new Gtk.Button();
1314 this.always_show_image = true;
1316 // set gobject values
1317 this.el.icon_name = "go-up";
1318 this.el.sensitive = false;
1321 this.el.clicked.connect( ( ) => {
1323 _this.backSearch(true);
1328 // user defined functions
1331 public class Xcls_MenuButton19 : Object
1333 public Gtk.MenuButton el;
1334 private Xcls_GtkView _this;
1338 public bool always_show_image;
1341 public Xcls_MenuButton19(Xcls_GtkView _owner )
1344 this.el = new Gtk.MenuButton();
1347 this.always_show_image = true;
1349 // set gobject values
1350 this.el.icon_name = "emblem-system";
1351 this.el.always_show_arrow = true;
1352 new Xcls_search_settings( _this );
1353 this.el.popover = _this.search_settings.el;
1356 // user defined functions
1358 public class Xcls_search_settings : Object
1360 public Gtk.PopoverMenu el;
1361 private Xcls_GtkView _this;
1367 public Xcls_search_settings(Xcls_GtkView _owner )
1370 _this.search_settings = this;
1371 this.el = new Gtk.PopoverMenu.from_model(null);
1375 // set gobject values
1376 var child_1 = new Xcls_Box21( _this );
1378 this.el.set_child ( child_1.el );
1381 // user defined functions
1383 public class Xcls_Box21 : Object
1386 private Xcls_GtkView _this;
1392 public Xcls_Box21(Xcls_GtkView _owner )
1395 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1399 // set gobject values
1400 new Xcls_case_sensitive( _this );
1401 this.el.append( _this.case_sensitive.el );
1402 new Xcls_regex( _this );
1403 this.el.append( _this.regex.el );
1404 new Xcls_multiline( _this );
1405 this.el.append( _this.multiline.el );
1408 // user defined functions
1410 public class Xcls_case_sensitive : Object
1412 public Gtk.CheckButton el;
1413 private Xcls_GtkView _this;
1419 public Xcls_case_sensitive(Xcls_GtkView _owner )
1422 _this.case_sensitive = this;
1423 this.el = new Gtk.CheckButton();
1427 // set gobject values
1428 this.el.label = "Case Sensitive";
1431 // user defined functions
1434 public class Xcls_regex : Object
1436 public Gtk.CheckButton el;
1437 private Xcls_GtkView _this;
1443 public Xcls_regex(Xcls_GtkView _owner )
1447 this.el = new Gtk.CheckButton();
1451 // set gobject values
1452 this.el.label = "Regex";
1455 // user defined functions
1458 public class Xcls_multiline : Object
1460 public Gtk.CheckButton el;
1461 private Xcls_GtkView _this;
1467 public Xcls_multiline(Xcls_GtkView _owner )
1470 _this.multiline = this;
1471 this.el = new Gtk.CheckButton();
1475 // set gobject values
1476 this.el.label = "Multi-line (add \\n)";
1479 // user defined functions