Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: Notification

[39:7] extends: object

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 [class@Gio.Application]. 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 [ctor@Gio.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 [method@Gio.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.

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • Notification (title = null)

    Creates a new #GNotification with @title as its title. After populating

    • @notification with more details, it can be sent to the desktop shell with g_application_send_notification(). Changing any properties after this call will not have any effect until resending @notification.
    • @p title is the title of the notification.
  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • asObject ()

    Wraps this handle as Object.

    • @r A Object object.
  • add_button (string label, string detailed_action)

    Adds a button to @notification 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 g_action_parse_detailed_name() for a description of the format for
    • @detailed_action. ``
    • @p label is label of the button.
    • @p detailed_action is a detailed action name.
    • @r None.
  • add_button_with_target_value (string label, string action, object target)

    Adds a button to @notification that activates @action when clicked.

    • @action must be an application-wide action (it must start with "app."). If @target is non-%NULL, @action will be activated with @target as its parameter.
    • @p label is label of the button.
    • @p action is an action name.
    • @p target is a #GVariant to use as @action's parameter, or %NULL.
    • @r None.
  • set_body (string body)

    Sets the body of @notification to @body.

    • @p body is the new body for @notification, or %NULL.
    • @r None.
  • set_category (string category)

    Sets the type of @notification 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.

    • @p category is the category for @notification, or %NULL for no category.
    • @r None.
  • set_default_action (string detailed_action)

    Sets the default action of @notification 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 g_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.
    • @p detailed_action is a detailed action name.
    • @r None.
  • set_default_action_and_target_value (string action, object target)

    Sets the default action of @notification to @action. This action is activated when the notification is clicked on. It must be an application-wide action (start with "app."). If @target is non-%NULL,

    • @action will be activated with @target as its parameter. If @target is floating, it will be consumed. When no default action is set, the application that the notification was sent on is activated.
    • @p action is an action name.
    • @p target is a #GVariant to use as @action's parameter, or %NULL.
    • @r None.
  • set_icon (object icon)

    Sets the icon of @notification to @icon.

    • @p icon is the icon to be shown in @notification, as a #GIcon.
    • @r None.
  • set_priority (string priority)

    Sets the priority of @notification to @priority. See #GNotificationPriority for possible values.

    • @p priority is a #GNotificationPriority.
    • @r None.
  • set_title (string title)

    Sets the title of @notification to @title.

    • @p title is the new title for @notification.
    • @r None.
  • set_urgent (bool urgent)

    Deprecated in favor of g_notification_set_priority().

    • @p urgent is %TRUE if @notification is urgent.
    • @r None.