Re: is there a way to change the starting position of the window



On 11/11/05, Yiannis <odysseus lost gmail com> wrote:
is there a way to change the position of the window when starting up?
In particular:
1. Is it possible to change it to a relative position... for example
the top right corner? I am using glade to create the interface and
libglade to load it....
2. Is it possible to "save" the positions of the windows and use them
in the next startup.

On window popdown I read out the final position and size with:

        iimage->window_width = GTK_WIDGET( iv )->allocation.width;
        iimage->window_height = GTK_WIDGET( iv )->allocation.height;
        gdk_window_get_root_origin(
                gtk_widget_get_toplevel( GTK_WIDGET( iv ) )->window,
                &iimage->window_x, &iimage->window_y );

And on the next create, I restore the old position and size with:

                GdkScreen *screen = gtk_widget_get_screen( GTK_WIDGET( iv ) );

                /* We need to clip x/y against the desktop size.
                 */
                int window_x = IM_CLIP( 0, iimage->window_x,
                        gdk_screen_get_width( screen ) - iimage->window_width );
                int window_y = IM_CLIP( 0, iimage->window_y,
                        gdk_screen_get_height( screen ) -
iimage->window_height );

                gtk_widget_set_uposition( GTK_WIDGET( iv ),
                        window_x, window_y );

                gtk_window_set_default_size( GTK_WINDOW( iv ),
                        IM_MIN( iimage->window_width,
                                gdk_screen_get_width( screen ) ),
                        IM_MIN( iimage->window_height,
                                gdk_screen_get_height( screen ) ) );

Seems to work OK on windows and linux. It breaks a bit with maximised
windows on win32 :-( but only slightly.

John



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