Fix #7353 - context on next/back on searching
authorAlan <alan@roojs.com>
Thu, 18 Aug 2022 11:42:51 +0000 (19:42 +0800)
committerAlan <alan@roojs.com>
Thu, 18 Aug 2022 11:42:51 +0000 (19:42 +0800)
src/Builder4/Editor.bjs
src/Builder4/Editor.vala
src/Builder4/GtkView.bjs
src/Builder4/GtkView.vala
src/Builder4/WindowRooView.bjs
src/Builder4/WindowRooView.vala
src/Builder4/WindowState.vala

index b871c86..8a457c1 100644 (file)
          "  ",
          " \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;",
          "",
         {
          "$ 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" : [
            "() => {",
            "}"
           ]
          },
-         "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"
       {
        "$ xns" : "Gtk",
        "bool always_show_image" : true,
+       "bool sensitive" : false,
+       "id" : "nextBtn",
        "items" : [
         {
          "$ xns" : "Gtk",
       {
        "$ xns" : "Gtk",
        "bool always_show_image" : true,
+       "bool sensitive" : false,
+       "id" : "backBtn",
        "items" : [
         {
          "$ xns" : "Gtk",
index 0bcbaaa..345ac21 100644 (file)
@@ -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();
index 251f311..ef61641 100644 (file)
             ],
             "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;",
              "",
             {
              "$ 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" : [
                "() => {",
                "}"
               ]
              },
-             "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"
           {
            "$ xns" : "Gtk",
            "bool always_show_image" : true,
+           "bool sensitive" : false,
+           "id" : "nextBtn",
            "items" : [
             {
              "$ xns" : "Gtk",
           {
            "$ xns" : "Gtk",
            "bool always_show_image" : true,
+           "bool sensitive" : false,
+           "id" : "backBtn",
            "items" : [
             {
              "$ xns" : "Gtk",
index 621f690..2cd2f70 100644 (file)
@@ -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();
index c98be69..cbb2a63 100644 (file)
             ],
             "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;",
              "",
             {
              "$ 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" : [
                "() => {",
                "}"
               ]
              },
-             "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"
           {
            "$ xns" : "Gtk",
            "bool always_show_image" : true,
+           "bool sensitive" : false,
+           "id" : "nextBtn",
            "items" : [
             {
              "$ xns" : "Gtk",
           {
            "$ xns" : "Gtk",
            "bool always_show_image" : true,
+           "bool sensitive" : false,
+           "id" : "backBtn",
            "items" : [
             {
              "$ xns" : "Gtk",
index fcc50f7..03e806a 100644 (file)
@@ -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();
index 14f24b8..16ad572 100644 (file)
@@ -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;