Gnome 3 extension development hints #6 Extension Preferences

Posted March 16, 2013 by at Development, Gnome, Gnome3, Hints.

In order to create your preferences mechanism for your extension, there’s a layout which must be followed:

  • myExtension@someExtension/ : the root path of the extension.
  • myExtension@someExtension/schemas/ : the root schema path of the extension.
  • myExtension@someExtension/schemas/ : The schema file which define the preference data structure.
  • myExtension@someExtension/prefs.js : Display the GUI coded with GTK.
  • myExtension@someExtension/convenience.js : Utils for our extensions (thirdparty).

First, define the schema:

In myExtension@someExtension/schemas/ the data structure of the preferences must be defined, this structure is just a schema for your settings:

The line 2 define the text domain which is gnome3-myExtension, line 3 fined the id of the schema, 4 to 11 define the json structure in which the settings will be saved, in this case it will be a string saved as json data, line 12 and 13 are self descriptive.

Be aware that this file must be compiled using: glib-compile-schemas schemas

Second, setup a file will be used as a “proxy” to save, and retrieve the settings saved. This file must be used since the prefs.js file do not permit saved and get configuration data directly form the schema, also in this way we keep a compatibility/scalability structure for the next gnome-shell versions. An example of this file:

Third, the prefs.js file:

  • The ‘gettext-domain’ is defined in the metadata.json.
  • Methods init, widget_initliaze, buildPrefsWidget must be defined.

In this example:

  • widget_initliaze define the GTk objects, the documentation of GUI elements and how to create them can be found as PyGTK.
  • widget_packaging, like the method name define how the elements is/are packaged, see PyGTK documentation.
  • widget_connect, connect the ‘click’ button to save the settings.
  • save_settings_button_callback, the method which is triggered by the save-button, line 103 and 103 get the settings saved, replace with the values defined in the GUI and line 100 save this settings as json data to the schema.
  • widget_init_values, this method get the saved (settings) value, line 117 and 118 get the json data.
  • buildPrefsWidget, initialize the preference GUI.

You can create lot of settings for your extension, the GUI is strongly based on GTk (see PyGTK documentation).

Run Rails server from Sublime Text 2

Posted by at General Coding Stuff.

Very easy, just create a new build system, in this case I’m using a linux based system

Go to:
Tools > Build System > New Build System

And add the command in order to open the new terminal instance.

e.g. for linux/gnome based, a new terminal instance (with some fancy arguments):

gnome-terminal –hide-menubar -t ‘/home/atejeda/Desktop/mojo’ –working-directory=/home/atejeda/Desktop/mojo –geometry=120×50+0+0 -e rails s

An example of this configuration:

Press Ctrl + B to run the server and you are done, if your are using OSX or Mac, open -a Terminal -n it will open a new instance of Terminal, easy to modify.

Gnome 3 extension development hints #5 repetitive time based task (loops)

Posted February 24, 2013 by at Development, Gnome, Gnome3, GNU/Linux, Hints.

Lot of extensions update his menus/information/etc.. every X minutes, e.g.: a monitor of the CPU load: take the information of the system and then update his UI.

It will be very nice have a some sort of Thread implementation for Javascript in order to perform this repetitive tasks, this repetetives task time based are very easy to achieve in JS Gnome-shell using the mainloop module/library.

The mechanism is pretty straight-fordward, let say that we have the method A and B, B has the main loop logic, this logic will wait the X milliseconds defined before to call the A method, when A method is executed, it will execute the B method and so on.

Lets take a look to the pseudo-code:

In this way you can execute time based tasks e.g.: to retrieve thirdparty information, system information, etc.

Gnome 3 extension development hints #4 Custom Icon to Main.Panel

Posted February 10, 2013 by at Development, Gnome, Gnome3, Hints.

The idea is to add a custom icon to, lets say to the Main.panel (System status and user menu). Take a look to h

Take a look to the extension.js code:

Gnome 3 extension development hints #3 Basic Structure

Posted by at Development, Gnome, Gnome3, Hints.

As a quick help, the basic structure of the gnome extension is located at extension.js file:

Gnome 3 extension development hints #2 Documentation

Posted by at Development, Gnome, Gnome3, Hints.

There’s a lot of info related to create an extension, but there’s not a lot of good documentation, lets face it, is kinda difficult to start reading the code if there’s no documentation for the classes, methods, functions, etc.

I’ve face this situation when I was trying to develop my extension, a lot of info how start developing one but I wasn’t able to find the documentation for the JavaScript libraries developed by gnome (instantiated in the code).

Based in my own experience, I recommend to read the following:

This is to put you in context of the Gnome shell architecture/design and elements (actors):

As the StepByStepTutorial says that the best documentation is the source code, here you can grab/read the libraries, this libraries also are located under /usr/share/gnome-shell/.

In this post, explain the js/libraries/scripts:

The official documentation of St and Shell libraries:

A couple of good post related of how to find documentation:

This is how I get the documentation, e.g.:

I want to create a icon and append it to the Main.panel, based on the example code (when you create a new extension):
Take a look to Main.panel, Main is just an alias for imports.ui.main and you can check how this function is working and his params by looking the code located at js/ui/main.js which, in this case, instantiate the js/ui/panel.js code.

But first I must create an icon, if you check the code to create an icon you must instantiate a new St.Icon.., everything relate to St.* and Shell.* can be found at, be aware of how to “translate/map” the method/functions name, is mapped like:

st_icon_set_gicon() to St.Icon.set_gicon()

To debug if you are calling the correct function name, take a look to this post: Gnome 3 extension development hints #1 Debugging.

Gnome 3 extension development hints #1 Debugging

Posted February 9, 2013 by at Development, Gnome, Gnome3, GNU/Linux, Hints.

Ok, this is the very first post of a series of a lot of Gnome 3 extension development hints.

In order to debug your extensions just use the print(); function in your code, this print will be printed in the session log file located at /home/myusername/.cache/gdm/, also the log will tell you how/when/what/etc.. your code is failing. E.g.: I was setting a custom icon for the panel (where the sound icon is located) but I was using the wrong function I’ve noticed the error looking at the log. Try to use tail for tracking the behaviour of your extension tail -f /home/atejeda/.cache/gdm/session.log.

Maybe a good idea it will be create a class which creates a custom log for the extensions.


Instead of using print(""); function, use global.log(""); function.

Manage several versions of Ruby with RVM

Posted January 28, 2013 by at GNU/Linux, Ruby.

RVM means Ruby Version Manager.

This should work in any GNU/Linux distribution/spin, but as always it was tested on Fedora.

Setup rvm by executing:

Add it to your PATH environment var by adding it to your bash profile:

Resource your profile e.g.: . ~/.bashrc and install the ruby flavors that you want, in my case for rails 2, 3 and jruby:

Then, setup the default ruby version with, e.g.: rvm --default ruby-1.9.2

Configuration for local gems (optional)

Add to your bash profile the following lines, and then resource the profile, it will setup the gems directory for every ruby installation that you are currently using, setting the things like this it will keep in separated directories the gems for the specified/currently-using ruby version:

And then, install the gems that you want, e.g.: rails.

101 Regular Expressions (regex)

Posted January 11, 2013 by at General Coding Stuff.

Regular expressions aren’t so easy to learn, most of the time developers try to avoid them because the learning curve is too, let say, long.

I’m not a regex-guru, but I know how to use them and that’s why I will show you using some examples, these examples can be applied to any programming language based/using POSIX C standard.

  • a*b = b, ab, aaab (0, 1 or more)
  • a+b = ab, aaab (1 or more)
  • ca?b = cb, cab (0 or 1)
  • a{2} = aa
  • a{2,} = aa, aaa, aaaa
  • a{2, 3} = aa, aaa
  • ^a{2,3}$ = aa, aaa
  • abc|def = abc, def
  • ab(d|ef) = add, adef
  • [abc] = a, b, c
  • [a-c] = a, b, c
  • [^a-w] = x, y, z

[1] Boost Regex

Install Django in Ubuntu 10.04 / Apache

Posted June 4, 2012 by at Django, GNU/Linux, Python, Ubuntu.

Installing Django it’s pretty easy, just a couple configurations. This tutorial can work on several linux distro, but it was tested in Ubuntu server 10.04.


check if is already installed mod_wsgi:

Install mod_wsgi and other python utils:

Install Django


Create app.wsgi file in your DocumentRoot directory, the add:

and in your virtual host configuration:

Test Django

Create the wsgi file for the application: django.wsgi

Also add to your virtual host configuration:

Create a new Django application

then reload apache.

Powered by Fedora, Wordpress, Twitter-Bootstrap and Emacs.*checkout*/emacs/emacs/etc/images/icons/hicolor/32x32/apps/emacs.png