ColumnView unbind doubts

I found this example - ColumnView Python Example.

I am using a SignalListItemFactory to use different widgets in the same column (think of it as a property editor - one column for a static key / TreeExpander, one for a widget depending upon the type of value).

Do I really need to bind and unbind the Gio.Binding in the respective signals? Can’t I just connect notify::text (for example) to a callback which updates the value in the model and forget about it?

IMO, it seems like a really hacky way to assign a (private) variable to use it across function calls.

Why do I need to unbind and delete (set it to None) the binding? Do I create a memory leak by not unbinding?

Btw, why does notify::changed signal not work on Gtk.Text instances?

Yes, unless you want the binding to persist. The same applies to signals: unless you want the signal handler to remain for the lifetime of the object, you have to disconnect it.

No, but the binding will remain, potentially resulting in the target object being updated by multiple sources.

Because GObject.Object::notify is a signal emitted for property changes and there is no such property called changed. You probably meant to connect to Gtk.Editable::changed.

Yea, right I meant just the changed signal

I create widgets in the bind handler and bind their properties their itself. As I scroll up and down, the bind handler gets called for the same row multiple times. If I don’t do anything in the unbind handler, does it mean I am creating widgets over existing widgets and / or duplicating the property bindings?

Also, if you could just help me with this SpinButton always gets set to 0.

That’s how these widgets work, and how they can scale to millions of rows by re-using widgets. You should create widgets in the ::setup handler and destroy them in ::teardown, and expect that ::bind/::unbind are emitted more times than ::setup/::teardown.

Probably, yes. Best just to use the API as intended, since not doing will result in some kind of “undefined behaviour” either way.

Sorry, I had a look, but I don’t know the answer to that question :confused:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.