As promised, attached is a heavily commented class implementing DBus Notifications. It is a complete implementation of the specification. There are two approaches to using the class:

1) fill in the properties and call SendNotification:

        Dim hDbusNotify As New DbusNotify
        hDbusNotify.Summary = "Device added:"
        hDbusNotify.Body = "/dev" &/ device
        hDbusNotify.FullPathToIcon = icon
        hDbusNotify.Actions = [""]
        notifyID = dbusNotify.SendNotification()
        mount = UDisks2.Mount(device)
        hDbusNotify.Summary = "Device mounted:"
        hDbusNotify.Body = "/dev" &/ device & " to " & mount
        hDbusNotify.Actions = ["browse=" & mount, "Browse"]
        hints.Add(2, "urgency")
        hDbusNotify.Hints = hints
        hDbusNotify.Duration = 5000
        notifyID = dbusNotify.SendNotification(notifyID)

2) Use the Notify function directly:

        Dim hDbusNotify As New DbusNotify
        Dim hints As New Collection
        hints.Add("device.removed", "category")
hDbusNotify.Notify("Device removed:", "/dev" &/ device, icon, [""], 0, hints, 5000)

DbusNotify raises 2 events:

Public Sub dbusNotify_ActionInvoked(iNotifyID As Integer, sActionKey As String)

  If Left(LCase(sActionKey), 7) = "browse=" Then
    'want to ensure a trailing "/"
    sActionKey = "file://" & Trim(Mid(sActionKey, 8) &/ " ")
    Shell "xdg-open " & sActionKey
  Endif

End

Public Sub dbusNotify_NotificationClosed(iNotifyID As Integer, iReason As Integer)
    'Usually ignored
End

Attachment: dbusNotify.class
Description: application/java

------------------------------------------------------------------------------
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

Reply via email to