GtkWindow resizing problems



Dear list,

I am using gtk 1.2 and have a window that has four widgets packed in a 
vertical vbox:
* a logo    (packed with false/false)
* a notebook    (packed with true/true)
* statusbar1    (packed with false/false)
* statusbar2+button    (packed with false/false)

Next to statusbar2 is a little button that, if clicked, either hides the 
notebook and the logo (leaving only the two statusbars), or shows all widgets 
again.

My problem is that I can't set the main window to the same size that it had 
before the logo+notebook were hidden.

Strangely, it always works perfectly for the first time, but never for the 
second time and all following times. Those times the window is smaller than I 
want it to be.

Here's the snippet of code that I use:

static void
notebook_mini_button_clicked (GtkWidget *widget, gpointer data)
{
        static gint width, height, xpos, ypos;

        if (GTK_WIDGET_VISIBLE(notebook))
        {
                gdk_window_get_size (window->window, &width, &height);
                gdk_window_get_position (window->window, &xpos, &ypos);
                gtk_widget_hide(notebook);
                gtk_widget_hide(logo);
                gtk_widget_set_usize(GTK_WIDGET(window), width, 0);
                gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, TRUE);
        } else {
                gtk_window_set_policy(GTK_WINDOW(window), FALSE, TRUE, FALSE);
                gtk_widget_show(notebook);
                gtk_widget_show(logo);
                gtk_window_set_default_size (GTK_WINDOW(window), width, height);
                gdk_window_move_resize (window->window, xpos, ypos, width, height);
                gtk_widget_set_usize(GTK_WIDGET(window), 640,400);
        }
}

Note: I want the main window to be user-resizable after blowing it up to its 
previous size again (if I set minimum size = previous size it works of 
course, but I don't really want that).

I have tried a lot of different combinations of the above, but just can't get 
it to work.

If anyone has any ideas, they would be much appreciated :-)

Many thanks in advance.
Cheers
-Tim





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