Re: gtk and window size



Matt Eisemann <meisemann dsrnet com> writes:

> Currently I am building an application which has many nested vetical and 
> horizontal boxes and I am trying to figure out if a parent box overrides 
> the parameters set by a child box.  It looks like it does if you want a 
> parent box to be nonhomogeneous and a child to be homogenious and visa 
> versa.  My actual question is in regard to a CLIST.  In my application I 
> have a CLIST in a scrolled window.  How do you set the default size of a 
> scrolled window so that a user can adjust its size?  If one uses 
> gtk_widget_set_usize it will set the size correctly but it seems to be 
> static and unmovable by the user and it prevents the user from being able 
> to expand the size of the scrolled window and hence the CLIST.  The 
> function I was thinking of using was gtk_window_set_default_size but I get 
> some strange error messages
> 
> Gtk-CRITICAL ** file gtkwindow.c: line 809 (gtk_window_set_default_size): 
> assertion 'GTK_IS_WINDOW (window)' failed.
> 
> The code for my window where I put my CLIST is.
> 
> scrolled_win = gtk_scrolled_window_new(NULL,NULL)
> gtk_window_set_default_size(scrolled_win,400,400);

GtkScrolledWindow does not derive from GtkWindow. 

> gtk_container_add(GTK_CONTAINER(scrolled_win),display_tasks);
> 
> where display_tasks should be the CLIST.
> 
> Any ideas?  Let me know if you need more code or a better explanation of 
> something.  Thanks ahead of time for your help.

Each individual widget in GTK+ only has a minimum size. If you want to set
default or maximum sizes, you need to set them on the toplevel window.

To make computing the correct size simple in the case when you have
a window with only one adjustable-size widget, GTK+ introduces the
concept of the 'geometry widget' - that is, the widget that the 
geometry parameters set on the toplevel apply to.

So, you should be able to get your desired effect with:

 gtk_window_set_geometry_hints (toplevel, scrolled_win, NULL, 0); 
 gtk_window_set_default_size (toplevel, 400, 400);

Regards,
                                        Owen




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