[gtkada] Handle signals inside a tagged record
Ludovic Brenta
ludovic.brenta at insalien.org
Wed Feb 19 23:14:40 CET 2003
Martin,
The problem was a discrepancy between your instantiation of
Gtk.Handlers.User_Callback, and the actual signature of your callback.
You were saying:
package Example_Handler is
new Gtk.Handlers.User_User_Callback
(Gtk_Button_Record, Example_Record);
...
procedure Update (Button : access Gtk_Button_Record'Class;
Example : access Example_Record'Class) is
...
end Update;
As you can see, an Example_Record is not the same thing as an access
Example_Record'Class.
I've attached a patch which makes your code compile; since I suppose you
still want your user data to be an access (as opposed to a record), I've
used Example_Access as the type in the instantiation. Note: now it
compiles, but I haven't tried to run it.
--
Ludovic Brenta.
-------------- next part --------------
--- the_example.ads 2003/02/19 22:04:30 1.1
+++ the_example.ads 2003/02/19 22:06:00
@@ -9,9 +9,9 @@
type Example_Access is access all Example_Record'Class;
procedure Gtk_New (Example : out Example_Access);
- procedure Initialize (Example : access Example_Record'Class);
- procedure Update (Button : access Gtk_Button_Record'Class;
- Example : access Example_Record'Class);
+ procedure Initialize (Example : Example_Access);
+ procedure Update (Button : access Gtk_Button_Record'Class;
+ Example : Example_Access);
private
--- the_example.adb 2003/02/19 21:51:47 1.1
+++ the_example.adb 2003/02/19 22:03:38
@@ -5,7 +5,7 @@
package body The_Example is
package Example_Handler is
- new Gtk.Handlers.User_Callback (Gtk_Button_Record, Example_Record);
+ new Gtk.Handlers.User_Callback (Gtk_Button_Record, Example_Access);
procedure Gtk_New (Example : out Example_Access) is
begin
@@ -13,7 +13,7 @@
Initialize (Example);
end Gtk_New;
- procedure Initialize (Example : access Example_Record'Class) is
+ procedure Initialize (Example : Example_Access) is
Win : Gtk_Window;
VBox : Gtk_Box;
Ok_Button : Gtk_Button;
@@ -29,16 +29,16 @@
Gtk_New (Ok_Button, "Update");
Pack_Start (VBox, Ok_Button, False, False);
- Example_Handler.Connect (
- Ok_Button, "clicked",
- Example_Handler.To_Marshaller (Update'Access),
- Update (Ok_Button, Example));
+ Example_Handler.Connect (Ok_Button,
+ "clicked",
+ Example_Handler.To_Marshaller (Update'Access),
+ Example);
Show_All (Win);
end Initialize;
procedure Update (Button : access Gtk_Button_Record'Class;
- Example : access Example_Record'Class) is
+ Example : Example_Access) is
begin
Put_Line (Get_Text (Example.Entry1));
end Update;
More information about the gtkada
mailing list