"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects." (Robert A. Heinlein)

Thursday, 26 July 2012

Developing Gnome 3 extensions (on the EEEPC)

When I decided to install Linux Mint on the EEEPC 900 I was, among other things, particularly interested by the hidden flexibility of Gnome 3. Linux Mint interface MGSE proved Gnome 3 being far more flexible and configurable than I would ever imagined by seeing it at first. At last I managed to find some time to give a look on how Gnome 3 extensions are written. There are many sites on the Internet about developing Gnome extensions I based my experiments mainly on articles on this blog.

Hello-worlding” in Gnome-Shell
A command-line utility “gnome-shell-extension-tool” is provided to prepare all files needed in a gnome-shell extension. Once executed:
gnome-shell-extension-tool --create-extension
it asks for the extension name, “helloworld” in my case, some descriptive info and the extension unique identifier. This identifier can be any string but it takes the following mail-like form: <extension-name>@<your-name>.<your-address>.
By the way my extension identifier was “helloworld.musante@EEEPC900”.

The Gnome-Shell extension tool create the three files needed for the extension project and places them in the proper directory, which is “.local/share/gnome-shell/extensions/” for locally installed extensions, in a folder named with the extension identifier previously chosen.
The code automatically generated by the extension tool contains all the necessary to display a small “Hello World” message on the middle of the screen.
The extension can be enabled using Gnome-Shell advanced settings
and here is how it looks like

Using a different IDE

GEdit is a good editor but I'd like to use something more to write code. Unfortunately there isn't yet a IDE, or a plug-in, designed for Gnome-Shell extensions but you can still take advantage of Javascript editors almost all modern IDEs have. With Netbeans, the IDE I have installed on my EEEPC 900, you can just add the extension folder to the “favourites” tab
you don't have a full featured auto-completion, the IDE doesn't know where extensions base files are located, but anyway it's a starting point.

No comments :

Post a comment