Skip to content

Glade and property binding: Finally something to see!

June 10, 2011

Hello fellow GNOMErs,

Since shortly before Google Summer of Code started, I haven’t blogged the least bit about my Google Summer of Code project (GObject property binding support for GtkBuilder and Glade; see my last post or here for what this about). The reason for this is easy: there simply wasn’t anything to show! Not that I didn’t get any coding work done in the first two weeks, I naturally did, and I am even slightly ahead of schedule despite having to study in parallel as my semester does not end until July. (Yay me.)

However, that work was of the boring type: implement support for a new <binding> tag in GTK+’s GtkBuilder class to codify property bindings in GtkBuilder files, writing a small GObject class named “GladeBinding” to represent property bindings in Glade, integrate it into Glade’s existing data model, extend Glade’s GtkBuilder parser to create GladeBinding objects from <binding> tags, and make Glade write such objects to <binding> tags again when saving. Sounds exciting, doesn’t it?

So after all of that, I basically was at the point where you can open GtkBuilder files with <binding>‘s and save them again without losing the binding definitions in the process. So far so good. However, the read binding definitions didn’t actually do anything whatsoever within Glade. Kind of boring. So this week, I devoted my time to make property bindings in Glade ALIVE!

First of all, this means that property bindings read from a GtkBuilder file are now actually created for real. That is, you can change the value of a binding’s source property and the target property is updated to the same value instantly.

The property inspector is now also aware of property bindings. If a property is the target of a binding, its name is now bold and italic, and its value editing contols are disabled (the property’s value depends on the source property, right?). As cherry on top, the tooltip of a bound property shows which property it is bound to.

Lovely, isn’t it? Finally something to see!

All of this work can be found in my “gbinding” branch at If you feel like compiling it and giving it a spin (which I would absolutely be happy about!): you can test the new code by taking a GtkBuilder file of your choice (or quickly creating a new one), opening it with a text file, and adding a tag like the following to the object you would like to be the binding target:

<binding to="target-property" from="source-property" source="source-object"/>

with target-property, source-property and source-object replaced with sensible values.

Well, that’s it for now. Next on my TODO list, apart from fixing bugs (which I have likely introduced) and memory leaks (which I have *most likely* introduced), is to make it possible to actually create and edit property bindings from within Glade. This will require me to go back to some boring work again for while (integrate with the undo/redo system and things), but if there is be anything new on the UI side, you’ll hear from me as soon as possible. I promise!


From → GNOME, Summer of Code

  1. Seems really useful to remove tons of boilerplate from the application logic.

    Do you plan to have the possibility of connecting a custom filter callback which can be used to change the value of a property before setting the new value of the bound property?

    In any case, keep up the good work!

    • Never mind, I just read the previous blog post and figured out that GBinding already supports what I was talking about.

      /me hides head under sand

      • No need to hide. 😉 Yes GBinding does support this, but I have not added this on the Glade/GtkBuilder side yet as my current focus is to get the basics right. I am planning to implement this after GSoC mid-term, though (where I will also have a *lot* more time due to my semester having ended), so stay tuned!

  2. Very nice work!
    Though I can imagine the UI is only in its initial stage, I’d like to suggest to add a button next to the binded property so you can quickly jump to the source property, which would have also some indicator showing the binded elements.
    Thanks for your work on glade!

  3. Looks great so far keep up the good work!

    I am curious as to how you will implement this in the UI though… any mockups yet? 🙂

Trackbacks & Pingbacks

  1. Glade and property binding: Create your own bindings now! « 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: