Add custom signal handlers to ui file (Gtk.ListItem) loaded from resource (for a Gtk.BuilderListItemFactory)

In this example listview application I am writing, I am attaching custom signals to custom widgets put inside the Gtk.ListItems.

I’d like the parent of the listview to receive such custom signals.

The way I am trying to do this is to propagate the signal in cascade from child to parent; to finish climbing up the tree I would need the Gtk.ListItem (the one for the factory) to connect to such signal and handle a custom callback to further propagate the signal, but I don’t know how to change the BuilderScope of the ListItem ui file to do that.

Can you help me?


You literally need to provide an object that implements the BuilderScope interface, and more accurately the BuilderScope.create_closure() virtual function. The create_closure() vfunc creates a closure—a callable object—from the name in the GtkBuilder UI definition file.

An example implementation of a BuilderScope in Python is inside the Gtk.Template override:

1 Like

Side question:
how do I define such custom class into the ui?
I tried with

<property name="scope">


<property name="scope">
  <object class="CustomBuilderScope"></object>

but neither of these work.

Import should be correct though (changes have been pushed)

EDIT: I forgot to set the __gtype_name__ attribute.

I’ve partially made it, meaning that I made the Gtk.ListItem execute a function which should emit the same custom signal of its child (hardcoded), but I still don’t know how to connect a callback to the Gtk.ListItems from the Gtk.Listview (changes pushed).

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