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

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

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

STF-7
        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.
_______________________________________________
dev-tech-xul mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xul
Reply | Threaded
Open this post in threaded view
|

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

Neil-4
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.
_______________________________________________
dev-tech-xul mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xul
Reply | Threaded
Open this post in threaded view
|

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

STF-7
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
_______________________________________________
dev-tech-xul mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xul
Reply | Threaded
Open this post in threaded view
|

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

Neil-4
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.

--
Warning: May contain traces of nuts.
_______________________________________________
dev-tech-xul mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xul