Mathias Hasselmann

Postings by Mathias in August 2007

Spell Checking for the Masses

Recently I needed spell checking support for some cairo (and Pango) based canvas widget. Should be easy to pick, considering there are several aproaches to implement spell checking for GTK+ widgets, like gtkspell or libsexy. Unfortunatly those pretty libraries have the fault of focusing on one single widget only. So equiped with the power of Vala I wrote some small generic spell checking library for GTK+. Instead of directly attaching to some widget this library uses a simple interface for adding spellcheck support:

using GLib;

namespace Gtk {
    public interface SpellCheckClient {
        public abstract List<SpellCheckCluster> get_clusters ();

        public abstract void reset_highlighting ();
        public abstract void highlight_word (SpellCheckCluster! word, 
                                             int start, int end);
        public abstract void replace_word (SpellCheckCluster! word, 
                                           string! replacement);

        public signal void changed ();
        public signal void populate_popup (SpellCheckCluster word, 
                                           Menu! menu);

As the result the library supports spell checking for several GTK+ classes now: GtkTextView, GtkLabel, GtkEntry, GtkTreeModel and PangoLayout.

Spell checking itself is provided by Enchant.

Update: Forgot to demonstrate the multi-lingual mode. Updated the screen cast. It works similiar to Evolution and gtkspell3: A word only fails if it isn't found in any dictionary and some of the menu entries are modified to contain - in violation to the HIG, but in lack of a better idea - submenus. Also forgot to mention future plans: For text views it should be possible to selectivly disable spell checking for read-only or code sections. Also it should be possible to retreive a section's language by inspecting Pango attributes of the text. Well, and finally I have to properly package the beast.

Automake support for Vala

Using Vala together with automake was quite painful so far. When looking into libvala's for instance you'll see alot of duplication.

So I hacked a little script generating the automake rules needed for vala code. After adding the vala-support script to your script your can look as simple as this:


libtest_la_CFLAGS = $(AM_CFLAGS) $(GTK_CFLAGS)
libtest_la_VALAFLAGS = --library=test --pkg=gtk+-2.0
libtest_la_LIBADD = $(GTK_LIBS)

libtest_la_SOURCES = \
    test-first.vala \
    test-second.vala \

include Makefile.vm

Unfortunatly this is not integrated into upstream automake yet - simply because I am not very skilled in reading other people's Perl code - but the vala-support script itself is written in Perl already, so it should be easy for some skilled Perl hacker to merge that code into automake.

So anyone there to take that task?

Final SoC-Status

So the summer of code has reached its hands-down phasis and few minutes before the deadline finally height-for-width support has landed:

Height for Width Support in GTK+

Proper support for rotated labels with ellipses also has been backported to GTK+:

Rotated text with ellipses backported.

Well, but end of Summer of Code doesn't mean end of hacking: Have to teach GtkHBox and GtkTable the size-for-allocation trick. The icon view could profit from exposing such information. Well, and finally the extended layout branch has to be merged into GTK+ trunk, which currently is feature frozen.

Guess this Summer of Code was quite some success for me: Implemented some useful features and finally managed to fully join the GNOME community.

SoC-Status 2007/08/02

I didn't provide a status report for some time, so what happend in extended layout world?

I stopped to waste time with baseline alignment and switched to spreading natural size support over GTK+. As a result of this effort many widgets and one cell renderer are providing and interpreting natural size information now: GtkAlignment, GtkBin, GtkButton, GtkCellRendererText, GtkCellView, GtkFrame, GtkHBox, GtkLabel, GtkSocket, GtkTable and GtkVBox.

When working on GtkVBox and vertical natural size aware alignment in GtkTable I realized GtkLabel doesn't support ellipses when rotated. So I implemented ellipsizing support for rotated labels. This code only works properly for angles being multiples of 90° so far (first screencast), but I managed to write some test program getting ellipses right for any angle (second screencast) - just have to adopt the code to the label.

Completly unrelated Teemu Ikonen reminded me of my common file format chooser project. So I moved the code from Bugzilla to libegg. Finally I also figured out how to automatically integrate that widget with file choosers. So I added file filter synchronization and automatic file extension appending (third screencast). The code still is quite rough. Icons should be retrieved via the MIME type API of GVFS. Nevertheless it would be nice if interested parties would verify if it works for them in principle. Change requests should be posted in Bug 440431.

Rotated labels with ellipses are broken still Testing how to rotate ellipsized labels The new file format chooser