Support for GObject instance_init in Glib.Object.Initialize_Class_Record
Nobody has claimed this yet.
- Dominant language
- Ada
- Stars
- 110
- Forks
- 22
- PR merge metrics
- No merged PRs in 30d
Description
Description
Currently Glib.Object.Initialize_Class_Record does not allow registering an instance_init function.
In the implementation (src/misc.c) the field is hardcoded to NULL:
info.instance_init = NULL;
This makes it impossible to create composite custom widgets that are properly initialized when instantiated by Gtk.Builder (or g_object_new).
In C, the standard way to initialize the children of a composite widget is the instance_init function. Without it, Ada developers are forced to call Initialize manually after every Builder.Get_Object, which is error-prone and inconsistent with how native widgets work.
Proposed solution
Extend Initialize_Class_Record (by add an overload / new parameter) so that the user can optionally provide an Instance_Init callback. This callback should be stored in the AdaGObjectClassRecord and assigned to info.instance_init when registering the type.
This would bring GtkAda closer to normal GObject practices and improve the experience of writing reusable composite widgets that work with Glade/GtkBuilder.
Additional context
The current limitation affects anyone writing composite widgets in Ada that need to work with UI files loaded by GtkBuilder.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/misc.c at Glib.Object.Initialize_Class_Record and inspect how AdaGObjectClassRecord is populated, especially the hardcoded info.instance_init = NULL. Trace the related declaration and registration path, then verify that an optional Instance_Init callback reaches info.instance_init and supports composite widgets created through Gtk.Builder or g_object_new.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- desktop
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100