My concern is that I created a callback function, which should display a Gtk_Entry when we click on the Gtk_Button but is that when I click on the button nothing happens. I don't understand.
File.ads
Package Test is
Type T_Test is record
Conteneur : Gtk_Fixe;
L_Entree : Gtk_Entry;
end Record;
Procedure Le_Callback (Emetteur : access Gtk_Button_Record'Class);
Package P is new Gtk.Handlers.Callback (Gtk_Button_Record);
Use P;
end Test;
File.adb
Package body Test is
Procedure Initialise_Conteneur (Object : T_Test) is
begin
Gtk_New (Object.Conteneur);
end Initialise_Conteneur;
Procedure Le_Callback (Emetteur : access Gtk_Button_Record'Classs) is
V : T_Test;
begin
Initialise_Conteneur (Object => V);
Gtk_New (V.L_Entree);
V.Conteneur.Add (V.L_Entree);
V.L_Entree.Show;
end Le_Callback;
end Test;
Main.adb
Procedure Main is
Win : Gtk_Window;
Button : Gtk_Button;
Posix : T_Test;
begin
Init;
Initialize (object => Posix);
1
Gtk_New (Win);
Win.Set_Default_Size (600,400);
Gtk_New (Button,"Bouton");
Test.P.Connect (Widget => Button,
Name => Signal_Clicked,
Marsh => P.To_Marshaller (Le_Test'Access),
After => true);
Posix.Conteneur.Add (Button);
Win.Add (Posix.Conteneur);
Win.Show_All;
Main;
end Main;
Revised answer.
Slightly hacked package ... to export the Initialize method called in Main. (I'm also adding a Button instead of an Entry to make my life simpler)
Several issues in the package body...
(junk text to fix markup issue)
And the main program (connecting Le_Callback, not the nonexistent Le_Test)...
and my GPR file for it.
Now it builds (in future, PLEASE make the example code buildable! would have saved a good chunk of time) and I get to see a button...
Press the button and the second button appears below it, so we know the handler is connected to the button, and receiving button press messages.