[gtkada] Handle signals inside a tagged record
Martin Klaiber
martinkl at zedat.fu-berlin.de
Wed Feb 19 16:46:51 CET 2003
Preben Randhol <randhol at pvv.org> wrote:
> Martin Klaiber <martinkl at zedat.fu-berlin.de> wrote on 19/02/2003 (08:45) :
>> Is it possible on this Mailinglist that I attach an *.adb and
>> *.ads-file with the code and you try to compile it? They are
>> together only about 1.7kB.
> yes
Thanks a lot (also to Arno!). I added a small Makefile, but not the
code to call this object within a main program. To simply print out
the content of the GEntry-Object is, of course, only for testing.
Martin
-------------- next part --------------
all:
gnatmake the_example `gtkada-config`
devel:
gnatmake -gnataEfo the_example `gtkada-config`
-------------- next part --------------
with Gtk.Window; use Gtk.Window;
with Gtk.GEntry; use Gtk.GEntry;
with Gtk.Button; use Gtk.Button;
Package The_Example is
type Example_Record is new Gtk_Window_Record with private;
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);
private
type Example_Record is new Gtk_Window_Record with
record
Entry1 : Gtk_GEntry;
end record;
end The_Example;
-------------- next part --------------
with Ada.Text_IO; use Ada.Text_IO;
with Gtk.Box; use Gtk.Box;
with Gtk.Handlers;
Package Body The_Example is
package Example_Handler is
new Gtk.Handlers.User_Callback (Gtk_Button_Record, Example_Record);
procedure Gtk_New (Example : out Example_Access) is
begin
Example := new Example_Record;
Initialize (Example);
end Gtk_New;
procedure Initialize (Example : access Example_Record'Class) is
Win : Gtk_Window;
VBox : Gtk_Box;
Ok_Button : Gtk_Button;
begin
Gtk_New (Win);
Gtk_New_VBox (VBox, False);
Add (Win, VBox);
Gtk_New (Example.Entry1);
Pack_Start (VBox, Example.Entry1, True, True);
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));
Show_All (Win);
end Initialize;
procedure Update (Button : access Gtk_Button_Record'Class;
Example : access Example_Record'Class) is
begin
Put_Line (Get_Text (Example.Entry1));
end Update;
end The_Example;
More information about the gtkada
mailing list