GTK: Trayicon with effective 2 lines of C-Code
Because I always wanted to learn some GTK, I decided to try it first with a trayicon. And wow, it was that easy - ok, the functional factor is zero, but you’ll have a trayicon with a tooltip. And if you want more you can read the GTK documentation and extend it to the max.
So here it is: trayicon.c
#include <gtk/gtk.h>
int main(int argc, char *argv[])
{
gtk_init (&argc;, &argv;);
GtkStatusIcon *status = gtk_status_icon_new_from_stock(GTK_STOCK_NO);
gtk_status_icon_set_tooltip(status, "Nice Tooltip");
gtk_main();
return 0;
}
As you can see, beside the C-Standard header and footer, and also the GTK header and footer, we have only two lines of code. Without the tooltip it would be only one.
To compile it, you’ll need the GTK libs and their development headers. The gcc command is:
gcc -Wall trayicon.c -o trayicon `pkg-config --cflags --libs gtk+-2.0`
After starting it, you’ll see a red circle in your tray - Good Luck!