Size requisition changes
- From: Owen Taylor <otaylor redhat com>
- To: gtk-devel-list redhat com
- Subject: Size requisition changes
- Date: 09 Feb 1999 21:30:44 -0500
I'm about to check in a fairly substantial change to
the way gtk_widget_size_request works. (More substantial
than I'd really like.)
The problem:
Currently, widget->requisition is used for two
different and incompatible things. Widgets generally
assume that it is the size they asked for, and use
it, for instance, to center themselves in their
requisition. On the other hand, container widgets
assume that it is the size the widget asked for
_modified_by_gtk_widget_set_usize_.
It currently is the latter, which means that setting
the usize on some widgets doesn't work correctly.
An example of this is the Box widgets. The box
widgets figure out how much extra size is available
by taking widget->allocation - widget->requisition.
The solution:
What we decided on for a fix was that widget->requisition
is always the first thing. (The unmodified requisition)
gtk_widget_size_request (widget, requisition) now calls
the widget->klass->size_request (widget, &widget->requisition)
then copies widget->requisition back to *requisition,
and modifies *requistion according to the usize.
In practice, what this means is that the old
idiom of calling gtk_widget_size_request (widget, &widget->requisition),
is now discouraged, since doing that defeats the
change, and will continue to trigger the old usize
bugs. You should instead do:
GtkRequisition child_requisition;
gtk_widget_size_request (widget, &child_requisition);
There is a warning now in GTK+, only printed if GTK+
is compiled with --enable-debug, that occurs when
gtk_widget_size_request is called with
requisition == widget->requisition.
Also, a container should not access its child's
requisition with child->requisition, but instead should
call:
void gtk_widget_get_child_requisition (GtkWidget *widget,
GtkRequisition *requisition);
If your code is affected by these changes (there are
about 4 places in GNOME that will print out warnings),
you should probably not change it immediately, but
wait for the next release of GTK+, and then call
AM_PATH_GTK () with a version of 1.1.16, since the
necesarry changes will not be compatible with older
versions of GTK+.
I apologize for any inconvience this causes (it shouldn't
really be much - I'll do the GNOME changes myself),
but I think this change is necesary and the
right thing to do.
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]