Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Possible Duplicate:
How to program a status icon that will display in Ubuntu 11.04 as well as in other distributions?

Hello, I have a small audio recording application programmed with GTK/GDK. (see picture). And I would like to add a tray-icon for it so users can control the application window and recording from it.

Adding a tray icon: I have planned to use the GtkStatusIcon class for this task. Ref: http://library.gnome.org/devel/gtk/2.11/GtkStatusIcon.html

Is GtkStatusIcon the recommended solution that also works in Ubuntu's Unity and in the GNOME 3.0 desktop? I already googled a bit and found a good example on GtkStatusIcon.

Could I also use Libindicator for this task? Ref: https://launchpad.net/libindicator

share|improve this question
    
possible duplicates: askubuntu.com/q/13197/3940 and askubuntu.com/q/11162/3940 –  Takkat Jan 3 '11 at 13:00
add comment

marked as duplicate by Marco Ceppi Jun 5 '11 at 20:16

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers

GtkStatusIcon is not supported in Unity.

If you need an icon displayed use Application Indicators instead. They are quite easy to handle but one drawback is that custom icons are not officially supported yet (see this question here), and that application indicators may not be available in other distributions.

In addition, defining custom icons as suggested here does not work in early versions of Application Indicators used in 10.04 LTS.

Therefore you may need that your program checks if Application Indicators are present, and in addition checks the version they have in order to get them running properly. If Application Indicators are not provided or if your application should also run in other distributions you can also use GtkStatusIcons. In this case you will have to program for both paths as was suggested here.

As far as I can see today GtkStatusIcons will still be supported when running classic GNOME Desktop in Ubuntu 11.04 but I don't know about GNOME3.

share|improve this answer
add comment

Thank you for the answer Takkat.

I have now coded the tray icon for my application. It implements both the older GtkStatusIcon class and the new tray icon that uses AppIndicator. The configuration step (before make) checks if the appindicator-0.1 library is present. If it is, then the HAS_APP_INDICATOR variable is defined and set.

Here is my test implementation. Please see http://www.futuredesktop.com/tmp/systray-icon.c

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.