Navigation


New User Interface Technologies

Graphical user interfaces, or GUIs, are what users expect to see on all platforms from desktop computers to cellular phones. In the Linux environment, there are several user interface development kits, of which GTK+ and Qt are probably the most popular nowadays.

GTK+ (The Gimp Toolkit) is used on the GNOME platform, the default desktop environment for many popular Linux distributions such as Ubuntu and Debian. GNOME might be considered "heavy", limiting its use in "slow" devices such as cellular phones, but GTK+ is also used, e.g., in the "light" LXDE desktop. GTK+ applications are written mainly in C, although bindings to other languages exist. Similarly, Qt is used on the popular KDE desktop, and Qt applications are written in C++.

Writing code in C/C++ is low-level, the syntax is strict, compilation is needed, and all this takes a lot of time and effort from developers. Also, porting a program written in C/C++ to another architecture requires at least a recompilation, and could be a long process.

There is an upcoming new way of writing GUI applications to GNOME: JavaScript. This scripting language is interpreted, dynamic, loose on syntax, and will run on almost any system. Also, JavaScript is already familiar to many developers from WWW. This means that developing an application in it is fast, easy, and it will require no porting. Of course, applications that need heavy algorithmic computations might be best written in a compiled language, but even in these, it might be possible to write only the computation-heavy parts in a compiled language and the UI in JavaScript.

The JavaScript UI technologies in GNOME are still maturing and there are two competitors:  Seed and  Gjs. Currently Seed seems to be the stronger candidate, especially its documentation is much wider. Seed is based on the WebKit JavaScriptCore JavaScript engine. As JavaScript itself lacks a general purpose UI library and many other things, Seed and Gjs use  GObject Introspection to generate a bridge from C to JavaScript. It provides ready-made bindings to GTK+ (UI development), Clutter (2D animation/graphics), GLib (low-level GNOME stuff), and many other libraries, which means that one can easily write a full-fledged application in JavaScript.

Getting Started

Seed (and/or Gjs) will probably become part of GNOME packages for Ubuntu and other distributions in the future. In the meanwhile, to try out Seed development, you can either compile and install up-to-date versions of WebKit, GObject Introspection with its repositories, and Seed/Gjs manually, or use our prebuilt Debian/Ubuntu packages (x86 and armel architectures). A convenient metapackage will install the whole bunch.

Installing the Seed/Gjs metapackage in Ubuntu Jaunty:

  1. add the following line to your '/etc/apt/sources.list':
    'deb http://mdeb.nomovok.info/repository mdeb-jaunty-x86 main'
    (or 'deb http://mdeb.nomovok.info/repository mdeb-jaunty-armel main' for armel)
  2. 'sudo apt-get update'
  3. 'sudo apt-get install gnomejs'

After the installation, you can start the Seed interpreter by calling 'seed' and Gjs by calling 'gjs-console'. You can find Seed examples in '/usr/share/doc/seed/examples/'.

Some tutorials and references:

The GTK+ and Clutter tutorials above are for C. Mappings from C to JavaScript are straightforward, but there are some name changes. Check  Seed documentation and look at the gir files that GObject Introspection provides under '/usr/share/gir-1.0/'.

Demos

We have two demos showcasing UI development in Seed:

  •  Seeded - a simple text editor that uses GTK+




















Running the demos is simple: make sure you are in the correct folder and that the .js files have execute permissions ('chmod u+x seedman.js seeded.js'), then just call './seeded.js' or './seedman.js'. Alternatively, you can run a demo without execute permissions by calling the Seed interpreter explicitely: 'seed seeded.js'.

Attachments