gi-gio-2.0.19: Gio bindings

Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com)
Safe Haskell | None
Language | Haskell2010

GI.Gio.Objects.Notification

Contents

- Exported types
- Methods
  - addButton
  - addButtonWithTarget
  - new
  - setBody
  - setDefaultAction
  - setDefaultActionAndTarget
  - setIcon
  - setPriority
  - setTitle
  - setUrgent

Description

`Notification` 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 `Notification` and other similar APIs is that, if supported by the desktop environment, notifications sent with `Notification` 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 `Notification` should be able to be started as a D-Bus service, using `Application`.

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 `applicationSendNotification`.

Since: 2.40

Synopsis

- newtype Notification = Notification (ManagedPtr Notification)
- class GObject o => IsNotification o
- toNotification :: (MonadIO m, IsNotification o) => o -> m Notification
- noNotification :: Maybe Notification
- notificationAddButton :: (HasCallStack, MonadIO m, IsNotification a) => a -> Text -> Text -> m ()
- notificationAddButtonWithTarget :: (HasCallStack, MonadIO m, IsNotification a) => a -> Text -> Text -> Maybe GVariant -> m ()
- notificationNew :: (HasCallStack, MonadIO m) => Text -> m Notification
- notificationSetBody :: (HasCallStack, MonadIO m, IsNotification a) => a -> Maybe Text -> m ()
- notificationSetDefaultAction :: (HasCallStack, MonadIO m, IsNotification a) => a -> Text -> m ()
- notificationSetDefaultActionAndTarget :: (HasCallStack, MonadIO m, IsNotification a) => a -> Text -> Maybe GVariant -> m ()
- notificationSetIcon :: (HasCallStack, MonadIO m, IsNotification a, IsIcon b) => a -> b -> m ()
- notificationSetPriority :: (HasCallStack, MonadIO m, IsNotification a) => a -> NotificationPriority -> m ()
- notificationSetTitle :: (HasCallStack, MonadIO m, IsNotification a) => a -> Text -> m ()
- notificationSetUrgent :: (HasCallStack, MonadIO m, IsNotification a) => a -> Bool -> m ()

# Exported types

newtype Notification Source #

Memory-managed wrapper type.

Constructors

Notification (ManagedPtr Notification) |

Instances

GObject Notification Source # |
Instance details Defined in GI.Gio.Objects.Notification Methods gobjectType :: Notification -> IO GType Source #
IsObject Notification Source # |
Instance details Defined in GI.Gio.Objects.Notification
IsNotification Notification Source # |
Instance details Defined in GI.Gio.Objects.Notification

class GObject o => IsNotification o Source #

Type class for types which can be safely cast to `Notification`, for instance with `toNotification`.

Instances

(GObject a, (UnknownAncestorError Notification a :: Constraint)) => IsNotification a Source # |
Instance details Defined in GI.Gio.Objects.Notification
IsNotification Notification Source # |
Instance details Defined in GI.Gio.Objects.Notification

toNotification :: (MonadIO m, IsNotification o) => o -> m Notification Source #

Cast to `Notification`, for types for which this is known to be safe. For general casts, use `castTo`.

noNotification :: Maybe Notification Source #

A convenience alias for `Nothing` :: `Maybe` `Notification`.

# Methods

## addButton

notificationAddButton Source #

Arguments

:: (HasCallStack, MonadIO m, IsNotification a) |
=> a | `notification`: a `Notification`
-> Text | `label`: label of the button
-> Text | `detailedAction`: a detailed action name
-> m () |

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

See `actionParseDetailedName` for a description of the format for `detailedAction`.

Since: 2.40

## addButtonWithTarget

notificationAddButtonWithTarget Source #

Arguments

:: (HasCallStack, MonadIO m, IsNotification a) |
=> a | `notification`: a `Notification`
-> Text | `label`: label of the button
-> Text | `action`: an action name
-> Maybe GVariant | `target`: a `GVariant` to use as `action`'s parameter, or `Nothing`
-> m () |

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-`Nothing`, `action` will be activated with `target` as its parameter.

Since: 2.40

## new

notificationNew Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Text | `title`: the title of the notification
-> m Notification | Returns: a new `Notification` instance

Creates a new `Notification` with `title` as its title.

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

Since: 2.40

## setBody

notificationSetBody Source #

Arguments

:: (HasCallStack, MonadIO m, IsNotification a) |
=> a | `notification`: a `Notification`
-> Maybe Text | `body`: the new body for `notification`, or `Nothing`
-> m () |

Sets the body of `notification` to `body`.

Since: 2.40

## setDefaultAction

notificationSetDefaultAction Source #

Arguments

:: (HasCallStack, MonadIO m, IsNotification a) |
=> a | `notification`: a `Notification`
-> Text | `detailedAction`: a detailed action name
-> m () |

Sets the default action of `notification` to `detailedAction`. This action is activated when the notification is clicked on.

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

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

Since: 2.40

## setDefaultActionAndTarget

notificationSetDefaultActionAndTarget Source #

Arguments

:: (HasCallStack, MonadIO m, IsNotification a) |
=> a | `notification`: a `Notification`
-> Text | `action`: an action name
-> Maybe GVariant | `target`: a `GVariant` to use as `action`'s parameter, or `Nothing`
-> m () |

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-`Nothing`, `action` will be activated with `target` as its parameter.

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

Since: 2.40

## setIcon

notificationSetIcon Source #

Arguments

:: (HasCallStack, MonadIO m, IsNotification a, IsIcon b) |
=> a | `notification`: a `Notification`
-> b | `icon`: the icon to be shown in `notification`, as a `Icon`
-> m () |

Sets the icon of `notification` to `icon`.

Since: 2.40

## setPriority

notificationSetPriority Source #

Arguments

:: (HasCallStack, MonadIO m, IsNotification a) |
=> a | `notification`: a `Notification`
-> NotificationPriority | `priority`: a `NotificationPriority`
-> m () |

Sets the priority of `notification` to `priority`. See `NotificationPriority` for possible values.

## setTitle

notificationSetTitle Source #

Arguments

:: (HasCallStack, MonadIO m, IsNotification a) |
=> a | `notification`: a `Notification`
-> Text | `title`: the new title for `notification`
-> m () |

Sets the title of `notification` to `title`.

Since: 2.40

## setUrgent

notificationSetUrgent Source #

Arguments

:: (HasCallStack, MonadIO m, IsNotification a) |
=> a | `notification`: a `Notification`
-> Bool | `urgent`: `True` if `notification` is urgent
-> m () |

Deprecated: (Since version 2.42)Since 2.42, this has been deprecated in favour of `notificationSetPriority`.

Deprecated in favor of `notificationSetPriority`.

Since: 2.40