[gtkada] simple.adb (again)

Vinicius F Arcaro varcaro at terra.com.br
Wed Jan 3 09:42:44 CET 2001


I read this on the documentation. However, in another example
(SCRIBBLE.ADB) the callback packages are not instantiated on separate
packages.

As a beginner studying this example, I became conscious that it is very
difficult to realize to what packages the GTK procedures belongs. I
would like to suggest avoiding the USE clause, at least in the small
examples like this.

Considering this example, it seems that some instructions should be
removed. Are the instructions marked with # necessary?

procedure Configure_Event (Drawing_Area : access
Gtk_Drawing_Area_Record'Class) is

  Win    : GDK_Window;
  Width  : Gint;
  Height : Gint;
  Sty    : Gtk.Style.Gtk_Style := Get_Style(Drawing_Area); #1
  Gc     : Gdk_GC;                                         #2

begin
  GC:= Gtk.Style.Get_White_Gc(Sty);                        #3

  Win:=Get_Window(Drawing_Area);

  Get_Size(Win, Width, Height);

  GDK.Pixmap.Gdk_New(Pixmap, Win, Width, Height, -1);

  Draw_Rectangle(Pixmap, Get_White(Get_Style(Drawing_Area)),True, 0, 0,
Width, Height);
end Configure_Event;

Thank you,
Vinicius

Joel Brobecker wrote:

> This is documented in the GtkAda Users Guide:
> << WARNING: all the generic packages allocate some memory for internal
> structures, and call internal functions. This memory is freed by gtk
> itself, by calling some Ada functions. Therefore the generic packages
> have to be instanciated at library level, not inside a subprogram, so
> that the functions are still defined when gtk needs to free the memory
> >>
> 
> In this very simple case, I suspect that it will work because the
> Handlers package will always be defined. However, this is a specific
> case which we did not want to detail, to avoid unnecessary confusion.




More information about the gtkada mailing list