20

I want my GTK application to have a status icon in the system tray, I have got this working quite nicely using a StatusIcon, however this has been deprecated:

gtk_status_icon_new has been deprecated since version 3.14 and should not be used in newly-written code.

Use notifications

The documentation says "Use notifications" but I have no idea what this actually means. I interpret this to mean "use desktop notifications", but as far as I can tell that serves an entirely different purpose. I want an always-visible system tray icon, not a temporary popup notification. Despite that, I can't find anything else which would seem to be what is meant by "Notifications".

Does there exist a new replacement for GtkStatusIcon which provides an icon in the system tray, with support for receiving mouse click/scroll signals and displaying popup menus?

Community
  • 1
  • 1
Tomha
  • 737
  • 2
  • 6
  • 16

1 Answers1

11

Unfortunately yes, they refer to desktop notifications. If you still want to use system tray icons, then keep using GtkStatusIcon; just note that it is likely going to be removed soon. (The point is that more things have desktop notifications than status icons, but I'm sure there's other reasons as well. GTK+ probably shouldn't deal with desktop environment-specific stuff like that anyway... There's nothing stopping anyone from making a GtkStatusIcon replacement of their own, but no one seems to have done so yet.)

andlabs
  • 10,462
  • 1
  • 25
  • 46
  • 7
    That's disappointing, I would have hoped GTK would make an effort to remain more versatile than that. I guess I'll just continue using GtkStatusIcon and hope an alternative arises before its removed. Thanks for clearing it up. – Tomha Jan 29 '17 at 07:57
  • 2
    It's not going to be removed in GTK+ 3, but it might be removed in GTK+ 4, which is not backwards compatible. So you won't have to worry until you do migrate your code over, when that version of GTK+ comes around. It might be removed in a later version that that; I wouldn't know. As for versatility, GTK+ doesn't provide notifications either! You'd have to go to a separate library, such as libnotify, to do it. – andlabs Jan 29 '17 at 08:11
  • That's true about notifications, I've primarily been using GTK with Python so I'm used to importing notifications along with GTK all from the GI API and that hadn't occured to me. I'll be interested to see how this is approached in future versions of GTK, though provided I can keep it working with GTK+ 3, that should do perfectly well for the time being. – Tomha Jan 29 '17 at 12:29
  • 8
    It is already removed from Gtk4. Also AppIndicator is a valid replacement on desktops where tray icons are part of their design (KDE 5, Unity), They are not a part of Gnome design though. – TingPing Jan 30 '17 at 02:18
  • 1
    Gtk+ 3 does have support for notifications through the `g_application_send_notification` API. However your application must be using `GApplication`/`GtkApplication` – Zander Brown Jun 21 '17 at 11:12
  • 9
    Deprecating the status-icon is the worst decision ever made by Gtk. Notifications simply are not the same thing and simply do not provide what status icons do. The assumption that developers have mostly been using status icons for notifications is outright preposterous. They've mostly been using it to create utilities that you always want running and remain readily accessible, but don't want in your way. Notifications are completely and utterly useless for that kind of functionality. – Teekin Aug 09 '19 at 17:24
  • 3
    Linux Mint has decided to implement their own fork of the GtkStatusIcon, named [XApPStatusIcon](https://blog.linuxmint.com/?p=3795) – bgStack15 Oct 19 '19 at 01:01