LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   [C/C++] Show notification "balloon" on tray icon -- portable way? (http://www.linuxquestions.org/questions/programming-9/%5Bc-c-%5D-show-notification-balloon-on-tray-icon-portable-way-823025/)

zirias 07-30-2010 07:23 AM

[C/C++] Show notification "balloon" on tray icon -- portable way?
 
Hi,

for showing incoming phone calls on all desktops in my home network, I'm using two little perl scripts, one on the server that sends UDP broadcasts with all call info, one on the desktops listening for this broadcasts and showing a popup window.

Now I'd like to improve usability by rewriting the "client" side so it just sits in the tray and shows "balloon" notifications there. The result should work on Linux (opendesktop specs for tray) and windows. Windows has an API for that, see here: http://msdn.microsoft.com/en-us/magazine/cc188923.aspx.

For doing it in Linux, I found libnotify (see for example here: http://manishtech.wordpress.com/2009...ith-libnotify/). Looks nice, but as far as I understand (the documentation is POOR), it needs d-bus and is NOT portable to win32. Or maybe I'm wrong here? Does anybody know of a portable way to show these notifications, maybe using another library?

I'd prefer C, although C++ would do, too. I don't want to use Mono and Windows.Forms, which uses win32 native api and emulates it on linux, because I think it's ridiculous to carry a huge runtime around for such a little tool.

MS3FGX 07-30-2010 08:08 AM

Libnotify is the only method I am aware of, and that is certainly not portable.

dugan 07-30-2010 08:29 AM

Displaying a system tray icon, which is the subject of your first link, is portable.

Qt:
http://doc.trolltech.com/latest/qsystemtrayicon.html

GTK:
http://library.gnome.org/devel/gtkmm...tatusIcon.html

Java:
http://java.sun.com/developer/techni...e6/systemtray/

SWT Java library:
http://www.eclipsezone.com/eclipse/forums/t66093.html

Listening on a socket to incoming UDP packets is portable too.

zirias 07-30-2010 08:35 AM

No, the icon itself is NOT subject of this article. I know GtkStatusIcon handles this portably, got the code for THAT working in 10 minutes ;)

It's really about the balloon notification and this particular article explains the "raw" C win32-api to do so.

Thanks MS3FGX, now I know at least ONE thing for sure. Do you have more info about libnotify? Is it possible to just use its "balloon drawing" capabilities, without the notification event communication through d-bus? Maybe I'm after all not to lazy to create separate code paths for win32 and *nix/opendesktop :o

dugan 07-30-2010 08:37 AM

The Qt and SWT tray icon widgets, which I've referred you to documentation on, support balloon tips.

zirias 07-30-2010 08:45 AM

Hi dugan,

look closer at the GtkStatusIcon interface ... it /doesn't/ have a balloon notification, only a tooltip (which can't be triggered actively but is shown for mouse-over). That's where I was coming from (although using the C binding).

But: Thanks a lot for pointing to the Qt interface. QSystemTrayIcon::showMessage() looks EXACTLY like what I've been looking for, and from the doxy description, it seems it IS portable, using native functionality of the different platforms -- great. Unfortunately it is C++ ... well then, byebye ISO-C for THIS project.


All times are GMT -5. The time now is 04:54 PM.