Method
XdpPortaladd_notification
Declaration [src]
void
xdp_portal_add_notification (
XdpPortal* portal,
const char* id,
GVariant* notification,
XdpNotificationFlags flags,
GCancellable* cancellable,
GAsyncReadyCallback callback,
gpointer data
)
Description [src]
Sends a desktop notification.
The following keys may be present in notification
:
- title
s
: a user-visible string to display as title - body
s
: a user-visible string to display as body - markup-body
s
: a user-visible string to display as body with support for markup - icon
v
: a serialized icon (in the format produced byg_icon_serialize()
for class@Gio.ThemedIcon, class@Gio.FileIcon and class@Gio.BytesIcon) - sound
v
: a serialized sound - priority
s
: “low”, “normal”, “high” or “urgent” - default-action
s
: name of an action that will be activated when the user clicks on the notification - default-action-target
v
: target parameter to send along when activating the default action. - buttons
aa{sv}
: array of serialized buttons - display-hint
as
: An array of display hints. - category
s
: A category for this notification. See the spec for supported categories
The serialized sound consists of a s
or sv
:
- default : Play the default sound for the notification.
- silent : Don’t ever play a sound for the notification.
- file s
: A path to a sound file.
- bytes ay
: An array of bytes.
The supported sound formats are ogg/opus, ogg/vorbis and wav/pcm.
Each serialized button is a dictionary with the following supported keys:
- label
s
: user-visible label for the button. Mandatory without a purpose. - action
s
: name of an action that will be activated when the user clicks on the button. Mandatory - purpose
s
: information used by the server to style the button specially. - target
v
: target parameter to send along when activating the button
Actions with a prefix of “app.” are assumed to be exported by the
application and will be activated via the org.freedesktop.Application
interface, others are activated by emitting the
XdpPortal::notification-action-invoked
signal.
It is the callers responsibility to ensure that the ID is unique among all notifications.
To withdraw a notification, use xdp_portal_remove_notification()
.
This method completes asynchronously. Use xdp_portal_add_notification_finish()
inside the GAsyncReadyCallback
to obtain the result of the operation.
Parameters
id
-
Type:
const char*
Unique ID for the notification.
The data is owned by the caller of the method. The value is a NUL terminated UTF-8 string. notification
-
Type:
GVariant
A
GVariant
dictionary with the content of the notification.The data is owned by the caller of the method. flags
-
Type:
XdpNotificationFlags
Options for this call.
cancellable
-
Type:
GCancellable
Optional
GCancellable
.The argument can be NULL
.The data is owned by the caller of the method. callback
-
Type:
GAsyncReadyCallback
A callback to call when the request is done.
The argument can be NULL
. data
-
Type:
gpointer
Data to pass to
callback
.The argument can be NULL
.The data is owned by the caller of the method.