Re: Add-on bar or navigation toolbar icon showing same status across windows
STF <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.xpfe |
|---|---|
| Message-ID | <[email protected]> |
On 2013.05.15 21:47, Neil wrote: > STF wrote: > >> To simplify the concept, let's say I have two PNG images, on.png and >> off.png and I need to show one of them according to a certain value. I >> have gone through XUL tutorial >> (https://developer.mozilla.org/en-US/docs/XUL/School_tutorial) but I >> still have problem finding tutorials for my app. >> >> In particular, here are my problems: >> * How am I supposed to change the image file (from on.png to off.png)? >> >> * I have found another app which uses the trick of changing class for >> the above problem, but this leads to another problem: when there are >> more than one window, only the current window's icon image is changed. > > It's a bit difficult to generalise. If this is a global value that you > maintain yourself, then you could enumerate all the windows so that they > are all updated. If this is some other value, e.g. a preference, then > you could use a global preference observer, or each window could observe > the preference individually. > > As for updating the icon, changing an attribute is usually easier than > changing the class, in case you need to use multiple classes. > Hi Neil, Thanks for your reply. I have roughly gone through about 1/2 of XUL tutorials I have found si far. They mostly just teach me how to build GUI. I still haven't found any tutorial to teach me how to store value. So I'm open to any suggestion. The value is supposed to be persistent (ie its value does not change from a session to another). So that means it's better to store it in preference? And suppose I'm to use the "global preference observer" method you suggested, could you give me a link to any doc or tutorial please? TIA