Skip to content

Glade and property binding: Create your own bindings now!

July 20, 2011

Hello inhabitants of the wonderful world of GNOME,

I admit it right away: I lied. Or, rather, didn’t do what I promised and planned. While I wrote in my last post that I would blog about any visible progress of my Google Summer of Code project, GObject property binding in GtkBuilder and Glade, right after it is commited, I didn’t post anything for, gosh, over a whole month. Which is a shame, as there *is* actually quite a lot to see: support for not only viewing, but also creating and deleting property bindings is now fully implemented and working! The UI for this is pretty non-obvious at the moment and could be much improved, but it’s fully functional and will receive a great deal of spit and polish once the mandatory implementation work is done (more on this later).

The right-click menu of every property in the inspector (what, you didn’t know there was a right-click menu? well, I said this isn’t obvious ;)) now contains a new item named Bind to source… which allows you to make the property the target of a new binding.

Choosing this item will present you will a nice little two-pane dialog which allows you to choose the source object and property you would like to bind to. As you can see in the screenshot below, properties whose type don’t match the target property are greyed out and appear after all the compatible ones.

(Yes, these screenshots are made in fallback mode, which is why the dialog is not visually attached to the Glade parent window. For some odd reason, the screenshot tool gives me only shots of my desktop background when I’m in the Shell – probably because the crappy propietary ATI Catalyst drivers which I have to use because my laptop’s GPU fan goes crazy with the open-source ones. *End of off-topic rant*)

Clicking Bind then makes the magic happen. Last but not least, the mentioned right-click menu also offers the option to remove an established property binding you don’t like it anymore, or replacing it if you like another one better.

So, voila, the whole CRUD family is there! You can now actually use the property binding feature in this basic form. (Okay, the resulting app won’t run anywhere as the code in my GTK+ branch is needed so that GtkBuilder is able to read the new <binding> element, but hey.)

So, where to go from here? For this second half of GSoC, my plan is to implement support for transformation functions, that is, being able to specify the name of a function which may arbitrarily transform the value of a binding’s source property before passing it on to the target. This includes further enhancements in my GTK+ branch – possibly with new GtkBuilder API functions for hooking up transformation functions automatically in the manner of gtk_builder_connect_signals() (I sent a message to gtk-devel-list to discuss this) -, some extensions to Glade’s data model and, naturally, exposing the whole thing in the UI. Should be more than doable in six weeks’ time, should it? After this is done, the agenda will be polishing, polishing, polishing: fixing bugs, gracefully handling edge cases and, lastly, making the UI a bit prettier and more discoverable.

Well, this is it for now. Sorry for taking so long for blogging about all of this, but I had a lot on my plate in the last weeks with my semester coming to an end and course work getting more and more time consuming. But now my lectures are over, next Monday is my last exam, and then I’ll have all the time of the world to bring you plenty of Glade property goodness! Stay tuned…


From → GNOME, Summer of Code

One Comment

Trackbacks & Pingbacks

  1. Glade and property binding: Finally continued « denisw

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: