Skip to content

More builder work

Benjamin Otte requested to merge wip/otte/builder into master

This is a follow up to !1204 (merged) and addresses things pointed out by @sdroege, @ptomato and @kjellahl as well as new issues I've figured out. In particular:

  1. It introduces the idea of a "current object", which is the template that's being constructed. Bindings should think of it as the this pointer, in particular when parsing templates.

  2. Replace the closure func with an actual scope object. This scope object can carry additional language-specific information and can be copied around and reused with different builder instances.
    For C, this means we can move the old gtk_builder_add_callback() to the scope object and get the same callbacks in multiple builders. This is extra interesting for the listview work where GtkBuilder-using listitem factories want to inherit this scope - and having an object makes that easy.
    This should hopefully also work without overrides having to be done in C, as g-i based languages can just create their custom Scope object and just replace the gtk_builder_new...() overrides with custom ones that set this custom scope.

  3. Resurrect the old vfuncs that were deleted from GtkBuilder as new vfuncs in the GtkBuilderScope. This fixes #2267 (closed) and allows the C++ backends to keep the type mangling they did in GTK3.

  4. Move all the module loading machinery out of gtkbuilder.c and into the scope. This is just cleanup work, but it makes the sources easier to read.

Merge request reports