SlideShare a Scribd company logo
Javascript, the GNOME way
Berlin, October 2nd, 2011
(follow the talk at http://10.109.2.56:8080)
A bit about of me
Eduardo Lima Mitev <elima@igalia.com>
Web apps developer, GNOME developer, eventdance, hildon-input-methods, libmeegotouch, filetea, ...
Not a gnome-shell/G-I/GJS core hacker myself, just a messenger...
What is GNOME?
http://bethesignal.org/blog/2011/03/12/thoughts-on-gnome/
GNOME is people
http://www.flickr.com/photos/lucasrocha/3913631234/sizes/l/in/photostream/
A full-featured desktop environment
A collection of libraries and programs
libgpg-error libgcrypt libxslt gnome-common intltool rarian gnome-doc-utils gtk-doc glib cairo gobject-introspection atk pango
gdk-pixbuf shared-mime-info gtk+ vala dconf libgnome-keyring expat polkit gudev NetworkManager libproxy cantarell-fonts gtk+-2
gtk-engines librsvg gnome-themes-standard gsettings-desktop-schemas glib-networking libsoup gconf libgweather libgdata
gstreamer liboil gst-plugins-base enchant WebKit p11-kit gnome-keyring libnotify librest json-glib gnome-online-accounts evolution-
data-server colord libdaemon avahi libatasmart libunique gnome-disk-utility gvfs gnome-desktop gnome-menus iso-codes libxklavier
libgnomekbd upower gnome-settings-daemon libgtop sound-theme-freedesktop accountsservice gnome-control-center gnome-
bluetooth hicolor-icon-theme gnome-icon-theme gnome-icon-theme-symbolic gnome-icon-theme-extras PackageKit gnome-
packagekit gnome-screensaver gnome-session pygobject cogl clutter libgee caribou telepathy-glib folks js185 gjs zenity metacity
mutter telepathy-logger gnome-shell mousetweaks network-manager-applet telepathy-mission-control meta-gnome-core-shell
gnome-backgrounds nautilus gnome-user-share vino itstool yelp-xsl yelp-tools gnome-user-docs meta-gnome-core-extras gmime
poppler gtkhtml evolution libgsf tracker totem-pl-parser brasero libnice farsight2 telepathy-farsight clutter-gtk libchamplain
empathy epiphany gnome-js-common seed libpeas eog evince gcalctool gnome-contacts libwnck mm-common libsigc++2 glibmm
cairomm pangomm atkmm gtkmm gnome-system-monitor vte gnome-terminal gnome-utils gucharmap libdiscid libmusicbrainz
clutter-gst gtksourceview sushi yelp meta-gnome-core-utilities gnome-panel notification-daemon dbus-python polkit-gnome ... ... ...
... all free software
GNOME 3 was released in April 2011
http://www.gnome.org/gnome-3/
GNOME 3 was released in April 2011
A major breakthrough in design
HW acceleration for graphics
Tons of cleaning up and restructuring of the stack
The gnome-shell to be the default UX
... and GNOME met Javascript
The gnome-shell
A modern, integrated user experience
Acts as a compositing manager for the desktop
Handles application launching, window switching, multiple desktops, and much more
Interfaces GNOME libraries using Javascript as glue
29,497 lines of Javascript code (39,538 of C)
the gnome-shell
https://live.gnome.org/GnomeShell/Technology
Javascript, the GNOME way (JSConf EU 2011)
what is gobject-introspection?
http://www.flyingdisk.com/badges.htm
what is gobject-introspection?
A set of tools for extracting and accessing the metadata of a
library's API in a convenient way for other programs to use it.
library APIs must be "annotated" and designed to be "introspection friendly"
gobject-introspection goals
Enable two level applications: C and <your favorite runtime>;
Share binding infrastructure work;
Other uses like API verification, improving documentation tools, etc
the big picture (with GJS)
the big picture (with Seed)
GIR file
An XML description of a library API
Can include documentation
Example: ZLibCompressor class from GIO's GIR
<class name="ZlibCompressor"
c:symbol-prefix="zlib_compressor"
c:type="GZlibCompressor"
parent="GObject.Object"
glib:type-name="GZlibCompressor"
glib:get-type="g_zlib_compressor_get_type"
glib:type-struct="ZlibCompressorClass">
<doc xml:whitespace="preserve">Zlib decompression</doc>
<implements name="Converter"/>
<constructor name="new"
c:identifier="g_zlib_compressor_new"
version="2.24">
<doc xml:whitespace="preserve">Creates a new #GZlibCompressor.</doc>
<return-value transfer-ownership="full">
<doc xml:whitespace="preserve">a new #GZlibCompressor</doc>
Typelib file
A binary representation of the GIR file for faster access during
run-time.
GIRepository: API for retrieving library info from a typelib file
http://moodleman.moodle.com.au/archives/202
libffi: fantasy fiction foreign function interface
http://moodleman.moodle.com.au/archives/202
Annotations
Go inline in the code (normally in the .c files)
Complement the API description with semantic information
Normally "guessed" correctly by the scanner
Documented at https://live.gnome.org/GObjectIntrospection/Annotations
Annotations example (I)
Annotations example (II)
Javascript, at last!
Two engines: GJS and Seed
GJS vs. Seed
GJS wraps Mozilla's Spidermonkey engine while Seed wraps Apple's JavascriptCore
GJS supports language features from ES-Harmony (let, const, etc), Seed doesn't (as of now)
GJS is more mature, it powers gnome-shell at the moment
Other minor differences (i.e module extensions, etc)
both have a fairly good G-I support
Oh wait! what about node-gir?
node-gir
G-I support for Node
early stage of development
written by Tim Caswell
code at https://github.com/creationix/node-gir
Why not use Seed or GJS?
"Because they are nice, but not what I'm looking for. Node is really popular and it would be nice to be able to
use it for desktop tools and applications.", Tim Caswell
Writing Javascript in GJS/Seed
Show time!
Importing modules
No 'require', sorry
The 'imports' keyword
Importing is an assignment, not a function call
The full module's global scope is imported
'imports.searchPath' similar to 'require.paths'
Only synchronous
Importing a Javascript module
// this will import file 'path/to/my/module.js'
var MyModule = imports.path.to.my.module;
// this will import 'lib/Http.js'
var Http = imports.lib.Http;
// using 'const' here is nice but only works in GJS :)
const Promise = imports.lib.Promise;
Importing a module from the G-I repository
// this will import GLib library namespace
var GLib = imports.gi.GLib;
// this will import GTK+ library namespace
// for API version 3.0
var Gtk = imports.gi.Gtk-3.0;
// in recent versions of GJS you can do
var Gtk = imports.gi.Gtk = 3.0;
Importing modules
There are also native Javascript modules for more convenient
APIs, i.e: mainloop, dbus, lang, signals.
Importing a native JS module
// built-in JS modules are always accessible
// from the root importer
var Mainloop = imports.mainloop;
var DBus = imports.dbus;
Using G-I APIs
There are "well defined" rules for mapping the C symbols to their
corresponding Javascript syntax
Using G-I APIs: Functions
Library functions are mapped to Namespace.function:
g_timeout_add(...) becomes GLib.timeout_add(...)
Using G-I APIs: GObject methods
GObject methods are mapped to Namespace.Class.method:
gtk_button_new_with_label(...) becomes Gtk.Button.new_with_label(...)
Using G-I APIs: Enums
Enums are mapped to Namespace.EnumName.VALUE:
GST_STATE_PLAYING becomes Gst.State.PLAYING,
CLUTTER_STAGE_STATE_FULLSCREEN becomes Clutter.StageState.FULLSCREEN
Using G-I APIs: GObject properties
GObject properties are mapped to normal Javascript Object members replacing '-' by '_':
Property 'use-markup' of a GtkLabel becomes obj.use_markup
Using G-I APIs: GObject signals
GJS
obj.connect(signalName, callback) method is used to connect to GObject signals:
obj.connect('destroy', callback);
Seed:
A bit different: obj.signal["signal name"].connect(callback)
obj.signal['destroy'].connect(callback);
What about documentation?
http://cdblog.centraldesktop.com/2010/05/is_your_technical_documentatio/
Documentation
No official documentation for Javascript bindings yet
Unofficial documentation at http://www.roojs.org/index.php/projects/gnome/introspection-docs.html
A hot topic right now
What about development tools?
http://blog.doomby.com/blog,7-of-the-best-free-website-development-tools,311404.html
Development tools
No specific developer tools for Javascript at the moment
Still too early: remains unclear what the needs will be
GNOME Javascript and CommonJS?
There is certain interest in the GNOME community, but
Not all CommonJS specs could make sense
More discussion and bridging is needed
node-gir?
gjs-commonjs?
gjs-commonjs
Wraps GJS to add CommonJS APIs
Just an experiment, not the way to go
Code at https://gitorious.org/gjs-commonjs (LGPL)
Only Modules 1.1 and Promises/D (partially) at the moment
Current issues and challenges
To complete introspection support in GNOME libraries
To complete introspection support in GJS/Seed
To have official documentation
To make GJS and Seed code fully compatible
To align with CommonJS for what makes sense
Final thoughts
An elegant and efficient combination of low-level and high-level languages
JS opened to a platform with 10+ years of evolution
Very convenient for fast prototyping and gluing
Expands the frontiers of JS in the desktop
An awesome stack!
your Javascript programs
GJS
(Spidermonkey)
Seed (JSC) node-gir (V8) ...
gobject introspection
Core
GIO
GLib
GObject
User
interface
GTK+
Cairo
Clutter
ATK
Pango
Webkit
Multimedia
gstreamer
Canberra
Pulseaudio
Communication
Telepathy
Avahi
GUPnP
Data
storage
EDS
GDA
Tracker
Utilities
Champlain
Enchant
Poppler
GeoClue
Desktop
integration
PackageKit
libnotify
seahorse
System
integration
upower
udisks
policykit
Thank you!
Questions?

More Related Content

PDF
step by step to write a gnome-shell extension
ODP
3 UIs for the price of one code
ODP
G T K+ 101
PDF
Gtk development-using-glade-3
PDF
Курсы по мобильной разработке под iOS. 4 лекция. Возможности телефона
PDF
Introdução ao Desenvolvimento Android com Kotlin
PDF
Learning WebGLで学ぶWebGL入門
PPT
WebGL: GPU acceleration for the open web
step by step to write a gnome-shell extension
3 UIs for the price of one code
G T K+ 101
Gtk development-using-glade-3
Курсы по мобильной разработке под iOS. 4 лекция. Возможности телефона
Introdução ao Desenvolvimento Android com Kotlin
Learning WebGLで学ぶWebGL入門
WebGL: GPU acceleration for the open web

What's hot (20)

PPTX
JavaScript on the Desktop
PDF
ng-conf 2017: Angular Mischief Maker Slides
PDF
Design Patterns in Game Programming
PDF
Introdução à Spring Web Flux
PDF
The event-driven nature of javascript – IPC2012
PDF
The Ring programming language version 1.8 book - Part 12 of 202
PDF
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
PDF
Programação de Jogos - Design Patterns
PDF
Javascript & Ajax Basics
PDF
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
KEY
Getting Started with WebGL
PDF
A split screen-viable UI event system - Unite Copenhagen 2019
PPTX
みんなの知らないChrome appsの世界
PPTX
A new way to develop with WordPress!
KEY
Beautiful Documentation with YUI Doc
PDF
GroovyConsole
PDF
Android Code Puzzles (DroidCon Amsterdam 2012)
PDF
Implementing a Simple Game using libGDX
PDF
Non stop random2b
PDF
303 TANSTAAFL: Using Open Source iPhone UI Code
JavaScript on the Desktop
ng-conf 2017: Angular Mischief Maker Slides
Design Patterns in Game Programming
Introdução à Spring Web Flux
The event-driven nature of javascript – IPC2012
The Ring programming language version 1.8 book - Part 12 of 202
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
Programação de Jogos - Design Patterns
Javascript & Ajax Basics
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Getting Started with WebGL
A split screen-viable UI event system - Unite Copenhagen 2019
みんなの知らないChrome appsの世界
A new way to develop with WordPress!
Beautiful Documentation with YUI Doc
GroovyConsole
Android Code Puzzles (DroidCon Amsterdam 2012)
Implementing a Simple Game using libGDX
Non stop random2b
303 TANSTAAFL: Using Open Source iPhone UI Code
Ad

Similar to Javascript, the GNOME way (JSConf EU 2011) (20)

PDF
Javascript in linux desktop (ICOS ver.)
PDF
Quick Review of Desktop and Native Apps using Javascript
PDF
DIY: Computer Vision with GWT.
PDF
DIY- computer vision with GWT
ODP
Javascript in Linux Desktop
PDF
Grails beginners workshop
PDF
Desktop apps with node webkit
PPT
JavaOne TS-5098 Groovy SwingBuilder
PDF
GQuery a jQuery clone for Gwt, RivieraDev 2011
ODP
Gnome Architecture
ODP
Griffon: Re-imaging Desktop Java Technology
PDF
Why Gradle?
PDF
Grunt.js introduction
PPTX
Introduction to git and Github
PDF
T 0230 Google Wave Powered By Gwt
PDF
Writing native Linux desktop apps with JavaScript
PDF
Javascript as a target language - GWT KickOff - Part 2/2
PPTX
Introduzione a GitHub Actions (beta)
PPT
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
PPT
Testing of javacript
Javascript in linux desktop (ICOS ver.)
Quick Review of Desktop and Native Apps using Javascript
DIY: Computer Vision with GWT.
DIY- computer vision with GWT
Javascript in Linux Desktop
Grails beginners workshop
Desktop apps with node webkit
JavaOne TS-5098 Groovy SwingBuilder
GQuery a jQuery clone for Gwt, RivieraDev 2011
Gnome Architecture
Griffon: Re-imaging Desktop Java Technology
Why Gradle?
Grunt.js introduction
Introduction to git and Github
T 0230 Google Wave Powered By Gwt
Writing native Linux desktop apps with JavaScript
Javascript as a target language - GWT KickOff - Part 2/2
Introduzione a GitHub Actions (beta)
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
Testing of javacript
Ad

More from Igalia (20)

PDF
Life of a Kernel Bug Fix
PDF
Unlocking the Full Potential of WPE to Build a Successful Embedded Product
PDF
Advancing WebDriver BiDi support in WebKit
PDF
Jumping Over the Garden Wall - WPE WebKit on Android
PDF
Collective Funding, Governance and Prioritiation of Browser Engine Projects
PDF
Don't let your motivation go, save time with kworkflow
PDF
Solving the world’s (localization) problems
PDF
The Whippet Embeddable Garbage Collection Library
PDF
Nobody asks "How is JavaScript?"
PDF
Getting more juice out from your Raspberry Pi GPU
PDF
WebRTC support in WebKitGTK and WPEWebKit with GStreamer: Status update
PDF
Demystifying Temporal: A Deep Dive into JavaScript New Temporal API
PDF
CSS :has() Unlimited Power
PDF
Device-Generated Commands in Vulkan
PDF
Current state of Lavapipe: Mesa's software renderer for Vulkan
PDF
Vulkan Video is Open: Application showcase
PDF
Scheme on WebAssembly: It is happening!
PDF
EBC - A new backend compiler for etnaviv
PDF
RISC-V LLVM State of the Union
PDF
Device-Generated Commands in Vulkan
Life of a Kernel Bug Fix
Unlocking the Full Potential of WPE to Build a Successful Embedded Product
Advancing WebDriver BiDi support in WebKit
Jumping Over the Garden Wall - WPE WebKit on Android
Collective Funding, Governance and Prioritiation of Browser Engine Projects
Don't let your motivation go, save time with kworkflow
Solving the world’s (localization) problems
The Whippet Embeddable Garbage Collection Library
Nobody asks "How is JavaScript?"
Getting more juice out from your Raspberry Pi GPU
WebRTC support in WebKitGTK and WPEWebKit with GStreamer: Status update
Demystifying Temporal: A Deep Dive into JavaScript New Temporal API
CSS :has() Unlimited Power
Device-Generated Commands in Vulkan
Current state of Lavapipe: Mesa's software renderer for Vulkan
Vulkan Video is Open: Application showcase
Scheme on WebAssembly: It is happening!
EBC - A new backend compiler for etnaviv
RISC-V LLVM State of the Union
Device-Generated Commands in Vulkan

Recently uploaded (20)

PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
cuic standard and advanced reporting.pdf
PDF
Encapsulation theory and applications.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
A Presentation on Artificial Intelligence
PDF
Empathic Computing: Creating Shared Understanding
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPT
Teaching material agriculture food technology
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Modernizing your data center with Dell and AMD
PDF
Encapsulation_ Review paper, used for researhc scholars
Diabetes mellitus diagnosis method based random forest with bat algorithm
“AI and Expert System Decision Support & Business Intelligence Systems”
cuic standard and advanced reporting.pdf
Encapsulation theory and applications.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
A Presentation on Artificial Intelligence
Empathic Computing: Creating Shared Understanding
NewMind AI Weekly Chronicles - August'25 Week I
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Teaching material agriculture food technology
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Per capita expenditure prediction using model stacking based on satellite ima...
Unlocking AI with Model Context Protocol (MCP)
Digital-Transformation-Roadmap-for-Companies.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Modernizing your data center with Dell and AMD
Encapsulation_ Review paper, used for researhc scholars

Javascript, the GNOME way (JSConf EU 2011)

  • 1. Javascript, the GNOME way Berlin, October 2nd, 2011 (follow the talk at http://10.109.2.56:8080)
  • 2. A bit about of me Eduardo Lima Mitev <elima@igalia.com> Web apps developer, GNOME developer, eventdance, hildon-input-methods, libmeegotouch, filetea, ... Not a gnome-shell/G-I/GJS core hacker myself, just a messenger...
  • 6. A collection of libraries and programs libgpg-error libgcrypt libxslt gnome-common intltool rarian gnome-doc-utils gtk-doc glib cairo gobject-introspection atk pango gdk-pixbuf shared-mime-info gtk+ vala dconf libgnome-keyring expat polkit gudev NetworkManager libproxy cantarell-fonts gtk+-2 gtk-engines librsvg gnome-themes-standard gsettings-desktop-schemas glib-networking libsoup gconf libgweather libgdata gstreamer liboil gst-plugins-base enchant WebKit p11-kit gnome-keyring libnotify librest json-glib gnome-online-accounts evolution- data-server colord libdaemon avahi libatasmart libunique gnome-disk-utility gvfs gnome-desktop gnome-menus iso-codes libxklavier libgnomekbd upower gnome-settings-daemon libgtop sound-theme-freedesktop accountsservice gnome-control-center gnome- bluetooth hicolor-icon-theme gnome-icon-theme gnome-icon-theme-symbolic gnome-icon-theme-extras PackageKit gnome- packagekit gnome-screensaver gnome-session pygobject cogl clutter libgee caribou telepathy-glib folks js185 gjs zenity metacity mutter telepathy-logger gnome-shell mousetweaks network-manager-applet telepathy-mission-control meta-gnome-core-shell gnome-backgrounds nautilus gnome-user-share vino itstool yelp-xsl yelp-tools gnome-user-docs meta-gnome-core-extras gmime poppler gtkhtml evolution libgsf tracker totem-pl-parser brasero libnice farsight2 telepathy-farsight clutter-gtk libchamplain empathy epiphany gnome-js-common seed libpeas eog evince gcalctool gnome-contacts libwnck mm-common libsigc++2 glibmm cairomm pangomm atkmm gtkmm gnome-system-monitor vte gnome-terminal gnome-utils gucharmap libdiscid libmusicbrainz clutter-gst gtksourceview sushi yelp meta-gnome-core-utilities gnome-panel notification-daemon dbus-python polkit-gnome ... ... ... ... all free software
  • 7. GNOME 3 was released in April 2011 http://www.gnome.org/gnome-3/
  • 8. GNOME 3 was released in April 2011 A major breakthrough in design HW acceleration for graphics Tons of cleaning up and restructuring of the stack The gnome-shell to be the default UX ... and GNOME met Javascript
  • 9. The gnome-shell A modern, integrated user experience Acts as a compositing manager for the desktop Handles application launching, window switching, multiple desktops, and much more Interfaces GNOME libraries using Javascript as glue 29,497 lines of Javascript code (39,538 of C)
  • 13. what is gobject-introspection? A set of tools for extracting and accessing the metadata of a library's API in a convenient way for other programs to use it. library APIs must be "annotated" and designed to be "introspection friendly"
  • 14. gobject-introspection goals Enable two level applications: C and <your favorite runtime>; Share binding infrastructure work; Other uses like API verification, improving documentation tools, etc
  • 15. the big picture (with GJS)
  • 16. the big picture (with Seed)
  • 17. GIR file An XML description of a library API Can include documentation Example: ZLibCompressor class from GIO's GIR <class name="ZlibCompressor" c:symbol-prefix="zlib_compressor" c:type="GZlibCompressor" parent="GObject.Object" glib:type-name="GZlibCompressor" glib:get-type="g_zlib_compressor_get_type" glib:type-struct="ZlibCompressorClass"> <doc xml:whitespace="preserve">Zlib decompression</doc> <implements name="Converter"/> <constructor name="new" c:identifier="g_zlib_compressor_new" version="2.24"> <doc xml:whitespace="preserve">Creates a new #GZlibCompressor.</doc> <return-value transfer-ownership="full"> <doc xml:whitespace="preserve">a new #GZlibCompressor</doc>
  • 18. Typelib file A binary representation of the GIR file for faster access during run-time.
  • 19. GIRepository: API for retrieving library info from a typelib file http://moodleman.moodle.com.au/archives/202
  • 20. libffi: fantasy fiction foreign function interface http://moodleman.moodle.com.au/archives/202
  • 21. Annotations Go inline in the code (normally in the .c files) Complement the API description with semantic information Normally "guessed" correctly by the scanner Documented at https://live.gnome.org/GObjectIntrospection/Annotations
  • 25. Two engines: GJS and Seed
  • 26. GJS vs. Seed GJS wraps Mozilla's Spidermonkey engine while Seed wraps Apple's JavascriptCore GJS supports language features from ES-Harmony (let, const, etc), Seed doesn't (as of now) GJS is more mature, it powers gnome-shell at the moment Other minor differences (i.e module extensions, etc) both have a fairly good G-I support
  • 27. Oh wait! what about node-gir?
  • 28. node-gir G-I support for Node early stage of development written by Tim Caswell code at https://github.com/creationix/node-gir Why not use Seed or GJS? "Because they are nice, but not what I'm looking for. Node is really popular and it would be nice to be able to use it for desktop tools and applications.", Tim Caswell
  • 31. Importing modules No 'require', sorry The 'imports' keyword Importing is an assignment, not a function call The full module's global scope is imported 'imports.searchPath' similar to 'require.paths' Only synchronous
  • 32. Importing a Javascript module // this will import file 'path/to/my/module.js' var MyModule = imports.path.to.my.module; // this will import 'lib/Http.js' var Http = imports.lib.Http; // using 'const' here is nice but only works in GJS :) const Promise = imports.lib.Promise;
  • 33. Importing a module from the G-I repository // this will import GLib library namespace var GLib = imports.gi.GLib; // this will import GTK+ library namespace // for API version 3.0 var Gtk = imports.gi.Gtk-3.0; // in recent versions of GJS you can do var Gtk = imports.gi.Gtk = 3.0;
  • 34. Importing modules There are also native Javascript modules for more convenient APIs, i.e: mainloop, dbus, lang, signals.
  • 35. Importing a native JS module // built-in JS modules are always accessible // from the root importer var Mainloop = imports.mainloop; var DBus = imports.dbus;
  • 36. Using G-I APIs There are "well defined" rules for mapping the C symbols to their corresponding Javascript syntax
  • 37. Using G-I APIs: Functions Library functions are mapped to Namespace.function: g_timeout_add(...) becomes GLib.timeout_add(...)
  • 38. Using G-I APIs: GObject methods GObject methods are mapped to Namespace.Class.method: gtk_button_new_with_label(...) becomes Gtk.Button.new_with_label(...)
  • 39. Using G-I APIs: Enums Enums are mapped to Namespace.EnumName.VALUE: GST_STATE_PLAYING becomes Gst.State.PLAYING, CLUTTER_STAGE_STATE_FULLSCREEN becomes Clutter.StageState.FULLSCREEN
  • 40. Using G-I APIs: GObject properties GObject properties are mapped to normal Javascript Object members replacing '-' by '_': Property 'use-markup' of a GtkLabel becomes obj.use_markup
  • 41. Using G-I APIs: GObject signals GJS obj.connect(signalName, callback) method is used to connect to GObject signals: obj.connect('destroy', callback); Seed: A bit different: obj.signal["signal name"].connect(callback) obj.signal['destroy'].connect(callback);
  • 43. Documentation No official documentation for Javascript bindings yet Unofficial documentation at http://www.roojs.org/index.php/projects/gnome/introspection-docs.html A hot topic right now
  • 44. What about development tools? http://blog.doomby.com/blog,7-of-the-best-free-website-development-tools,311404.html
  • 45. Development tools No specific developer tools for Javascript at the moment Still too early: remains unclear what the needs will be
  • 46. GNOME Javascript and CommonJS? There is certain interest in the GNOME community, but Not all CommonJS specs could make sense More discussion and bridging is needed node-gir? gjs-commonjs?
  • 47. gjs-commonjs Wraps GJS to add CommonJS APIs Just an experiment, not the way to go Code at https://gitorious.org/gjs-commonjs (LGPL) Only Modules 1.1 and Promises/D (partially) at the moment
  • 48. Current issues and challenges To complete introspection support in GNOME libraries To complete introspection support in GJS/Seed To have official documentation To make GJS and Seed code fully compatible To align with CommonJS for what makes sense
  • 49. Final thoughts An elegant and efficient combination of low-level and high-level languages JS opened to a platform with 10+ years of evolution Very convenient for fast prototyping and gluing Expands the frontiers of JS in the desktop
  • 50. An awesome stack! your Javascript programs GJS (Spidermonkey) Seed (JSC) node-gir (V8) ... gobject introspection Core GIO GLib GObject User interface GTK+ Cairo Clutter ATK Pango Webkit Multimedia gstreamer Canberra Pulseaudio Communication Telepathy Avahi GUPnP Data storage EDS GDA Tracker Utilities Champlain Enchant Poppler GeoClue Desktop integration PackageKit libnotify seahorse System integration upower udisks policykit