Hi, planet GNOME! GSoC on (mainly) GtkSourceView

My blog has just been added to the planet GNOME!

I’m now a GSoC student, working mainly on GtkSourceView (my proposal).

I’m implementing a higher-level asynchronous API for the search and replace. I hope to finish this task in two weeks.
Then: regex search, adapt gedit, modernize the color schemes and ideally GtkTextTag to use CSS.

Search API, some progress

The highlighting of search matches works fine, there was a flickering issue that I fixed.

A property contains the total number of search occurrences. So while the user is typing the text to search, the buffer is scanned to highlight and count the number of matches. What will be really nice is that, once the buffer is entirely scanned, going to the previous/next occurrence will be a O(log n) operation, thanks to gtk_text_iter_forward_to_tag_toggle() (that’s why the matches must be highlighted even if they are not visible on the screen). It was more difficult to implement than always using gtk_text_iter_forward_search() and backward_search() to navigate through the occurrences, but I think it was worth the effort.

If you want to read more details, I’ve written a quite long implementation overview, with the problems to avoid, at the top of gtksourcesearch.c (it will also be useful to future maintainers).

I’ll continue to blog to explain my progress, so stay tuned!

My work on GtkSourceView so far

During the GNOME 3.7 development cycle I’ve been busy working on GtkSourceView, a library used by gedit, Anjuta DevStudio, LaTeXila, and other applications.

The main change is that the completion system has been revamped, mainly under the hood.

Completion: user-visible changes

The only user-visible changes are the bug fixes and the new calltip window sizing, also used for displaying extra pieces of information for proposals. In GtkSourceView 2 there was a function for tuning the calltip sizing, but this function has been removed when porting GtkSourceView to GTK+ 3. Now the sizing works correctly without any tuning function, the window simply fits the natural size of its child widget.

Now the user-comprehensible explanation:

Image of: “completion calltip before”

Image of: “completion calltip after”

You see that the main completion window is still quite big when there are only a few proposals. For now it’s not possible to change that, but a more compact completion window should be possible in the future.

Completion: developer-visible changes

The completion system is now better documented. A few functions have been deprecated. The code has been simplified (two classes have been almost completely rewritten). There are also some performance improvements, but it was not really an issue previously. Some statistics on the number of lines:

Before:

$ wc -l gtksourcecompletion*.{c,h} | tail -1
8012 total

After:

$ wc -l gtksourcecompletion*.{c,h} | tail -1
6728 total

Perfection is achieved not when there is nothing more to add, but rather when there is nothing more to take away. (Antoine de Saint-Exupéry)

Other enhancements to GtkSourceView

Paolo and I wrote more unit tests, and code coverage support has been added, to have statistics with nice colors.

Lots of compilation warnings have been fixed, especially for the API documentation. For example, the links to GLib or GTK+ symbols work now in the documentation. Compilation warnings are generally easy to fix, it’s a good way to get involved in a project I think, if there are no easy bugs to fix.

That’s all folks. Thanks to Paolo, Ignacio and Jesse for their advices and reviews!