[gtkada] Handle signals inside a tagged record

Martin Klaiber martinkl at zedat.fu-berlin.de
Sat Feb 15 22:25:10 CET 2003


Hi,

I have problems to handle signals within a tagged record. All examples
call external functions, but with them I don't have access to functions
inside of an object. Here is an example of what I mean:

  type Example_Record is new Gtk_Window_Record with
    record
      Entry1, Entry2 : Gtk_GEntry;
    end record;

  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 (Example : access Example_Record'Class);

-- Body

  procedure Initialize (Example : access Example_Record'Class) is
    ...
    Ok_Button : Gtk_Button;
  begin
    ...
    Gtk_New (Ok_Button, "Update");
    <Handler, see below>
  end Initialize;

  procedure Update (Example : access Example_Record'Class) is
  begin
    A_Variable_Somewhere := Integer'Value (Get_Text (Entry1));
    Another_Variable := Integer'Value (Get_Text (Entry2));
  end Update;

What I want is, when the button is pressed, Update shall be called.
But how can I do that? In most of the examples coming with GtkAda, I
find handlers like that:

  Handlers.Connect (Ok_Button, "clicked", Handlers.To_Marshaller (Button_Ok'Access));
  
which would call an external (not part of the tagged record) procedure
Button_Ok. Well this works fine here too, but from such an external
procedure, I have no access to internal fields of the tagged record.

Is there any way to handle such events within the tagged record? I
couldn't manage yet, but I am only a beginner in GtkAda.

Thanks,
Martin



More information about the gtkada mailing list