class Gio::Notification
- Gio::Notification
- GObject::Object
- Reference
- Object
Overview
#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 #GApplication.
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 g_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 g_application_send_notification().
Defined in:
lib/gi-crystal/src/auto/gio-2.0/notification.crConstructors
-
.new(title : String) : self
Creates a new #GNotification with @title as its title.
-
.new
Initialize a new
Notification
.
Class Method Summary
-
.g_type : UInt64
Returns the type id (GType) registered in GLib type system.
Instance Method Summary
-
#add_button(label : String, detailed_action : String) : Nil
Adds a button to @notification that activates the action in @detailed_action when clicked.
-
#add_button_with_target(label : String, action : String, target : _?) : Nil
Adds a button to @notification that activates @action when clicked.
-
#body=(body : String?) : Nil
Sets the body of @notification to @body.
-
#category=(category : String?) : Nil
Sets the type of @notification to @category.
-
#default_action=(detailed_action : String) : Nil
Sets the default action of @notification to @detailed_action.
-
#icon=(icon : Gio::Icon) : Nil
Sets the icon of @notification to @icon.
-
#priority=(priority : Gio::NotificationPriority) : Nil
Sets the priority of @notification to @priority.
-
#set_default_action_and_target(action : String, target : _?) : Nil
Sets the default action of @notification to @action.
-
#title=(title : String) : Nil
Sets the title of @notification to @title.
-
#urgent=(urgent : Bool) : Nil
Deprecated in favor of g_notification_set_priority().
Instance methods inherited from class GObject::Object
bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding
bind_property,
bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding
bind_property_full,
data(key : String) : Pointer(Void)?
data,
finalize
finalize,
freeze_notify : Nil
freeze_notify,
getv(names : Enumerable(String), values : Enumerable(_)) : Nil
getv,
notify(property_name : String) : Nil
notify,
notify_by_pspec(pspec : GObject::ParamSpec) : Nil
notify_by_pspec,
notify_signal
notify_signal,
property(property_name : String, value : _) : Nil
property,
qdata(quark : UInt32) : Pointer(Void)?
qdata,
ref_count : UInt32
ref_count,
run_dispose : Nil
run_dispose,
set_data(key : String, data : Pointer(Void)?) : Nil
set_data,
set_property(property_name : String, value : _) : Nil
set_property,
steal_data(key : String) : Pointer(Void)?
steal_data,
steal_qdata(quark : UInt32) : Pointer(Void)?
steal_qdata,
thaw_notify : Nil
thaw_notify,
to_unsafe : Pointer(Void)
to_unsafe,
watch_closure(closure : GObject::Closure) : Nil
watch_closure
Constructor methods inherited from class GObject::Object
cast(obj : GObject::Object) : self
cast,
cast?(obj : GObject::Object) : self?
cast?,
new(pointer : Pointer(Void), transfer : GICrystal::Transfer)new new, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv
Class methods inherited from class GObject::Object
compat_control(what : UInt64, data : Pointer(Void)?) : UInt64
compat_control,
g_type : UInt64
g_type,
interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec
interface_find_property,
interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec)
interface_list_properties
Constructor Detail
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.
Class Method Detail
Instance Method Detail
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.
Adds a button to @notification that activates @action when clicked. @action must be an application-wide action (it must start with "app.").
If @target_format is given, it is used to collect remaining positional parameters into a #GVariant instance, similar to g_variant_new(). @action will be activated with that #GVariant as its parameter.
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.
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.
Sets the priority of @notification to @priority. See #GNotificationPriority for possible values.
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 (it must start with "app.").
If @target_format is given, it is used to collect remaining positional parameters into a #GVariant instance, similar to g_variant_new(). @action will be activated with that #GVariant as its parameter.
When no default action is set, the application that the notification was sent on is activated.