I am utilizing a Gtk.Offscreen_Window to investigate the heights of various off-screen widgets in order to figure out where to place them on-screen based on their height. I managed to accomplish this with the following pseudo code.
procedure My_Proc
is
use Gtk.Offscreen_Window;
use Gtk.Box;
Offscreen : Gtk_Offscreen_Window := Gtk_Offscreen_Window_New;
Box : Gtk_Box := Gtk_Box_New ( Orientation_Vertical );
begin
Offscreen.Set_Default_Geometry ( 1000, 1000 );
Offscreen.Add ( Box );
Offscreen.Show_All;
Ada.Text_IO.Put_Line( Glib.Gint'Image ( Box.Get_Allocated_Height ));
end My_Proc;
This code will correctly tell me the height of Box. Note that my original code is a bit more complex than this but I've simplified it for the sake of this posting.
The problem here has to do with Offscreen.Show_All procedure. I know that this is not correct practice with an Offscreen widget since it cannot be shown like a normal Window. This is further emphasized by a warning that shows up on the console when this code is executed:
(main:26724): Gdk-WARNING **: /build/buildd/gtk+3.0-3.10.8/./gdk/x11/gdkwindow-x11.c:5531 drawable is not a native X11 window
Without including the Show_All function the size calculations will be incorrect (returns 1), so the Show_All function seems to be doing something important albeit a little too much. I believe the solution is as simple as finding out what runs the allocation calculations within the Show_All function and running that directly. Unfortunately I don't know what that function is.
So the bottom line is: How do I correctly instruct the Offscreen_Window widget to perform its sizing calculations without using the Show_All function?
Thank you.
I am using Ada 2012, GtkAda (latest since mid 2015), Linux Kubuntu 14.04 but also expect this to run in Windows 7/8.
I've recently learned that using the Gtk.Widget.Size_Request function was more correct for my situation than using Gtk.Widget.Get_Allocated_Height to find out the height of my newly spawned widget. Using this eliminates the erroneous use of Gtk.Widget.Show_All all together.
Thank you again for all your help.