I am using this code to set appropriate appindicator icon for my application. Basically I set separate mono dark/light icon for Ambiance and Radiance theme in order to integrate my app into Unity desktop just like many other apps do. This works well, but what I noticed is that other apps (Tomboy, thunderbird...) update their appindicator icons immediately after the theme is changed. How do they do that? With my current implementation, I need to restart my app in order to get the right icon.
Tomboy does not actually have a code for detecting theme changes. Its icon changes automatically because there is a Tomboy icon both in the ubuntu-icon-dark icon theme (used by Ambiance) and in the ubuntu-icon-light icon theme (used by Radiance). That's the recommended way.