Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Add-on bar or navigation toolbar icon showing same status across windows

12 views
Skip to first unread message

STF

unread,
May 14, 2013, 12:59:28 PM5/14/13
to
I want to make an app which shows a status (let's say ON and OFF) by
changing an icon image in the add-on bar or the navigation toolbar.

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.

If someone has some tutorial on this, it would be a great help. Thanks
in advance.

Neil

unread,
May 15, 2013, 3:47:38 PM5/15/13
to
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.

--
Warning: May contain traces of nuts.

STF

unread,
May 24, 2013, 9:54:27 AM5/24/13
to
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

Neil

unread,
May 27, 2013, 4:12:33 PM5/27/13
to
STF wrote:

> 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?

For a simple boolean value then that is probably the easiest way to
persist it.

> 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?

There are a number of useful documents for traditional extensions. This
one seems particularly suited for someone wanting to add preferences to
an existing extension:
https://developer.mozilla.org/en/docs/Adding_preferences_to_an_extension

Unfortunately I couldn't find any documentation for JetPack extensions.
0 new messages