Can't GtkStatusIcon be modified to show icons in the top bar?
No.
GtkStatusIcon encodes the XEMBED-based tray icon specification; this means that the application code is responsible for:
- sending icon data over the wire (no HiDPI, and transparency is a hack that breaks every other release)
- responding to pointer and keyboard events
The latter part means that applications that show a menu are responsible for creating and managing the menu window and placing it at the right coordinates—which simply does not work in a compositor and in Wayland, respectively. The menu would also be styled by the toolkit, instead of being styled by the compositor.
The only way to integrate "status icons" inside the shell UI is to move to a purely descriptive format:
- send the icon name from the theme
- send the description of the menu over the wire
This would let the compositor display the icon using the appropriate resolution and transparency, and it would let the compositor build and display the menu. Sadly, this means a complete API change, which makes the point moot: applications would need to be changed.
In any case, we do have API to achieve this—it's GMenu, and we used it for the application menu and for integration inside Unity for the global menus; it's also not used outside of GTK3 applications, and even then people do like using GtkMenu so much, so the point is still moot.
The appindicator API/StatusNotifier specification comes close to this, but:
- appindicator is a deprecated and unmaintained API, which still falls back to the XEMBED protocol
- it's also a hack that takes a GtkMenu, serialises it, and sends it over the wire
- the StatusNotifier specification is all kinds of terrible, and basically the only implementation (appindicator and the KDE one) are normative because, according to the letter of the StatusNotifier specification, implementations that didn't do anything, or sent your status icons to Alpha Centauri and waited for user input there, are perfectly conformant
Permanently adding the extension code to the shell (which, if I've undesrtood properly, "moves" icons from tray to topbar) will be a dirty but effective solution.
Which would achieve nothing except, once again, shoving icons and menus into one of the most important pieces of screen real estate we have just because some application developers simply cannot live without their application icons being visible at all times. If you want to do that, use the extension. It's there for a reason.
The tray icons were designed and meant for system status notifications: network state connectivity, volume level, battery level, IM status (when it was a thing). They were hijacked by application developers to have panel applets that would work across desktop environments. It was a bad idea then, and nothing has changed in that regard.
Maybe we should maintain top-icons inside gnome-shell-extensions, so that
it doesn't fall into disrepair because its maintainers are busy or
bored.
I think, from my deep lack of knowledge about how it works, thak GtkStatusIcon could be modified to show icons in the topbar, so applications will keep calling to it without modifications, but icons would appear in the topbar instead of in the tray.
If this is technically impossible just forget about it :-)
Believe me, I would *love* if people "forgot about it"; but it seems this things have to be explained every six months, on every forum in existence, until the end of time, so here we are.
Ciao,
Emmanuele.