Skip to content

IndicatorMenuItemFactory: back to activate() for switch, but more clever

As it turns out, not every indicator supports using changeState(). I think none of us [1] has ever used changeState() before - I only observe that many indicators support it. As such, it's probably not the correct way after all. It's a great example of "trying to be too clever".

As such, I figure that it's better to go back to activate() rather than inspect every indicator if it supports using changeState() or not. This time, however, instead of checking for item type, check if the menu item has a 'target' attribute or not. This is required for actions with parameter already as otherwise it won't show up as activatible, thus it's perfect for detection. (I hope I'm not being "too clever" this time...)

That said, at least 1 indicator from AyatanaIndicator is updated to support changeState() [2]. Luckily for it, using activate() is still supported through the "default code" provided by GIO itself [3]. So activate() should continue to work. Actually, it has to continue to work otherwise ayatana-ido breaks.

[1] As in, Canonical, UBports, and AyatanaIndicator. [2] https://github.com/AyatanaIndicators/ayatana-indicator-power/pull/73 [3] https://gitlab.gnome.org/GNOME/glib/-/blob/30202e9b59b0ba1bda50ce8f472be7f4a4c49550/gio/gsimpleaction.c#L230-242

Fixes: indicator-location#2 (closed)

Merge request reports