Re: Need to restore a window to last size/position on restart



On Mon, Jan 15, 2007 at 09:29:56AM -0800, Russell Markus wrote:
I need to be able to restore the size and position of a dialog whenever the
application starts.  I am using the function calls:
      gtk_window_get_size(GTK_WINDOW(dialog1), &w, &h) and
gtk_window_get_position(GTK_WINDOW), &x, &y)

However, no matter what I do to the window, resize or move, these two
functions always return the same values.  I get 0, 0 for the x and y
position and 448, 196 for the width and height.  Can someone point me to the
correct functions to be using?

These are the correct functions.  I have no idea why they do
not work for you.  Post some code...

Also, which functions to use to set the
location and size.

See gtk_window_get_position() docs on why this sometimes
does not work as expected.

Use gtk_window_set_default_size() to set the default size.

Use gtk_window_move() to move the window.  Call it twice:
once when it's not shown yet, second time immediately after
showing it (this works reasonably across window managers).

Ensure the values you are saving are not bogus (e.g. when
the window is minimized) and you are not restoring it
bigger than the screen, offscreen...

Yeti


--
Whatever.



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