Re: GTK 1.2.8: resize problem



The main window of my application has an initial size. If the user
activates a specific menu entry, the size of the main window is resized
to the initial size again. Unfortunately, this doesn't work. If the user
starts my application, resizes the main window with the mouse and
activates the menu item, nothing happen. It seems, that the main window
'thinks', that the size has not changed and therefore don't change the
size.

If you start the program, you get a window with a button on it. If you
press the button, the window is resized to a width of 200 and a height
of 100 (using the function gtk_widget_set_usize). Now, resize the window
with the mouse and press the button again. Surprisingly, the window is
NOT resized.

You probably should set the window policy to automatic, for example:

gtk_window_set_policy (GTK_WINDOW (window), FALSE, FALSE, TRUE);

Another thing, gtk_widget_set_usize sets the minimum size of the
window, so it cannot be used to decrease, only to increase.
Use functions like gdk_window_move_resize, for example.

You might also consider the gtk_window_set_default_size function.
I tried all of the above, but didn't get it to work. Would it be
possible for you to get the test program below to work (which means
if you press the button, resize the window with your mouse, press
the button again and get the main window be resized to a width of
200 and a height of 100)?
This would be a great help!

        Roland Scholz

Here is the test program:
#include <gtk/gtk.h>

void hello( GtkWidget *widget, GtkWidget *win)
{
    gtk_widget_set_usize(win, 200, 100);
}

void destroy( GtkWidget *widget,
              gpointer   data )
{
    gtk_main_quit();
}

int main( int   argc,
          char *argv[] )
{
    GtkWidget *window;
    GtkWidget *button;
    gtk_init(&argc, &argv);
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_signal_connect (GTK_OBJECT (window), "destroy",
                        GTK_SIGNAL_FUNC (destroy), NULL);
    gtk_main_quit();
}

int main( int   argc,
          char *argv[] )
{
    GtkWidget *window;
    GtkWidget *button;
    gtk_init(&argc, &argv);
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_signal_connect (GTK_OBJECT (window), "destroy",
                        GTK_SIGNAL_FUNC (destroy), NULL);
    gtk_container_set_border_width (GTK_CONTAINER (window), 10);
    button = gtk_button_new_with_label ("Hello World");
    gtk_signal_connect (GTK_OBJECT (button), "clicked",
                        GTK_SIGNAL_FUNC (hello), (gpointer)window);
    gtk_container_add (GTK_CONTAINER (window), button);
    gtk_widget_show (button);
    gtk_widget_show (window);
    gtk_main ();

    return(0);
}




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