[gtkada] Addressing Widgets from Timeout_Callback

Rick Duley 30294025 at student.murdoch.edu.au
Wed Jul 13 03:37:22 CEST 2005


Hi folks

I devised this Timeout_Callback Function to receive permission to proceed from
the protected type and to carry out an action in the GUI.

   function Free_Execute_Button
     (Window : Analyse60_Window_Access)
      return Boolean
   is
      Permitted : Boolean;
   begin  -- Free_Execute_Button
      Gdk.Threads.Enter;

      -- Check the protected type for process completion.
      Window.Signal_Box.Job_Completed(Confirmed => Permitted);

      -- Here I can do something in the Window, for example:
      if Permitted
      then
         Gtk.GEntry.Set_Text
           (The_Entry => Window.Analyse60_Processing_File_Entry,
            Text      => "Some text");
      end if;  -- Permitted

      Gdk.Threads.Leave;
      return Permitted;
   end Free_Execute_Button;

In the GUI task I include the command

   Analyse60_Window_Pkg.Free_Execute_Button_Timeout_Handler_ID :=
     Gtk.Main.Timeout_Add
       (Interval => 5_000,
        Func     => Analyse60_Window_Pkg.Free_Execute_Button'Access);

and get the compiler error message

   "expected type "Timeout_Callback" defined at gtk-main.ads:294
    found type access to "Free_Execute_Button" defined at line 72
    ==> in call to "Timeout_Add" at gtk-main.ads:299"

Now,
that is to be expected because I have included the Parameter "Window" in the
declaration of Free_Execute_Button so it does not conform to the type
definition:

     "type Timeout_Callback is access function return Boolean;"

in the package Gtk.Main.  My problem is that, without the parameter "Window" I
(1) cannot see the protected type "Signal_Box" and (2) cannot see the widget in
the Window on which I might wish to perform an operation!

Question:

How does a Timeout_Callback access these widgets?

Alternatively:

Have I missed something?  Type Init_Function doesn't seem to be any use here
(even though it accesses a procedure with a parameter) because it is registered
with Init_Add which is called only once, not repetitively as in a
Timeout_Callback.


Thanks
-------------------------------------------
"Professional qualitative judgement
   consists in knowing the rules
     for using (or occasionally breaking)
       the rules."
                            D. Royce Sadler
-------------------------------------------
Rick Duley
Murdoch University
School of Engineering Science
Perth, Western Australia
http://eng.murdoch.edu.au/~rick
aussie : 040 910 6049                .-_|\
o'seas : + 61 40 910 6049           /     \
                              perth *_.-._/
                                         v






More information about the gtkada mailing list