Developing GNOME Apps in Javascript

Preview:

Citation preview

Developing GNOME Apps in JavascriptFelipe Borges

<felipeborges@gnome.org>

Why talk about Gjs?

GNOME is....

Desktop environment Development platform

GNOME Developer Platform

Javascript is pretty cool!

It has bad parts! Globals Unexpected behaviour No block scope

But it also has good parts! Closures are central Functions are first-class objects Prototypal inheritance Is everywhere!

Gjs First released in 2008 Well maintained Main development language for

writing GNOME Apps

GNOME Apps in JS

Documents Shell Polari

gjs-console

Get started

Gjs and Gtk Actions and signals Run your application

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)); },

_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); }});

Run your application

let app = new App();app.run(ARGV);

$ gjs helloWorld.js

http://developer.gnome.org/

Become a Friend of GNOME

Individual donation program Donations support the

GNOME project http://gnome.org/friends

Developing GNOME Apps in JavascriptFelipe Borges

<felipeborges@gnome.org>