[gtkada] simple.adb (again)
Vinicius F Arcaro
varcaro at terra.com.br
Tue Jan 2 23:24:32 CET 2001
Dear list member,
On a previous message about the simple.adb procedure Joel Brobecker
wrote:
> Remember that callback packages must be instantiated at library
> level, so in this example, you'll have to create a separate package
> (simple is just a procedure).
What does it means to instantiate at library level? Why do I need a
separate package? What is wrong with the following version of
simple.adb?
Thank you,
Vinicius
with
Gtk.Window,
Gtk.Widget,
Gtk.Handlers,
Gtk.Main;
procedure Test00 is
Window : Gtk.Window.Gtk_Window;
-- Callback
procedure Destroy (Widget : access
Gtk.Widget.Gtk_Widget_Record'Class) is
begin
Gtk.Main.Main_Quit;
end Destroy;
package Handlers is new Gtk.Handlers.Callback
(Gtk.Widget.Gtk_Widget_Record);
begin
-- This is called in all GtkAda applications. Arguments are parsed
-- from the command line and are returned to the application.
Gtk.Main.Init;
-- Create a new window.
Gtk.Window.Gtk_New (Window);
-- Change the title of the window.
Gtk.Window.Set_Title (Window,"Test00");
-- Specify a minimal size for the window.
Gtk.Window.Set_Default_Size (Window,300,200);
-- Connect the "destroy" event to a signal handler.
-- This event occurs when we call Gtk.Widget.Destroy on the window.
Handlers.Connect (Window, "destroy", Handlers.To_Marshaller
(Destroy'Access));
-- Display the newly created window.
Gtk.Window.Show (Window);
-- All GtkAda applications must have a Main. Control ends here
-- and waits for an event to occur (like a key press or
-- mouse event).
Gtk.Main.Main;
end Test00;
More information about the gtkada
mailing list