[Thunderbird] Adding and removing UI elements in restartless TB addon

Hi guys

I develop a restartless addon for Thunderbird. I need to add some UI elements in compose window when the addon is activated.

What I did so far is:

  • at startup, add an observer on windows via nsIWindowWatcher

  • at shutdown, remove window observer, and set a variable X to true

  • when this observer observes domwindowopened event, add a
    eventlistener to the opened window for “compose-window-init” event (when
    it observes domwindowclosed, it removes the eventlistener)

  • when this compose-window-init event is fired, check the
    document.location of the window, if it corresponds to a message
    composer:

  • add the UI elements,

  • or remove UI elements and remove eventListener, if X is set to true

This works well (UI is added to compose message when addon is
activated, and removed when deactivated) except the following : when
addon is deactivated then activated again, the first compose message is
not provided with the UI elements. The UI is added to the other one, but
not to the first.

Any idea on why and how to solve this ?

Thx

Its nice to see some dev on TB, we need more of that.

    o_marce can you share your code? Maybe a GitHub link

Hi, I found what was wrong, see my post here:
http://forums.mozillazine.org/viewtopic.php?f=19&t=2949755&p=14254205#p14254205

I’ll share the code later on, when my addon will be ready or close to.

Regards