Re: Problems with Gtk::Expander



Jonathon Jongsma wrote:
On 12/1/06, Jef Driesen <jefdriesen hotmail com> wrote:
I have created a toplevel window like this:

<window>
   <vbox>
     <expander>
       <treeview>
     <table>
       <label><entry>
       <label><entry>
       ...

The glade file is available on my website [1].

The labels and entries in the table have a fixed height. Thus, resizing
the window should change the size of the treeview (if it's not hidden by
the expander of course). But it doesn' work the way I want it.

The window starts with the expander collapsed. When I use the arrow to
expand it, the arrow changes its state, but the treeview remains
invisible. See screenshot [2]. Only when I enlarge the toplevel window,
I can make the treeview visible. It seems like the initial height of the
treeview is zero? If I replace the treeview with another widget like a
button, it is shown instantly (e.g. without enlarging the toplevel window).

This is probably because the treeview doesn't specify a minimum size /
size request, whereas a button does.  If you set a minimum size, it'll
probably expand the window when you expand the expander.

Setting the size request does fix this problem.

Now, if I collapse again, the treeview disappears like it should, but
the space where it used to be remains empty. See screenshot [3]. And
that's not certainly not what I wanted. This empty space should be gone
and the toplevel window should shrink. How can I do that?

I think this is a pretty common issue with GTK apps.  I think the
general solution is: avoid designing your UI so that the top-level
window can change size based on user interaction.  However, there are
a couple of things you can do.  One is to connect to the expander
activation signal, and resize your window manually (note: I think if
you set the height to some small value like 1 then GTK will try to
make it as small as it can while still showing all widgets, but then
the user will lose any resizing they did before they collapsed the
window).  Another option is to make your window non-resizeable, and
then GTK+ will automatically shrink the size when you collapse the
expander.  Of course the disadavantage of this is that your window is
... non-resizeable.

Making the toplevel window non-resizeable is not really an option. My toplevel window is a master-detail view. The master view consist of a treeview, which is rather annoying non-resizable. Maybe I can make only the detail view (which contains the expander to maximize space for the master view) non-resizable.

Maybe I can calculate the actual height of my treeview and reduce only the height of the toplevel window with that amount.

The gtk 'save as' dialog has an expander which behaves as I want, so it must be possible somehow.




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