GTK 4: how to replace gtk_builder_connect_signals()?

Hi,
in GTK 4, gtk_builder_connect_signals and gtk_builder_connect_signals_full were removed:
https://developer.gnome.org/gtk4/stable/GtkBuilder.html

What are your advice to replace those functions ?

Look at GtkBuilderScope, though where possible you should use templates instead of GtkBuilder directly

1 Like

To clarify:

  • your language binding will need to implement the GtkBuilderScope interface in an ancillary object
  • the GtkBuilderScope interface provides virtual functions for:
    • determining the GType of a type from its type name (the old GtkBuilderClass.get_type_from_name() virtual function)
    • determining the GType of a type from a function name
    • creating a GClosure for a function name and its arguments (the old GtkBuilderConnectFunc)
  • once you have a GtkBuilderScope implementation, you set it as the scope of the GtkBuilder instance you need to connect signals to

So, for instance, Python bindings would need to create a BuilderPythonScope class that implements GtkBuilderScope, and set it as the scope for the GtkBuilder instance if they want to resolve Python callables to signal handlers.

1 Like

Thank you @ebassi and @zbrown for your precise answers.
We will work in that direction.

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