18
Developing GNOME Apps in Javascript Felipe Borges <[email protected]>

Developing GNOME Apps in Javascript

Embed Size (px)

Citation preview

Page 1: Developing GNOME Apps in Javascript

Developing GNOME Apps in JavascriptFelipe Borges

<[email protected]>

Page 2: Developing GNOME Apps in Javascript

Why talk about Gjs?

Page 3: Developing GNOME Apps in Javascript

GNOME is....

Desktop environment Development platform

Page 4: Developing GNOME Apps in Javascript

GNOME Developer Platform

Page 5: Developing GNOME Apps in Javascript

Javascript is pretty cool!

Page 6: Developing GNOME Apps in Javascript

It has bad parts! Globals Unexpected behaviour No block scope

Page 7: Developing GNOME Apps in Javascript

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

Page 8: Developing GNOME Apps in Javascript
Page 9: Developing GNOME Apps in Javascript

Gjs First released in 2008 Well maintained Main development language for

writing GNOME Apps

Page 10: Developing GNOME Apps in Javascript

GNOME Apps in JS

Documents Shell Polari

Page 11: Developing GNOME Apps in Javascript

gjs-console

Page 12: Developing GNOME Apps in Javascript

Get started

Gjs and Gtk Actions and signals Run your application

Page 13: Developing GNOME Apps in Javascript

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

Page 14: Developing GNOME Apps in Javascript

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

Page 15: Developing GNOME Apps in Javascript

Run your application

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

$ gjs helloWorld.js

Page 16: Developing GNOME Apps in Javascript

http://developer.gnome.org/

Page 17: Developing GNOME Apps in Javascript

Become a Friend of GNOME

Individual donation program Donations support the

GNOME project http://gnome.org/friends

Page 18: Developing GNOME Apps in Javascript

Developing GNOME Apps in JavascriptFelipe Borges

<[email protected]>