Category Archives: gtk+

GTK+ and GSoC

I’d like to share some exciting new about GTK+ development.

In short: GTK+ master branch:  Development towards 3.0 !! 🙂

Mathias Clasen has been merged the gtk-2-90 branch. This branch has been used to prepare a lot of the deprecation removal, etc, for 3.0.

So we have now:

  • gtk-2-20: the usual stable branch
  • gtk-2-22: special branch that will only pick up remaining accessors that are needed to make GTK+ 2.x users build with GSEAL and get them ready to work with 3.x (no new features)
  • master: Development towards GTK+ 3.0 with new features 🙂

More information of the actual status of the GTK+ branches in this mail on gtk-devel-list.

Also, I’m very exciting to announce that I’ve been accepted in this year GSoC (you can see my application here), so I can help GTK+ devels in the GTK+3 transition tasks.

Thanks to the GNOME people for accept my application!

Also, thanks to GTK+ devels for their help (and their patience sometimes ;)), specially to Carlos Garnacho to be my mentor 😉

The fun begins!

Improve performance: Use ->priv instead GET_PRIV() macros

Sure you already know this, but if someone don’t:

Maybe some of you have this in your *.c GObject files:


And then you use this macro in all your functions to access the GObject private structure.

You shouldn’t do this.

Instead, declare a *priv member in public structure and then access private members with my_object->priv->var

Maybe you think the performance improvement is not a lot. Well, I applied a similar patch to giggle [1] and now the startup time is ~10 second faster when opening the evolution git repository.

So, I think it’s worth 😉

Update: From Edward Hervey comments: Some of the benefits of use of G_TYPE_INSTANCE_GET_PRIVATE(): memory space gets allocated alongside your instance, avoids an extra alloc, memory is contiguous, …


Help improve Glib/GTK+ documentation

Update: Before start working in a module, check that It’s not already deprecated (like CList or CTree): these modules will be removed in GTK+3 so the doc migration is not needed

One of the tasks to improve the GTK+/Glib docs maintenance is to convert the documentation from templates (*.sgml) files into source-comments. This is a easy tasks that everybody can do.

All the process is documented here: [1]

Here a step-by-step example to help new contributors 😉

  1. Download GTK+ and gtk-doc source code:

    cd ~/git
    git clone git://
    git clone git://

  2. Execute gtk-doc script to convert the documentation

    cd gtk+/docs/reference/gtk
    ~/git/gtk-doc/tools/ –module=gtk

    This creates a “src” directory containing “*.c” files with all the comments.

  3. Copy and paste them to the right place.

    The section docs are best placed in the *.c file. Put them below the copyright header and the main includes (if there is no *.c file use the appropriate *.h file).
    All other comment blocks should be put directly above the definition of the symbol.

    For example, for GtkAccelGroup, we’d move the comments from gtk+/docs/reference/gtk/src/gtkaccelgroup.c to gtk+/gtkaccelgroup.c and gtk+/gtkaccelgroup.h

  4. Remove the template file:

    git rm docs/reference/gtk/tmpl/gtkaccelgroup.sgml

  5. Check that the documentation is correctly generated with:

    ./autogen –enable-gtk-doc

    then go with a browser to docs/reference/gtk/html

  6. Send a patch to bugzilla and make it block 599599 for GTK+ or 589775 for Glib documentation.
  7. Update the wiki page [1] to avoid duplicate work

When adding the source code comment, its a good opportunity to review it a bit. Have a look on spelling and style. Is it really giving a helpful explanation what the function does, etc. Also improve cross references. The gtk-doc syntax of the comments is described in the gtk-doc manual [2].

You can take a look to the gtkwidget.h [3] and gtkwidget.c [4] code as an example.





Adapt your module to GNOME3 / GTK+3

Hello all!

I’ve been working in GNOME3 “cleaning” tasks for some time and I’d like to share this mini-guide to make your library/application GNOME3 / GTK+3-compilant. The process is quite easy:


Don’t use deprecated libraries:

GTK+ 3:

When you finish, use GNOME_MAINTAINER_MODE_DEFINES macro ( included in gnome-common ) in your files, so you will be notified when you use a new deprecated symbol.

Also, take a look to the awesome Frederic Peters graphs to track the status of your module: