[Gambas-user] Balloons, everywhere but when I don't want them.

Tony Morehen tmorehen at ...3602...
Fri Aug 18 16:34:39 CEST 2017


BTW the attached code is not fully functional.  It tries to listen for a 
signal on both the system bus (Udisks2 signal) and the session bus 
(Notifications).  Unfortunately, Gambas can only listen to one bus at a 
time, the second declared bus is ignored. As a result, the code that 
responds to the Notifications signal is never called.

I've opened a bug report (1132) on this issue.


On 2017-08-18 10:05 AM, Tony Morehen wrote:
> 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 etc
>   Dim 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 notifications
>
> Private  NotifySignal as New DbusSignal(Dbus.Session,NotifyInterface, 
> True) As "NotifyDbusSignal"
> 'signal handler
> Public Sub NotifyDbusSignal_Signal(Signal As String, Arguments As 
> Variant[])
>   Select Case Signal
>     Case "NotificationClosed"
>     Case "ActionInvoked"
>       'Arguments[0] contains TextToSignal from above
>   End Select
> End
>
> You 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, adamnt42 at ...626... 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
>>
>
>
>
> ------------------------------------------------------------------------------
> 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 at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user




More information about the User mailing list