Changeset 998

Show
Ignore:
Timestamp:
07/30/08 00:19:20 (1 month ago)
Author:
MaierMan
Message:

#822: Preferences Filters doesn't update

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.0.x/chrome/content/preferences/prefs.js

    r916 r998  
    145145                this._elem.view = this; 
    146146                 
    147                 this.registerObserver(); 
     147                this.Observer.registerObserver(); 
    148148                this.reloadFilters(); 
    149149        }, 
    150         registerObserver: function() { 
    151                 try { 
    152                         makeObserver(this); 
    153                         var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService); 
    154                         os.addObserver(this, 'DTA:filterschanged', true); 
    155                 } catch (ex) { 
    156                         Debug.dump("cannot install filterManager observer!", ex); 
    157                         return false; 
    158                 } 
    159                 return true; 
    160         },       
     150        Observer: { 
     151                registerObserver: function() { 
     152                        try { 
     153                                makeObserver(this); 
     154                                var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService); 
     155                                os.addObserver(this, 'DTA:filterschanged', true); 
     156                        } 
     157                        catch (ex) { 
     158                                Debug.dump("cannot install filterManager observer!", ex); 
     159                                return false; 
     160                        } 
     161                        return true; 
     162                },       
     163                // nsIObserver::observe 
     164                observe : function(subject, topic, prefName) { 
     165                        // filterManager will throw this topic at us. 
     166                        if (topic == 'DTA:filterschanged') { 
     167                                // the heavy work will be performed by changeTab.. 
     168                                // it will create the filter boxen for us, and furthermore do another selection 
     169                                Filters.reloadFilters(); 
     170                        } 
     171                } 
     172        },               
    161173        reloadFilters: function() { 
    162174                // something has changed.. 
     
    422434        getCellProperties: function(idx, column, prop) {}, 
    423435        getColumnProperties: function(column, element, prop) {}, 
    424         setCellValue: function(idx, col, value) {}, 
    425          
    426         // nsIObserver::observe 
    427         observe : function(subject, topic, prefName) { 
    428                 // filterManager will throw this topic at us. 
    429                 if (topic == 'DTA:filterschanged') { 
    430                         // the heavy work will be performed by changeTab.. 
    431                         // it will create the filter boxen for us, and furthermore do another selection 
    432                         this.reloadFilters(); 
    433                 } 
    434         } 
     436        setCellValue: function(idx, col, value) {} 
    435437}; 
    436438 
  • branches/1.0.x/components/filterManager.js

    r538 r998  
    4949include("chrome://dta/content/common/regconvert.js"); 
    5050 
     51const Timer = Components.Constructor('@mozilla.org/timer;1', 'nsITimer', 'initWithCallback'); 
     52const TYPE_ONE_SHOT = CI.nsITimer.TYPE_ONE_SHOT; 
     53 
    5154// no not create DTA_Filter yourself, managed by DTA_FilterManager 
    5255function Filter(name, prefs) { 
     
    328331 
    329332        _done: true, 
    330         _mustReload: true, 
     333        _mustReload: false, 
    331334        _prefs: CC['@mozilla.org/preferences-service;1'] 
    332335                .getService(CI.nsIPrefService) 
    333336                .getBranch("extensions.dta.filters."), 
    334         _timer: CC['@mozilla.org/timer;1'] 
    335                         .createInstance(CI.nsITimer), 
     337        _timer: null, 
    336338 
    337339        _init: function FM_init() { 
     
    351353                // register (the observer) and initialize our timer, so that we'll get a reload event. 
    352354                this.register(); 
    353                 this._timer.initWithCallback( 
    354                         this, 
    355                         100, 
    356                         this._timer.TYPE_ONE_SHOT 
    357                 ); 
     355                this._delayedReload(); 
    358356        }, 
    359357 
    360358        _delayedReload: function FM_delayedReload() { 
     359                if (this._mustReload) { 
     360                        return; 
     361                } 
    361362                this._mustReload = true; 
    362                 this._timer.delay = 100; 
     363                this._timer = new Timer(this, 100, TYPE_ONE_SHOT);  
    363364        }, 
    364365