[Project_owners] Apply Options dialog changes

HJ bugus at universum.org
Mon Nov 29 17:57:02 EST 2004


Chris Means wrote:
> I'm finishing up an extension that updates the status bar with a users'
> current SETI @ Home statistics.
> 
> The updating is done through a window.setTimeout.
> 
> However, the user has some options about what data is displayed, and how
> often to update them (this is limited to just a few choices so as to not
> overload their servers).
> 
> My problem is...after the user has made changes in the options dialog, I'm
> unsure about how to get my main overlay code to reload the users's
> configuration and apply any changes to the display or update frequency.
> 
> Currently, I just popup a message and tell the user to force an immediate
> update on the control (by right-clicking).
> 
> Any suggestions how best to approach this?
> 
> I've tried calling routines in the main code, however, I never seem to get
> the right object references.
> 
> Thanks.
> 
> -Chris

I'm not sure what you want/need, but this might help:

// Setup observer
observerService = 
Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
observerService.addObserver(setiObserver, "updateSETI", false);

// Trigger update (should be used in Options dialog)
observerService.notifyObservers(null, "updateSETI", "update");

// Removing the observer:
observerService.removeObserver(setiObserver, "updateSETI");

var setiObserver = {
   observe: function(subject, topic, state) {
     if (topic == "updateSETI" && state == "update") {
       // call some function that handles the update
     }
   }
}

see also: 
http://lxr.mozilla.org/firebird/source/xpcom/ds/nsIObserverService.idl


/HJ


More information about the Project_owners mailing list