Linux Lib: notify lib (asynchronous notifications)

Developed or developing a new product in PureBasic? Tell the world about it.
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Linux Lib: notify lib (asynchronous notifications)

Post 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...
Last edited by walker on Sat Oct 28, 2006 1:44 am, edited 1 time in total.
thamarok
Enthusiast
Enthusiast
Posts: 282
Joined: Wed Sep 06, 2006 1:37 pm

Post 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!
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Post 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...
Post Reply