[gtkada] GTKAda and tasking ???

Per Sandberg per.sandberg at bredband.net
Mon Sep 6 22:46:59 CEST 2004


All,
I hav been playin with a  notebook and tasking, aperantly i am doing 
somthing fundamentally wrong since the program is ether crasching with 
program error
or Just hanging .
Running GtkAda-2.2.0 under windows.

/Per

-------------------------------------------------
with Gtk.Window; use Gtk.Window;
with Gtk.Notebook; use Gtk.Notebook;
package P1 is
   type Window_Record is new Gtk_Window_Record with record
      Notebook          : Gtk_Notebook;
   end record;
   type Window_Access is access all Window_Record'Class;
   procedure Append (Window  : access Window_Record;
                     Name    : in String;
                     Message : in String);
   procedure Gtk_New (Window : out Window_Access);
   procedure Initialize (Window : access Window_Record'Class);
end P1;
-----------------------------------------------------------
with Gtk; use Gtk;
with Gtk.Enums; use Gtk.Enums;
with Gtk.Label; use Gtk.Label;
with Gtk.Notebook; use Gtk.Notebook;
package body P1 is
   procedure Append (Window  : access Window_Record;
                     Name    : in String;
                     Message : in String) is
      Label : Gtk_Label;    Data  : Gtk_Label;
   begin
      Gtk_New (Data, Message);
      Gtk_New (Label, Name);
      Append_Page (Window.Notebook, Data, Label);
      Set_Tab_Label_Packing
        (Window.Notebook, Data, False, True, Pack_Start);
      Show_All (Window.Notebook);
   end Append;
   procedure Gtk_New (Window : out Window_Access) is
   begin
      Window := new Window_Record;
      P1.Initialize (Window);
   end Gtk_New;
   procedure Initialize (Window : access Window_Record'Class) is
   begin
      Gtk.Window.Initialize (Window, Window_Toplevel);
      Set_Title (Window, "Test");
      Gtk_New (Window.Notebook);
      Add (Window, Window.Notebook);
      Append (Window, "fix", "fool");  --- << These works fine
      Append (Window, "fix", "fool");
      Append (Window, "fix", "fool");
      Append (Window, "fix", "fool");
      Append (Window, "fix", "fool");
   end Initialize;
end P1;
-------------------------------------------------
with Gtk; use Gtk;
with Gtk; use Gtk;
with Gtk.Main;
with Gdk.Threads;
with P1; use P1;
procedure Main is
   Window : Window_Access;
   task Pump_Type is  end Pump_Type;
   task body Pump_Type  is
   begin    delay 5.0;
      for I in 1 .. 10 loop
         Append (Window, "pump", "data");          delay 0.5; --<< By By 
for ever
      end loop;
   end Pump_Type;
begin
   Gdk.Threads.G_Init;   Gdk.Threads.Init;
   Gtk.Main.Init;
   Gtk_New (Window);    Show_All (Window);
   Gdk.Threads.Enter;    Gtk.Main.Main;    Gdk.Threads.Leave;
end Main;
-------------------------------------------------



More information about the gtkada mailing list