Notification


Object Hierarchy:

Notify.Notification Notify.Notification Notify.Notification GLib.Object GLib.Object GLib.Object->Notify.Notification

Description:

[ CCode ( type_id = "notify_notification_get_type ()" ) ]
public class Notification : Object

A passive pop-up notification.

Notification represents a passive pop-up notification. It can contain summary text, body text, and an icon, as well as hints specifying how the notification should be presented. The notification is rendered by a notification daemon, and may present the notification in any number of ways. As such, there is a clear separation of content and presentation, and this API enforces that.

Example: A basic notification:

public static int main (string[] args) {
string summary = "Short summary";
string body = "A long description";
// = Gtk.Stock.DIALOG_INFO
string icon = "dialog-information";

Notify.init ("My test app");

try {
Notify.Notification notification = new Notify.Notification (summary, body, icon);
notification.show ();
} catch (Error e) {
error ("Error: %s", e.message);
}
return 0;
}

valac --pkg libnotify basic.vala

Example: Notification with a button:

public static int main (string[] args) {
string summary = "Short summary";
string body = "A long description";
// = Gtk.Stock.DIALOG_INFO
string icon = "dialog-information";

Notify.init ("My test app");

GLib.MainLoop loop = new GLib.MainLoop ();
try {
Notify.Notification notification = new Notify.Notification (summary, body, icon);
notification.add_action ("action-name", "Quit", (notification, action) => {
print ("Bye!\n");
try {
notification.close ();
} catch (Error e) {
debug ("Error: %s", e.message);
}
loop.quit ();
});
notification.show ();
loop.run ();
} catch (Error e) {
error ("Error: %s", e.message);
}
return 0;
}

valac --pkg libnotify with-button.vala


Namespace: Notify
Package: libnotify

Content:

Properties:

Creation methods:

Methods:

Signals:

Inherited Members: