Steve Frécinaux

GtkSourceView 1.90

Last week was released what is meant to become GtkSourceView 2, and the python bindings for that new library were released shortly afterwards.

GtkSourceView is a library that provides a widget for source code display and editing, derived from GtkTextView. It is used by gedit and nemiver, among others.

This new 1.90 release brings quite a few hot news.

GtkSourceView 1.90 highlighting sample

First of all, there is now a new, smarter highlighting engine. It is context- aware, which means we are now able to highlight parts of texts that are recognized in a given context, recursively. In practice, it means you can highlight HTML code in a PHP file, and doxygen bits in a comment block. It also caused a large amount of bugs to be fixed. To do that it uses a new language description format.

The other novelty is the theming support: colors are now grouped in a file that maps symbolic names into RGB tuples. Those symbolic names are common for every language files and can optionnaly be overwritten on a per-language basis. This will make the color customisation easier than before and will allow a better fit with dark themes. Currently we only provide a ⤽vim⤝ theme, but we would appreciate new ones.

On the other hand, the printing support has been removed (thus dropping the gnomeprint dependency). This was done because we currently expect people to implement custom printing support on an application basis, using the new GtkPrint API, allowing much more control than what was available with the printing code in GtkSourceView 1.

The bad news is that all those nifty things come along with an API/ABI break. Testers and bleeding edge developpers, be aware the new API is not yet frozen: it can still change. Application development should stick on the old GtkSourceView 1.0 line, which lies in the gtksourceview-1-8 branch, unless their developpers wish to experiment a bit and give us some (needed) feedback. Both versions are parallel installable anyway.

You should not be too afraid anyway: we took profit from the API break to fix some longstanding mistakes (typos in function names, for instance), but the API stays very similar to what it has been for quite a long time now. Updating programs should not be hard at all.

As I said earlier, python lovers have not been forgotten: pygtksourceview 1.90 has been released as well. Same remark as before, the API is not frozen, so be careful.

As you can figure by yourself, this widget is meant to be used in gedit. We hope to provide you a gedit version with support of GtkSourceView 2 and its new features for Gnome 2.20. We already have a “gsv2-integration” branch which mostly work, and you can try it out. What we need to do now is to figure out what to do for printing and theming support. To build that branch of gedit you’ll need both GtkSourceView 1.90 and pygtksourceview 1.90.

Let’s not finish that presentation without citing the kind people responsible for this: Marco Barisione, Yevgen Muntyan and Emanuele Aina. Thanks to them!