glibmm 2.66.5
Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | 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 Member Functions

 Notification (Notification && src) noexcept
 
Notificationoperator= (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
 
Objectoperator= (const Object &)=delete
 
 Object (Object && src) noexcept
 
Objectoperator= (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
 
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. 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...
 

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< Notificationcreate (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
 
ObjectBaseoperator= (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::Notificationwrap (GNotification * object, bool take_copy=false)
 A Glib::wrap() method for this object. More...
 

Additional Inherited Members

- Public Types inherited from Glib::Object
using DestroyNotify = void(*)(gpointer data)
 

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

◆ 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_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.

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 ( NotificationPriority  priority = NOTIFICATION_PRIORITY_NORMAL)

Sets the priority of notification to priority.

See NotificationPriority for possible values.

Since glibmm 2.44:
Parameters
priorityA NotificationPriority.

◆ 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.

◆ set_urgent()

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
urgenttrue if notification is urgent.

Friends And Related Function 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.