Page 1 of 1

Linux Lib: notify lib (asynchronous notifications)

Posted: Fri Oct 27, 2006 6:17 pm
by walker
You ever wanted to have an asynchronous notification? here it is:
Requires the libnotify and devel files...
It looks like:

Image

which will (if no gadget or window is specified) pops up in the lower right corner

or like this if a gadget is specified (a WindowID will work too)

Image

An example:

Code: Select all

	#NOTIFY_URGENCY_LOW         = 0;,		 /**< Low urgency.      */
	#NOTIFY_URGENCY_NORMAL   = 1;,	    /**< Normal urgency.   */
	#NOTIFY_URGENCY_CRITICAL   = 2;,       /**< Critical urgency. */

Procedure mycallback()
; if the notification is clicked somwhere, this code will be executed...
EndProcedure

pgm.s=ProgramFilename()
notify_init_(@pgm); necessary to init the notification server for your program
hwnd=OpenWindow(0,200,100,500,350,"")
CreateGadgetList(WindowID(0))
    ButtonGadget(1,10,10,100,30,"Test")
    mn=notify_show("titel","body",50,#NOTIFY_URGENCY_NORMAL,GadgetID(1)); the notification is added to a gadget
;     mn=notify_show("titel","body",50,2,0); use this line to see the difference
;if you need an action when the notification is clicked
    action.s="default"
    label.s="clicked"
    notify_add_action(mn,@action,@label,@mycallback(),0,0)
;---------------------
CloseGadgetList()
Repeat
    ev=WaitWindowEvent(1)
ForEver
End
and at least the lib:
http://home.arcor.de/x-linux/pure/notify/notify_lib (copy it to purebasic/purelibraries/userlibraries

and the source:
http://home.arcor.de/x-linux/pure/notify/notify_lib.pb

there is a further commant in the lib notify_close(*notify) which is not used in the example...

I guess, you can see how it works.. otherwise questions are welcome as well as suggestions and comments...

Posted: Fri Oct 27, 2006 8:04 pm
by thamarok
Thank you walker!
If someone knows what software Linux needs then you :wink:
I'm going to use that for my TeamSpeak clone for Linux, ok?

Thanks!

Posted: Fri Oct 27, 2006 8:10 pm
by walker
yes, why not.... feel free to use it ... that's the reason why I'd released it :D :D and I'm happy if my work is used somewhere (so I know it wasn't wasted time :wink: )
The libnotify-lib has much more possibillities than used for now (i.E a image in the notification and much more) and they will be integrated by time...