From 49176ef8e368ad253267f5c69e1cc36b22032871 Mon Sep 17 00:00:00 2001 From: Alan Date: Thu, 18 Aug 2022 19:42:51 +0800 Subject: [PATCH] Fix #7353 - context on next/back on searching --- src/Builder4/Editor.bjs | 53 ++++++++++------ src/Builder4/Editor.vala | 103 +++++++++++++++---------------- src/Builder4/GtkView.bjs | 55 +++++++++++------ src/Builder4/GtkView.vala | 105 ++++++++++++++++---------------- src/Builder4/WindowRooView.bjs | 55 +++++++++++------ src/Builder4/WindowRooView.vala | 105 ++++++++++++++++---------------- src/Builder4/WindowState.vala | 2 - 7 files changed, 264 insertions(+), 214 deletions(-) diff --git a/src/Builder4/Editor.bjs b/src/Builder4/Editor.bjs index b871c8692..8a457c131 100644 --- a/src/Builder4/Editor.bjs +++ b/src/Builder4/Editor.bjs @@ -594,11 +594,13 @@ " ", " \tif (event.keyval == Gdk.Key.Return && this.el.text.length > 0) {", "\t\tvar res = _this.search(this.el.text);", - "\t\tif (res > 0) {", - "\t\t\t_this.search_results.el.label = \"%d Matches\".printf(res);", - "\t\t} else {", - "\t\t\t_this.search_results.el.label = \"No Matches\";", - "\t\t}", + "\t\t _this.search_results.updateResults();", + "", + "\t\tGLib.Timeout.add_seconds(2,() => {", + "\t\t\t _this.search_results.updateResults();", + "\t\t\t return false;", + "\t\t });", + "\t ", "\t\t", "\t return true;", "", @@ -649,18 +651,9 @@ { "$ xns" : "Gtk", "* pack" : "add", - "Xcls_ValaCompileErrors popup" : "", "bool always_show_image" : true, + "bool visible" : false, "id" : "search_results", - "items" : [ - { - "$ xns" : "Gtk", - "* pack" : "set_image", - "bool sensitive" : false, - "utf8 icon_name" : "system-search", - "xtype" : "Image" - } - ], "listeners" : { "button_press_event" : [ "() => {", @@ -677,8 +670,30 @@ "}" ] }, - "string label" : "Matches", - "xtype" : "ImageMenuItem" + "xtype" : "ImageMenuItem", + "| void updateResults" : [ + "() {", + "\tthis.el.visible = true;", + "\t", + "\tvar res = _this.searchcontext.get_occurrences_count();", + "\tif (res < 0) {", + "\t\t_this.search_results.el.label = \"??? Matches\";\t\t", + "\t\treturn;", + "\t}", + "", + "\t_this.nextBtn.el.sensitive = false;", + "\t_this.backBtn.el.sensitive = false;\t", + "", + "\tif (res > 0) {", + "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);", + "\t\t_this.nextBtn.el.sensitive = true;", + "\t\t_this.backBtn.el.sensitive = true;", + "\t\treturn;", + "\t} ", + "\t_this.search_results.el.label = \"No Matches\";", + "\t", + "}" + ] } ], "xtype" : "MenuBar" @@ -686,6 +701,8 @@ { "$ xns" : "Gtk", "bool always_show_image" : true, + "bool sensitive" : false, + "id" : "nextBtn", "items" : [ { "$ xns" : "Gtk", @@ -711,6 +728,8 @@ { "$ xns" : "Gtk", "bool always_show_image" : true, + "bool sensitive" : false, + "id" : "backBtn", "items" : [ { "$ xns" : "Gtk", diff --git a/src/Builder4/Editor.vala b/src/Builder4/Editor.vala index 0bcbaaaab..345ac2100 100644 --- a/src/Builder4/Editor.vala +++ b/src/Builder4/Editor.vala @@ -19,6 +19,8 @@ public class Editor : Object public Xcls_buffer buffer; public Xcls_search_entry search_entry; public Xcls_search_results search_results; + public Xcls_nextBtn nextBtn; + public Xcls_backBtn backBtn; public Xcls_search_settings search_settings; public Xcls_case_sensitive case_sensitive; public Xcls_regex regex; @@ -907,13 +909,13 @@ public class Editor : Object var child_1 = new Xcls_MenuBar14( _this ); child_1.ref(); this.el.add ( child_1.el ); - var child_2 = new Xcls_Button17( _this ); + var child_2 = new Xcls_nextBtn( _this ); child_2.ref(); this.el.add( child_2.el ); - var child_3 = new Xcls_Button19( _this ); + var child_3 = new Xcls_backBtn( _this ); child_3.ref(); this.el.add( child_3.el ); - var child_4 = new Xcls_MenuButton21( _this ); + var child_4 = new Xcls_MenuButton20( _this ); child_4.ref(); this.el.add( child_4.el ); } @@ -959,11 +961,13 @@ public class Editor : Object if (event.keyval == Gdk.Key.Return && this.el.text.length > 0) { var res = _this.search(this.el.text); - if (res > 0) { - _this.search_results.el.label = "%d Matches".printf(res); - } else { - _this.search_results.el.label = "No Matches"; - } + _this.search_results.updateResults(); + + GLib.Timeout.add_seconds(2,() => { + _this.search_results.updateResults(); + return false; + }); + return true; @@ -1069,7 +1073,6 @@ public class Editor : Object // my vars (def) - public Xcls_ValaCompileErrors popup; // ctor public Xcls_search_results(Editor _owner ) @@ -1082,10 +1085,7 @@ public class Editor : Object // set gobject values this.el.always_show_image = true; - this.el.label = "Matches"; - var child_0 = new Xcls_Image16( _this ); - child_0.ref(); - this.el.set_image ( child_0.el ); + this.el.visible = false; //listeners this.el.button_press_event.connect( () => { @@ -1103,34 +1103,31 @@ public class Editor : Object } // user defined functions - } - public class Xcls_Image16 : Object - { - public Gtk.Image el; - private Editor _this; - - - // my vars (def) - - // ctor - public Xcls_Image16(Editor _owner ) - { - _this = _owner; - this.el = new Gtk.Image(); - - // my vars (dec) - - // set gobject values - this.el.icon_name = "system-search"; - this.el.sensitive = false; + public void updateResults () { + this.el.visible = true; + + var res = _this.searchcontext.get_occurrences_count(); + if (res < 0) { + _this.search_results.el.label = "??? Matches"; + return; + } + + _this.nextBtn.el.sensitive = false; + _this.backBtn.el.sensitive = false; + + if (res > 0) { + _this.search_results.el.label = "%d Matches".printf(res); + _this.nextBtn.el.sensitive = true; + _this.backBtn.el.sensitive = true; + return; + } + _this.search_results.el.label = "No Matches"; + } - - // user defined functions } - - public class Xcls_Button17 : Object + public class Xcls_nextBtn : Object { public Gtk.Button el; private Editor _this; @@ -1139,9 +1136,10 @@ public class Editor : Object // my vars (def) // ctor - public Xcls_Button17(Editor _owner ) + public Xcls_nextBtn(Editor _owner ) { _this = _owner; + _this.nextBtn = this; this.el = new Gtk.Button(); // my vars (dec) @@ -1149,7 +1147,8 @@ public class Editor : Object // set gobject values this.el.always_show_image = true; this.el.label = "Next"; - var child_0 = new Xcls_Image18( _this ); + this.el.sensitive = false; + var child_0 = new Xcls_Image17( _this ); child_0.ref(); this.el.image = child_0.el; @@ -1164,7 +1163,7 @@ public class Editor : Object // user defined functions } - public class Xcls_Image18 : Object + public class Xcls_Image17 : Object { public Gtk.Image el; private Editor _this; @@ -1173,7 +1172,7 @@ public class Editor : Object // my vars (def) // ctor - public Xcls_Image18(Editor _owner ) + public Xcls_Image17(Editor _owner ) { _this = _owner; this.el = new Gtk.Image(); @@ -1188,7 +1187,7 @@ public class Editor : Object } - public class Xcls_Button19 : Object + public class Xcls_backBtn : Object { public Gtk.Button el; private Editor _this; @@ -1197,9 +1196,10 @@ public class Editor : Object // my vars (def) // ctor - public Xcls_Button19(Editor _owner ) + public Xcls_backBtn(Editor _owner ) { _this = _owner; + _this.backBtn = this; this.el = new Gtk.Button(); // my vars (dec) @@ -1207,7 +1207,8 @@ public class Editor : Object // set gobject values this.el.always_show_image = true; this.el.label = "Previous"; - var child_0 = new Xcls_Image20( _this ); + this.el.sensitive = false; + var child_0 = new Xcls_Image19( _this ); child_0.ref(); this.el.image = child_0.el; @@ -1222,7 +1223,7 @@ public class Editor : Object // user defined functions } - public class Xcls_Image20 : Object + public class Xcls_Image19 : Object { public Gtk.Image el; private Editor _this; @@ -1231,7 +1232,7 @@ public class Editor : Object // my vars (def) // ctor - public Xcls_Image20(Editor _owner ) + public Xcls_Image19(Editor _owner ) { _this = _owner; this.el = new Gtk.Image(); @@ -1246,7 +1247,7 @@ public class Editor : Object } - public class Xcls_MenuButton21 : Object + public class Xcls_MenuButton20 : Object { public Gtk.MenuButton el; private Editor _this; @@ -1255,7 +1256,7 @@ public class Editor : Object // my vars (def) // ctor - public Xcls_MenuButton21(Editor _owner ) + public Xcls_MenuButton20(Editor _owner ) { _this = _owner; this.el = new Gtk.MenuButton(); @@ -1265,7 +1266,7 @@ public class Editor : Object // set gobject values this.el.always_show_image = true; this.el.label = "Settings"; - var child_0 = new Xcls_Image22( _this ); + var child_0 = new Xcls_Image21( _this ); child_0.ref(); this.el.image = child_0.el; var child_1 = new Xcls_search_settings( _this ); @@ -1275,7 +1276,7 @@ public class Editor : Object // user defined functions } - public class Xcls_Image22 : Object + public class Xcls_Image21 : Object { public Gtk.Image el; private Editor _this; @@ -1284,7 +1285,7 @@ public class Editor : Object // my vars (def) // ctor - public Xcls_Image22(Editor _owner ) + public Xcls_Image21(Editor _owner ) { _this = _owner; this.el = new Gtk.Image(); diff --git a/src/Builder4/GtkView.bjs b/src/Builder4/GtkView.bjs index 251f311b8..ef61641eb 100644 --- a/src/Builder4/GtkView.bjs +++ b/src/Builder4/GtkView.bjs @@ -490,22 +490,22 @@ ], "key_press_event" : [ "(event) => {", - " ", " if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {", "\t GLib.debug(\"SAVE: ctrl-g pressed\");", "\t\t_this.forwardSearch(true);", "\t return true;", "\t}", " ", - " ", " ", " \tif (event.keyval == Gdk.Key.Return && this.el.text.length > 0) {", "\t\tvar res = _this.search(this.el.text);", - "\t\tif (res > 0) {", - "\t\t\t_this.search_results.el.label = \"%d Matches\".printf(res);", - "\t\t} else {", - "\t\t\t_this.search_results.el.label = \"No Matches\";", - "\t\t}", + "\t\t _this.search_results.updateResults();", + "", + "\t\tGLib.Timeout.add_seconds(2,() => {", + "\t\t\t _this.search_results.updateResults();", + "\t\t\t return false;", + "\t\t });", + "\t ", "\t\t", "\t return true;", "", @@ -556,18 +556,9 @@ { "$ xns" : "Gtk", "* pack" : "add", - "Xcls_ValaCompileErrors popup" : "", "bool always_show_image" : true, + "bool visible" : false, "id" : "search_results", - "items" : [ - { - "$ xns" : "Gtk", - "* pack" : "set_image", - "bool sensitive" : false, - "utf8 icon_name" : "system-search", - "xtype" : "Image" - } - ], "listeners" : { "button_press_event" : [ "() => {", @@ -584,8 +575,30 @@ "}" ] }, - "string label" : "Matches", - "xtype" : "ImageMenuItem" + "xtype" : "ImageMenuItem", + "| void updateResults" : [ + "() {", + "\tthis.el.visible = true;", + "\t", + "\tvar res = _this.searchcontext.get_occurrences_count();", + "\tif (res < 0) {", + "\t\t_this.search_results.el.label = \"??? Matches\";\t\t", + "\t\treturn;", + "\t}", + "", + "\t_this.nextBtn.el.sensitive = false;", + "\t_this.backBtn.el.sensitive = false;\t", + "", + "\tif (res > 0) {", + "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);", + "\t\t_this.nextBtn.el.sensitive = true;", + "\t\t_this.backBtn.el.sensitive = true;", + "\t\treturn;", + "\t} ", + "\t_this.search_results.el.label = \"No Matches\";", + "\t", + "}" + ] } ], "xtype" : "MenuBar" @@ -593,6 +606,8 @@ { "$ xns" : "Gtk", "bool always_show_image" : true, + "bool sensitive" : false, + "id" : "nextBtn", "items" : [ { "$ xns" : "Gtk", @@ -618,6 +633,8 @@ { "$ xns" : "Gtk", "bool always_show_image" : true, + "bool sensitive" : false, + "id" : "backBtn", "items" : [ { "$ xns" : "Gtk", diff --git a/src/Builder4/GtkView.vala b/src/Builder4/GtkView.vala index 621f69025..2cd2f704d 100644 --- a/src/Builder4/GtkView.vala +++ b/src/Builder4/GtkView.vala @@ -21,6 +21,8 @@ public class Xcls_GtkView : Object public Xcls_buffer buffer; public Xcls_search_entry search_entry; public Xcls_search_results search_results; + public Xcls_nextBtn nextBtn; + public Xcls_backBtn backBtn; public Xcls_search_settings search_settings; public Xcls_case_sensitive case_sensitive; public Xcls_regex regex; @@ -957,13 +959,13 @@ public class Xcls_GtkView : Object var child_1 = new Xcls_MenuBar14( _this ); child_1.ref(); this.el.add ( child_1.el ); - var child_2 = new Xcls_Button17( _this ); + var child_2 = new Xcls_nextBtn( _this ); child_2.ref(); this.el.add( child_2.el ); - var child_3 = new Xcls_Button19( _this ); + var child_3 = new Xcls_backBtn( _this ); child_3.ref(); this.el.add( child_3.el ); - var child_4 = new Xcls_MenuButton21( _this ); + var child_4 = new Xcls_MenuButton20( _this ); child_4.ref(); this.el.add( child_4.el ); } @@ -1000,22 +1002,22 @@ public class Xcls_GtkView : Object //listeners this.el.key_press_event.connect( (event) => { - if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { GLib.debug("SAVE: ctrl-g pressed"); _this.forwardSearch(true); return true; } - if (event.keyval == Gdk.Key.Return && this.el.text.length > 0) { var res = _this.search(this.el.text); - if (res > 0) { - _this.search_results.el.label = "%d Matches".printf(res); - } else { - _this.search_results.el.label = "No Matches"; - } + _this.search_results.updateResults(); + + GLib.Timeout.add_seconds(2,() => { + _this.search_results.updateResults(); + return false; + }); + return true; @@ -1121,7 +1123,6 @@ public class Xcls_GtkView : Object // my vars (def) - public Xcls_ValaCompileErrors popup; // ctor public Xcls_search_results(Xcls_GtkView _owner ) @@ -1134,10 +1135,7 @@ public class Xcls_GtkView : Object // set gobject values this.el.always_show_image = true; - this.el.label = "Matches"; - var child_0 = new Xcls_Image16( _this ); - child_0.ref(); - this.el.set_image ( child_0.el ); + this.el.visible = false; //listeners this.el.button_press_event.connect( () => { @@ -1155,34 +1153,31 @@ public class Xcls_GtkView : Object } // user defined functions - } - public class Xcls_Image16 : Object - { - public Gtk.Image el; - private Xcls_GtkView _this; - - - // my vars (def) - - // ctor - public Xcls_Image16(Xcls_GtkView _owner ) - { - _this = _owner; - this.el = new Gtk.Image(); - - // my vars (dec) - - // set gobject values - this.el.icon_name = "system-search"; - this.el.sensitive = false; + public void updateResults () { + this.el.visible = true; + + var res = _this.searchcontext.get_occurrences_count(); + if (res < 0) { + _this.search_results.el.label = "??? Matches"; + return; + } + + _this.nextBtn.el.sensitive = false; + _this.backBtn.el.sensitive = false; + + if (res > 0) { + _this.search_results.el.label = "%d Matches".printf(res); + _this.nextBtn.el.sensitive = true; + _this.backBtn.el.sensitive = true; + return; + } + _this.search_results.el.label = "No Matches"; + } - - // user defined functions } - - public class Xcls_Button17 : Object + public class Xcls_nextBtn : Object { public Gtk.Button el; private Xcls_GtkView _this; @@ -1191,9 +1186,10 @@ public class Xcls_GtkView : Object // my vars (def) // ctor - public Xcls_Button17(Xcls_GtkView _owner ) + public Xcls_nextBtn(Xcls_GtkView _owner ) { _this = _owner; + _this.nextBtn = this; this.el = new Gtk.Button(); // my vars (dec) @@ -1201,7 +1197,8 @@ public class Xcls_GtkView : Object // set gobject values this.el.always_show_image = true; this.el.label = "Next"; - var child_0 = new Xcls_Image18( _this ); + this.el.sensitive = false; + var child_0 = new Xcls_Image17( _this ); child_0.ref(); this.el.image = child_0.el; @@ -1216,7 +1213,7 @@ public class Xcls_GtkView : Object // user defined functions } - public class Xcls_Image18 : Object + public class Xcls_Image17 : Object { public Gtk.Image el; private Xcls_GtkView _this; @@ -1225,7 +1222,7 @@ public class Xcls_GtkView : Object // my vars (def) // ctor - public Xcls_Image18(Xcls_GtkView _owner ) + public Xcls_Image17(Xcls_GtkView _owner ) { _this = _owner; this.el = new Gtk.Image(); @@ -1240,7 +1237,7 @@ public class Xcls_GtkView : Object } - public class Xcls_Button19 : Object + public class Xcls_backBtn : Object { public Gtk.Button el; private Xcls_GtkView _this; @@ -1249,9 +1246,10 @@ public class Xcls_GtkView : Object // my vars (def) // ctor - public Xcls_Button19(Xcls_GtkView _owner ) + public Xcls_backBtn(Xcls_GtkView _owner ) { _this = _owner; + _this.backBtn = this; this.el = new Gtk.Button(); // my vars (dec) @@ -1259,7 +1257,8 @@ public class Xcls_GtkView : Object // set gobject values this.el.always_show_image = true; this.el.label = "Previous"; - var child_0 = new Xcls_Image20( _this ); + this.el.sensitive = false; + var child_0 = new Xcls_Image19( _this ); child_0.ref(); this.el.image = child_0.el; @@ -1274,7 +1273,7 @@ public class Xcls_GtkView : Object // user defined functions } - public class Xcls_Image20 : Object + public class Xcls_Image19 : Object { public Gtk.Image el; private Xcls_GtkView _this; @@ -1283,7 +1282,7 @@ public class Xcls_GtkView : Object // my vars (def) // ctor - public Xcls_Image20(Xcls_GtkView _owner ) + public Xcls_Image19(Xcls_GtkView _owner ) { _this = _owner; this.el = new Gtk.Image(); @@ -1298,7 +1297,7 @@ public class Xcls_GtkView : Object } - public class Xcls_MenuButton21 : Object + public class Xcls_MenuButton20 : Object { public Gtk.MenuButton el; private Xcls_GtkView _this; @@ -1307,7 +1306,7 @@ public class Xcls_GtkView : Object // my vars (def) // ctor - public Xcls_MenuButton21(Xcls_GtkView _owner ) + public Xcls_MenuButton20(Xcls_GtkView _owner ) { _this = _owner; this.el = new Gtk.MenuButton(); @@ -1317,7 +1316,7 @@ public class Xcls_GtkView : Object // set gobject values this.el.always_show_image = true; this.el.label = "Settings"; - var child_0 = new Xcls_Image22( _this ); + var child_0 = new Xcls_Image21( _this ); child_0.ref(); this.el.image = child_0.el; var child_1 = new Xcls_search_settings( _this ); @@ -1327,7 +1326,7 @@ public class Xcls_GtkView : Object // user defined functions } - public class Xcls_Image22 : Object + public class Xcls_Image21 : Object { public Gtk.Image el; private Xcls_GtkView _this; @@ -1336,7 +1335,7 @@ public class Xcls_GtkView : Object // my vars (def) // ctor - public Xcls_Image22(Xcls_GtkView _owner ) + public Xcls_Image21(Xcls_GtkView _owner ) { _this = _owner; this.el = new Gtk.Image(); diff --git a/src/Builder4/WindowRooView.bjs b/src/Builder4/WindowRooView.bjs index c98be69dc..cbb2a636b 100644 --- a/src/Builder4/WindowRooView.bjs +++ b/src/Builder4/WindowRooView.bjs @@ -1282,22 +1282,22 @@ ], "key_press_event" : [ "(event) => {", - " ", " if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {", "\t GLib.debug(\"SAVE: ctrl-g pressed\");", "\t\t_this.forwardSearch(true);", "\t return true;", "\t}", " ", - " ", " ", " \tif (event.keyval == Gdk.Key.Return && this.el.text.length > 0) {", "\t\tvar res = _this.search(this.el.text);", - "\t\tif (res > 0) {", - "\t\t\t_this.search_results.el.label = \"%d Matches\".printf(res);", - "\t\t} else {", - "\t\t\t_this.search_results.el.label = \"No Matches\";", - "\t\t}", + "\t\t _this.search_results.updateResults();", + "", + "\t\tGLib.Timeout.add_seconds(2,() => {", + "\t\t\t _this.search_results.updateResults();", + "\t\t\t return false;", + "\t\t });", + "\t ", "\t\t", "\t return true;", "", @@ -1348,18 +1348,9 @@ { "$ xns" : "Gtk", "* pack" : "add", - "Xcls_ValaCompileErrors popup" : "", "bool always_show_image" : true, + "bool visible" : false, "id" : "search_results", - "items" : [ - { - "$ xns" : "Gtk", - "* pack" : "set_image", - "bool sensitive" : false, - "utf8 icon_name" : "system-search", - "xtype" : "Image" - } - ], "listeners" : { "button_press_event" : [ "() => {", @@ -1376,8 +1367,30 @@ "}" ] }, - "string label" : "Matches", - "xtype" : "ImageMenuItem" + "xtype" : "ImageMenuItem", + "| void updateResults" : [ + "() {", + "\tthis.el.visible = true;", + "\t", + "\tvar res = _this.searchcontext.get_occurrences_count();", + "\tif (res < 0) {", + "\t\t_this.search_results.el.label = \"??? Matches\";\t\t", + "\t\treturn;", + "\t}", + "", + "\t_this.nextBtn.el.sensitive = false;", + "\t_this.backBtn.el.sensitive = false;\t", + "", + "\tif (res > 0) {", + "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);", + "\t\t_this.nextBtn.el.sensitive = true;", + "\t\t_this.backBtn.el.sensitive = true;", + "\t\treturn;", + "\t} ", + "\t_this.search_results.el.label = \"No Matches\";", + "\t", + "}" + ] } ], "xtype" : "MenuBar" @@ -1385,6 +1398,8 @@ { "$ xns" : "Gtk", "bool always_show_image" : true, + "bool sensitive" : false, + "id" : "nextBtn", "items" : [ { "$ xns" : "Gtk", @@ -1410,6 +1425,8 @@ { "$ xns" : "Gtk", "bool always_show_image" : true, + "bool sensitive" : false, + "id" : "backBtn", "items" : [ { "$ xns" : "Gtk", diff --git a/src/Builder4/WindowRooView.vala b/src/Builder4/WindowRooView.vala index fcc50f7ad..03e806a37 100644 --- a/src/Builder4/WindowRooView.vala +++ b/src/Builder4/WindowRooView.vala @@ -25,6 +25,8 @@ public class Xcls_WindowRooView : Object public Xcls_buffer buffer; public Xcls_search_entry search_entry; public Xcls_search_results search_results; + public Xcls_nextBtn nextBtn; + public Xcls_backBtn backBtn; public Xcls_search_settings search_settings; public Xcls_case_sensitive case_sensitive; public Xcls_regex regex; @@ -1751,13 +1753,13 @@ public class Xcls_WindowRooView : Object var child_1 = new Xcls_MenuBar20( _this ); child_1.ref(); this.el.add ( child_1.el ); - var child_2 = new Xcls_Button23( _this ); + var child_2 = new Xcls_nextBtn( _this ); child_2.ref(); this.el.add( child_2.el ); - var child_3 = new Xcls_Button25( _this ); + var child_3 = new Xcls_backBtn( _this ); child_3.ref(); this.el.add( child_3.el ); - var child_4 = new Xcls_MenuButton27( _this ); + var child_4 = new Xcls_MenuButton26( _this ); child_4.ref(); this.el.add( child_4.el ); } @@ -1794,22 +1796,22 @@ public class Xcls_WindowRooView : Object //listeners this.el.key_press_event.connect( (event) => { - if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { GLib.debug("SAVE: ctrl-g pressed"); _this.forwardSearch(true); return true; } - if (event.keyval == Gdk.Key.Return && this.el.text.length > 0) { var res = _this.search(this.el.text); - if (res > 0) { - _this.search_results.el.label = "%d Matches".printf(res); - } else { - _this.search_results.el.label = "No Matches"; - } + _this.search_results.updateResults(); + + GLib.Timeout.add_seconds(2,() => { + _this.search_results.updateResults(); + return false; + }); + return true; @@ -1915,7 +1917,6 @@ public class Xcls_WindowRooView : Object // my vars (def) - public Xcls_ValaCompileErrors popup; // ctor public Xcls_search_results(Xcls_WindowRooView _owner ) @@ -1928,10 +1929,7 @@ public class Xcls_WindowRooView : Object // set gobject values this.el.always_show_image = true; - this.el.label = "Matches"; - var child_0 = new Xcls_Image22( _this ); - child_0.ref(); - this.el.set_image ( child_0.el ); + this.el.visible = false; //listeners this.el.button_press_event.connect( () => { @@ -1949,34 +1947,31 @@ public class Xcls_WindowRooView : Object } // user defined functions - } - public class Xcls_Image22 : Object - { - public Gtk.Image el; - private Xcls_WindowRooView _this; - - - // my vars (def) - - // ctor - public Xcls_Image22(Xcls_WindowRooView _owner ) - { - _this = _owner; - this.el = new Gtk.Image(); - - // my vars (dec) - - // set gobject values - this.el.icon_name = "system-search"; - this.el.sensitive = false; + public void updateResults () { + this.el.visible = true; + + var res = _this.searchcontext.get_occurrences_count(); + if (res < 0) { + _this.search_results.el.label = "??? Matches"; + return; + } + + _this.nextBtn.el.sensitive = false; + _this.backBtn.el.sensitive = false; + + if (res > 0) { + _this.search_results.el.label = "%d Matches".printf(res); + _this.nextBtn.el.sensitive = true; + _this.backBtn.el.sensitive = true; + return; + } + _this.search_results.el.label = "No Matches"; + } - - // user defined functions } - - public class Xcls_Button23 : Object + public class Xcls_nextBtn : Object { public Gtk.Button el; private Xcls_WindowRooView _this; @@ -1985,9 +1980,10 @@ public class Xcls_WindowRooView : Object // my vars (def) // ctor - public Xcls_Button23(Xcls_WindowRooView _owner ) + public Xcls_nextBtn(Xcls_WindowRooView _owner ) { _this = _owner; + _this.nextBtn = this; this.el = new Gtk.Button(); // my vars (dec) @@ -1995,7 +1991,8 @@ public class Xcls_WindowRooView : Object // set gobject values this.el.always_show_image = true; this.el.label = "Next"; - var child_0 = new Xcls_Image24( _this ); + this.el.sensitive = false; + var child_0 = new Xcls_Image23( _this ); child_0.ref(); this.el.image = child_0.el; @@ -2010,7 +2007,7 @@ public class Xcls_WindowRooView : Object // user defined functions } - public class Xcls_Image24 : Object + public class Xcls_Image23 : Object { public Gtk.Image el; private Xcls_WindowRooView _this; @@ -2019,7 +2016,7 @@ public class Xcls_WindowRooView : Object // my vars (def) // ctor - public Xcls_Image24(Xcls_WindowRooView _owner ) + public Xcls_Image23(Xcls_WindowRooView _owner ) { _this = _owner; this.el = new Gtk.Image(); @@ -2034,7 +2031,7 @@ public class Xcls_WindowRooView : Object } - public class Xcls_Button25 : Object + public class Xcls_backBtn : Object { public Gtk.Button el; private Xcls_WindowRooView _this; @@ -2043,9 +2040,10 @@ public class Xcls_WindowRooView : Object // my vars (def) // ctor - public Xcls_Button25(Xcls_WindowRooView _owner ) + public Xcls_backBtn(Xcls_WindowRooView _owner ) { _this = _owner; + _this.backBtn = this; this.el = new Gtk.Button(); // my vars (dec) @@ -2053,7 +2051,8 @@ public class Xcls_WindowRooView : Object // set gobject values this.el.always_show_image = true; this.el.label = "Previous"; - var child_0 = new Xcls_Image26( _this ); + this.el.sensitive = false; + var child_0 = new Xcls_Image25( _this ); child_0.ref(); this.el.image = child_0.el; @@ -2068,7 +2067,7 @@ public class Xcls_WindowRooView : Object // user defined functions } - public class Xcls_Image26 : Object + public class Xcls_Image25 : Object { public Gtk.Image el; private Xcls_WindowRooView _this; @@ -2077,7 +2076,7 @@ public class Xcls_WindowRooView : Object // my vars (def) // ctor - public Xcls_Image26(Xcls_WindowRooView _owner ) + public Xcls_Image25(Xcls_WindowRooView _owner ) { _this = _owner; this.el = new Gtk.Image(); @@ -2092,7 +2091,7 @@ public class Xcls_WindowRooView : Object } - public class Xcls_MenuButton27 : Object + public class Xcls_MenuButton26 : Object { public Gtk.MenuButton el; private Xcls_WindowRooView _this; @@ -2101,7 +2100,7 @@ public class Xcls_WindowRooView : Object // my vars (def) // ctor - public Xcls_MenuButton27(Xcls_WindowRooView _owner ) + public Xcls_MenuButton26(Xcls_WindowRooView _owner ) { _this = _owner; this.el = new Gtk.MenuButton(); @@ -2111,7 +2110,7 @@ public class Xcls_WindowRooView : Object // set gobject values this.el.always_show_image = true; this.el.label = "Settings"; - var child_0 = new Xcls_Image28( _this ); + var child_0 = new Xcls_Image27( _this ); child_0.ref(); this.el.image = child_0.el; var child_1 = new Xcls_search_settings( _this ); @@ -2121,7 +2120,7 @@ public class Xcls_WindowRooView : Object // user defined functions } - public class Xcls_Image28 : Object + public class Xcls_Image27 : Object { public Gtk.Image el; private Xcls_WindowRooView _this; @@ -2130,7 +2129,7 @@ public class Xcls_WindowRooView : Object // my vars (def) // ctor - public Xcls_Image28(Xcls_WindowRooView _owner ) + public Xcls_Image27(Xcls_WindowRooView _owner ) { _this = _owner; this.el = new Gtk.Image(); diff --git a/src/Builder4/WindowState.vala b/src/Builder4/WindowState.vala index 14f24b8ff..16ad5723f 100644 --- a/src/Builder4/WindowState.vala +++ b/src/Builder4/WindowState.vala @@ -14,11 +14,9 @@ public class WindowState : Object PREVIEW, CODE, CODEONLY - } public State state = State.NONE; - public bool children_loaded = false; public Project.Project project; -- 2.39.2