Gio::Notification Class Reference

User Notifications (pop up messages). More...

`#include <giomm/notification.h>`

Inheritance diagram for Gio::Notification:
[legend]

## Public Member Functions

| Notification (Notification&& src) noexcept
Notification& | operator= (Notification&& src) noexcept
| ~Notification () noexcept override
GNotification* | gobj ()
| Provides access to the underlying C GObject. More...
const GNotification* | gobj () const
| Provides access to the underlying C GObject. More...
GNotification* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
void | set_title (const Glib::ustring& title)
| Sets the title of notification to title. More...
void | set_body (const Glib::ustring& body)
| Sets the body of notification to body. More...
void | set_icon (const Glib::RefPtr< Icon >& icon)
| Sets the icon of notification to icon. More...
void | set_urgent (bool urgent=true)
| Deprecated in favor of g_notification_set_priority(). More...
void | set_priority (NotificationPriority priority=NOTIFICATION_PRIORITY_NORMAL)
| Sets the priority of notification to priority. More...
void | add_button (const Glib::ustring& label, const Glib::ustring& detailed_action)
| Adds a button to notification that activates the action in detailed_action when clicked. More...
template<typename T_Value >
void | add_button (const Glib::ustring& label, const Glib::ustring& action, const T_Value& target)
| Adds a button that activates action when clicked. More...
void | add_button_variant (const Glib::ustring& label, const Glib::ustring& action, const Glib::VariantBase& target)
| Adds a button to notification that activates action when clicked. More...
void | set_default_action (const Glib::ustring& detailed_action)
| Sets the default action of notification to detailed_action. More...
template<typename T_Value >
void | set_default_action (const Glib::ustring& action, const T_Value& target)
| Sets the default action to action. More...
void | set_default_action_variant (const Glib::ustring& action, const Glib::VariantBase& target)
| Sets the default action of notification to action. More...
Public Member Functions inherited from Glib::Object
| Object (const Object&)=delete
Object& | operator= (const Object&)=delete
| Object (Object&& src) noexcept
Object& | operator= (Object&& src) noexcept
void* | get_data (const QueryQuark& key)
void | set_data (const Quark& key, void* data)
void | set_data (const Quark& key, void* data, DestroyNotify notify)
void | remove_data (const QueryQuark& quark)
void* | steal_data (const QueryQuark& quark)
Public Member Functions inherited from Glib::ObjectBase
| ObjectBase (const ObjectBase&)=delete
ObjectBase& | operator= (const ObjectBase&)=delete
void | set_property_value (const Glib::ustring& property_name, const Glib::ValueBase& value)
| You probably want to use a specific property_*() accessor method instead. More...
void | get_property_value (const Glib::ustring& property_name, Glib::ValueBase& value) const
| You probably want to use a specific property_*() accessor method instead. More...
template<class PropertyType >
void | set_property (const Glib::ustring& property_name, const PropertyType& value)
| You probably want to use a specific property_*() accessor method instead. More...
template<class PropertyType >
void | get_property (const Glib::ustring& property_name, PropertyType& value) const
| You probably want to use a specific property_*() accessor method instead. More...
void | connect_property_changed (const Glib::ustring& property_name, const sigc::slot< void >& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
void | connect_property_changed (const Glib::ustring& property_name, sigc::slot< void >&& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
sigc::connection | connect_property_changed_with_return (const Glib::ustring& property_name, const sigc::slot< void >& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
sigc::connection | connect_property_changed_with_return (const Glib::ustring& property_name, sigc::slot< void >&& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
void | freeze_notify ()
| Increases the freeze count on object. More...
void | thaw_notify ()
| Reverts the effect of a previous call to freeze_notify(). More...
virtual void | reference () const
| Increment the reference count for this object. More...
virtual void | unreference () const
| Decrement the reference count for this object. More...
GObject* | gobj ()
| Provides access to the underlying C GObject. More...
const GObject* | gobj () const
| Provides access to the underlying C GObject. More...
GObject* | gobj_copy () const
| Give a ref-ed copy to someone. Use for direct struct access. More...
Public Member Functions inherited from sigc::trackable
| trackable () noexcept
| trackable (const trackable &src) noexcept
| trackable (trackable &&src)
| ~trackable ()
void | add_destroy_notify_callback (void *data, func_destroy_notify func) const
void | notify_callbacks ()
trackable & | operator= (const trackable &src)
trackable & | operator= (trackable &&src)
void | remove_destroy_notify_callback (void *data) const

## Static Public Member Functions

static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...
static Glib::RefPtr< Notification > | create (const Glib::ustring& title)
| Creates a new Notification with title as its title. More...

## Protected Member Functions

| Notification (const Glib::ustring& title)
Protected Member Functions inherited from Glib::Object
| Object ()
| Object (const Glib::ConstructParams& construct_params)
| Object (GObject* castitem)
| ~Object () noexcept override
Protected Member Functions inherited from Glib::ObjectBase
| ObjectBase ()
| This default constructor is called implicitly from the constructor of user-derived classes, even if, for instance, Gtk::Button calls a different ObjectBase constructor. More...
| ObjectBase (const char* custom_type_name)
| A derived constructor always overrides this choice. More...
| ObjectBase (const std::type_info& custom_type_info)
| This constructor is a special feature to allow creation of derived types on the fly, without having to use g_object_new() manually. More...
| ObjectBase (ObjectBase&& src) noexcept
ObjectBase& | operator= (ObjectBase&& src) noexcept
virtual | ~ObjectBase () noexcept=0
void | initialize (GObject* castitem)
void | initialize_move (GObject* castitem, Glib::ObjectBase* previous_wrapper)

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr< Gio::Notification > | wrap (GNotification* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...
Related Functions inherited from Glib::Object
Glib::RefPtr< Glib::Object > | wrap (GObject* object, bool take_copy=false)

## Additional Inherited Members

Public Types inherited from Glib::Object
using | DestroyNotify = void(*)(gpointer data)
Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify | func_destroy_notify

## Detailed Description

User Notifications (pop up messages).

Gio::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 Gio::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 Gio::Application::send_notification().

Since glibmm 2.40:

## Constructor & Destructor Documentation

Gio::Notification::Notification | ( | Notification&& | src | ) |

noexcept

Gio::Notification::~Notification | ( |  | ) |

override noexcept

Gio::Notification::Notification | ( | const Glib::ustring& | title | ) |

explicit protected

## Member Function Documentation

void Gio::Notification::add_button | ( | const Glib::ustring& | label,
|  | const Glib::ustring& | 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.

Since glibmm 2.40:

Parameters

  label | Label of the button.
  detailed_action | A detailed action name.

template <typename T_Value >

void Gio::Notification::add_button | ( | const Glib::ustring& | label,
|  | const Glib::ustring& | action,
|  | const T_Value & | target
| ) |  |

Adds a button that activates action when clicked.

action must be an application-wide action (it must start with "app."). action will be activated with target as its parameter.

Since glibmm 2.40:

Parameters

  label | Label of the button.
  action | An action name.
  target | action's parameter.

void Gio::Notification::add_button_variant | ( | const Glib::ustring& | label,
|  | const Glib::ustring& | action,
|  | const Glib::VariantBase& | 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-`nullptr`, action will be activated with target as its parameter.

Since glibmm 2.40:

Parameters

  label | Label of the button.
  action | An action name.
  target | A Variant to use as action's parameter, or `nullptr`.

static Glib::RefPtr<Notification> Gio::Notification::create | ( | const Glib::ustring& | title | ) |

static

Creates a new Notification 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.

Since glibmm 2.40:

Parameters

  title | The title of the notification.

Returns
  A new Notification instance.

static GType Gio::Notification::get_type | ( |  | ) |

static

Get the GType for this class, for use with the underlying GObject type system.

GNotification* Gio::Notification::gobj | ( |  | ) |

inline

Provides access to the underlying C GObject.

const GNotification* Gio::Notification::gobj | ( |  | ) | const

inline

Provides access to the underlying C GObject.

GNotification* Gio::Notification::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

Notification& Gio::Notification::operator= | ( | Notification&& | src | ) |

noexcept

void Gio::Notification::set_body | ( | const Glib::ustring& | body | ) |

Sets the body of notification to body.

Since glibmm 2.40:

Parameters

  body | The new body for notification, or `nullptr`.

void Gio::Notification::set_default_action | ( | const Glib::ustring& | 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.

Since glibmm 2.40:

Parameters

  detailed_action | A detailed action name.

template <typename T_Value >

void Gio::Notification::set_default_action | ( | const Glib::ustring& | action,
|  | const T_Value & | target
| ) |  |

Sets the default action to action.

This action is activated when the notification is clicked on. It must be an application-wide action (start with "app."). 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 glibmm 2.40:

Parameters

  action | An action name.
  target | action's parameter.

void Gio::Notification::set_default_action_variant | ( | const Glib::ustring& | action,
|  | const Glib::VariantBase& | 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-`nullptr`, 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 glibmm 2.40:

Parameters

  action | An action name.
  target | A Variant to use as action's parameter, or `nullptr`.

void Gio::Notification::set_icon | ( | const Glib::RefPtr< Icon >& | icon | ) |

Sets the icon of notification to icon.

Since glibmm 2.40:

Parameters

  icon | The icon to be shown in notification, as a Icon.

void Gio::Notification::set_priority | ( | NotificationPriority | priority = `NOTIFICATION_PRIORITY_NORMAL` | ) |

Sets the priority of notification to priority.

See NotificationPriority for possible values.

Since glibmm 2.44:

Parameters

  priority | A NotificationPriority.

void Gio::Notification::set_title | ( | const Glib::ustring& | title | ) |

Sets the title of notification to title.

Since glibmm 2.40:

Parameters

  title | The new title for notification.

void Gio::Notification::set_urgent | ( | bool | urgent = `true` | ) |

Deprecated in favor of g_notification_set_priority().

Since glibmm 2.40:
  Deprecated: 2.42: Since 2.42, this has been deprecated in favour of g_notification_set_priority().

Deprecated:
  Use set_priority() instead.

Parameters

  urgent | `true` if notification is urgent.

## Friends And Related Function Documentation

Glib::RefPtr< Gio::Notification > wrap | ( | GNotification * | object,
|  | bool | take_copy = `false`
| ) |  |

related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.