[gtkada] display a window without giving the hand to the user

Stefan Bellon sbellon at sbellon.de
Mon Oct 22 09:01:45 CEST 2007


Thomas De Contes wrote:

> well, it doesn't works with Window_Popup, i need to use a  
> Window_Toplevel

I can't deduce this from your desciption of what you need.

> and i don't know how to use Glib.Main.Timeout_Add at all, i never  
> used it

bellonsn at cube$ cat splashdemo.adb
with Glib.Main;
with Gtk.Enums;
with Gtk.Main;
with Gtk.Window;

procedure Splashdemo is

   Window : Gtk.Window.Gtk_Window;
   Dummy  : Glib.Main.G_Source_Id;

   function Destroy
     return Boolean
   is
      use type Gtk.Window.Gtk_Window;
   begin
      Gtk.Window.Destroy (Window);
      Gtk.Main.Main_Quit;
      return False;
   end Destroy;

begin
   Gtk.Main.Init;
   Gtk.Window.Gtk_New (Window, Gtk.Enums.Window_Popup);
   Gtk.Window.Set_Size_Request (Window, 640, 480);
   Gtk.Window.Set_Position (Window, Gtk.Enums.Win_Pos_Center);
   Gtk.Window.Show_All (Window);
   Dummy:= Glib.Main.Timeout_Add (2000, Destroy'Unrestricted_Access);
   Gtk.Main.Main;
end Splashdemo;

Size of window and duration of display is hardcoded with the integer
literals. The non-standard 'Unrestricted_Access is necessary in this
example because Destroy in this case is a nested function, if you put
the whole thing in an own package, then you can make both at the same
level and use 'Access.

I hope this helps.

Greetings,
Stefan

-- 
Stefan Bellon



More information about the gtkada mailing list