1.62 <GNotification>

Class: <GNotification>

It derives from <GObject>.

<GNotification> is a mechanism for creating a notification to be shown to the user — typically as a pop-up notification presented by the desktop environment shell.

The key difference between <GNotification> and other similar APIs is that, if supported by the desktop environment, notifications sent with <GNotification> will persist after the application has exited, and even across system reboots.

Since the user may click on a notification while the application is not running, applications using <GNotification> should be able to be started as a D-Bus service, using <GApplication>.

In order for <GNotification> to work, the application must have installed a .desktop file. For example:

[Desktop Entry]
Name=Test Application
Comment=Description of what Test Application does
Exec=gnome-test-application
Icon=org.gnome.TestApplication
Terminal=false
Type=Application
Categories=GNOME;GTK;TestApplication Category;
StartupNotify=true
DBusActivatable=true
X-GNOME-UsesNotifications=true

The X-GNOME-UsesNotifications key indicates to GNOME Control Center that this application uses notifications, so it can be listed in the Control Center’s ‘Notifications’ panel.

The .desktop file must be named as org.gnome.TestApplication.desktop, where org.gnome.TestApplication is the ID passed to application:new.

User interaction with a notification (either the default action, or buttons) must be associated with actions on the application (ie: app. actions). It is not possible to route user interaction through the notification itself, because the object will not exist if the application is autostarted as a result of a notification being clicked.

A notification can be sent with application:send-notification.

In Windows, notification actions are unsupported, when sending the notification a warning will be printed if a default action or action buttons were added.

Procedures

Method: notification:add-button self label detailed-action
Method: add-button self label detailed-action

Adds a button to self that activates the action in detailed-action when clicked. That action must be an application-wide action (starting with "app."). If detailed-action contains a target, the action will be activated with that target as its parameter.

See action-parse-detailed-name for a description of the format for detailed-action.

self

Passed: a <GNotification>.

a <GNotification>

label

Passed: a string.

label of the button

detailed-action

Passed: a string.

a detailed action name

Method: notification:add-button-with-target self label action [target]
Method: add-button-with-target self label action [target]

Adds a button to self that activates action when clicked. action must be an application-wide action (it must start with "app.").

If target-format is given, it is used to collect remaining positional parameters into a <GVariant> instance, similar to g_variant_new(). action will be activated with that <GVariant> as its parameter.

self

Passed: a <GNotification>.

a <GNotification>

label

Passed: a string.

label of the button

action

Passed: a string.

an action name

target

Passed, or left out: a <GVariant>, or #f.

target-format

a <GVariant> format string, or #f

...

positional parameters, as determined by target-format

Procedure: notification:new title ⇒ %return

Creates a new <GNotification> with title as its title.

After populating notification with more details, it can be sent to the desktop shell with application:send-notification. Changing any properties after this call will not have any effect until resending notification.

title

Passed: a string.

the title of the notification

%return

Returned: a <GNotification>.

a new <GNotification> instance

Method: notification:set-body self [body]
Method: set-body self [body]

Sets the body of self to body.

self

Passed: a <GNotification>.

a <GNotification>

body

Passed, or left out: a string, or #f.

the new body for self, or #f

Method: notification:set-category self [category]
Method: set-category self [category]

Sets the type of self to category. Categories have a main type like email, im or device and can have a detail separated by a ., e.g. im.received or email.arrived. Setting the category helps the notification server to select proper feedback to the user.

Standard categories are listed in the specification.

self

Passed: a <GNotification>.

a <GNotification>

category

Passed, or left out: a string, or #f.

the category for self, or #f for no category

Method: notification:set-default-action self detailed-action
Method: set-default-action self detailed-action

Sets the default action of self to detailed-action. This action is activated when the notification is clicked on.

The action in detailed-action must be an application-wide action (it must start with "app."). If detailed-action contains a target, the given action will be activated with that target as its parameter. See action-parse-detailed-name for a description of the format for detailed-action.

When no default action is set, the application that the notification was sent on is activated.

self

Passed: a <GNotification>.

a <GNotification>

detailed-action

Passed: a string.

a detailed action name

Method: notification:set-default-action-and-target self action [target]
Method: set-default-action-and-target self action [target]

Sets the default action of self to action. This action is activated when the notification is clicked on. It must be an application-wide action (it must start with "app.").

If target-format is given, it is used to collect remaining positional parameters into a <GVariant> instance, similar to g_variant_new(). action will be activated with that <GVariant> as its parameter.

When no default action is set, the application that the notification was sent on is activated.

self

Passed: a <GNotification>.

a <GNotification>

action

Passed: a string.

an action name

target

Passed, or left out: a <GVariant>, or #f.

target-format

a <GVariant> format string, or #f

...

positional parameters, as determined by target-format

Method: notification:set-icon self icon
Method: set-icon self icon

Sets the icon of self to icon.

self

Passed: a <GNotification>.

a <GNotification>

icon

Passed: a <GIcon>.

the icon to be shown in self, as a <GIcon>

Method: notification:set-priority self priority
Method: set-priority self priority

Sets the priority of self to priority. See <GNotificationPriority> for possible values.

self

Passed: a <GNotification>.

a <GNotification>

priority

Passed: a <GNotificationPriority>, or one of its symbols.

a <GNotificationPriority>

Method: notification:set-title self title
Method: set-title self title

Sets the title of self to title.

self

Passed: a <GNotification>.

a <GNotification>

title

Passed: a string.

the new title for self

Method: notification:set-urgent self urgent
Method: set-urgent self urgent

Deprecated in favor of notification:set-priority.

self

Passed: a <GNotification>.

a <GNotification>

urgent

Passed: a boolean.

#t if self is urgent