LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 07-30-2010, 08:23 AM   #1
zirias
Member
 
Registered: Jun 2010
Posts: 361

Rep: Reputation: 59
[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.
 
Old 07-30-2010, 09:08 AM   #2
MS3FGX
Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 351Reputation: 351Reputation: 351Reputation: 351
Libnotify is the only method I am aware of, and that is certainly not portable.
 
Old 07-30-2010, 09:29 AM   #3
dugan
Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 5,004

Rep: Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560Reputation: 1560
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.

Last edited by dugan; 07-30-2010 at 09:35 AM.
 
1 members found this post helpful.
Old 07-30-2010, 09:35 AM   #4
zirias
Member
 
Registered: Jun 2010
Posts: 361

Original Poster
Rep: Reputation: 59
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
 
Old 07-30-2010, 09:37 AM   #5
dugan
Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 5,004

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

Last edited by dugan; 07-30-2010 at 09:45 AM.
 
Old 07-30-2010, 09:45 AM   #6
zirias
Member
 
Registered: Jun 2010
Posts: 361

Original Poster
Rep: Reputation: 59
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Multicolumn" or "tiles", or even "list" icon view on desktop, in any DE? the dsc Linux - Desktop 3 02-20-2010 10:25 AM
icon not in "notification area icons" CmdoColin Linux - Software 1 01-24-2010 08:30 AM
Tray Icon says "A package manager is working" merious Linux - Newbie 6 05-07-2009 12:31 PM
Kde "show desktop" icon / real player plug in alek66 Linux - General 3 06-19-2006 11:33 AM
Cups says "Media tray empty!" but I have +50 sheets of paper in tray... r_jensen11 Linux - Hardware 8 09-07-2004 11:46 PM


All times are GMT -5. The time now is 07:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration