Commits

Shlomi Fish committed 7fa5c8e

Add a "Regular Expression" checkbox.

Currently it does nothing, but its status is preserved after restarting.

  • Participants
  • Parent commits 9d35277

Comments (0)

Files changed (5)

content/overlay.js

         this.strings = document.getElementById("smartfind-strings");
 
         this.findSimilar = gFindBar.getElement("find-similar");
+        this.findRegex = gFindBar.getElement("find-regex");
         this.findMatchCase = gFindBar.getElement("find-case-sensitive");
         this.findMenuItem = document.getElementById("smartfind-menu");
 
                 .getBranch("extensions.smartfind.")
                 .QueryInterface(Components.interfaces.nsIPrefBranch2);
 
+        this.mRegexPrefs = Components.classes["@mozilla.org/preferences-service;1"]
+                .getService(Components.interfaces.nsIPrefService)
+                .getBranch("extensions.smartfind.regex.")
+                .QueryInterface(Components.interfaces.nsIPrefBranch2);
+
         this.mPrefs.addObserver("", this, false);
+        this.mRegexPrefs.addObserver("", this, false);
     },
 
     openFindBar: function() {
         this.findMatchCase.disabled = enabled;
         this.findSimilar.checked = enabled;
 
+        var regex_enabled = this.mRegexPrefs.getBoolPref("enabled");
+        this.findRegex.checked = regex_enabled;
+
         gFindBar.onFindCommand();
     },
 

content/smartfindbar.xml

                 oncommand="_setSimilar(this.checked)"
                 label="&smartfindSimilarCheckbox.label;"
                 accesskey="&smartfindSimilarCheckbox.accesskey;"/>
+            <xul:checkbox anonid="find-regex"
+                oncommand="_setRegex(this.checked)"
+                label="&smartfindRegexCheckbox.label;"
+                accesskey="&smartfindRegexCheckbox.accesskey;"/>
             <xul:label anonid="match-case-status" class="findbar-find-fast"/>
             <xul:image anonid="find-status-icon" class="findbar-find-fast find-status-icon"/>
             <xul:description anonid="find-status" class="findbar-find-fast findbar-find-status"
                 this._similarLevel =
                     prefsvc.getIntPref("extensions.smartfind.similarity_level");
 
+                // Regex
+                this._regex =
+                    prefsvc.getBoolPref("extensions.smartfind.regex.enabled");
+
                 // Convenience
                 this.nsITypeAheadFind = Components.interfaces.nsITypeAheadFind;
                 this.nsISelectionController = Components.interfaces.nsISelectionController;
                 ]]></body>
             </method>
 
+            <method name="_setRegex">
+                <parameter name="aRegex"/>
+                <body><![CDATA[
+                    var prefsvc = Components.classes["@mozilla.org/preferences-service;1"]
+                        .getService(Components.interfaces.nsIPrefBranch2);
+
+                    prefsvc.setBoolPref("extensions.smartfind.regex.enabled", aRegex ? true : false);
+                    this._regex = aRegex;
+                ]]></body>
+            </method>
+
             <method name="_setSimilarLevel">
                 <parameter name="aValue"/>
                 <body><![CDATA[

defaults/preferences/smartfind.js

 pref("extensions.smartfind.enabled", true);
+pref("extensions.smartfind.regex.enabled", true);
 pref("extensions.smartfind.similarity_level", 50);
 // See http://kb.mozillazine.org/Localize_extension_descriptions
 pref("extensions.smartfind@smartfind.org.description", "chrome://smartfind/locale/smartfind.properties");
   <Description about="urn:mozilla:install-manifest">
     <em:id>smartfind@smartfind.org</em:id>
     <em:name>Smart Find</em:name>
-    <em:version>0.2.3</em:version>
+    <em:version>0.3.2</em:version>
     <em:type>2</em:type>
     <em:creator>Roberto Oliveira dos Santos</em:creator>
     <em:contributor>Roberto Oliveira do Santos</em:contributor>
       <Description>
         <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <!-- firefox -->
         <em:minVersion>3.0</em:minVersion>
-        <em:maxVersion>3.7a4pre</em:maxVersion>
+        <em:maxVersion>17</em:maxVersion>
       </Description>
     </em:targetApplication>
   </Description>

locale/en-US/smartfind.dtd

 <!ENTITY smartfindSimilarCheckbox.accesskey "s">
 <!ENTITY smartfindSimilarMenu.label "Find Similarity Level">
 <!ENTITY smartfindSimilarMenu.key "L">
+<!ENTITY smartfindRegexCheckbox.label "Regular Expression">
+<!ENTITY smartfindRegexCheckbox.accesskey "r">
 <!ENTITY smartfindMenuItemLow.label "Low">
 <!ENTITY smartfindMenuItemLow.key "L">
 <!ENTITY smartfindMenuItemMedium.label "Medium">