glibmm 2.80.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Symbols | List of all members
Gio::Notification Class Reference

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

#include <giomm/notification.h>

Inheritance diagram for Gio::Notification:
Inheritance graph
[legend]

Public Types

enum class  Priority {
  NORMAL ,
  LOW ,
  HIGH ,
  URGENT
}
 
- Public Types inherited from Glib::Object
using DestroyNotify = void(*)(gpointer data)
 

Public Member Functions

 Notification (Notification &&src) noexcept
 
Notificationoperator= (Notification &&src) noexcept
 
 ~Notification () noexcept override
 
GNotificationgobj ()
 Provides access to the underlying C GObject.
 
const GNotificationgobj () const
 Provides access to the underlying C GObject.
 
GNotificationgobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
 
void set_title (const Glib::ustring &title)
 Sets the title of notification to title.
 
void set_body (const Glib::ustring &body)
 Sets the body of notification to body.
 
void set_icon (const Glib::RefPtr< Icon > &icon)
 Sets the icon of notification to icon.
 
void set_priority (Priority priority=Priority::NORMAL)
 Sets the priority of notification to priority.
 
void set_category (const Glib::ustring & category)
 Sets the type of notification to category.
 
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.
 
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.
 
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.
 
void set_default_action (const Glib::ustring &detailed_action)
 Sets the default action of notification to detailed_action.
 
template<typename T_Value >
void set_default_action (const Glib::ustring &action, const T_Value & target)
 Sets the default action to action.
 
void set_default_action_variant (const Glib::ustring &action, const Glib::VariantBase & target)
 Sets the default action of notification to action.
 
- Public Member Functions inherited from Glib::Object
 Object (const Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&src) noexcept
 
Objectoperator= (Object &&src) noexcept
 
voidget_data (const QueryQuark & key)
 
void set_data (const Quark & key, void *data)
 
void set_data_with_c_callback (const Quark & key, void *data, GDestroyNotify notify)
 
void set_data (const Quark & key, void *data, DestroyNotify notify)
 Prefer set_data_with_c_callback() with a callback with C linkage.
 
void remove_data (const QueryQuark &quark)
 
voidsteal_data (const QueryQuark &quark)
 
- Public Member Functions inherited from Glib::ObjectBase
 ObjectBase (const ObjectBase &)=delete
 
ObjectBaseoperator= (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.
 
void get_property_value (const Glib::ustring & property_name, Glib::ValueBase & value) const
 You probably want to use a specific property_*() accessor method instead.
 
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.
 
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.
 
template<class PropertyType >
PropertyType get_property (const Glib::ustring & property_name) const
 You probably want to use a specific property_*() accessor method instead.
 
sigc::connection 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.
 
sigc::connection connect_property_changed (const Glib::ustring & property_name, sigc::slot< void()> &&slot)
 You can use the signal_changed() signal of the property proxy instead.
 
void freeze_notify ()
 Increases the freeze count on object.
 
void thaw_notify ()
 Reverts the effect of a previous call to freeze_notify().
 
virtual void reference () const
 Increment the reference count for this object.
 
virtual void unreference () const
 Decrement the reference count for this object.
 
GObject * gobj ()
 Provides access to the underlying C GObject.
 
const GObject * gobj () const
 Provides access to the underlying C GObject.
 
GObject * gobj_copy () const
 Give a ref-ed copy to someone. Use for direct struct access.
 

Static Public Member Functions

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

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.
 
 ObjectBase (const char *custom_type_name)
 A derived constructor always overrides this choice.
 
 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.
 
 ObjectBase (ObjectBase &&src) noexcept
 
ObjectBaseoperator= (ObjectBase &&src) noexcept
 
virtual ~ObjectBase () noexcept=0
 
void initialize (GObject *castitem)
 
void initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)
 

Related Symbols

(Note that these are not member symbols.)

Glib::RefPtr< Gio::Notificationwrap (GNotification *object, bool take_copy=false)
 A Glib::wrap() method for this object.
 

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:

Member Enumeration Documentation

◆ Priority

Enumerator
NORMAL 

The default priority, to be used for the majority of notifications (for example email messages, software updates, completed download/sync operations).

LOW 

For notifications that do not require immediate attention - typically used for contextual background information, such as contact birthdays or local weather.

HIGH 

For events that require more attention, usually because responses are time-sensitive (for example chat and SMS messages or alarms).

URGENT 

For urgent notifications, or notifications that require a response in a short space of time (for example phone calls or emergency warnings).

Constructor & Destructor Documentation

◆ Notification() [1/2]

Gio::Notification::Notification ( Notification &&  src)
noexcept

◆ ~Notification()

Gio::Notification::~Notification ( )
overridenoexcept

◆ Notification() [2/2]

Gio::Notification::Notification ( const Glib::ustring title)
explicitprotected

Member Function Documentation

◆ add_button() [1/2]

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
labelLabel of the button.
actionAn action name.
targetaction's parameter.

◆ add_button() [2/2]

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
labelLabel of the button.
detailed_actionA detailed action name.

◆ add_button_variant()

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
labelLabel of the button.
actionAn action name.
targetA Variant to use as action's parameter, or nullptr.

◆ create()

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
titleThe title of the notification.
Returns
A new Notification instance.

◆ get_type()

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

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

◆ gobj() [1/2]

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

Provides access to the underlying C GObject.

◆ gobj() [2/2]

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

Provides access to the underlying C GObject.

◆ gobj_copy()

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.

◆ operator=()

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

◆ set_body()

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

Sets the body of notification to body.

Since glibmm 2.40:
Parameters
bodyThe new body for notification, or nullptr.

◆ set_category()

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

Since glibmm 2.70:
Parameters
categoryThe category for notification, or nullptr for no category.

◆ set_default_action() [1/2]

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
actionAn action name.
targetaction's parameter.

◆ set_default_action() [2/2]

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_actionA detailed action name.

◆ set_default_action_variant()

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. If target is floating, it will be consumed.

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

Since glibmm 2.40:
Parameters
actionAn action name.
targetA Variant to use as action's parameter, or nullptr.

◆ set_icon()

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

Sets the icon of notification to icon.

Since glibmm 2.40:
Parameters
iconThe icon to be shown in notification, as a Icon.

◆ set_priority()

void Gio::Notification::set_priority ( Priority  priority = Priority::NORMAL)

Sets the priority of notification to priority.

See Gio::Notification::Priority for possible values.

Since glibmm 2.44:
Parameters
priorityA Gio::Notification::Priority.

◆ set_title()

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

Sets the title of notification to title.

Since glibmm 2.40:
Parameters
titleThe new title for notification.

Friends And Related Symbol Documentation

◆ wrap()

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

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

Parameters
objectThe C instance.
take_copyFalse 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.