You are not logged in.

#1 2005-04-09 22:29:52

darkcoder
Member
From: A bar near you
Registered: 2004-09-10
Posts: 310

help with freedesktop notification area

Can someone point to a sample code to implement an icon on the notification area using the freedesktop standard from http://www.freedesktop.org/wiki/Standar … ray_2dspec

And if possible, a sample which uses only GTK/Xfree calls, no Gnome, or QT/KDE libs please.

Offline

#2 2005-04-10 00:00:51

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: help with freedesktop notification area

http://www-106.ibm.com/developerworks/l … ry/l-wrap/

That page is wrapping python over the top of a C module, so if you're smart enough you ought to be able to work out the C module it's using. Either way, you could also do it in python too big_smile

Offline

#3 2005-04-10 16:54:25

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: help with freedesktop notification area

int format;
long nitems, bytes, *data;
Atom type, net_wm_icon = XInternAtom(display,"_NET_WM_ICON",False);

XGetWindowProperty(display,window,net_wm_icon,0, MAX_LONG,False, XA_CARDINAL,
                          &type,&fmt,&nitems,&bytes,(unsigned char **)&data);
//...data now has pixel values for icon

that's how to *get* and icon from the application... you'd just need to use that data to draw the icon.... that depends entirely on whatever you're doing

Offline

#4 2005-04-10 18:50:35

neri
Forum Fellow
From: Victoria, Canada
Registered: 2003-05-04
Posts: 552

Re: help with freedesktop notification area

Hi,

I think you can have a look at sylpheeds systray-icon, it's all in one .c file
using gtk or gtk2, depends on which version you use. It implemets a lot of
functionality, hiding , right-click, procedure calls ...

-ner

Offline

#5 2005-04-12 04:14:28

darkcoder
Member
From: A bar near you
Registered: 2004-09-10
Posts: 310

Re: help with freedesktop notification area

thanks a lot for the info and samples, I will give it a look.

Offline

#6 2005-04-12 15:21:03

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: help with freedesktop notification area

oh wait - you're looking for sys-tray... the netWM stuff I listed was for the embedded icon that's displayed in taskbars/titlebars... i.e. firefox has it's icon next to it when listed on a netWM compatible panel.

Offline

#7 2005-04-12 15:31:59

darkcoder
Member
From: A bar near you
Registered: 2004-09-10
Posts: 310

Re: help with freedesktop notification area

yes, I already has the icon, I only want to put that Icon on the system tray when the main window is closed, for example like Gaim do.  I'm currently studying the gaim source.

I want to do that with X, or GTK2 code.  Do not want any Gnome code at all.  The less bindings to gnome it has, the more attractive at the end the program will be for non gnome users. big_smile

Offline

#8 2005-04-12 15:59:30

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: help with freedesktop notification area

Well, to do it with raw Xlib, you can use the following to dock the new window:

/*** NOTE:
tray_icon is the window which you want docked
It should support: _NET_WM_NAME, WM_CLASS, _NET_WM_ICON

I'm not sure if the window actually needs any visual representation... the _NET_WM_ICON may handle it
***/
    Window tray_icon, systray;
    unsigned long xembed_info[2];
    XEvent e;

    //Set XEMBED info
    xembed_info[0] = 0;
    xembed_info[1] = 0;
    XChangeProperty(display, tray_icon,
        XInternAtom(display, "_XEMBED_INFO", False ),
        XInternAtom(display, "_XEMBED_INFO", False ),
        32, PropModeReplace, (unsigned char*)xembed_info, 2);

    //systray window
    //NOTE: _NET_SYSTEM_TRAY_Sx where x is Screen#
    //    You can use DefaultScreen(...) to get the actual #
    systray = XGetSelectionOwner(display, XInternAtom(display, "_NET_SYSTEM_TRAY_S0", False ),

    //now dock into the systray
    e.xclient.type = ClientMessage;
    e.xclient.window = systray;
    e.xclient.message_type = XInternAtom (display, "_NET_SYSTEM_TRAY_OPCODE", False );
    e.xclient.format = 32;
    e.xclient.data.l[0] = CurrentTime;
    e.xclient.data.l[1] = SYSTEM_TRAY_REQUEST_DOCK;
    e.xclient.data.l[2] = tray_icon;
    e.xclient.data.l[3] = 0;
    e.xclient.data.l[4] = 0;

    XSendEvent(display, systray, False, NoEventMask, &e);
    XSync(display, False);

This isn't guarenteed to work... I've done it once before, but this was written in the forums, so who knows what crazy errors I introduced... take it with a grain of salt - I'm assuming you know what you're doing and can make this work

Offline

Board footer

Powered by FluxBB