Gambas can talk to the notifications daemon via Dbus. I use this code:
Private NotifyInterface As String = "org.freedesktop.Notifications" Private NotifyApp As String = "session://" & NotifyInterface Private NotifyPath As String = "/" & Replace(NotifyInterface, ".", "/") 'does the daemon support icon, body, button to click etcDim sArray As String[] = Dbus[NotifyApp][NotifyPath, NotifyInterface].GetCapabilities() 'popup (the hintsCollection is an empty collection, iDuration = -1, use default) notifyID = Dbus[NotifyApp][NotifyPath, NotifyInterface].Notify(AppName, notifyID, IconPath,SummaryText, BodyText, [TextToSignal, ButtonText], hintsCollection, iDuration)
'setup dbussignal to get popup closed and and buttonpressed notificationsPrivate NotifySignal as New DbusSignal(Dbus.Session,NotifyInterface, True) As "NotifyDbusSignal"
'signal handlerPublic Sub NotifyDbusSignal_Signal(Signal As String, Arguments As Variant[])
Select Case Signal Case "NotificationClosed" Case "ActionInvoked" 'Arguments[0] contains TextToSignal from above End Select EndYou can see the code in action in the attached gbAutoMount code. This app uses Udisks2 to automatically mount usb drives when plugged in.
On 2017-08-18 09:28 AM, Tobias Boege wrote:
On Fri, 18 Aug 2017, adamn...@gmail.com wrote:Probably obscure, but I'll give it a go anyway... This project has about 80 or so Timers running at any given time, when they fire some stuff is updated and then a balloon pops up to alert the user that some update has happened. All fantastic. And an added bonus is that the balloon pops up on any virtual desktop. Which is even more fantastic as far as I am concerned and exactly what I have been looking for for some years. What is not so great is that when this happens on the desktop where the app is running, not only does the balloon appear, but the actual form that produces the balloon gets popped up to the top of the desktop. Which is infuriating if the user is actually in another app on that desktop. Even further, the project itself has a bunch of popup forms where the user can enter manual updates of some data. When the balloon appears (and the main form) the popup is lowered and you cannot bring it back to the top layer. I'll try a more concrete example (or two), to see if I can explain what I am trying to do a bit more clearly. I have my email client (sylpheed) running, every so often it goes and checks for incoming mail. If there is some new mail a boxy looking thing appears at the bottom right corner of the screen telling me I have new mail. No matter which desktop I am actually on at the time. A bit later that boxy thing fades away. It doesn't interrupt what I am doing in any way, nor does it pop up the main email client screen. Similarly, on my laptop I have Batti running which when I'm getting a bit low on battery power pops up a message in the desktop panel telling me to plug the damn thing in. Again this does not interrupt what I'm doing. So, how can I achieve the same effect in gambas?Sounds like a feature of your DE (and I'm not good with DEs) but a quick search suggests something called libnotify for sending desktop notifications. It is said to be toolkit- and desktop-independent, but you need a conforming notification daemon running -- which you may already have, if you can see notifications from other programs (assuming they use the same machinery). So, I guess you would need a gb.libnotify component (it really doesn't look hard to do, there's only maybe 3 dozen functions in the library and it seems you only need as few as 5 of them to show your first notification). If you can't do that, there seems to be a tool called "notify-send" which looks like it lets you access all the library features via the command-line. That said, notify-send does nothing on my desktop, probably because I don't run a fancy notification server... Regards, Tobi
gbAutoMount-0.0.3.tar.gz
Description: application/gzip
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user