libmodel and GTK+ from Codethink Labs!

A few months ago we announced libmodel to the masses, the shiny data model API for GObject, one of our pet projects from Codethink Labs.

Last week we decided to spend some time doing R&D at the company and I asked Ryan how hard would it be to come up with a generic GtkTreeModel implementation, in two days he put together libmodel-gtk!

This solves a quite important problem, GtkTreeModel, and abstract Model APIs are meant to be implemented pretty much for every use case unless you are doing extremely simple stuff, so that you can add smart filtering and sorting from the data source. However, the GtkTreeModel has an API quite hard to implement so everyone end up using List and TreeStore.

Now that we have a libmodel implementation, doing TheRightThing(TM) and wrap the API around the real data store becomes trivial. I quickly put together this twitter client using libsoup-2.4 and json-glib, and it is the first time that I have fun writting an data driven (let alone online) app for GTK+ in quite some time 🙂

Screenshot-model-twittfeed
Grab the source here, it's only 230 lines of Vala, most of it picture retreival/treemodel code actually, to compile it you'll need a fairly recent vala release. Copile using this command line:

~$ valac -g --thread --pkg gtk+-2.0 --pkg json-glib-1.0 --pkg libsoup-2.4 --pkg model-gtk model-twittfeed.vala

We are already planning having some standard set of providers, there's already a filesystem implementation in the model-examples repository, we are cooking a Tracker one and I should be adding a JSON one soon, other implementations are welcome! I would be quite excited to see SQLite, XML, CouchDB ones as well.

This is the kind of things that makes me really proud of working at Codethink, there's an exceptional bunch of smart guys willing to kick the complexity out of the way with elegance and simplicity!

Kudos to Ryan for this one, we should be putting together another release soon.

Advertisements

10 thoughts on “libmodel and GTK+ from Codethink Labs!

  1. mie: the ? in vala either means that the variable can be null, or that the type is boxed (when using it with generics)

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s