i created two buttons a that display a Gtk_Radio_Button and a button that display a GtK_label but when i click on buttons nothing happens. I don't understand why it doesn't work yet the code compiles and runs without finding any error.
main_Program.adb
With Gtk.Window; Use Gtk.Window;
With Gtk.Button; Use Gtk.Button;
With Gtk.Grid; Use Gtk.Grid;
With file; Use file;
Procedure main_program is
Bouton : Gtk_Button;
Bouton2 : Gtk_Button;
Win : Gtk_Window;
Test : Test_Record;
begin
Gtk.Main.Init;
Init_Grid (Container => Test);
Gtk_New (Win);
Win.Add (Test.Grid);
Win.Set_Default_Size (Width => 600,
Height => 400);
Gtk_New (Bouton,Label => "Bouton");
Test.Grid.Attach (Bouton,0,0);
P.Connect (Widget => Bouton,
Name => Signal_Clicked,
Marsh => Test2.P.To_Marshaller (Init_Button'Access),
After => False);
Gtk_New (Bouton2,Label => "Bouton2");
Test.Grid.Attach (Bouton2,50,4);
P.Connect (Widget => Bouton2,
Name => Signal_Clicked,
Marsh => Test2.P.To_Marshaller (Init_Text'Access),
After => False);
Win.Show_All;
Main;
end Main_Program;
file.ads
With Gtk.Label; Use Gtk.Label;
With Gtk.Radio_Button; Use Gtk.Radio_Button;
With Gtk.Grid; Use Gtk.Grid;
With Gtk.Handlers;
Package file is
type Test_Record is record
Text : Gtk_Label;
Grid : Gtk_Grid;
Button_Radio : Gtk_Radio_Button;
end record;
Procedure Init_Text ( Self : access Gtk_Widget_Record'Class );
-- Callback for create the text
Procedure Init_Button (Self : access Gtk_Widget_Record'Class );
-- Callback for Initialize the Radio Button;
Procedure Init_Grid (Container : out Test_Record);
-- Initialize the Gtk.Grid.Gtk_Grid
Package P is new Gtk.Handlers.Callback (Gtk_Widget_Record);
Use P;
end file;
file.adb
With file; Use file;
Package body file is
Procedure Init_Grid ( Container : out Test_Record ) is
begin
Gtk_New (Container.Grid);
end Init_Grid;
Procedure Init_Button ( Self : access Gtk_Widget_Record'Class ) is
V : Test_Record;
begin
Init_Grid (Container => V);
Gtk_New (V.Button_Radio,
Group => null,
Label => "Button Radio");
V.Grid.Attach (V.Button_Radio,0,50);
V.Grid.Show;
end Init_Button;
Procedure Init_Text (Self : access Gtk_Widget_Record'Class) is
V : Test_Record;
begin
Init_Grid (Container => V);
Gtk_New (V.Text);
V.Text.Set_Label ("Hello,World");
V.Grid.Attach (V.Text,150,0);
V.Grid.Show;
end Init_Text;
end file;
I want that when I click on the first button it shows me a radio button and when I click on the second button it shows me a label.