DBus notify images

Post

Posted
Rating:
#1 (In Topic #1142)
Guru
BruceSteers is in the usergroup ‘Guru’
Has anyone managed to use the "icon" property when using DBus DesktopPortal.Notify ?



I've tried various methods
I've read the docs here Portal API Reference - Flatpak documentation

portal docs said

<COLOR color="#0000FF">icon</COLOR> v

    Serialized icon (see g_icon_serialize()).

    The portal only accepts serialized GThemedIcon and GBytesIcons.
Both of these have the form (sv).
For themed icons, the string is "themed", and the value is an array of strings containing the icon names.
For bytes icons, the string is "bytes", and the value is a bytestring containing the icon data in png, jpeg or svg form.
For historical reasons, it is also possible to send a simple string for themed icons with a single icon name.

    There may be further restrictions on the supported kinds of icons.

Code (gambas)

  1.   Dim cNotification As Collection
  2.   Dim s As String = User.Home & "/Pictures/Me.png"
  3.  
  4.   cNotification = ["icon": ["themed": s], "title": Title, "body": "\n" & Text & "\n", "priority": $aPriorities[Priority]]
  5.   DBus["session://org.freedesktop.portal.Desktop"]["/org/freedesktop/portal/desktop", "org.freedesktop.portal.Notification"].AddNotification(Application.Id, cNotification)
  6.  
  7.  

I've tried as an array
Ive tried as a direct string

Code (gambas)

  1.   Dim s As String = File.Load(User.Home & "/Pictures/Me.png")
  2.   cNotification = ["icon": ["bytes": s], "title": Title, "body": "\n" & Text & "\n", "priority": $aPriorities[Priority]]
  3.  

looking like i may need extern library function to get g_icon_serialize() and make a proper GIcon
:(

Or to find someone who knows a way to do this :roll:  :)
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
I'm making an alternative to Message.class that uses DBus notify

This is it in action..
Image

(Click to enlarge)



really need to be able to make images show though.

Currently i have DBMessage.Info() and DBMessage.Question() but want images to enable others like Error.

Code (gambas)

  1. DBMessage.Question(Title As String, Text As String, Buttons As String[], Optional \{Default} As Integer = -1) As Integer
  2.  

There's property DBMessage.Wait that if true DBMessage.Question() will wait for selection then return the value

if false then the program can continue and the static DBMessage_Click() event is used.  (if not Wait then the message can and will timeout)
The form that will get the DBMessage_Click() event can be set using the DBMessage.AttachTo property otherwise it uses either Application.MainWindow or if not set Windows[0].

There is no way to tell if a notification has timed out so to enable "Wait" i am using a trick that just cancels and resends the notification every 6 seconds.
notifications normally timeout in 7 seconds on my machine so i redo the notification until the user interacts.
Online now: No Back to the top

Post

Posted
Rating:
#3
Guru
BruceSteers is in the usergroup ‘Guru’
So I figured something out.

I was trying my code with the icon name "question" thinking that was a stock icon name.
I was wrong and the stock icon i was looking for was called dialog-question :-\

So it turns out you can add icons by simply giving a icon name., i think the available icon name vary on theme being used.
I found the official list from freedesktop https://specifications.freedesktop.org/icon-naming-spec/latest/ar01s04.html

so for notify with a question image i just need to add ["icon": "dialog-question"] to the collection.
Online now: No Back to the top
1 guest and 0 members have just viewed this.