Often when writing C, I find myself copying utility functions from program to program. Here are some that are not always obvious, especially for those who don't write a lot of C, or are still learning about GTK+.
Converting a Cairo image surface to a GdkPixbufCairo's image surface and GdkPixbuf use different byte orderings for their buffers, so it's not possible to simply memcpy from one to the other, you have to swap the bytes around. I'm not sure why GDK doesn't provide a function to do this, I think I originally got this one from Murray.
cairo_convert_to_pixbufGlade signal autoconnection with user_dataThe glade_xml_signal_autoconnect() function doesn't let you specify user_data or flags. This utility function provides for both of those. I don't remember where I got this function from originally, I've since modified it to also support flags so that I can pass G_CONNECT_SWAPPED.
signal_autoconnect_with_dataSearching a GtkTreeModel for a particular piece of dataRecently I found myself needing to be able to search a GtkTreeModel for a row that contained a particular piece of information. Of course, I found myself wanting this functionality twice, for two different data types, so I wrote a generic version. Unfortunately, it seems that GLib doesn't provide an generic way to compare to GValues (the only compare function I've seen requires a GParamSpec) so at the moment it's introspecting the type and implements custom compare functions.
tree_model_find_rowMaking Buttons glow when they're activeAn application I'm developing has a series of GtkButtons that pop up dialog boxes. I wanted to offer some UI indication that the primary setting controlled by this dialog was switched on, so I decided that I would make them faintly glow with the selection colour (e.g. blue in the default GNOME theme). It's looks really good on buttons, I have no idea what it looks like on any other widget, although it should alter them in some way.
set_button_active (perhaps should have a better name)
Converting GdkColors to RGBA valuesThis is useful when dealing with GooCanvas, which takes guint RGBA values for colours. It's a pretty straightforward function, as long as you know that GDK's colour model is 16-bits per channel and how bitwise operations work in C.
gdk_color_to_rgbaFeel free to comment with your own favourite GTK+ utility routines, or to point out any mistakes/bugs in mine (I'm after all, not perfect).
Sculpture by the Sea is on again at Cottesloe Beach. Steph and I went to check it out yesterday evening. Lots of abstract pieces this year and unfortunately nothing as awesome as
this.


Unfortunately it was somewhat overcast and the light was failing, especially towards the end, so some of the photos are a bit dull.
All PhotosWhile on the topic of photos, I uploaded my photos from
O'Day this year. Some of which I quite like.