LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 11-21-2005, 04:58 PM   #1
Mr_Munkey
Member
 
Registered: Sep 2004
Distribution: Slackware Current
Posts: 33

Rep: Reputation: 15
Linux System Tray Application


Hello everyone,

I'm trying to create a test program that runs in the System Tray on different Window Managers. I haven't been able to find any information yet on how to do it. I'm writing my program in C++ with KDevelop. Does anyone have any good tutorials on the subject?

Thanks!
 
Old 11-21-2005, 05:00 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
AFAIK there is no common API or wrapper for this at all, each panel, dock etc... has it's own interfaces within kde's / gnome's or whoever's API's.
 
Old 11-21-2005, 05:28 PM   #3
Mr_Munkey
Member
 
Registered: Sep 2004
Distribution: Slackware Current
Posts: 33

Original Poster
Rep: Reputation: 15
Thank you for the information.

I've been looking around on both KDE's and Fluxbox's sites, but have yet to find the API for the kicker or the toolbar. If anyone knows information off the top of their head I'd appreciate some help.

Thanks!
 
Old 11-21-2005, 08:27 PM   #4
Mr_Munkey
Member
 
Registered: Sep 2004
Distribution: Slackware Current
Posts: 33

Original Poster
Rep: Reputation: 15
I found this information. It's quite helpful, but I'm not able to tie all the information together just yet.

http://standards.freedesktop.org/sys...-spec-0.2.html

If you've done this before, I'd appreciate some pointers on good documentation or references.

Thanks!
 
Old 11-21-2005, 10:01 PM   #5
gizmo_thunder
Member
 
Registered: Apr 2004
Posts: 101

Rep: Reputation: 15
http://research.iiit.net/~vkrishna/data/trayicon.html
http://research.iiit.net/~vkrishna/data/trayicon1.html

Last edited by gizmo_thunder; 11-21-2005 at 10:48 PM.
 
Old 11-21-2005, 10:04 PM   #6
Mr_Munkey
Member
 
Registered: Sep 2004
Distribution: Slackware Current
Posts: 33

Original Poster
Rep: Reputation: 15
Thank you very much It looks very informitive.

I'll have to try it tomorrow as I'm heading out the door from work.
 
Old 11-22-2005, 05:48 PM   #7
Mr_Munkey
Member
 
Registered: Sep 2004
Distribution: Slackware Current
Posts: 33

Original Poster
Rep: Reputation: 15
I have successfully created a system tray icon with this program. However, I'm running into a bit of a snag.

If you haven't figured out by now, I'm a bit of a noob to QT and KDE programming, but am learning with all the documentation I've found. With that said I'll dive into the issue at hand.

I have figured out how to add items to the KPopupMenu (context menu of KSystemTray), but I am having issues with adding my own custom SLOTS when inheriting off of KPopupMenu. For now I have taken out the feeble attempts at inheriting off of KPopupMenu, as KSystemTray expects only a KPopupMenu, and not a subclass of it.

Code:
#include <kapplication.h>
#include <ksystemtray.h>
#include <kcmdlineargs.h>
#include <qpixmap.h>
#include <kpopupmenu.h>
#include "kickertest.h"

int main( int argc, char **argv ) {
    KApplication q( argc, argv, "Systemtray Test" );
    KickerTest *wid = new KickerTest( );
    
    //Create Instance of KSystemTray
    KSystemTray *tray = new KSystemTray( wid, "Systemtray Test" );
    QPixmap tmp("/opt/kde/share/icons/crystalsvg/22x22/apps/agent.png");

    KPopupMenu *menu = tray->contextMenu();
    menu->changeTitle(0, NULL, "Testing");
    menu->insertTitle("Testing",1,1);
    menu->insertItem( "&Test", menu, SLOT(button_clicked()) );
    
    tray->setPixmap( tmp );
    tray->show( );
    q.setMainWidget( wid );

    return q.exec( );
}
This code works okay, except that the "Test" item does nothing, and the system spits out the following error:

Code:
QObject::connect: No such slot KPopupMenu::button_clicked()
Creating a subclass for a widget or something to that effect would be a lot easier to do, but that's for creating a File, Edit, etc. menu.

I'd appreciate any suggestions on how to add slots for a systemtray application, thanks!
 
Old 11-23-2005, 02:49 PM   #8
Mr_Munkey
Member
 
Registered: Sep 2004
Distribution: Slackware Current
Posts: 33

Original Poster
Rep: Reputation: 15
Hello again,

I thought I'd give everyone an update so that it might help someone else. I have been following the code of KMobileTools, and it makes a lot more sense now.

Instead of creating the KSystemTray in the main.cpp file, I put it in the constructor for my main widget. This allows me to create my public slots for the signals to be connected to.

I'm having another issue now though. From the ksystemtray.cpp and ksystemtray.h files, it looks like the application's Icon and Caption are used for the default title. I am using KDevelop, and have created my .ui file. In there I specified the icon and icon text to be used, but it's not working. The form does not have the icon on it, and the systray title doesn't either.

I tested it by using one of my slots to print out the widget->caption() (KDE uses kapp->caption()) and that printed out the text I expected.

Is there anywhere else that I need to tell the program to set the caption text and miniIcon, or even better, where does kapp come from that's being referenced in ksystemtray so that I can make sure and set those values?

Thanks!
 
  


Reply



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
Linux equivilent to Window's "system tray"? TippyToes Linux - General 18 07-17-2005 08:08 AM
Generating A Tray Application in Linux(as we have in Windows) pihu Programming 2 07-09-2005 02:14 PM
How to generate a Tray like application in Linux as we have in Windows pihu Linux - Software 3 07-09-2005 03:17 AM
Things for KDE system tray in gnome system tray Boffy Linux - General 3 09-17-2004 07:56 AM
Putting my application in the system tray chaturang Linux - Software 2 04-02-2004 09:52 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:55 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
Open Source Consulting | Domain Registration