[gtkada] Gtk & Genericity
Frederic Gobry
frederic.gobry at epfl.ch
Wed Aug 16 09:14:35 CEST 2000
Hi,
For teaching purposes, I try to build some generic packages for
manipulating generic data structures from a Gtk interface. My idea is
to have a generic package, let's call it Relations, which has a child
unit Relations.Edition containing primitives for UI manipulation. I
only want to provide simple high level functions in it, like Display
and Edit, and hide all the internal methods needed for Gtk (esp.
callbacks).
But I can't compile the enclosed code, due to genericity problems. Is
there a workaround for that ?
> gnatmake test_gen.adb `gtkada-config`
gcc -c -I/opt/gnat/include/gtkada test_gen.adb
simple_gen.adb:12:04: instantiation error at gtk-marshallers.ads:359
simple_gen.adb:12:04: instantiation error at gtk-handlers.ads:437
simple_gen.adb:12:04: parent type must not be outside generic body
Thanks for your help...
Frédéric
--
Frédéric GOBRY
EPFL
Research Assistant CH 1015 - Lausanne
GRIP - LITH Tel: +41 21 693 66 92
-------------- next part --------------
with Gtk; use Gtk;
with Gtk.Main; use Gtk.Main;
with Gtk.Widget; use Gtk.Widget;
with Gtk.Window; use Gtk.Window;
with Ada.Text_Io; use Ada.Text_Io;
with Gdk.Event; use Gdk.Event;
with Gtk.Button; use Gtk.Button;
with Gtk.Handlers; use Gtk.Handlers;
package body Simple_Gen is
package Button_Callback is new
Gtk.Handlers.Callback
(Widget_Type => Gtk_Button_Record);
procedure Close_Window (Button : access Gtk_Button_Record'Class) is
begin
Destroy(Get_Toplevel (Button));
Gtk.Main.Main_Quit;
end Close_window;
procedure Display(Text : String) is
Window : Gtk_Window;
Button : Gtk_Button;
begin
Gtk.Main.Init;
Gtk_New (Window);
Gtk_New (Button,"test");
Add (Window, Button);
Button_Callback.Connect (Button, "clicked",
Button_Callback.To_Marshaller (Close_Window'Access));
Set_Usize(Window,50,50);
Set_Title(Window,Text);
Show_all(Window);
Gtk.Main.Main;
end Display;
end Simple_gen;
-------------- next part --------------
generic
package Simple_gen is
procedure Display(Text : String);
end Simple_gen;
-------------- next part --------------
with Simple_Gen;
procedure Test_Gen is
package Gen is new Simple_Gen;
begin
Gen.Display ("hey !");
end;
More information about the gtkada
mailing list