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_search_entry search_entry;
24 public Xcls_search_results search_results;
25 public Xcls_nextBtn nextBtn;
26 public Xcls_backBtn backBtn;
27 public Xcls_search_settings search_settings;
28 public Xcls_case_sensitive case_sensitive;
29 public Xcls_regex regex;
30 public Xcls_multiline multiline;
33 public Gtk.Widget lastObj;
34 public Gtk.CssProvider css;
35 public Xcls_MainWindow main_window;
36 public GtkSource.SearchContext searchcontext;
37 public int last_error_counter;
38 public int last_search_end;
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 );
63 this.css = new Gtk.CssProvider();
65 this.css.load_from_string(
66 "#gtkview-view-layout { background-color: #ccc; }"
69 Gtk.StyleContext.add_provider_for_display(
70 this.el.get_display(),
72 Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
79 // user defined functions
80 public void loadFile (JsRender.JsRender file)
84 if (file.tree == null) {
87 this.last_error_counter = -1;
88 this.notebook.el.page = 0;// gtk preview
93 this.sourceview.loadFile();
95 this.searchcontext = null;
96 this.last_error_counter = -1;
97 this.updateErrorMarks();
98 if (this.lastObj != null) {
99 this.container.el.remove(this.lastObj);
102 // hide the compile view at present..
105 var w = this.el.get_width();
106 var h = this.el.get_height();
108 print("ALLOC SET SIZES %d, %d\n", w,h);
110 // set the container size min to 500/500 or 20 px less than max..
111 w = int.max (w-20, 500);
112 h = int.max (h-20, 500);
114 print("SET SIZES %d, %d\n", w,h);
115 _this.container.el.set_size_request(w,h);
117 _this.view_layout.el.set_size_request(w,h);
118 // should be baded on calc.. -- see update_scrolled.
120 var fc = this.container.el.get_first_child();
122 this.container.el.remove(fc);
125 var xmlstr = JsRender.NodeToGlade.mungeFile( file);
126 var builder = new Gtk.Builder.from_string (xmlstr, xmlstr.length);
127 var obj = (Gtk.Widget) builder.get_object("w"+ file.tree.oid.to_string());
128 this.container.el.append(obj);
136 public void highlightNodeAtLine (int ln) {
138 // this is done from clicking on the editor..
143 var node = _this.file.lineToNode(ln+1);
146 //print("can not find node\n");
149 var prop = node.lineToProp(ln+1);
150 print("prop : %s", prop == null ? "???" : prop.name);
153 // ---------- this selects the tree's node...
155 var ltree = _this.main_window.windowstate.left_tree;
156 ltree.model.selectNode(node);
157 //var tp = ltree.model.treePathFromNode(node);
159 //print("got tree path %s\n", tp);
163 //_this.sourceview.allow_node_scroll = false; /// block node scrolling..
166 //print("changing cursor on tree..\n");
170 // let's try allowing editing on the methods.
171 // a little klunky at present..
172 _this.sourceview.prop_selected = "";
175 //see if we can find it..
176 var kv = prop.split(":");
179 //var k = prop.get_key(kv[1]);
180 // fixme -- need to determine if it's an editable property...
181 _this.sourceview.prop_selected = prop;
183 } else if (kv[0] == "l") {
184 _this.sourceview.prop_selected = prop;
189 //ltree.view.setCursor(tp, "editor");
190 // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false);
191 _this.sourceview.nodeSelected(node,false);
193 // scrolling is disabled... as node selection calls scroll 10ms after it changes.
194 // GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {
195 // this.allow_node_scroll = true;
211 public void forwardSearch (bool change_focus) {
213 if (this.searchcontext == null) {
216 this.notebook.el.page = 1;
217 Gtk.TextIter beg, st,en;
218 bool has_wrapped_around;
219 var buf = this.sourceview.el.get_buffer();
220 buf.get_iter_at_offset(out beg, this.last_search_end);
221 if (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {
222 this.last_search_end = 0;
225 this.last_search_end = en.get_offset();
227 this.sourceview.el.grab_focus();
229 buf.place_cursor(st);
233 this.sourceview.el.scroll_to_iter(st, 0.0f, true, 0.0f, 0.5f);
236 var ln = st.get_line();
238 this.highlightNodeAtLine(ln);
240 public void backSearch (bool change_focus) {
242 if (this.searchcontext == null) {
246 Gtk.TextIter beg, st,en;
247 bool has_wrapped_around;
248 this.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );
250 if (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {
252 this.last_search_end = 0;
255 this.last_search_end = en.get_offset();
257 this.sourceview.el.grab_focus();
259 this.buffer.el.place_cursor(st);
260 this.sourceview.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);
261 var ln = st.get_line();
262 this.highlightNodeAtLine(ln);
265 public int search (string in_txt) {
266 this.notebook.el.page = 1;
270 var s = new GtkSource.SearchSettings();
271 s.case_sensitive = _this.case_sensitive.el.active;
272 s.regex_enabled = _this.regex.el.active;
273 s.wrap_around = false;
275 this.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);
276 this.searchcontext.set_highlight(true);
279 if (_this.multiline.el.active) {
280 txt = in_txt.replace("\\n", "\n");
283 s.set_search_text(txt);
284 Gtk.TextIter beg, st,en;
285 bool has_wrapped_around;
286 this.buffer.el.get_start_iter(out beg);
287 this.searchcontext.forward(beg, out st, out en, out has_wrapped_around);
288 this.last_search_end = 0;
290 return this.searchcontext.get_occurrences_count();
296 public void createThumb () {
299 if (this.file == null) {
302 // only screenshot the gtk preview..
303 if (this.notebook.el.page > 0 ) {
308 this.file.widgetToIcon(this.container.el);
317 // should we hold until it's printed...
323 public void updateErrorMarks () {
327 var buf = _this.buffer.el;
330 buf.get_bounds (out start, out end);
334 GLib.debug("highlight errors");
336 // we should highlight other types of errors..
341 if (_this.file == null) {
342 GLib.debug("file is null?");
346 var ar = this.file.getErrors();
348 buf.remove_tag_by_name ("ERR", start, end);
349 buf.remove_tag_by_name ("WARN", start, end);
350 buf.remove_tag_by_name ("DEPR", start, end);
351 buf.remove_source_marks (start, end, null);
352 this.last_error_counter = file.error_counter ;
353 GLib.debug("higjlight has no errors");
356 if (this.last_error_counter == file.error_counter) {
364 var tlines = buf.get_line_count () +1;
368 buf.remove_source_marks (start, end, null);
369 buf.remove_tag_by_name ("ERR", start, end);
370 buf.remove_tag_by_name ("WARN", start, end);
371 buf.remove_tag_by_name ("DEPR", start, end);
372 foreach(var diag in ar) {
376 // print("get inter\n");
377 var eline = (int)diag.range.start.line ;
378 var eline_to = (int)diag.range.end.line;
379 if (eline > tlines || eline < 0) {
384 buf.get_iter_at_line( out iter, eline);
386 buf.get_iter_at_line_offset( out start,
387 eline, (int)diag.range.start.character);
388 buf.get_iter_at_line_offset( out end,
389 eline_to, (int)diag.range.end.character);
391 buf.apply_tag_by_name(diag.category, start, end);
394 var msg = "Line: %d %s : %s".printf(eline+1, diag.category, diag.message);
395 buf.create_source_mark( msg, diag.category, iter);
396 GLib.debug("set line %d to %s", eline, msg);
397 //this.marks.set(eline, msg);
399 this.last_error_counter = file.error_counter ;
406 public void scroll_to_line (int line) {
409 GLib.Timeout.add(100, () => {
412 this.notebook.el.set_current_page(1);
414 var buf = this.sourceview.el.get_buffer();
416 var sbuf = (GtkSource.Buffer) buf;
420 sbuf.get_iter_at_line(out iter, line);
421 this.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);
427 public class Xcls_notebook : Object
429 public Gtk.Notebook el;
430 private Xcls_GtkView _this;
436 public Xcls_notebook(Xcls_GtkView _owner )
439 _this.notebook = this;
440 this.el = new Gtk.Notebook();
444 // set gobject values
445 this.el.overflow = Gtk.Overflow.VISIBLE;
446 new Xcls_label_preview( _this );
447 new Xcls_label_code( _this );
448 var child_3 = new Xcls_ScrolledWindow5( _this );
450 this.el.append_page ( child_3.el , _this.label_preview.el );
451 var child_4 = new Xcls_Box8( _this );
453 this.el.append_page ( child_4.el , _this.label_code.el );
456 // user defined functions
458 public class Xcls_label_preview : Object
461 private Xcls_GtkView _this;
467 public Xcls_label_preview(Xcls_GtkView _owner )
470 _this.label_preview = this;
471 this.el = new Gtk.Label( "Preview" );
475 // set gobject values
478 // user defined functions
481 public class Xcls_label_code : Object
484 private Xcls_GtkView _this;
490 public Xcls_label_code(Xcls_GtkView _owner )
493 _this.label_code = this;
494 this.el = new Gtk.Label( "Preview Generated Code" );
498 // set gobject values
501 // user defined functions
504 public class Xcls_ScrolledWindow5 : Object
506 public Gtk.ScrolledWindow el;
507 private Xcls_GtkView _this;
513 public Xcls_ScrolledWindow5(Xcls_GtkView _owner )
516 this.el = new Gtk.ScrolledWindow();
520 // set gobject values
521 new Xcls_view_layout( _this );
522 this.el.set_child ( _this.view_layout.el );
525 // user defined functions
527 public class Xcls_view_layout : Object
530 private Xcls_GtkView _this;
536 public Xcls_view_layout(Xcls_GtkView _owner )
539 _this.view_layout = this;
540 this.el = new Gtk.Fixed();
544 // set gobject values
545 this.el.name = "gtkview-view-layout";
546 new Xcls_container( _this );
547 this.el.put ( _this.container.el , 10,10 );
550 // user defined functions
552 public class Xcls_container : Object
555 private Xcls_GtkView _this;
561 public Xcls_container(Xcls_GtkView _owner )
564 _this.container = this;
565 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
569 // set gobject values
572 // user defined functions
577 public class Xcls_Box8 : Object
580 private Xcls_GtkView _this;
586 public Xcls_Box8(Xcls_GtkView _owner )
589 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
593 // set gobject values
594 new Xcls_sourceviewscroll( _this );
595 this.el.append( _this.sourceviewscroll.el );
596 var child_2 = new Xcls_Box13( _this );
598 this.el.append( child_2.el );
601 // user defined functions
603 public class Xcls_sourceviewscroll : Object
605 public Gtk.ScrolledWindow el;
606 private Xcls_GtkView _this;
612 public Xcls_sourceviewscroll(Xcls_GtkView _owner )
615 _this.sourceviewscroll = this;
616 this.el = new Gtk.ScrolledWindow();
620 // set gobject values
621 this.el.vexpand = true;
622 new Xcls_sourceview( _this );
623 this.el.set_child ( _this.sourceview.el );
626 // user defined functions
628 public class Xcls_sourceview : Object
630 public GtkSource.View el;
631 private Xcls_GtkView _this;
636 public bool zallow_node_scroll;
637 public string prop_selected;
638 public Gtk.CssProvider css;
639 public JsRender.Node? node_selected;
642 public Xcls_sourceview(Xcls_GtkView _owner )
645 _this.sourceview = this;
646 this.el = new GtkSource.View();
649 this.loading = false;
650 this.zallow_node_scroll = true;
651 this.prop_selected = "";
653 // set gobject values
654 this.el.name = "gtkview-view";
655 this.el.editable = false;
656 this.el.show_line_marks = true;
657 this.el.show_line_numbers = true;
658 this.el.tab_width = 4;
659 new Xcls_buffer( _this );
660 this.el.set_buffer ( _this.buffer.el );
661 var child_2 = new Xcls_EventControllerKey12( _this );
663 this.el.add_controller( child_2.el );
670 this.css = new Gtk.CssProvider();
672 this.css.load_from_string("#gtkview-view { font: 10px monospace ;}");
674 Gtk.StyleContext.add_provider_for_display(
675 this.el.get_display(),
677 Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
685 var attrs = new GtkSource.MarkAttributes();
686 attrs.set_icon_name ( "process-stop");
687 attrs.query_tooltip_text.connect(( mark) => {
688 //print("tooltip query? %s\n", mark.name);
692 this.el.set_mark_attributes ("ERR", attrs, 1);
694 var wattrs = new GtkSource.MarkAttributes();
695 wattrs.set_icon_name ( "process-stop");
696 wattrs.query_tooltip_text.connect(( mark) => {
697 //print("tooltip query? %s\n", mark.name);
701 this.el.set_mark_attributes ("WARN", wattrs, 1);
705 var dattrs = new GtkSource.MarkAttributes();
706 dattrs.set_icon_name ( "process-stop");
707 dattrs.query_tooltip_text.connect(( mark) => {
708 //print("tooltip query? %s\n", mark.name);
712 this.el.set_mark_attributes ("DEPR", dattrs, 1);
715 var gattrs = new GtkSource.MarkAttributes();
716 var grey = Gdk.RGBA();
717 grey.parse ( "#ccc");
718 gattrs.set_background ( grey);
721 this.el.set_mark_attributes ("grey", gattrs, 1);
731 this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
733 //GLib.debug("query tooltip");
737 var yoff = (int) _this.sourceviewscroll.el.vadjustment.value;
739 this.el.get_iter_at_position (out iter, out trailing, x, y + yoff);
741 var l = iter.get_line();
742 // GLib.debug("query tooltip line %d", (int) l);
743 var marks = _this.buffer.el.get_source_marks_at_line(l, "ERR");
744 if (marks.is_empty()) {
745 marks = _this.buffer.el.get_source_marks_at_line(l, "WARN");
747 if (marks.is_empty()) {
748 marks = _this.buffer.el.get_source_marks_at_line(l, "DEPR");
751 // GLib.debug("query tooltip line marks %d", (int) marks.length());
753 marks.@foreach((m) => {
754 //GLib.debug("got mark %s", m.name);
755 str += (str.length > 0 ? "\n" : "") + m.name;
758 // true if there is a mark..
759 tooltip.set_text( str);
760 return str.length > 0 ? true : false;
765 // user defined functions
766 public void loadFile ( ) {
768 var buf = this.el.get_buffer();
770 var sbuf = (GtkSource.Buffer) buf;
771 var cpos = buf.cursor_position;
773 print("BEFORE LOAD cursor = %d\n", cpos);
774 var vadj_pos = this.el.get_vadjustment().get_value();
776 if (_this.file == null || _this.file.xtype != "Gtk") {
777 print("xtype != Gtk");
778 this.loading = false;
784 var regex = new Regex("\\.bjs$");
787 valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
788 } catch (GLib.RegexError e) {
789 this.loading = false;
794 if (!FileUtils.test(valafn,FileTest.IS_REGULAR) ) {
795 print("File path has no errors\n");
796 this.loading = false;
803 GLib.FileUtils.get_contents (valafn, out str);
805 this.loading = false;
809 var str = _this.file.toSource();
811 // print("setting str %d\n", str.length);
812 buf.set_text(str, str.length);
813 var lm = GtkSource.LanguageManager.get_default();
815 //?? is javascript going to work as js?
817 ((GtkSource.Buffer)(buf)) .set_language(lm.get_language(_this.file.language));
820 _this.main_window.windowstate.updateErrorMarksAll();
821 // restore the cursor position?
822 // after reloading the contents.
823 GLib.Timeout.add(500, () => {
824 _this.buffer.in_cursor_change = true;
825 print("RESORTING cursor to = %d\n", cpos);
826 Gtk.TextIter cpos_iter;
827 buf.get_iter_at_offset(out cpos_iter, cpos);
828 buf.place_cursor(cpos_iter);
830 this.el.get_vadjustment().set_value(vadj_pos);;
831 _this.buffer.in_cursor_change = false;
835 //_this.buffer.checkSyntax();
840 this.loading = false;
842 public void nodeSelected (JsRender.Node? sel, bool scroll) {
848 // this is connected in widnowstate
849 print("Roo-view - node selected\n");
850 var buf = this.el.get_buffer();
852 var sbuf = (GtkSource.Buffer) buf;
858 // clear all the marks..
862 sbuf.get_bounds (out start, out end);
863 sbuf.remove_source_marks (start, end, "grey");
865 this.node_selected = sel;
871 sbuf.get_iter_at_line(out iter, sel.line_start);
874 Gtk.TextIter cur_iter;
875 sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);
878 if (!_this.buffer.in_cursor_change) {
880 this.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);
885 for (var i = 0; i < buf.get_line_count();i++) {
886 if (i < sel.line_start || i > sel.line_end) {
888 sbuf.get_iter_at_line(out iter, i);
889 sbuf.create_source_mark(null, "grey", iter);
897 public string toString () {
900 this.el.get_buffer().get_start_iter(out s);
901 this.el.get_buffer().get_end_iter(out e);
902 var ret = this.el.get_buffer().get_text(s,e,true);
903 //print("TO STRING? " + ret);
907 public class Xcls_buffer : Object
909 public GtkSource.Buffer el;
910 private Xcls_GtkView _this;
914 public int error_line;
915 public bool in_cursor_change;
917 public int last_line;
920 public Xcls_buffer(Xcls_GtkView _owner )
924 this.el = new GtkSource.Buffer( null );
927 this.error_line = -1;
928 this.in_cursor_change = false;
932 // set gobject values
937 buf.create_tag ("bold", "weight", Pango.Weight.BOLD);
938 buf.create_tag ("type", "weight", Pango.Weight.BOLD, "foreground", "#204a87");
939 buf.create_tag ("keyword", "weight", Pango.Weight.BOLD, "foreground", "#a40000");
940 buf.create_tag ("text", "weight", Pango.Weight.NORMAL, "foreground", "#729fcf");
941 buf.create_tag ("number", "weight", Pango.Weight.BOLD, "foreground", "#ad7fa8");
942 buf.create_tag ("method", "weight", Pango.Weight.BOLD, "foreground", "#729fcf");
943 buf.create_tag ("property", "weight", Pango.Weight.BOLD, "foreground", "#BC1F51");
944 buf.create_tag ("variable", "weight", Pango.Weight.BOLD, "foreground", "#A518B5");
947 buf.create_tag ("ERR", "weight", Pango.Weight.BOLD, "background", "pink");
948 buf.create_tag ("WARN", "weight", Pango.Weight.BOLD, "background", "#ABF4EB");
949 buf.create_tag ("DEPR", "weight", Pango.Weight.BOLD, "background", "#EEA9FF");
952 this.el.cursor_moved.connect( ( ) => {
953 GLib.debug("cursor moved called");
956 if (this.in_cursor_change ) {
957 GLib.debug("cursor changed : %d [ignoring nested call)", this.el.cursor_position);
961 GLib.debug("cursor changed : %d", this.el.cursor_position);
963 this.el.get_iter_at_offset(out cpos, this.el.cursor_position);
965 var ln = cpos.get_line();
966 if (this.last_line == ln ){
970 var node = _this.file.lineToNode(ln);
973 print("can not find node\n");
976 this.in_cursor_change = true;
977 var ltree = _this.main_window.windowstate.left_tree;
978 ltree.model.selectNode(node);
979 this.in_cursor_change = false;
983 // user defined functions
986 public class Xcls_EventControllerKey12 : Object
988 public Gtk.EventControllerKey el;
989 private Xcls_GtkView _this;
995 public Xcls_EventControllerKey12(Xcls_GtkView _owner )
998 this.el = new Gtk.EventControllerKey();
1002 // set gobject values
1005 this.el.key_pressed.connect( (keyval, keycode, state) => {
1009 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1010 GLib.debug("SAVE: ctrl-g pressed");
1011 _this.forwardSearch(true);
1014 if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1015 GLib.debug("SAVE: ctrl-f pressed");
1016 _this.search_entry.el.grab_focus();
1024 // user defined functions
1029 public class Xcls_Box13 : Object
1032 private Xcls_GtkView _this;
1038 public Xcls_Box13(Xcls_GtkView _owner )
1041 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1045 // set gobject values
1046 this.el.homogeneous = false;
1047 this.el.vexpand = false;
1048 new Xcls_search_entry( _this );
1049 this.el.append( _this.search_entry.el );
1050 new Xcls_search_results( _this );
1051 this.el.append( _this.search_results.el );
1052 new Xcls_nextBtn( _this );
1053 this.el.append( _this.nextBtn.el );
1054 new Xcls_backBtn( _this );
1055 this.el.append( _this.backBtn.el );
1056 var child_5 = new Xcls_MenuButton19( _this );
1058 this.el.append( child_5.el );
1061 // user defined functions
1063 public class Xcls_search_entry : Object
1065 public Gtk.SearchEntry el;
1066 private Xcls_GtkView _this;
1070 public Gtk.CssProvider css;
1073 public Xcls_search_entry(Xcls_GtkView _owner )
1076 _this.search_entry = this;
1077 this.el = new Gtk.SearchEntry();
1081 // set gobject values
1082 this.el.name = "gtkview-search-entry";
1083 this.el.hexpand = true;
1084 this.el.placeholder_text = "Press enter to search";
1085 this.el.search_delay = 3;
1086 var child_1 = new Xcls_EventControllerKey15( _this );
1088 this.el.add_controller( child_1.el );
1092 this.css = new Gtk.CssProvider();
1094 this.css.load_from_string("
1095 #gtkview-search-entry { font: 10px monospace ;}"
1098 Gtk.StyleContext.add_provider_for_display(
1099 this.el.get_display(),
1101 Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
1105 this.el.search_changed.connect( () => {
1107 _this.search(_this.search_entry.el.text);
1108 _this.search_results.updateResults();
1110 GLib.Timeout.add_seconds(1,() => {
1111 _this.search_results.updateResults();
1120 // user defined functions
1121 public void forwardSearch (bool change_focus) {
1124 _this.forwardSearch(change_focus);
1128 switch(_this.windowstate.state) {
1129 case WindowState.State.CODEONLY:
1130 //case WindowState.State.CODE:
1131 // search the code being edited..
1132 _this.windowstate.code_editor_tab.forwardSearch(change_focus);
1135 case WindowState.State.PREVIEW:
1136 if (_this.windowstate.file.xtype == "Gtk") {
1137 _this.windowstate.window_gladeview.forwardSearch(change_focus);
1139 _this.windowstate.window_rooview.forwardSearch(change_focus);
1148 public class Xcls_EventControllerKey15 : Object
1150 public Gtk.EventControllerKey el;
1151 private Xcls_GtkView _this;
1157 public Xcls_EventControllerKey15(Xcls_GtkView _owner )
1160 this.el = new Gtk.EventControllerKey();
1164 // set gobject values
1167 this.el.key_pressed.connect( (keyval, keycode, state) => {
1169 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1170 GLib.debug("SAVE: ctrl-g pressed");
1171 _this.forwardSearch(true);
1176 if (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {
1177 _this.forwardSearch(true);
1183 // print(event.key.keyval)
1189 // user defined functions
1193 public class Xcls_search_results : Object
1195 public Gtk.Label el;
1196 private Xcls_GtkView _this;
1202 public Xcls_search_results(Xcls_GtkView _owner )
1205 _this.search_results = this;
1206 this.el = new Gtk.Label( "No Results" );
1210 // set gobject values
1211 this.el.margin_end = 4;
1212 this.el.margin_start = 4;
1215 // user defined functions
1216 public void updateResults () {
1217 this.el.visible = true;
1219 var res = _this.searchcontext.get_occurrences_count();
1221 _this.search_results.el.label = "??? Matches";
1225 _this.nextBtn.el.sensitive = false;
1226 _this.backBtn.el.sensitive = false;
1229 _this.search_results.el.label = "%d Matches".printf(res);
1230 _this.nextBtn.el.sensitive = true;
1231 _this.backBtn.el.sensitive = true;
1234 _this.search_results.el.label = "No Matches";
1239 public class Xcls_nextBtn : Object
1241 public Gtk.Button el;
1242 private Xcls_GtkView _this;
1246 public bool always_show_image;
1249 public Xcls_nextBtn(Xcls_GtkView _owner )
1252 _this.nextBtn = this;
1253 this.el = new Gtk.Button();
1256 this.always_show_image = true;
1258 // set gobject values
1259 this.el.icon_name = "go-down";
1260 this.el.sensitive = false;
1263 this.el.clicked.connect( ( ) => {
1264 _this.forwardSearch(true);
1270 // user defined functions
1273 public class Xcls_backBtn : Object
1275 public Gtk.Button el;
1276 private Xcls_GtkView _this;
1280 public bool always_show_image;
1283 public Xcls_backBtn(Xcls_GtkView _owner )
1286 _this.backBtn = this;
1287 this.el = new Gtk.Button();
1290 this.always_show_image = true;
1292 // set gobject values
1293 this.el.icon_name = "go-up";
1294 this.el.sensitive = false;
1297 this.el.clicked.connect( ( ) => {
1299 _this.backSearch(true);
1304 // user defined functions
1307 public class Xcls_MenuButton19 : Object
1309 public Gtk.MenuButton el;
1310 private Xcls_GtkView _this;
1314 public bool always_show_image;
1317 public Xcls_MenuButton19(Xcls_GtkView _owner )
1320 this.el = new Gtk.MenuButton();
1323 this.always_show_image = true;
1325 // set gobject values
1326 this.el.icon_name = "emblem-system";
1327 this.el.always_show_arrow = true;
1328 new Xcls_search_settings( _this );
1329 this.el.popover = _this.search_settings.el;
1332 // user defined functions
1334 public class Xcls_search_settings : Object
1336 public Gtk.PopoverMenu el;
1337 private Xcls_GtkView _this;
1343 public Xcls_search_settings(Xcls_GtkView _owner )
1346 _this.search_settings = this;
1347 this.el = new Gtk.PopoverMenu.from_model(null);
1351 // set gobject values
1352 var child_1 = new Xcls_Box21( _this );
1354 this.el.set_child ( child_1.el );
1357 // user defined functions
1359 public class Xcls_Box21 : Object
1362 private Xcls_GtkView _this;
1368 public Xcls_Box21(Xcls_GtkView _owner )
1371 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1375 // set gobject values
1376 new Xcls_case_sensitive( _this );
1377 this.el.append( _this.case_sensitive.el );
1378 new Xcls_regex( _this );
1379 this.el.append( _this.regex.el );
1380 new Xcls_multiline( _this );
1381 this.el.append( _this.multiline.el );
1384 // user defined functions
1386 public class Xcls_case_sensitive : Object
1388 public Gtk.CheckButton el;
1389 private Xcls_GtkView _this;
1395 public Xcls_case_sensitive(Xcls_GtkView _owner )
1398 _this.case_sensitive = this;
1399 this.el = new Gtk.CheckButton();
1403 // set gobject values
1404 this.el.label = "Case Sensitive";
1407 // user defined functions
1410 public class Xcls_regex : Object
1412 public Gtk.CheckButton el;
1413 private Xcls_GtkView _this;
1419 public Xcls_regex(Xcls_GtkView _owner )
1423 this.el = new Gtk.CheckButton();
1427 // set gobject values
1428 this.el.label = "Regex";
1431 // user defined functions
1434 public class Xcls_multiline : Object
1436 public Gtk.CheckButton el;
1437 private Xcls_GtkView _this;
1443 public Xcls_multiline(Xcls_GtkView _owner )
1446 _this.multiline = this;
1447 this.el = new Gtk.CheckButton();
1451 // set gobject values
1452 this.el.label = "Multi-line (add \\n)";
1455 // user defined functions