src/Builder4/MainWindow.bjs
authorAlan Knowles <alan@roojs.com>
Tue, 2 Jun 2015 12:20:55 +0000 (20:20 +0800)
committerAlan Knowles <alan@roojs.com>
Tue, 2 Jun 2015 12:20:55 +0000 (20:20 +0800)
src/Builder4/MainWindow.vala

src/Builder4/MainWindow.bjs
src/Builder4/MainWindow.vala

index 0eaeecf..45869cc 100644 (file)
         },
         {
          "listeners" : {
-          "changed" : "() => {\n\tif (this.el.text != \"\") {\n\t\t\n\t\n\t}\n}\n"
+          "changed" : "() => {\n\tif (this.el.text == \"\") {\n\t\treturn;\n\t}\n\tGee.ArrayList<int> res = new Gee.ArrayList<int>();;\n\tswitch(_this.windowstate.state) {\n\t\tcase WindowState.State.CODEONLY:\n\t\tcase WindowState.State.CODE:\n\t\t\t// search the code being edited..\n\t\t\tres = _this.windowstate.code_editor.search(this.el.text);\n\t\t\t\n\t\t\tbreak;\n\t\tcase WindowState.State.PREVIEW:\n\t\t\tif (this.windowstate.file.xtype == \"Gtk\") {\n\t\t\t\tvar res = _this.windowstate.window_gladeview.search(this.el.text);\n\t\t\t}\n\t\t\n\t\t\tbreak;\n\t}\n\tif (res.size > 0) {\n\t\t_this.search_results.el.text = \"%d Matches\".printf(res.size);\n\t} else {\n\t\t_this.search_results.el.text = \"No Matches\";\n\t}\n\t\t\n\t\n\t\n}\n"
          },
          "id" : "search_entry",
          "* init" : "var description =   Pango.FontDescription.from_string(\"monospace\");\n\tdescription.set_size(8000);\n\t this.el.override_font(description);\n\n",
index 1ae1444..3749726 100644 (file)
@@ -2327,10 +2327,32 @@ public class Xcls_MainWindow : Object
 
             //listeners
             this.el.changed.connect( () => {
-               if (this.el.text != "") {
+               if (this.el.text == "") {
+                       return;
+               }
+               Gee.ArrayList<int> res = new Gee.ArrayList<int>();;
+               switch(_this.windowstate.state) {
+                       case WindowState.State.CODEONLY:
+                       case WindowState.State.CODE:
+                               // search the code being edited..
+                               res = _this.windowstate.code_editor.search(this.el.text);
+                               
+                               break;
+                       case WindowState.State.PREVIEW:
+                               if (this.windowstate.file.xtype == "Gtk") {
+                                       var res = _this.windowstate.window_gladeview.search(this.el.text);
+                               }
                        
-               
+                               break;
+               }
+               if (res.size > 0) {
+                       _this.search_results.el.text = "%d Matches".printf(res.size);
+               } else {
+                       _this.search_results.el.text = "No Matches";
                }
+                       
+               
+               
             });
         }