Changeset 489
- Timestamp:
- 2007-07-08 19:19:10 (2 years ago)
- Files:
-
- trunk/chrome/content/preferences/filtersPane.js (modified) (5 diffs)
- trunk/chrome/content/preferences/filtersPane.xul (modified) (1 diff)
- trunk/chrome/locale/en-US/prefpanes.dtd (modified) (1 diff)
- trunk/chrome/locale/en-US/prefpanes.properties (modified) (2 diffs)
- trunk/components/filterManager.idl (modified) (1 diff)
- trunk/components/filterManager.js (modified) (9 diffs)
- trunk/defaults/preferences/filters.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/chrome/content/preferences/filtersPane.js
r395 r489 247 247 248 248 if (idx==-1) { 249 $("filterLabel", "filterTest", "filterText", "filterImage", "filterIsRegex", "re movebutton").forEach(function(a){a.disabled=true});249 $("filterLabel", "filterTest", "filterText", "filterImage", "filterIsRegex", "restoreremovebutton").forEach(function(a){a.disabled=true}); 250 250 $("filterLabel", "filterTest").forEach(function(a){a.value=""}); 251 251 $("filterText", "filterImage", "filterIsRegex").forEach(function(a){a.checked=false}); 252 $("restoreremovebutton").label = _('removebutton'); 252 253 return; 253 254 } … … 264 265 $("filterText").checked = currentFilter.type & 1; 265 266 $("filterImage").checked = currentFilter.type & 2; 266 267 $("filterLabel", "filterTest", "filterText", "filterImage", "filterIsRegex", "removebutton").forEach(function(a){a.disabled=currentFilter.defFilter});268 267 $("filterLabel", "filterTest", "filterText", "filterImage", "filterIsRegex", "restoreremovebutton").forEach(function(a){a.disabled=false}); 268 269 $("restoreremovebutton").label = currentFilter.defFilter?_('restorebutton'):_('removebutton'); 269 270 this.doCheckboxValidation(); 270 271 }, … … 275 276 var currentFilter = this.getFilter(idx); 276 277 // invalid idx 277 if (!currentFilter || currentFilter.defFilter) {278 if (!currentFilter) { 278 279 return; 279 280 } … … 350 351 var currentFilter = this.getFilter(idx); 351 352 // invalid idx 352 if (!currentFilter || currentFilter.defFilter) {353 if (!currentFilter) { 353 354 return; 354 355 } … … 398 399 removeFilter: function() { 399 400 Debug.dump("remove"); 400 var idx = this.getSelectedRow(); 401 var currentFilter = this.getFilter(idx); 402 403 // invalid idx 404 if (!currentFilter || currentFilter.defFilter) { 405 return; 406 } 407 401 var currentFilter = this.getFilter(this.getSelectedRow()); 408 402 this._table.view.selection.select(-1); 409 403 var currentFilter = currentFilter.remove(); 410 404 }, 411 restoreDefaultFilter s: function() {405 restoreDefaultFilter: function() { 412 406 if (DTA_confirm(_('restorefilterstitle'), _('restorefilterstext'), _('restore'), DTA_confirm.CANCEL, null, 1) == 1) { 413 407 return; 414 408 } 415 this._table.view.selection.select(-1); 416 var e = DTA_FilterManager.enumAll(); 417 while (e.hasMoreElements()) { 418 var filter = e.getNext().QueryInterface(Components.interfaces.dtaIFilter); 419 if (!filter.defFilter) 420 filter.remove(); 409 var currentFilter = this.getFilter(this.getSelectedRow()); 410 currentFilter.restore(); 411 }, 412 restoreRemoveFilter: function() { 413 var idx = this.getSelectedRow(); 414 if (idx==-1){ 415 return; 416 } 417 var currentFilter = this.getFilter(idx); 418 if (currentFilter.defFilter) { 419 this.restoreDefaultFilter() 420 } else { 421 this.removeFilter(); 421 422 } 422 423 } trunk/chrome/content/preferences/filtersPane.xul
r395 r489 52 52 <spacer flex="1"/> 53 53 <button label="&add.label;" oncommand="Dialog.createFilter();"/> 54 <button label="&remove.label;" oncommand="Dialog.removeFilter();" id="removebutton"/> 55 <button label="&default.label;" oncommand="Dialog.restoreDefaultFilters();" id="defaultbutton"/> 54 <button label="" oncommand="Dialog.restoreRemoveFilter();" id="restoreremovebutton"/> 56 55 <spacer flex="1"/> 57 56 </hbox> trunk/chrome/locale/en-US/prefpanes.dtd
r469 r489 8 8 <!ENTITY linksf.label "Links filter"> 9 9 <!ENTITY add.label "Add new filter"> 10 <!ENTITY remove.label "Delete filter">11 <!ENTITY default.label "Restore default filters">12 10 <!ENTITY highlight.label "Highlight files checked by filters"> 13 11 <!ENTITY dtacontext2.label "Preferences"> trunk/chrome/locale/en-US/prefpanes.properties
r262 r489 6 6 restoreprefstitle=Restore Preferences 7 7 restoreprefstext=Do you want to restore preferences to their default state?\nThere is no way to undo this! 8 restorefilterstitle=Restore Filter s9 restorefilterstext=Do you want to re move all user filters and restore the built-in ones?\nThere is no way to undo this!8 restorefilterstitle=Restore Filter 9 restorefilterstext=Do you want to restore the built-in values for this filter?\nThere is no way to undo this! 10 10 restore=Restore 11 11 regex=Reg. Ex. … … 14 14 newfilt=New filter 15 15 inserthere=Insert here extensions (split using commas) 16 removebutton=Delete filter 17 restorebutton=Restore default filter trunk/components/filterManager.idl
r170 r489 53 53 boolean match(in string test); 54 54 void save(); 55 void restore(); 55 56 void remove(); 56 57 }; trunk/components/filterManager.js
r212 r489 58 58 LINK_FILTER: (1 << 0), 59 59 IMAGE_FILTER: (1 << 1), 60 61 defaultFilters: { 62 deffilter0: { 63 test: "/.*/i", 64 regex: true, 65 type: this.LINK_FILTER + this.IMAGE_FILTER 66 }, 67 deffilter1: { 68 test: "/\\.(?:z(?:ip|[0-9]{2})|r(?:ar|[0-9]{2})|jar|bz2|gz|tar|rpm)$/i", 69 regex: true, 70 type: this.LINK_FILTER 71 }, 72 deffilter2: { 73 test: "/\\.(?:mpeg|rm|mpe|avi|mpg|mp4|mov|divx|asf|qt|wmv|ram|m1v|m2v|rv|vob|asx)$/i", 74 regex: true, 75 type: this.LINK_FILTER + this.IMAGE_FILTER 76 }, 77 deffilter3: { 78 test: "/\\.(?:jp(?:e?g|e|2)|gif|png|tif|tiff|bmp|ico)$/i", 79 regex: true, 80 type: this.LINK_FILTER + this.IMAGE_FILTER 81 }, 82 deffilter4: { 83 test: "/\\.(?:exe|msi|dmg|bin|xpi)$/i", 84 regex: true, 85 type: this.LINK_FILTER 86 }, 87 deffilter5: { 88 test: "/\\.jp(e?g|e|2)$/i", 89 regex: true, 90 type: this.LINK_FILTER + this.IMAGE_FILTER 91 } 92 }, 60 93 61 94 _modified: false, … … 115 148 }, 116 149 set test(value) { 117 if (this._defFilter) {118 throw new Components.Exception("default filters cannot be modified!");119 }120 150 if (this._test == value) { 121 151 return; … … 149 179 }, 150 180 set isRegex(value) { 151 if (this._defFilter) {152 throw new Components.Exception("default filters cannot be deleted!");153 }154 181 if (this._isRegex == value) { 155 182 return; … … 171 198 }, 172 199 set type(t) { 173 if (this._defFilter) {174 throw new Components.Exception("default filters cannot be modified!");175 }176 200 if (this._type == t) { 177 201 return; … … 197 221 */ 198 222 load: function F_load(localizedLabel) { 223 this._localizedLabel = localizedLabel; 199 224 this._label = this.getMultiBytePref(this.pref('label')); 200 225 if (!this._label || !this._label.length) { … … 220 245 } 221 246 this._prefs.setBoolPref(this.pref('active'), this._active); 222 223 // do not change defFilters 224 if (!this.defFilter) { 225 this.setMultiBytePref(this.pref('test'), this._test); 226 this._prefs.setIntPref(this.pref('type'), this._type); 227 this._prefs.setBoolPref(this.pref('regex'), this._isRegex); 228 229 } 247 248 this.setMultiBytePref(this.pref('test'), this._test); 249 this._prefs.setIntPref(this.pref('type'), this._type); 250 this._prefs.setBoolPref(this.pref('regex'), this._isRegex); 251 230 252 // save this last as FM will test for it. 231 253 this.setMultiBytePref(this.pref('label'), this._label); 232 254 233 255 this._modified = false; 256 }, 257 258 // exported 259 restore: function F_restore() { 260 if (!this._defFilter) { 261 throw new Components.Exception("only default filters can be restored!"); 262 } 263 this._label = this._localizedLabel; 264 this._test = defaultFilters[this._id].test; 265 this._type = defaultFilters[this._id].type; 266 this._isRegex = defaultFilters[this._id].regex; 267 268 this.save(); 234 269 }, 235 270 … … 335 370 336 371 // load those localized labels for default filters. 337 this._l abels = {};372 this._localizedLabels = {}; 338 373 var b = CC['@mozilla.org/intl/stringbundle;1'] 339 374 .getService(CI.nsIStringBundleService) … … 342 377 while (e.hasMoreElements()) { 343 378 var prop = e.getNext().QueryInterface(CI.nsIPropertyElement); 344 this._l abels[prop.key] = prop.value;379 this._localizedLabels[prop.key] = prop.value; 345 380 } 346 381 … … 389 424 // overwrite with localized labels. 390 425 var localizedLabel = null; 391 if (filter.id in this._l abels) {392 localizedLabel = this._l abels[filter.id];426 if (filter.id in this._localizedLabels) { 427 localizedLabel = this._localizedLabels[filter.id]; 393 428 } 394 429 filter.load(localizedLabel); trunk/defaults/preferences/filters.js
r118 r489 35 35 * ***** END LICENSE BLOCK ***** */ 36 36 pref("extensions.dta.filters.deffilter0.label", "All files"); 37 pref("extensions.dta.filters.deffilter0.test", " .*");37 pref("extensions.dta.filters.deffilter0.test", "/.*/i"); 38 38 pref("extensions.dta.filters.deffilter0.regex", true); 39 39 pref("extensions.dta.filters.deffilter0.active", false);
