This post was made with an older stylesheet

GJS is a part of the amazing Gnome3 technologies and an excellent choice for the thousands web-developers to build small (or larger) Gnome Apps.

I’ll quickly tell you a story of mine. About a year ago I was trying to build a Gnome App to manage my Ruby on Rails instances; basically it was a user interface for RVM (Ruby’s Version Manager). Because I didn’t want to learn a new language like Vala, I was looking for JavaScript. I knew there was GJS, but I couldn’t find any documentation for it to start; and I end up to use Seed which is also a framework for Javascript bindings in Gnome.

In Seed there was a start up guide I used, but then I had to check on Python’s documentation about GTK as Seed hadn’t any GTK API docs. My torment didn’t stop there, as I was forced to ask Seed devs some things in order to complete my App.

Finally it took me 2-3 days to find out the documentation and 2-3 hours to write the App. And still with Seed you couldn’t do much because you had to check on headers file for functions as GTK bindings were way incomplete. Anyway enough said!

GJS Hello World

This is a simple example how to create a Gnome Box, but creating a webkit Gnome web-browser is like 20 more lines of code :)

#!/usr/bin/gjs

//The previous line is a hash bang which tells how to run the script.

// Note that the script has to be executable (run in terminal in the right folder: chmod +x scriptname)

// Initialize GTK+

var Gtk = imports.gi.Gtk;

Gtk.init(null, 0);

// Create your window, name it, and connect the “click x to quit” function.

// The word “window” is a JavaScript keyword, so we have to

// call it something different.

var mywindow = new Gtk.Window({type: Gtk.WindowType.TOPLEVEL});

mywindow.title = “Hello World!”;

mywindow.connect(“destroy”, function(){Gtk.main_quit()});

// Add some text to your window

var label = new Gtk.Label({label: “Hello World”});

mywindow.add(label);

// Make the label and the window itself visible to the user

label.show();

mywindow.show();

// Let the user run the app

Gtk.main();

The result

You realize how cool GJS is? A whole new promising prospect for Gnome Apps is ahead. Besides half people in world know JS and the rest are learning :)

You better read more at Taryn’s weird(!) blog and you can also check the Gnome Javascript beginning tutorials.