Contenu connexe
Similaire à Developing GNOME Apps in Javascript
Similaire à Developing GNOME Apps in Javascript (20)
Developing GNOME Apps in Javascript
- 6. It has bad parts!
Globals
Unexpected behaviour
No block scope
- 7. But it also has good parts!
Closures are central
Functions are first-class objects
Prototypal inheritance
Is everywhere!
- 13. const Lang = imports.lang;
const Gtk = imports.gi.Gtk;
const App = new Lang.Class({
Name: 'App',
Extends: Gtk.Application,
_init: function () {
this.parent({ application_id: 'org.example.App' });
this.connect('activate', Lang.bind(this, this._onActivate));
this.connect('startup', Lang.bind(this, this._onStartup));
},
- 14. _onActivate: function () {
this._window.show_all();
},
_onStartup: function () {
this._window = new Gtk.ApplicationWindow({
application: this,
title: "Hello World!" });
this._window.set_default_size(200, 200);
let label = new Gtk.Label({ label: "Hello World" });
this._window.add(label);
}
});
- 17. Become a Friend of GNOME
Individual donation program
Donations support the
GNOME project
http://gnome.org/friends