diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/gtk-application.js | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/examples/gtk-application.js b/examples/gtk-application.js index 99a3fd98..d4893a7b 100644 --- a/examples/gtk-application.js +++ b/examples/gtk-application.js @@ -39,43 +39,43 @@ var ExampleApplication = GObject.registerClass({ return this._exampleprop; } - + set exampleprop(value) { this._exampleprop = value; - + // notify() has to be called, if you want it this.notify('exampleprop'); } - + // Example signal emission emitExamplesig(number) { this.emit('examplesig', number); } - + vfunc_startup() { super.vfunc_startup(); - + // An example GAction, see: https://wiki.gnome.org/HowDoI/GAction let exampleAction = new Gio.SimpleAction({ name: 'exampleAction', parameter_type: new GLib.VariantType('s'), }); - + exampleAction.connect('activate', (action, param) => { param = param.deepUnpack().toString(); - + if (param === 'exampleParameter') log('Yes!'); }); - + this.add_action(exampleAction); } - + vfunc_activate() { super.vfunc_activate(); - + this.hold(); - + // Example ApplicationWindow let window = new Gtk.ApplicationWindow({ application: this, @@ -83,16 +83,16 @@ var ExampleApplication = GObject.registerClass({ default_width: 300, default_height: 200, }); - + let label = new Gtk.Label({label: this.exampleprop}); window.add(label); - + window.connect('delete-event', () => { this.quit(); }); - + window.show_all(); - + // Example GNotification, see: https://developer.gnome.org/GNotification/ let notif = new Gio.Notification(); notif.set_title('Example Notification'); @@ -100,20 +100,20 @@ var ExampleApplication = GObject.registerClass({ notif.set_icon( new Gio.ThemedIcon({name: 'dialog-information-symbolic'}) ); - + // A default action for when the body of the notification is clicked notif.set_default_action("app.exampleAction('exampleParameter')"); - + // A button for the notification notif.add_button( 'Button Text', "app.exampleAction('exampleParameter')" ); - + // This won't actually be shown, since an application needs a .desktop // file with a base name matching the application id this.send_notification('example-notification', notif); - + // Withdraw this.withdraw_notification('example-notification'); } |