Re: Open a window on top of another

On Wed, 22 Aug 2001 09:01:00 +0200, Fabio Rotondo said:

  I'd like to know what is the fastest method to open a window centered 
 on top  of another.
 I have some "quick" dialogs that popup on my app window, but at the 
 moment they appear
 randomly on the screen, while I'd like them to be centered on the parent 
 window. Any hint?

Hello Fabio,

   M'kay, I asked this question a while ago but unfortunatly
the answer at the time is that GTK+ 1.x really dosen't have
a viable solution to this. I can get into the details
but it can't be done (atleast that is what I was told).

However there is a workaround but it only works under the
following conditions.

Your dialog's toplevel window size must remain at a constant
size, meaning you need to have gtk_widget_set_usize() on it
before you realize it and the size must be positive.

Once you have that you can then set the dialog as modal and be
a transient for your main toplevel window.

Then use gtk_widget_set_uposition to set the position of
the dialog just before you map it.

Now to find the coordinates and size of your main toplevel

Get the GdkWindow from your toplevel window GtkWidget,
then use gdk_window_get_geometry() on the GdkWindow. Now
you have the size and position of yer main toplevel window
plus you know the size of your constant dialog toplevel.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]