Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env gjs
- /*
- * Example showing how to make notifications.
- * The use of Gio.Application is to keep the program alive.
- */
- const Notify = imports.gi.Notify;
- const GLib = imports.gi.GLib;
- const Gio = imports.gi.Gio;
- const Lang = imports.lang;
- Notify.init ("Test app");
- const Application = new Lang.Class ({
- Name: "TestApp",
- Extends: Gio.Application,
- _init : function () {
- this.parent ({
- application_id: "org.gego.test.notify"
- });
- },
- vfunc_activate : function () {
- this.n = new Notify.Notification ({"summary" : "Something",
- "body" : "What do you want to say?",
- "icon-name" :"dialog-warning-symbolic"});
- this.n.connect ("closed", Lang.bind (this, function () {
- let r = this.n.get_closed_reason (); // The reason never seem to change.
- print ("close reason: " + r + "\n");
- this.quit ();
- }));
- this.n.add_action ("say_hello", "Say Hello", Lang.bind (this, function () {
- print ("Hello\n");
- }));
- this.n.add_action ("say_hi", "Say Hi!", Lang.bind (this, function () {
- print ("Hi!\n");
- }));
- this.n.show ();
- this.hold ();
- }
- });
- function main (argv) {
- var app = new Application ();
- return app.run(argv);
- }
- main (ARGV);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement