diff options
author | Owen Taylor <otaylor@redhat.com> | 1999-02-10 02:35:09 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 1999-02-10 02:35:09 +0000 |
commit | d1bda8d56232ff0431796add4029e129f877fd6a (patch) | |
tree | 63c722c3ed4b8a886242bc78ae78dae1811c6b3a | |
parent | 84d9f5f9a13d52cd91bffc6230445d1e0ac73431 (diff) | |
download | gtk+-d1bda8d56232ff0431796add4029e129f877fd6a.tar.gz |
Fixed some bugs with set_default_size.
Sun Feb 7 19:49:21 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwindow.c (gtk_window_move_resize): Fixed some
bugs with set_default_size.
Sat Feb 6 13:23:51 1999 Owen Taylor <otaylor@redhat.com>
* docs/Changes-1.2.txt: Added information about
the change to gtk_widget_size_request().
* gtk/gtkentry.c: Call gtk_widget_get_child_requisition
explicitely since we differentiate between the usize
set by the user and what we got. (Ugh)
* gtk/gtkwidget.[ch] (gtk_widget_get_child_requisition):
New function to return the effective size of a widget
as it looks to its parent.
* gtk/gtkwidget.c (gtk_widget_size_request): Leave
widget->requisition set to exactly what the widget
asked for, and then make a copy of that into
the requisition argument. Allow a NULL requisition
argument, and, if G_ENABLE_DEBUG, warn if
requisition == &widget->requisition.
* gtkalignment.c gtkaspectframe.c gtkbutton.c gtkclist.c
gtkcontainer.c gtkentry.c gtkeventbox.c gtkfixed.c
gtkframe.c gtkhandlebox.c gtkhbox.c gtkhpaned.c
gtklayout.c gtklist.c gtklistitem.c gtkmenu.c
gtkmenubar.c gtkmenuitem.c gtknotebook.c
gtkoptionmenu.c gtkpacker.c gtkscrolledwindow.c
gtktable.c gtktoolbar.c gtktree.c gtktreeitem.c
gtkvbox.c gtkviewport.c gtkvpaned.c gtkwindow.c
Avoid calling gtk_widget_size_request with
requisition == widget->requisition; use
gtk_widget_get_child_requisition to get the
size of children.
44 files changed, 746 insertions, 221 deletions
@@ -1,3 +1,42 @@ +Sun Feb 7 19:49:21 1999 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwindow.c (gtk_window_move_resize): Fixed some + bugs with set_default_size. + +Sat Feb 6 13:23:51 1999 Owen Taylor <otaylor@redhat.com> + + * docs/Changes-1.2.txt: Added information about + the change to gtk_widget_size_request(). + + * gtk/gtkentry.c: Call gtk_widget_get_child_requisition + explicitely since we differentiate between the usize + set by the user and what we got. (Ugh) + + * gtk/gtkwidget.[ch] (gtk_widget_get_child_requisition): + New function to return the effective size of a widget + as it looks to its parent. + + * gtk/gtkwidget.c (gtk_widget_size_request): Leave + widget->requisition set to exactly what the widget + asked for, and then make a copy of that into + the requisition argument. Allow a NULL requisition + argument, and, if G_ENABLE_DEBUG, warn if + requisition == &widget->requisition. + + * gtkalignment.c gtkaspectframe.c gtkbutton.c gtkclist.c + gtkcontainer.c gtkentry.c gtkeventbox.c gtkfixed.c + gtkframe.c gtkhandlebox.c gtkhbox.c gtkhpaned.c + gtklayout.c gtklist.c gtklistitem.c gtkmenu.c + gtkmenubar.c gtkmenuitem.c gtknotebook.c + gtkoptionmenu.c gtkpacker.c gtkscrolledwindow.c + gtktable.c gtktoolbar.c gtktree.c gtktreeitem.c + gtkvbox.c gtkviewport.c gtkvpaned.c gtkwindow.c + + Avoid calling gtk_widget_size_request with + requisition == widget->requisition; use + gtk_widget_get_child_requisition to get the + size of children. + Tue Feb 9 19:49:46 1999 Owen Taylor <otaylor@redhat.com> * configure.in (LDFLAGS): Removed extraneous line @@ -59,6 +98,7 @@ Mon Feb 8 12:50:06 GMT 1999 Tony Gale <gale@gtk.org> * Makefile.am: update to include the latest Tutorial examples. +>>>>>>> 1.1009 Sat Feb 6 11:20:16 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c (gtk_widget_idle_draw): Add the diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index b7b63f0685..fb61ad7d33 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,42 @@ +Sun Feb 7 19:49:21 1999 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwindow.c (gtk_window_move_resize): Fixed some + bugs with set_default_size. + +Sat Feb 6 13:23:51 1999 Owen Taylor <otaylor@redhat.com> + + * docs/Changes-1.2.txt: Added information about + the change to gtk_widget_size_request(). + + * gtk/gtkentry.c: Call gtk_widget_get_child_requisition + explicitely since we differentiate between the usize + set by the user and what we got. (Ugh) + + * gtk/gtkwidget.[ch] (gtk_widget_get_child_requisition): + New function to return the effective size of a widget + as it looks to its parent. + + * gtk/gtkwidget.c (gtk_widget_size_request): Leave + widget->requisition set to exactly what the widget + asked for, and then make a copy of that into + the requisition argument. Allow a NULL requisition + argument, and, if G_ENABLE_DEBUG, warn if + requisition == &widget->requisition. + + * gtkalignment.c gtkaspectframe.c gtkbutton.c gtkclist.c + gtkcontainer.c gtkentry.c gtkeventbox.c gtkfixed.c + gtkframe.c gtkhandlebox.c gtkhbox.c gtkhpaned.c + gtklayout.c gtklist.c gtklistitem.c gtkmenu.c + gtkmenubar.c gtkmenuitem.c gtknotebook.c + gtkoptionmenu.c gtkpacker.c gtkscrolledwindow.c + gtktable.c gtktoolbar.c gtktree.c gtktreeitem.c + gtkvbox.c gtkviewport.c gtkvpaned.c gtkwindow.c + + Avoid calling gtk_widget_size_request with + requisition == widget->requisition; use + gtk_widget_get_child_requisition to get the + size of children. + Tue Feb 9 19:49:46 1999 Owen Taylor <otaylor@redhat.com> * configure.in (LDFLAGS): Removed extraneous line @@ -59,6 +98,7 @@ Mon Feb 8 12:50:06 GMT 1999 Tony Gale <gale@gtk.org> * Makefile.am: update to include the latest Tutorial examples. +>>>>>>> 1.1009 Sat Feb 6 11:20:16 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c (gtk_widget_idle_draw): Add the diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index b7b63f0685..fb61ad7d33 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,42 @@ +Sun Feb 7 19:49:21 1999 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwindow.c (gtk_window_move_resize): Fixed some + bugs with set_default_size. + +Sat Feb 6 13:23:51 1999 Owen Taylor <otaylor@redhat.com> + + * docs/Changes-1.2.txt: Added information about + the change to gtk_widget_size_request(). + + * gtk/gtkentry.c: Call gtk_widget_get_child_requisition + explicitely since we differentiate between the usize + set by the user and what we got. (Ugh) + + * gtk/gtkwidget.[ch] (gtk_widget_get_child_requisition): + New function to return the effective size of a widget + as it looks to its parent. + + * gtk/gtkwidget.c (gtk_widget_size_request): Leave + widget->requisition set to exactly what the widget + asked for, and then make a copy of that into + the requisition argument. Allow a NULL requisition + argument, and, if G_ENABLE_DEBUG, warn if + requisition == &widget->requisition. + + * gtkalignment.c gtkaspectframe.c gtkbutton.c gtkclist.c + gtkcontainer.c gtkentry.c gtkeventbox.c gtkfixed.c + gtkframe.c gtkhandlebox.c gtkhbox.c gtkhpaned.c + gtklayout.c gtklist.c gtklistitem.c gtkmenu.c + gtkmenubar.c gtkmenuitem.c gtknotebook.c + gtkoptionmenu.c gtkpacker.c gtkscrolledwindow.c + gtktable.c gtktoolbar.c gtktree.c gtktreeitem.c + gtkvbox.c gtkviewport.c gtkvpaned.c gtkwindow.c + + Avoid calling gtk_widget_size_request with + requisition == widget->requisition; use + gtk_widget_get_child_requisition to get the + size of children. + Tue Feb 9 19:49:46 1999 Owen Taylor <otaylor@redhat.com> * configure.in (LDFLAGS): Removed extraneous line @@ -59,6 +98,7 @@ Mon Feb 8 12:50:06 GMT 1999 Tony Gale <gale@gtk.org> * Makefile.am: update to include the latest Tutorial examples. +>>>>>>> 1.1009 Sat Feb 6 11:20:16 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c (gtk_widget_idle_draw): Add the diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index b7b63f0685..fb61ad7d33 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,42 @@ +Sun Feb 7 19:49:21 1999 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwindow.c (gtk_window_move_resize): Fixed some + bugs with set_default_size. + +Sat Feb 6 13:23:51 1999 Owen Taylor <otaylor@redhat.com> + + * docs/Changes-1.2.txt: Added information about + the change to gtk_widget_size_request(). + + * gtk/gtkentry.c: Call gtk_widget_get_child_requisition + explicitely since we differentiate between the usize + set by the user and what we got. (Ugh) + + * gtk/gtkwidget.[ch] (gtk_widget_get_child_requisition): + New function to return the effective size of a widget + as it looks to its parent. + + * gtk/gtkwidget.c (gtk_widget_size_request): Leave + widget->requisition set to exactly what the widget + asked for, and then make a copy of that into + the requisition argument. Allow a NULL requisition + argument, and, if G_ENABLE_DEBUG, warn if + requisition == &widget->requisition. + + * gtkalignment.c gtkaspectframe.c gtkbutton.c gtkclist.c + gtkcontainer.c gtkentry.c gtkeventbox.c gtkfixed.c + gtkframe.c gtkhandlebox.c gtkhbox.c gtkhpaned.c + gtklayout.c gtklist.c gtklistitem.c gtkmenu.c + gtkmenubar.c gtkmenuitem.c gtknotebook.c + gtkoptionmenu.c gtkpacker.c gtkscrolledwindow.c + gtktable.c gtktoolbar.c gtktree.c gtktreeitem.c + gtkvbox.c gtkviewport.c gtkvpaned.c gtkwindow.c + + Avoid calling gtk_widget_size_request with + requisition == widget->requisition; use + gtk_widget_get_child_requisition to get the + size of children. + Tue Feb 9 19:49:46 1999 Owen Taylor <otaylor@redhat.com> * configure.in (LDFLAGS): Removed extraneous line @@ -59,6 +98,7 @@ Mon Feb 8 12:50:06 GMT 1999 Tony Gale <gale@gtk.org> * Makefile.am: update to include the latest Tutorial examples. +>>>>>>> 1.1009 Sat Feb 6 11:20:16 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c (gtk_widget_idle_draw): Add the diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index b7b63f0685..fb61ad7d33 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,42 @@ +Sun Feb 7 19:49:21 1999 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwindow.c (gtk_window_move_resize): Fixed some + bugs with set_default_size. + +Sat Feb 6 13:23:51 1999 Owen Taylor <otaylor@redhat.com> + + * docs/Changes-1.2.txt: Added information about + the change to gtk_widget_size_request(). + + * gtk/gtkentry.c: Call gtk_widget_get_child_requisition + explicitely since we differentiate between the usize + set by the user and what we got. (Ugh) + + * gtk/gtkwidget.[ch] (gtk_widget_get_child_requisition): + New function to return the effective size of a widget + as it looks to its parent. + + * gtk/gtkwidget.c (gtk_widget_size_request): Leave + widget->requisition set to exactly what the widget + asked for, and then make a copy of that into + the requisition argument. Allow a NULL requisition + argument, and, if G_ENABLE_DEBUG, warn if + requisition == &widget->requisition. + + * gtkalignment.c gtkaspectframe.c gtkbutton.c gtkclist.c + gtkcontainer.c gtkentry.c gtkeventbox.c gtkfixed.c + gtkframe.c gtkhandlebox.c gtkhbox.c gtkhpaned.c + gtklayout.c gtklist.c gtklistitem.c gtkmenu.c + gtkmenubar.c gtkmenuitem.c gtknotebook.c + gtkoptionmenu.c gtkpacker.c gtkscrolledwindow.c + gtktable.c gtktoolbar.c gtktree.c gtktreeitem.c + gtkvbox.c gtkviewport.c gtkvpaned.c gtkwindow.c + + Avoid calling gtk_widget_size_request with + requisition == widget->requisition; use + gtk_widget_get_child_requisition to get the + size of children. + Tue Feb 9 19:49:46 1999 Owen Taylor <otaylor@redhat.com> * configure.in (LDFLAGS): Removed extraneous line @@ -59,6 +98,7 @@ Mon Feb 8 12:50:06 GMT 1999 Tony Gale <gale@gtk.org> * Makefile.am: update to include the latest Tutorial examples. +>>>>>>> 1.1009 Sat Feb 6 11:20:16 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c (gtk_widget_idle_draw): Add the diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index b7b63f0685..fb61ad7d33 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,42 @@ +Sun Feb 7 19:49:21 1999 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwindow.c (gtk_window_move_resize): Fixed some + bugs with set_default_size. + +Sat Feb 6 13:23:51 1999 Owen Taylor <otaylor@redhat.com> + + * docs/Changes-1.2.txt: Added information about + the change to gtk_widget_size_request(). + + * gtk/gtkentry.c: Call gtk_widget_get_child_requisition + explicitely since we differentiate between the usize + set by the user and what we got. (Ugh) + + * gtk/gtkwidget.[ch] (gtk_widget_get_child_requisition): + New function to return the effective size of a widget + as it looks to its parent. + + * gtk/gtkwidget.c (gtk_widget_size_request): Leave + widget->requisition set to exactly what the widget + asked for, and then make a copy of that into + the requisition argument. Allow a NULL requisition + argument, and, if G_ENABLE_DEBUG, warn if + requisition == &widget->requisition. + + * gtkalignment.c gtkaspectframe.c gtkbutton.c gtkclist.c + gtkcontainer.c gtkentry.c gtkeventbox.c gtkfixed.c + gtkframe.c gtkhandlebox.c gtkhbox.c gtkhpaned.c + gtklayout.c gtklist.c gtklistitem.c gtkmenu.c + gtkmenubar.c gtkmenuitem.c gtknotebook.c + gtkoptionmenu.c gtkpacker.c gtkscrolledwindow.c + gtktable.c gtktoolbar.c gtktree.c gtktreeitem.c + gtkvbox.c gtkviewport.c gtkvpaned.c gtkwindow.c + + Avoid calling gtk_widget_size_request with + requisition == widget->requisition; use + gtk_widget_get_child_requisition to get the + size of children. + Tue Feb 9 19:49:46 1999 Owen Taylor <otaylor@redhat.com> * configure.in (LDFLAGS): Removed extraneous line @@ -59,6 +98,7 @@ Mon Feb 8 12:50:06 GMT 1999 Tony Gale <gale@gtk.org> * Makefile.am: update to include the latest Tutorial examples. +>>>>>>> 1.1009 Sat Feb 6 11:20:16 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c (gtk_widget_idle_draw): Add the diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index b7b63f0685..fb61ad7d33 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,42 @@ +Sun Feb 7 19:49:21 1999 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwindow.c (gtk_window_move_resize): Fixed some + bugs with set_default_size. + +Sat Feb 6 13:23:51 1999 Owen Taylor <otaylor@redhat.com> + + * docs/Changes-1.2.txt: Added information about + the change to gtk_widget_size_request(). + + * gtk/gtkentry.c: Call gtk_widget_get_child_requisition + explicitely since we differentiate between the usize + set by the user and what we got. (Ugh) + + * gtk/gtkwidget.[ch] (gtk_widget_get_child_requisition): + New function to return the effective size of a widget + as it looks to its parent. + + * gtk/gtkwidget.c (gtk_widget_size_request): Leave + widget->requisition set to exactly what the widget + asked for, and then make a copy of that into + the requisition argument. Allow a NULL requisition + argument, and, if G_ENABLE_DEBUG, warn if + requisition == &widget->requisition. + + * gtkalignment.c gtkaspectframe.c gtkbutton.c gtkclist.c + gtkcontainer.c gtkentry.c gtkeventbox.c gtkfixed.c + gtkframe.c gtkhandlebox.c gtkhbox.c gtkhpaned.c + gtklayout.c gtklist.c gtklistitem.c gtkmenu.c + gtkmenubar.c gtkmenuitem.c gtknotebook.c + gtkoptionmenu.c gtkpacker.c gtkscrolledwindow.c + gtktable.c gtktoolbar.c gtktree.c gtktreeitem.c + gtkvbox.c gtkviewport.c gtkvpaned.c gtkwindow.c + + Avoid calling gtk_widget_size_request with + requisition == widget->requisition; use + gtk_widget_get_child_requisition to get the + size of children. + Tue Feb 9 19:49:46 1999 Owen Taylor <otaylor@redhat.com> * configure.in (LDFLAGS): Removed extraneous line @@ -59,6 +98,7 @@ Mon Feb 8 12:50:06 GMT 1999 Tony Gale <gale@gtk.org> * Makefile.am: update to include the latest Tutorial examples. +>>>>>>> 1.1009 Sat Feb 6 11:20:16 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c (gtk_widget_idle_draw): Add the diff --git a/docs/Changes-1.2.txt b/docs/Changes-1.2.txt index 0d452d6831..1830aa239a 100644 --- a/docs/Changes-1.2.txt +++ b/docs/Changes-1.2.txt @@ -245,3 +245,30 @@ Incompatible Changes from GTK+-1.0 to GTK+-1.2: You can get these CFLAGS and LIBS by passing gthread as the fourth parameter to the AM_PATH_GTK automake macro. + +* Prior to GTK+-1.2, there were two conflicting interpretations + of widget->requistion. It was either taken to be + the size that the widget requested, or that size + modified by calls to gtk_widget_set_usize(). In GTK+-1.2, + it is always interpreted the first way. + + Container widgets are affected in two ways by this: + + 1) Container widgets should not pass widget->requisition + as the second parameter to gtk_widget_size_request(). + Instead they should call it like: + + GtkRequisition child_requisition; + gtk_widget_size_request (widget, &child_requisition); + + 2) Container widgets should not access child->requisition + directly. Either they should use the values returned + by gtk_widget_size_request(), or they should call + the new function: + + void gtk_widget_get_child_requisition (GtkWidget *widget, + GtkRequisition *requisition); + + which returns the requisition of the given widget, modified + by calls to gtk_widget_set_usize(). + diff --git a/gtk/gtkalignment.c b/gtk/gtkalignment.c index 77e0656733..f8c9bfded8 100644 --- a/gtk/gtkalignment.c +++ b/gtk/gtkalignment.c @@ -241,10 +241,12 @@ gtk_alignment_size_request (GtkWidget *widget, if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { - gtk_widget_size_request (bin->child, &bin->child->requisition); + GtkRequisition child_requisition; + + gtk_widget_size_request (bin->child, &child_requisition); - requisition->width += bin->child->requisition.width; - requisition->height += bin->child->requisition.height; + requisition->width += child_requisition.width; + requisition->height += child_requisition.height; } } @@ -255,6 +257,7 @@ gtk_alignment_size_allocate (GtkWidget *widget, GtkAlignment *alignment; GtkBin *bin; GtkAllocation child_allocation; + GtkRequisition child_requisition; gint width, height; gint x, y; @@ -268,20 +271,22 @@ gtk_alignment_size_allocate (GtkWidget *widget, if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { + gtk_widget_get_child_requisition (bin->child, &child_requisition); + x = GTK_CONTAINER (alignment)->border_width; y = GTK_CONTAINER (alignment)->border_width; width = MAX (allocation->width - 2 * x, 0); height = MAX (allocation->height - 2 * y, 0); - if (width > bin->child->requisition.width) - child_allocation.width = (bin->child->requisition.width * + if (width > child_requisition.width) + child_allocation.width = (child_requisition.width * (1.0 - alignment->xscale) + width * alignment->xscale); else child_allocation.width = width; - if (height > bin->child->requisition.height) - child_allocation.height = (bin->child->requisition.height * + if (height > child_requisition.height) + child_allocation.height = (child_requisition.height * (1.0 - alignment->yscale) + height * alignment->yscale); else diff --git a/gtk/gtkaspectframe.c b/gtk/gtkaspectframe.c index 5ee502266b..9faaeb3a70 100644 --- a/gtk/gtkaspectframe.c +++ b/gtk/gtkaspectframe.c @@ -295,13 +295,16 @@ gtk_aspect_frame_size_allocate (GtkWidget *widget, { if (aspect_frame->obey_child) { - if (bin->child->requisition.height != 0) + GtkRequisition child_requisition; + + gtk_widget_get_child_requisition (bin->child, &child_requisition); + if (child_requisition.height != 0) { - ratio = (gdouble)bin->child->requisition.width / - bin->child->requisition.height; + ratio = (gdouble)child_requisition.width / + child_requisition.height; if (ratio < MIN_RATIO) ratio = MIN_RATIO; } - else if (bin->child->requisition.width != 0) + else if (child_requisition.width != 0) ratio = MAX_RATIO; else ratio = 1.0; diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index 8e3593bff9..30346368ce 100644 --- a/gtk/gtkbutton.c +++ b/gtk/gtkbutton.c @@ -435,10 +435,12 @@ gtk_button_size_request (GtkWidget *widget, if (GTK_BIN (button)->child && GTK_WIDGET_VISIBLE (GTK_BIN (button)->child)) { - gtk_widget_size_request (GTK_BIN (button)->child, >K_BIN (button)->child->requisition); + GtkRequisition child_requisition; - requisition->width += GTK_BIN (button)->child->requisition.width; - requisition->height += GTK_BIN (button)->child->requisition.height; + gtk_widget_size_request (GTK_BIN (button)->child, &child_requisition); + + requisition->width += child_requisition.width; + requisition->height += child_requisition.height; } } diff --git a/gtk/gtkclist.c b/gtk/gtkclist.c index ecaaf51088..f13449d33c 100644 --- a/gtk/gtkclist.c +++ b/gtk/gtkclist.c @@ -5393,11 +5393,13 @@ gtk_clist_size_request (GtkWidget *widget, for (i = 0; i < clist->columns; i++) if (clist->column[i].button) { + GtkRequisition child_requisition; + gtk_widget_size_request (clist->column[i].button, - &clist->column[i].button->requisition); + &child_requisition); clist->column_title_area.height = MAX (clist->column_title_area.height, - clist->column[i].button->requisition.height); + child_requisition.height); } requisition->width += (widget->style->klass->xthickness + @@ -6088,14 +6090,15 @@ adjust_adjustments (GtkCList *clist, if (!block_resize && (!clist->vadjustment || !clist->hadjustment)) { GtkWidget *widget; + GtkRequisition requisition; widget = GTK_WIDGET (clist); - gtk_widget_size_request (widget, &widget->requisition); + gtk_widget_size_request (widget, &requisition); if ((!clist->hadjustment && - widget->requisition.width != widget->allocation.width) || + requisition.width != widget->allocation.width) || (!clist->vadjustment && - widget->requisition.height != widget->allocation.height)) + requisition.height != widget->allocation.height)) gtk_widget_queue_resize (widget); } } diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index e9b405bd1f..564068cc8e 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -897,16 +897,17 @@ static void gtk_container_real_check_resize (GtkContainer *container) { GtkWidget *widget; + GtkRequisition requisition; g_return_if_fail (container != NULL); g_return_if_fail (GTK_IS_CONTAINER (container)); widget = GTK_WIDGET (container); - gtk_widget_size_request (widget, &widget->requisition); + gtk_widget_size_request (widget, &requisition); - if (widget->requisition.width > widget->allocation.width || - widget->requisition.height > widget->allocation.height) + if (requisition.width > widget->allocation.width || + requisition.height > widget->allocation.height) { if (GTK_IS_RESIZE_CONTAINER (container)) gtk_widget_size_allocate (GTK_WIDGET (container), diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 642ea264e8..9aca131566 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -539,6 +539,7 @@ gtk_entry_realize (GtkWidget *widget) { GtkEntry *entry; GtkEditable *editable; + GtkRequisition requisition; GdkWindowAttr attributes; gint attributes_mask; @@ -548,13 +549,15 @@ gtk_entry_realize (GtkWidget *widget) GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); entry = GTK_ENTRY (widget); editable = GTK_EDITABLE (widget); + + gtk_widget_get_child_requisition (widget, &requisition); attributes.window_type = GDK_WINDOW_CHILD; attributes.x = widget->allocation.x; attributes.y = widget->allocation.y + (widget->allocation.height - - widget->requisition.height) / 2; + requisition.height) / 2; attributes.width = widget->allocation.width; - attributes.height = widget->requisition.height; + attributes.height = requisition.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); @@ -576,7 +579,7 @@ gtk_entry_realize (GtkWidget *widget) attributes.x = widget->style->klass->xthickness; attributes.y = widget->style->klass->ythickness; attributes.width = widget->allocation.width - attributes.x * 2; - attributes.height = widget->requisition.height - attributes.y * 2; + attributes.height = requisition.height - attributes.y * 2; attributes.cursor = entry->cursor = gdk_cursor_new (GDK_XTERM); attributes_mask |= GDK_WA_CURSOR; @@ -774,15 +777,22 @@ gtk_entry_size_allocate (GtkWidget *widget, if (GTK_WIDGET_REALIZED (widget)) { + /* We call gtk_widget_get_child_requisition, since we want (for + * backwards compatibility reasons) the realization here to + * be affected by the usize of the entry, if set + */ + GtkRequisition requisition; + gtk_widget_get_child_requisition (widget, &requisition); + gdk_window_move_resize (widget->window, allocation->x, - allocation->y + (allocation->height - widget->requisition.height) / 2, - allocation->width, widget->requisition.height); + allocation->y + (allocation->height - requisition.height) / 2, + allocation->width, requisition.height); gdk_window_move_resize (entry->text_area, widget->style->klass->xthickness, widget->style->klass->ythickness, allocation->width - widget->style->klass->xthickness * 2, - widget->requisition.height - widget->style->klass->ythickness * 2); + requisition.height - widget->style->klass->ythickness * 2); /* And make sure the cursor is on screen */ entry_adjust_scroll (entry); diff --git a/gtk/gtkeventbox.c b/gtk/gtkeventbox.c index 3880a050a9..ddf0f1d15f 100644 --- a/gtk/gtkeventbox.c +++ b/gtk/gtkeventbox.c @@ -142,10 +142,12 @@ gtk_event_box_size_request (GtkWidget *widget, if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { - gtk_widget_size_request (bin->child, &bin->child->requisition); + GtkRequisition child_requisition; + + gtk_widget_size_request (bin->child, &child_requisition); - requisition->width += bin->child->requisition.width; - requisition->height += bin->child->requisition.height; + requisition->width += child_requisition.width; + requisition->height += child_requisition.height; } } diff --git a/gtk/gtkfixed.c b/gtk/gtkfixed.c index ef75f7728f..5b8c72f414 100644 --- a/gtk/gtkfixed.c +++ b/gtk/gtkfixed.c @@ -250,6 +250,7 @@ gtk_fixed_size_request (GtkWidget *widget, GtkFixed *fixed; GtkFixedChild *child; GList *children; + GtkRequisition child_requisition; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_FIXED (widget)); @@ -267,14 +268,14 @@ gtk_fixed_size_request (GtkWidget *widget, if (GTK_WIDGET_VISIBLE (child->widget)) { - gtk_widget_size_request (child->widget, &child->widget->requisition); + gtk_widget_size_request (child->widget, &child_requisition); requisition->height = MAX (requisition->height, child->y + - child->widget->requisition.height); + child_requisition.height); requisition->width = MAX (requisition->width, child->x + - child->widget->requisition.width); + child_requisition.width); } } @@ -289,6 +290,7 @@ gtk_fixed_size_allocate (GtkWidget *widget, GtkFixed *fixed; GtkFixedChild *child; GtkAllocation child_allocation; + GtkRequisition child_requisition; GList *children; guint16 border_width; @@ -316,10 +318,11 @@ gtk_fixed_size_allocate (GtkWidget *widget, if (GTK_WIDGET_VISIBLE (child->widget)) { + gtk_widget_get_child_requisition (child->widget, &child_requisition); child_allocation.x = child->x + border_width; child_allocation.y = child->y + border_width; - child_allocation.width = child->widget->requisition.width; - child_allocation.height = child->widget->requisition.height; + child_allocation.width = child_requisition.width; + child_allocation.height = child_requisition.height; gtk_widget_size_allocate (child->widget, &child_allocation); } } diff --git a/gtk/gtkframe.c b/gtk/gtkframe.c index 789d158deb..afb19fcf15 100644 --- a/gtk/gtkframe.c +++ b/gtk/gtkframe.c @@ -456,10 +456,12 @@ gtk_frame_size_request (GtkWidget *widget, if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { - gtk_widget_size_request (bin->child, &bin->child->requisition); + GtkRequisition child_requisition; + + gtk_widget_size_request (bin->child, &child_requisition); - requisition->width += MAX (bin->child->requisition.width, frame->label_width); - requisition->height += bin->child->requisition.height; + requisition->width += MAX (child_requisition.width, frame->label_width); + requisition->height += child_requisition.height; } else { diff --git a/gtk/gtkhandlebox.c b/gtk/gtkhandlebox.c index ff72ce08d7..4df645ab01 100644 --- a/gtk/gtkhandlebox.c +++ b/gtk/gtkhandlebox.c @@ -415,6 +415,7 @@ gtk_handle_box_size_request (GtkWidget *widget, { GtkBin *bin; GtkHandleBox *hb; + GtkRequisition child_requisition; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_HANDLE_BOX (widget)); @@ -439,7 +440,7 @@ gtk_handle_box_size_request (GtkWidget *widget, * won't have any usefull hint for our size otherwise. */ if (bin->child) - gtk_widget_size_request (bin->child, &bin->child->requisition); + gtk_widget_size_request (bin->child, &child_requisition); if (hb->child_detached) { @@ -447,9 +448,9 @@ gtk_handle_box_size_request (GtkWidget *widget, { if (hb->handle_position == GTK_POS_LEFT || hb->handle_position == GTK_POS_RIGHT) - requisition->height += bin->child->requisition.height; + requisition->height += child_requisition.height; else - requisition->width += bin->child->requisition.width; + requisition->width += child_requisition.width; } else { @@ -467,8 +468,8 @@ gtk_handle_box_size_request (GtkWidget *widget, if (bin->child) { - requisition->width += bin->child->requisition.width; - requisition->height += bin->child->requisition.height; + requisition->width += child_requisition.width; + requisition->height += child_requisition.height; } else { @@ -484,6 +485,7 @@ gtk_handle_box_size_allocate (GtkWidget *widget, { GtkBin *bin; GtkHandleBox *hb; + GtkRequisition child_requisition; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_HANDLE_BOX (widget)); @@ -494,16 +496,24 @@ gtk_handle_box_size_allocate (GtkWidget *widget, widget->allocation.x = allocation->x; + if (bin->child) + gtk_widget_get_child_requisition (bin->child, &child_requisition); + else + { + child_requisition.width = 0; + child_requisition.height = 0; + } + if (hb->child_detached) { guint max_req_height; guint max_req_width; max_req_height = MAX (widget->requisition.height, - bin->child->requisition.height + + child_requisition.height + 2 * widget->style->klass->ythickness); max_req_width = MAX (widget->requisition.width, - bin->child->requisition.width + + child_requisition.width + 2 * widget->style->klass->xthickness); if (allocation->height > max_req_height) @@ -549,8 +559,8 @@ gtk_handle_box_size_allocate (GtkWidget *widget, guint float_width; guint float_height; - child_allocation.width = child->requisition.width; - child_allocation.height = child->requisition.height; + child_allocation.width = child_requisition.width; + child_allocation.height = child_requisition.height; float_width = child_allocation.width + 2 * border_width; float_height = child_allocation.height + 2 * border_width; diff --git a/gtk/gtkhandlebox.h b/gtk/gtkhandlebox.h index 26bc649d72..215a7efcbd 100644 --- a/gtk/gtkhandlebox.h +++ b/gtk/gtkhandlebox.h @@ -57,7 +57,14 @@ struct _GtkHandleBox guint in_drag : 1; guint shrink_on_detach : 1; - gint dragoff_x, dragoff_y; /* start drag position (wrt widget->window) */ + /* Variables used during a drag + */ + gint dragoff_x, dragoff_y; /* offset from event->root_x/y and + * attach point on float */ + gint deskoff_x, deskoff_y; /* Offset between root relative coordinates + * and deskrelative coordinates */ + gint attach_x, attach_y; /* Root relative-coordinates of attach + * point on widget->window */ }; struct _GtkHandleBoxClass diff --git a/gtk/gtkhbox.c b/gtk/gtkhbox.c index f705d9f563..5f3de5cd44 100644 --- a/gtk/gtkhbox.c +++ b/gtk/gtkhbox.c @@ -110,19 +110,21 @@ gtk_hbox_size_request (GtkWidget *widget, if (GTK_WIDGET_VISIBLE (child->widget)) { - gtk_widget_size_request (child->widget, &child->widget->requisition); + GtkRequisition child_requisition; + + gtk_widget_size_request (child->widget, &child_requisition); if (box->homogeneous) { - width = child->widget->requisition.width + child->padding * 2; + width = child_requisition.width + child->padding * 2; requisition->width = MAX (requisition->width, width); } else { - requisition->width += child->widget->requisition.width + child->padding * 2; + requisition->width += child_requisition.width + child->padding * 2; } - requisition->height = MAX (requisition->height, child->widget->requisition.height); + requisition->height = MAX (requisition->height, child_requisition.height); nvis_children += 1; } @@ -189,7 +191,7 @@ gtk_hbox_size_allocate (GtkWidget *widget, } else if (nexpand_children > 0) { - width = (gint)allocation->width - (gint)widget->requisition.width; + width = (gint) allocation->width - (gint) widget->requisition.width; extra = width / nexpand_children; } else @@ -200,7 +202,7 @@ gtk_hbox_size_allocate (GtkWidget *widget, x = allocation->x + GTK_CONTAINER (box)->border_width; child_allocation.y = allocation->y + GTK_CONTAINER (box)->border_width; - child_allocation.height = MAX (1, (gint)allocation->height - (gint)GTK_CONTAINER (box)->border_width * 2); + child_allocation.height = MAX (1, (gint) allocation->height - (gint) GTK_CONTAINER (box)->border_width * 2); children = box->children; while (children) @@ -222,7 +224,11 @@ gtk_hbox_size_allocate (GtkWidget *widget, } else { - child_width = child->widget->requisition.width + child->padding * 2; + GtkRequisition child_requisition; + + gtk_widget_get_child_requisition (child->widget, &child_requisition); + + child_width = child_requisition.width + child->padding * 2; if (child->expand) { @@ -238,12 +244,15 @@ gtk_hbox_size_allocate (GtkWidget *widget, if (child->fill) { - child_allocation.width = MAX (1, (gint)child_width - (gint)child->padding * 2); + child_allocation.width = MAX (1, (gint) child_width - (gint) child->padding * 2); child_allocation.x = x + child->padding; } else { - child_allocation.width = child->widget->requisition.width; + GtkRequisition child_requisition; + + gtk_widget_get_child_requisition (child->widget, &child_requisition); + child_allocation.width = child_requisition.width; child_allocation.x = x + (child_width - child_allocation.width) / 2; } @@ -263,6 +272,9 @@ gtk_hbox_size_allocate (GtkWidget *widget, if ((child->pack == GTK_PACK_END) && GTK_WIDGET_VISIBLE (child->widget)) { + GtkRequisition child_requisition; + gtk_widget_get_child_requisition (child->widget, &child_requisition); + if (box->homogeneous) { if (nvis_children == 1) @@ -275,7 +287,7 @@ gtk_hbox_size_allocate (GtkWidget *widget, } else { - child_width = child->widget->requisition.width + child->padding * 2; + child_width = child_requisition.width + child->padding * 2; if (child->expand) { @@ -296,7 +308,7 @@ gtk_hbox_size_allocate (GtkWidget *widget, } else { - child_allocation.width = child->widget->requisition.width; + child_allocation.width = child_requisition.width; child_allocation.x = x + (child_width - child_allocation.width) / 2 - child_width; } diff --git a/gtk/gtkhpaned.c b/gtk/gtkhpaned.c index 1eac179b85..e71935a4e1 100644 --- a/gtk/gtkhpaned.c +++ b/gtk/gtkhpaned.c @@ -96,6 +96,7 @@ gtk_hpaned_size_request (GtkWidget *widget, GtkRequisition *requisition) { GtkPaned *paned; + GtkRequisition child_requisition; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_HPANED (widget)); @@ -107,19 +108,18 @@ gtk_hpaned_size_request (GtkWidget *widget, if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1)) { - gtk_widget_size_request (paned->child1, &paned->child1->requisition); + gtk_widget_size_request (paned->child1, &child_requisition); - requisition->height = paned->child1->requisition.height; - requisition->width = paned->child1->requisition.width; + requisition->height = child_requisition.height; + requisition->width = child_requisition.width; } if (paned->child2 && GTK_WIDGET_VISIBLE (paned->child2)) { - gtk_widget_size_request (paned->child2, &paned->child2->requisition); + gtk_widget_size_request (paned->child2, &child_requisition); - requisition->height = MAX(requisition->height, - paned->child2->requisition.height); - requisition->width += paned->child2->requisition.width; + requisition->height = MAX(requisition->height, child_requisition.height); + requisition->width += child_requisition.width; } requisition->width += GTK_CONTAINER (paned)->border_width * 2 + paned->gutter_size; @@ -131,6 +131,8 @@ gtk_hpaned_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkPaned *paned; + GtkRequisition child1_requisition; + GtkRequisition child2_requisition; GtkAllocation child1_allocation; GtkAllocation child2_allocation; GdkRectangle old_groove_rectangle; @@ -145,12 +147,22 @@ gtk_hpaned_size_allocate (GtkWidget *widget, paned = GTK_PANED (widget); border_width = GTK_CONTAINER (paned)->border_width; + if (paned->child1) + gtk_widget_get_child_requisition (paned->child1, &child1_requisition); + else + child1_requisition.width = 0; + + if (paned->child2) + gtk_widget_get_child_requisition (paned->child2, &child2_requisition); + else + child2_requisition.width = 0; + gtk_paned_compute_position (paned, widget->allocation.width - paned->gutter_size - 2 * border_width, - paned->child1 ? paned->child1->requisition.width : 0, - paned->child2 ? paned->child2->requisition.width : 0); + child1_requisition.width, + child2_requisition.width); /* Move the handle before the children so we don't get extra expose events */ diff --git a/gtk/gtklayout.c b/gtk/gtklayout.c index 353c3f1a8c..532755c0c5 100644 --- a/gtk/gtklayout.c +++ b/gtk/gtklayout.c @@ -244,8 +244,6 @@ gtk_layout_put (GtkLayout *layout, child->widget = child_widget; child->x = x; child->y = y; - child->widget->requisition.width = 0; - child->widget->requisition.height = 0; layout->children = g_list_append (layout->children, child); @@ -559,9 +557,11 @@ gtk_layout_size_request (GtkWidget *widget, while (tmp_list) { GtkLayoutChild *child = tmp_list->data; + GtkRequisition child_requisition; + tmp_list = tmp_list->next; - gtk_widget_size_request (child->widget, &child->widget->requisition); + gtk_widget_size_request (child->widget, &child_requisition); } } @@ -776,11 +776,13 @@ gtk_layout_allocate_child (GtkLayout *layout, GtkLayoutChild *child) { GtkAllocation allocation; + GtkRequisition requisition; allocation.x = child->x - layout->xoffset; allocation.y = child->y - layout->yoffset; - allocation.width = child->widget->requisition.width; - allocation.height = child->widget->requisition.height; + gtk_widget_get_child_requisition (child->widget, &requisition); + allocation.width = requisition.width; + allocation.height = requisition.height; gtk_widget_size_allocate (child->widget, &allocation); } diff --git a/gtk/gtklist.c b/gtk/gtklist.c index c18431d4be..9948c0582e 100644 --- a/gtk/gtklist.c +++ b/gtk/gtklist.c @@ -326,11 +326,13 @@ gtk_list_size_request (GtkWidget *widget, if (GTK_WIDGET_VISIBLE (child)) { - gtk_widget_size_request (child, &child->requisition); + GtkRequisition child_requisition; + + gtk_widget_size_request (child, &child_requisition); requisition->width = MAX (requisition->width, - child->requisition.width); - requisition->height += child->requisition.height; + child_requisition.width); + requisition->height += child_requisition.height; } } @@ -378,7 +380,10 @@ gtk_list_size_allocate (GtkWidget *widget, if (GTK_WIDGET_VISIBLE (child)) { - child_allocation.height = child->requisition.height; + GtkRequisition child_requisition; + gtk_widget_get_child_requisition (child, &child_requisition); + + child_allocation.height = child_requisition.height; gtk_widget_size_allocate (child, &child_allocation); diff --git a/gtk/gtklistitem.c b/gtk/gtklistitem.c index de94536878..7fd7dfcfa7 100644 --- a/gtk/gtklistitem.c +++ b/gtk/gtklistitem.c @@ -392,6 +392,7 @@ gtk_list_item_size_request (GtkWidget *widget, GtkRequisition *requisition) { GtkBin *bin; + GtkRequisition child_requisition; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_LIST_ITEM (widget)); @@ -405,10 +406,10 @@ gtk_list_item_size_request (GtkWidget *widget, if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { - gtk_widget_size_request (bin->child, &bin->child->requisition); + gtk_widget_size_request (bin->child, &child_requisition); - requisition->width += bin->child->requisition.width; - requisition->height += bin->child->requisition.height; + requisition->width += child_requisition.width; + requisition->height += child_requisition.height; } } diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index 14c01f3cc5..e4e1a709ff 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -702,6 +702,7 @@ gtk_menu_size_request (GtkWidget *widget, GList *children; guint max_toggle_size; guint max_accel_width; + GtkRequisition child_requisition; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_MENU (widget)); @@ -725,10 +726,10 @@ gtk_menu_size_request (GtkWidget *widget, if (GTK_WIDGET_VISIBLE (child)) { GTK_MENU_ITEM (child)->show_submenu_indicator = TRUE; - gtk_widget_size_request (child, &child->requisition); + gtk_widget_size_request (child, &child_requisition); - requisition->width = MAX (requisition->width, child->requisition.width); - requisition->height += child->requisition.height; + requisition->width = MAX (requisition->width, child_requisition.width); + requisition->height += child_requisition.height; max_toggle_size = MAX (max_toggle_size, MENU_ITEM_CLASS (child)->toggle_size); max_accel_width = MAX (max_accel_width, GTK_MENU_ITEM (child)->accelerator_width); @@ -791,7 +792,10 @@ gtk_menu_size_allocate (GtkWidget *widget, if (GTK_WIDGET_VISIBLE (child)) { - child_allocation.height = child->requisition.height; + GtkRequisition child_requisition; + gtk_widget_get_child_requisition (child, &child_requisition); + + child_allocation.height = child_requisition.height; gtk_widget_size_allocate (child, &child_allocation); gtk_widget_queue_draw (child); @@ -1013,6 +1017,7 @@ static void gtk_menu_position (GtkMenu *menu) { GtkWidget *widget; + GtkRequisition requisition; gint x, y; g_return_if_fail (menu != NULL); @@ -1027,7 +1032,7 @@ gtk_menu_position (GtkMenu *menu) * if one a size_request was queued while we weren't popped up, * the requisition won't have been recomputed yet. */ - gtk_widget_size_request (widget, &widget->requisition); + gtk_widget_size_request (widget, &requisition); if (menu->position_func) (* menu->position_func) (menu, &x, &y, menu->position_func_data); @@ -1042,12 +1047,12 @@ gtk_menu_position (GtkMenu *menu) x -= 2; y -= 2; - if ((x + widget->requisition.width) > screen_width) - x -= ((x + widget->requisition.width) - screen_width); + if ((x + requisition.width) > screen_width) + x -= ((x + requisition.width) - screen_width); if (x < 0) x = 0; - if ((y + widget->requisition.height) > screen_height) - y -= ((y + widget->requisition.height) - screen_height); + if ((y + requisition.height) > screen_height) + y -= ((y + requisition.height) - screen_height); if (y < 0) y = 0; } diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c index d01fe2c2c5..81610850ee 100644 --- a/gtk/gtkmenubar.c +++ b/gtk/gtkmenubar.c @@ -208,6 +208,7 @@ gtk_menu_bar_size_request (GtkWidget *widget, GtkWidget *child; GList *children; gint nchildren; + GtkRequisition child_requisition; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_MENU_BAR (widget)); @@ -232,13 +233,13 @@ gtk_menu_bar_size_request (GtkWidget *widget, if (GTK_WIDGET_VISIBLE (child)) { GTK_MENU_ITEM (child)->show_submenu_indicator = FALSE; - gtk_widget_size_request (child, &child->requisition); + gtk_widget_size_request (child, &child_requisition); - requisition->width += child->requisition.width; - requisition->height = MAX (requisition->height, child->requisition.height); + requisition->width += child_requisition.width; + requisition->height = MAX (requisition->height, child_requisition.height); /* Support for the right justified help menu */ - if ( (children == NULL) && (GTK_IS_MENU_ITEM(child)) - && (GTK_MENU_ITEM(child)->right_justify)) + if ((children == NULL) && GTK_IS_MENU_ITEM(child) && + GTK_MENU_ITEM(child)->right_justify) { requisition->width += CHILD_SPACING; } @@ -268,6 +269,7 @@ gtk_menu_bar_size_allocate (GtkWidget *widget, GtkWidget *child; GList *children; GtkAllocation child_allocation; + GtkRequisition child_requisition; guint offset; g_return_if_fail (widget != NULL); @@ -301,16 +303,18 @@ gtk_menu_bar_size_allocate (GtkWidget *widget, child = children->data; children = children->next; + gtk_widget_get_child_requisition (child, &child_requisition); + /* Support for the right justified help menu */ if ( (children == NULL) && (GTK_IS_MENU_ITEM(child)) && (GTK_MENU_ITEM(child)->right_justify)) { child_allocation.x = allocation->width - - child->requisition.width - CHILD_SPACING - offset; + child_requisition.width - CHILD_SPACING - offset; } if (GTK_WIDGET_VISIBLE (child)) { - child_allocation.width = child->requisition.width; + child_allocation.width = child_requisition.width; gtk_widget_size_allocate (child, &child_allocation); diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c index 3241a1a768..ac3d47eeb9 100644 --- a/gtk/gtkmenuitem.c +++ b/gtk/gtkmenuitem.c @@ -346,10 +346,12 @@ gtk_menu_item_size_request (GtkWidget *widget, if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { - gtk_widget_size_request (bin->child, &bin->child->requisition); + GtkRequisition child_requisition; + + gtk_widget_size_request (bin->child, &child_requisition); - requisition->width += bin->child->requisition.width; - requisition->height += bin->child->requisition.height; + requisition->width += child_requisition.width; + requisition->height += child_requisition.height; } if (menu_item->submenu && menu_item->show_submenu_indicator) diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 88dd829054..b8d3cb75c9 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -563,6 +563,7 @@ gtk_notebook_size_request (GtkWidget *widget, GtkNotebook *notebook; GtkNotebookPage *page; GList *children; + GtkRequisition child_requisition; gboolean switch_page = FALSE; gint vis_pages; @@ -582,12 +583,12 @@ gtk_notebook_size_request (GtkWidget *widget, if (GTK_WIDGET_VISIBLE (page->child)) { vis_pages++; - gtk_widget_size_request (page->child, &page->child->requisition); + gtk_widget_size_request (page->child, &child_requisition); widget->requisition.width = MAX (widget->requisition.width, - page->child->requisition.width); + child_requisition.width); widget->requisition.height = MAX (widget->requisition.height, - page->child->requisition.height); + child_requisition.height); if (GTK_WIDGET_MAPPED (page->child) && page != notebook->cur_page) gtk_widget_unmap (page->child); @@ -627,14 +628,14 @@ gtk_notebook_size_request (GtkWidget *widget, if (!GTK_WIDGET_VISIBLE (page->tab_label)) gtk_widget_show (page->tab_label); - gtk_widget_size_request (page->tab_label, - &page->tab_label->requisition); + gtk_widget_size_request (page->tab_label, + &child_requisition); page->requisition.width = - page->tab_label->requisition.width + + child_requisition.width + 2 * widget->style->klass->xthickness; page->requisition.height = - page->tab_label->requisition.height + + child_requisition.height + 2 * widget->style->klass->ythickness; switch (notebook->tab_pos) @@ -2990,6 +2991,7 @@ gtk_notebook_page_allocate (GtkNotebook *notebook, { GtkWidget *widget; GtkAllocation child_allocation; + GtkRequisition tab_requisition; gint xthickness; gint ythickness; gint padding; @@ -3051,6 +3053,7 @@ gtk_notebook_page_allocate (GtkNotebook *notebook, } page->allocation = *allocation; + gtk_widget_get_child_requisition (page->tab_label, &tab_requisition); if (notebook->cur_page != page) { @@ -3086,8 +3089,8 @@ gtk_notebook_page_allocate (GtkNotebook *notebook, { child_allocation.x = (page->allocation.x + (page->allocation.width - - page->tab_label->requisition.width) / 2); - child_allocation.width = page->tab_label->requisition.width; + tab_requisition.width) / 2); + child_allocation.width = tab_requisition.width; } child_allocation.y = (notebook->tab_vborder + FOCUS_WIDTH + page->allocation.y); @@ -3110,8 +3113,8 @@ gtk_notebook_page_allocate (GtkNotebook *notebook, { child_allocation.y = (page->allocation.y + (page->allocation.height - - page->tab_label->requisition.height) / 2); - child_allocation.height = page->tab_label->requisition.height; + tab_requisition.height) / 2); + child_allocation.height = tab_requisition.height; } child_allocation.x = (page->allocation.x + notebook->tab_hborder + FOCUS_WIDTH); diff --git a/gtk/gtkoptionmenu.c b/gtk/gtkoptionmenu.c index c888625fca..78dae5cf59 100644 --- a/gtk/gtkoptionmenu.c +++ b/gtk/gtkoptionmenu.c @@ -517,6 +517,7 @@ static void gtk_option_menu_update_contents (GtkOptionMenu *option_menu) { GtkWidget *child; + GtkRequisition child_requisition; g_return_if_fail (option_menu != NULL); g_return_if_fail (GTK_IS_OPTION_MENU (option_menu)); @@ -540,7 +541,7 @@ gtk_option_menu_update_contents (GtkOptionMenu *option_menu) gtk_widget_reparent (child, GTK_WIDGET (option_menu)); } - gtk_widget_size_request (child, &child->requisition); + gtk_widget_size_request (child, &child_requisition); gtk_widget_size_allocate (GTK_WIDGET (option_menu), &(GTK_WIDGET (option_menu)->allocation)); @@ -572,6 +573,7 @@ gtk_option_menu_calc_size (GtkOptionMenu *option_menu) { GtkWidget *child; GList *children; + GtkRequisition child_requisition; g_return_if_fail (option_menu != NULL); g_return_if_fail (GTK_IS_OPTION_MENU (option_menu)); @@ -589,10 +591,10 @@ gtk_option_menu_calc_size (GtkOptionMenu *option_menu) if (GTK_WIDGET_VISIBLE (child)) { - gtk_widget_size_request (child, &child->requisition); + gtk_widget_size_request (child, &child_requisition); - option_menu->width = MAX (option_menu->width, child->requisition.width); - option_menu->height = MAX (option_menu->height, child->requisition.height); + option_menu->width = MAX (option_menu->width, child_requisition.width); + option_menu->height = MAX (option_menu->height, child_requisition.height); } } } diff --git a/gtk/gtkpacker.c b/gtk/gtkpacker.c index 2909f7c288..7713a9e9e6 100644 --- a/gtk/gtkpacker.c +++ b/gtk/gtkpacker.c @@ -897,7 +897,8 @@ gtk_packer_unmap (GtkWidget *widget) } static void -gtk_packer_draw (GtkWidget *widget, GdkRectangle *area) +gtk_packer_draw (GtkWidget *widget, + GdkRectangle *area) { GtkPacker *packer; GtkPackerChild *child; @@ -925,7 +926,8 @@ gtk_packer_draw (GtkWidget *widget, GdkRectangle *area) } static gint -gtk_packer_expose (GtkWidget *widget, GdkEventExpose *event) +gtk_packer_expose (GtkWidget *widget, + GdkEventExpose *event) { GtkPacker *packer; GtkPackerChild *child; @@ -958,7 +960,8 @@ gtk_packer_expose (GtkWidget *widget, GdkEventExpose *event) } static void -gtk_packer_size_request (GtkWidget *widget, GtkRequisition *requisition) +gtk_packer_size_request (GtkWidget *widget, + GtkRequisition *requisition) { GtkPacker *packer; GtkContainer *container; @@ -968,6 +971,7 @@ gtk_packer_size_request (GtkWidget *widget, GtkRequisition *requisition) gint nvis_horz_children; gint width, height; gint maxWidth, maxHeight; + GtkRequisition child_requisition; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_PACKER (widget)); @@ -990,27 +994,29 @@ gtk_packer_size_request (GtkWidget *widget, GtkRequisition *requisition) if (GTK_WIDGET_VISIBLE (child->widget)) { - gtk_widget_size_request (child->widget, &child->widget->requisition); + GtkRequisition child_requisition; + + gtk_widget_size_request (child->widget, &child_requisition); - if((child->side == GTK_SIDE_TOP) || (child->side == GTK_SIDE_BOTTOM)) + if ((child->side == GTK_SIDE_TOP) || (child->side == GTK_SIDE_BOTTOM)) { maxWidth = MAX (maxWidth, - (child->widget->requisition.width + + (child_requisition.width + 2 * child->border_width + child->pad_x + child->i_pad_x + width)); - height += (child->widget->requisition.height + + height += (child_requisition.height + 2 * child->border_width + child->pad_y + child->i_pad_y); } else { maxHeight = MAX (maxHeight, - (child->widget->requisition.height + + (child_requisition.height + 2 * child->border_width + child->pad_y + child->i_pad_y + height)); - width += (child->widget->requisition.width + + width += (child_requisition.width + 2 * child->border_width + child->pad_x + child->i_pad_x); } @@ -1024,7 +1030,8 @@ gtk_packer_size_request (GtkWidget *widget, GtkRequisition *requisition) } static gint -YExpansion (GList *children, gint cavityHeight) +YExpansion (GList *children, + gint cavityHeight) { GList *list; GtkPackerChild *child; @@ -1038,9 +1045,13 @@ YExpansion (GList *children, gint cavityHeight) list = children; while (list != NULL) { + GtkRequisition child_requisition; + child = list->data; widget = child->widget; - childHeight = (widget->requisition.height + + gtk_widget_get_child_requisition (widget, &child_requisition); + + childHeight = (child_requisition.height + 2 * child->border_width + child->i_pad_y + child->pad_y); @@ -1064,7 +1075,8 @@ YExpansion (GList *children, gint cavityHeight) } static gint -XExpansion (GList *children, gint cavityWidth) +XExpansion (GList *children, + gint cavityWidth) { GList *list; GtkPackerChild *child; @@ -1078,9 +1090,13 @@ XExpansion (GList *children, gint cavityWidth) list = children; while (list != NULL) { + GtkRequisition child_requisition; + child = list->data; widget = child->widget; - childWidth = (widget->requisition.width + + gtk_widget_get_child_requisition (widget, &child_requisition); + + childWidth = (child_requisition.width + 2 * child->border_width + child->i_pad_x + child->pad_x); @@ -1105,7 +1121,8 @@ XExpansion (GList *children, gint cavityWidth) } static void -gtk_packer_size_allocate (GtkWidget *widget, GtkAllocation *allocation) +gtk_packer_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) { GtkPacker *packer; GtkContainer *container; @@ -1137,12 +1154,15 @@ gtk_packer_size_allocate (GtkWidget *widget, GtkAllocation *allocation) list = g_list_first (packer->children); while (list != NULL) { + GtkRequisition child_requisition; + child = list->data; + gtk_widget_get_child_requisition (child->widget, &child_requisition); if ((child->side == GTK_SIDE_TOP) || (child->side == GTK_SIDE_BOTTOM)) { frameWidth = cavityWidth; - frameHeight = (child->widget->requisition.height + + frameHeight = (child_requisition.height + 2 * child->border_width + child->pad_y + child->i_pad_y); @@ -1168,7 +1188,7 @@ gtk_packer_size_allocate (GtkWidget *widget, GtkAllocation *allocation) else { frameHeight = cavityHeight; - frameWidth = (child->widget->requisition.width + + frameWidth = (child_requisition.width + 2 * child->border_width + child->pad_x + child->i_pad_x); @@ -1194,13 +1214,13 @@ gtk_packer_size_allocate (GtkWidget *widget, GtkAllocation *allocation) borderX = child->pad_x + 2 * child->border_width; borderY = child->pad_y + 2 * child->border_width; - width = (child->widget->requisition.width + + width = (child_requisition.width + 2 * child->border_width + child->i_pad_x); if ((child->options & GTK_FILL_X) || (width > (frameWidth - borderX))) width = frameWidth - borderX; - height = (child->widget->requisition.height + + height = (child_requisition.height + 2 * child->border_width + child->i_pad_y); if ((child->options & GTK_FILL_Y) || (height > (frameHeight - borderY))) diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index b80a4a04eb..2651acc880 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -581,6 +581,9 @@ gtk_scrolled_window_size_request (GtkWidget *widget, GtkBin *bin; gint extra_height; gint extra_width; + GtkRequisition hscrollbar_requisition; + GtkRequisition vscrollbar_requisition; + GtkRequisition child_requisition; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_SCROLLED_WINDOW (widget)); @@ -593,9 +596,9 @@ gtk_scrolled_window_size_request (GtkWidget *widget, requisition->height = 0; gtk_widget_size_request (scrolled_window->hscrollbar, - &scrolled_window->hscrollbar->requisition); + &hscrollbar_requisition); gtk_widget_size_request (scrolled_window->vscrollbar, - &scrolled_window->vscrollbar->requisition); + &vscrollbar_requisition); if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { @@ -604,10 +607,10 @@ gtk_scrolled_window_size_request (GtkWidget *widget, if (!quark_aux_info) quark_aux_info = g_quark_from_static_string ("gtk-aux-info"); - gtk_widget_size_request (bin->child, &bin->child->requisition); + gtk_widget_size_request (bin->child, &child_requisition); if (scrolled_window->hscrollbar_policy == GTK_POLICY_NEVER) - requisition->width += bin->child->requisition.width; + requisition->width += child_requisition.width; else { GtkWidgetAuxInfo *aux_info; @@ -616,11 +619,11 @@ gtk_scrolled_window_size_request (GtkWidget *widget, if (aux_info && aux_info->width > 0) requisition->width += aux_info->width; else - requisition->width += scrolled_window->vscrollbar->requisition.width; + requisition->width += vscrollbar_requisition.width; } if (scrolled_window->vscrollbar_policy == GTK_POLICY_NEVER) - requisition->height += bin->child->requisition.height; + requisition->height += child_requisition.height; else { GtkWidgetAuxInfo *aux_info; @@ -629,7 +632,7 @@ gtk_scrolled_window_size_request (GtkWidget *widget, if (aux_info && aux_info->height > 0) requisition->height += aux_info->height; else - requisition->height += scrolled_window->hscrollbar->requisition.height; + requisition->height += hscrollbar_requisition.height; } } @@ -639,15 +642,15 @@ gtk_scrolled_window_size_request (GtkWidget *widget, if ((scrolled_window->hscrollbar_policy == GTK_POLICY_AUTOMATIC) || GTK_WIDGET_VISIBLE (scrolled_window->hscrollbar)) { - requisition->width = MAX (requisition->width, scrolled_window->hscrollbar->requisition.width); - extra_height = SCROLLBAR_SPACING (scrolled_window) + scrolled_window->hscrollbar->requisition.height; + requisition->width = MAX (requisition->width, hscrollbar_requisition.width); + extra_height = SCROLLBAR_SPACING (scrolled_window) + hscrollbar_requisition.height; } if ((scrolled_window->vscrollbar_policy == GTK_POLICY_AUTOMATIC) || GTK_WIDGET_VISIBLE (scrolled_window->vscrollbar)) { - requisition->height = MAX (requisition->height, scrolled_window->vscrollbar->requisition.height); - extra_width = SCROLLBAR_SPACING (scrolled_window) + scrolled_window->vscrollbar->requisition.width; + requisition->height = MAX (requisition->height, vscrollbar_requisition.height); + extra_width = SCROLLBAR_SPACING (scrolled_window) + vscrollbar_requisition.width; } requisition->width += GTK_CONTAINER (widget)->border_width * 2 + extra_width; @@ -672,24 +675,32 @@ gtk_scrolled_window_relative_allocation (GtkWidget *widget, if (scrolled_window->vscrollbar_visible) { + GtkRequisition vscrollbar_requisition; + gtk_widget_get_child_requisition (scrolled_window->vscrollbar, + &vscrollbar_requisition); + if (scrolled_window->window_placement == GTK_CORNER_TOP_RIGHT || scrolled_window->window_placement == GTK_CORNER_BOTTOM_RIGHT) - allocation->x += (scrolled_window->vscrollbar->requisition.width + + allocation->x += (vscrollbar_requisition.width + SCROLLBAR_SPACING (scrolled_window)); allocation->width = MAX (1, (gint)allocation->width - - ((gint)scrolled_window->vscrollbar->requisition.width + + ((gint)vscrollbar_requisition.width + (gint)SCROLLBAR_SPACING (scrolled_window))); } if (scrolled_window->hscrollbar_visible) { + GtkRequisition hscrollbar_requisition; + gtk_widget_get_child_requisition (scrolled_window->hscrollbar, + &hscrollbar_requisition); + if (scrolled_window->window_placement == GTK_CORNER_BOTTOM_LEFT || scrolled_window->window_placement == GTK_CORNER_BOTTOM_RIGHT) - allocation->y += (scrolled_window->hscrollbar->requisition.height + + allocation->y += (hscrollbar_requisition.height + SCROLLBAR_SPACING (scrolled_window)); allocation->height = MAX (1, (gint)allocation->height - - ((gint)scrolled_window->hscrollbar->requisition.height + + ((gint)hscrollbar_requisition.height + (gint)SCROLLBAR_SPACING (scrolled_window))); } } @@ -767,6 +778,10 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget, if (scrolled_window->hscrollbar_visible) { + GtkRequisition hscrollbar_requisition; + gtk_widget_get_child_requisition (scrolled_window->hscrollbar, + &hscrollbar_requisition); + if (!GTK_WIDGET_VISIBLE (scrolled_window->hscrollbar)) gtk_widget_show (scrolled_window->hscrollbar); @@ -780,7 +795,7 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget, child_allocation.y = GTK_CONTAINER (scrolled_window)->border_width; child_allocation.width = relative_allocation.width; - child_allocation.height = scrolled_window->hscrollbar->requisition.height; + child_allocation.height = hscrollbar_requisition.height; child_allocation.x += allocation->x; child_allocation.y += allocation->y; @@ -791,9 +806,13 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget, if (scrolled_window->vscrollbar_visible) { + GtkRequisition vscrollbar_requisition; if (!GTK_WIDGET_VISIBLE (scrolled_window->vscrollbar)) gtk_widget_show (scrolled_window->vscrollbar); + gtk_widget_get_child_requisition (scrolled_window->vscrollbar, + &vscrollbar_requisition); + if (scrolled_window->window_placement == GTK_CORNER_TOP_LEFT || scrolled_window->window_placement == GTK_CORNER_BOTTOM_LEFT) child_allocation.x = (relative_allocation.x + @@ -803,7 +822,7 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget, child_allocation.x = GTK_CONTAINER (scrolled_window)->border_width; child_allocation.y = relative_allocation.y; - child_allocation.width = scrolled_window->vscrollbar->requisition.width; + child_allocation.width = vscrollbar_requisition.width; child_allocation.height = relative_allocation.height; child_allocation.x += allocation->x; child_allocation.y += allocation->y; diff --git a/gtk/gtksocket.c b/gtk/gtksocket.c index 1df52ffafa..c673f617e8 100644 --- a/gtk/gtksocket.c +++ b/gtk/gtksocket.c @@ -47,6 +47,8 @@ static GdkFilterReturn gtk_socket_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data); +#define DEBUG_PLUGSOCKET + #ifdef DEBUG_PLUGSOCKET #define DPRINTF(arg) g_print arg #else diff --git a/gtk/gtktable.c b/gtk/gtktable.c index f3e5aca30d..ec4c927aea 100644 --- a/gtk/gtktable.c +++ b/gtk/gtktable.c @@ -919,7 +919,7 @@ gtk_table_size_request_init (GtkTable *table) children = children->next; if (GTK_WIDGET_VISIBLE (child->widget)) - gtk_widget_size_request (child->widget, &child->widget->requisition); + gtk_widget_size_request (child->widget, NULL); } } @@ -939,11 +939,14 @@ gtk_table_size_request_pass1 (GtkTable *table) if (GTK_WIDGET_VISIBLE (child->widget)) { + GtkRequisition child_requisition; + gtk_widget_get_child_requisition (child->widget, &child_requisition); + /* Child spans a single column. */ if (child->left_attach == (child->right_attach - 1)) { - width = child->widget->requisition.width + child->xpadding * 2; + width = child_requisition.width + child->xpadding * 2; table->cols[child->left_attach].requisition = MAX (table->cols[child->left_attach].requisition, width); } @@ -951,7 +954,7 @@ gtk_table_size_request_pass1 (GtkTable *table) */ if (child->top_attach == (child->bottom_attach - 1)) { - height = child->widget->requisition.height + child->ypadding * 2; + height = child_requisition.height + child->ypadding * 2; table->rows[child->top_attach].requisition = MAX (table->rows[child->top_attach].requisition, height); } } @@ -1003,6 +1006,10 @@ gtk_table_size_request_pass3 (GtkTable *table) */ if (child->left_attach != (child->right_attach - 1)) { + GtkRequisition child_requisition; + + gtk_widget_get_child_requisition (child->widget, &child_requisition); + /* Check and see if there is already enough space * for the child. */ @@ -1018,9 +1025,9 @@ gtk_table_size_request_pass3 (GtkTable *table) * its requisition, then divide up the needed space evenly * amongst the columns it spans. */ - if (width < child->widget->requisition.width + child->xpadding * 2) + if (width < child_requisition.width + child->xpadding * 2) { - width = child->widget->requisition.width + child->xpadding * 2 - width; + width = child_requisition.width + child->xpadding * 2 - width; for (col = child->left_attach; col < child->right_attach; col++) { @@ -1035,6 +1042,10 @@ gtk_table_size_request_pass3 (GtkTable *table) */ if (child->top_attach != (child->bottom_attach - 1)) { + GtkRequisition child_requisition; + + gtk_widget_get_child_requisition (child->widget, &child_requisition); + /* Check and see if there is already enough space * for the child. */ @@ -1050,9 +1061,9 @@ gtk_table_size_request_pass3 (GtkTable *table) * its requisition, then divide up the needed space evenly * amongst the columns it spans. */ - if (height < child->widget->requisition.height + child->ypadding * 2) + if (height < child_requisition.height + child->ypadding * 2) { - height = child->widget->requisition.height + child->ypadding * 2 - height; + height = child_requisition.height + child->ypadding * 2 - height; for (row = child->top_attach; row < child->bottom_attach; row++) { @@ -1454,6 +1465,9 @@ gtk_table_size_allocate_pass2 (GtkTable *table) if (GTK_WIDGET_VISIBLE (child->widget)) { + GtkRequisition child_requisition; + gtk_widget_get_child_requisition (child->widget, &child_requisition); + x = GTK_WIDGET (table)->allocation.x + GTK_CONTAINER (table)->border_width; y = GTK_WIDGET (table)->allocation.y + GTK_CONTAINER (table)->border_width; max_width = 0; @@ -1492,7 +1506,7 @@ gtk_table_size_allocate_pass2 (GtkTable *table) } else { - allocation.width = child->widget->requisition.width; + allocation.width = child_requisition.width; allocation.x = x + (max_width - allocation.width) / 2; } @@ -1503,7 +1517,7 @@ gtk_table_size_allocate_pass2 (GtkTable *table) } else { - allocation.height = child->widget->requisition.height; + allocation.height = child_requisition.height; allocation.y = y + (max_height - allocation.height) / 2; } diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c index 546c3e4256..f57412184f 100644 --- a/gtk/gtktoolbar.c +++ b/gtk/gtktoolbar.c @@ -389,6 +389,7 @@ gtk_toolbar_size_request (GtkWidget *widget, gint nbuttons; gint button_maxw, button_maxh; gint widget_maxw, widget_maxh; + GtkRequisition child_requisition; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TOOLBAR (widget)); @@ -423,11 +424,11 @@ gtk_toolbar_size_request (GtkWidget *widget, case GTK_TOOLBAR_CHILD_TOGGLEBUTTON: if (GTK_WIDGET_VISIBLE (child->widget)) { - gtk_widget_size_request (child->widget, &child->widget->requisition); + gtk_widget_size_request (child->widget, &child_requisition); nbuttons++; - button_maxw = MAX (button_maxw, child->widget->requisition.width); - button_maxh = MAX (button_maxh, child->widget->requisition.height); + button_maxw = MAX (button_maxw, child_requisition.width); + button_maxh = MAX (button_maxh, child_requisition.height); } break; @@ -435,15 +436,15 @@ gtk_toolbar_size_request (GtkWidget *widget, case GTK_TOOLBAR_CHILD_WIDGET: if (GTK_WIDGET_VISIBLE (child->widget)) { - gtk_widget_size_request (child->widget, &child->widget->requisition); + gtk_widget_size_request (child->widget, &child_requisition); - widget_maxw = MAX (widget_maxw, child->widget->requisition.width); - widget_maxh = MAX (widget_maxh, child->widget->requisition.height); + widget_maxw = MAX (widget_maxw, child_requisition.width); + widget_maxh = MAX (widget_maxh, child_requisition.height); if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL) - requisition->width += child->widget->requisition.width; + requisition->width += child_requisition.width; else - requisition->height += child->widget->requisition.height; + requisition->height += child_requisition.height; } break; @@ -477,6 +478,7 @@ gtk_toolbar_size_allocate (GtkWidget *widget, GtkToolbarChild *child; GtkToolbarChildSpace *child_space; GtkAllocation alloc; + GtkRequisition child_requisition; gint border_width; g_return_if_fail (widget != NULL); @@ -545,20 +547,22 @@ gtk_toolbar_size_allocate (GtkWidget *widget, if (!GTK_WIDGET_VISIBLE (child->widget)) break; - alloc.width = child->widget->requisition.width; - alloc.height = child->widget->requisition.height; + gtk_widget_get_child_requisition (child->widget, &child_requisition); + + alloc.width = child_requisition.width; + alloc.height = child_requisition.height; if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL) - alloc.y = allocation->y + (allocation->height - child->widget->requisition.height) / 2; + alloc.y = allocation->y + (allocation->height - child_requisition.height) / 2; else - alloc.x = allocation->x + (allocation->width - child->widget->requisition.width) / 2; + alloc.x = allocation->x + (allocation->width - child_requisition.width) / 2; gtk_widget_size_allocate (child->widget, &alloc); if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL) - alloc.x += child->widget->requisition.width; + alloc.x += child_requisition.width; else - alloc.y += child->widget->requisition.height; + alloc.y += child_requisition.height; break; diff --git a/gtk/gtktree.c b/gtk/gtktree.c index 6b1eb162e9..6c56702025 100644 --- a/gtk/gtktree.c +++ b/gtk/gtktree.c @@ -939,7 +939,10 @@ gtk_tree_size_allocate (GtkWidget *widget, if (GTK_WIDGET_VISIBLE (child)) { - child_allocation.height = child->requisition.height; + GtkRequisition child_requisition; + gtk_widget_get_child_requisition (child, &child_requisition); + + child_allocation.height = child_requisition.height; gtk_widget_size_allocate (child, &child_allocation); @@ -965,6 +968,7 @@ gtk_tree_size_request (GtkWidget *widget, GtkTree *tree; GtkWidget *child, *subtree; GList *children; + GtkRequisition child_requisition; g_return_if_fail (widget != NULL); @@ -983,20 +987,20 @@ gtk_tree_size_request (GtkWidget *widget, if (GTK_WIDGET_VISIBLE (child)) { - gtk_widget_size_request (child, &child->requisition); + gtk_widget_size_request (child, &child_requisition); - requisition->width = MAX (requisition->width, child->requisition.width); - requisition->height += child->requisition.height; + requisition->width = MAX (requisition->width, child_requisition.width); + requisition->height += child_requisition.height; if((subtree = GTK_TREE_ITEM(child)->subtree) && GTK_WIDGET_VISIBLE (subtree)) { - gtk_widget_size_request (subtree, &subtree->requisition); + gtk_widget_size_request (subtree, &child_requisition); requisition->width = MAX (requisition->width, - subtree->requisition.width); + child_requisition.width); - requisition->height += subtree->requisition.height; + requisition->height += child_requisition.height; } } } diff --git a/gtk/gtktreeitem.c b/gtk/gtktreeitem.c index 4ac5c362fd..72ad78aee5 100644 --- a/gtk/gtktreeitem.c +++ b/gtk/gtktreeitem.c @@ -485,6 +485,7 @@ gtk_tree_item_size_request (GtkWidget *widget, { GtkBin *bin; GtkTreeItem* item; + GtkRequisition child_requisition; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TREE_ITEM (widget)); @@ -499,16 +500,16 @@ gtk_tree_item_size_request (GtkWidget *widget, if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { - gtk_widget_size_request (bin->child, &bin->child->requisition); + gtk_widget_size_request (bin->child, &child_requisition); - requisition->width += bin->child->requisition.width; + requisition->width += child_requisition.width; gtk_widget_size_request (item->pixmaps_box, &item->pixmaps_box->requisition); requisition->width += item->pixmaps_box->requisition.width + DEFAULT_DELTA + GTK_TREE(widget->parent)->current_indent; - requisition->height += MAX (bin->child->requisition.height, + requisition->height += MAX (child_requisition.height, item->pixmaps_box->requisition.height); } } diff --git a/gtk/gtkvbox.c b/gtk/gtkvbox.c index a4b8d031f9..b5c2e9e3ba 100644 --- a/gtk/gtkvbox.c +++ b/gtk/gtkvbox.c @@ -89,6 +89,7 @@ gtk_vbox_size_request (GtkWidget *widget, { GtkBox *box; GtkBoxChild *child; + GtkRequisition child_requisition; GList *children; gint nvis_children; gint height; @@ -110,19 +111,19 @@ gtk_vbox_size_request (GtkWidget *widget, if (GTK_WIDGET_VISIBLE (child->widget)) { - gtk_widget_size_request (child->widget, &child->widget->requisition); + gtk_widget_size_request (child->widget, &child_requisition); if (box->homogeneous) { - height = child->widget->requisition.height + child->padding * 2; + height = child_requisition.height + child->padding * 2; requisition->height = MAX (requisition->height, height); } else { - requisition->height += child->widget->requisition.height + child->padding * 2; + requisition->height += child_requisition.height + child->padding * 2; } - requisition->width = MAX (requisition->width, child->widget->requisition.width); + requisition->width = MAX (requisition->width, child_requisition.width); nvis_children += 1; } @@ -189,7 +190,7 @@ gtk_vbox_size_allocate (GtkWidget *widget, } else if (nexpand_children > 0) { - height = (gint)allocation->height - (gint)widget->requisition.height; + height = (gint) allocation->height - (gint) widget->requisition.height; extra = height / nexpand_children; } else @@ -200,7 +201,7 @@ gtk_vbox_size_allocate (GtkWidget *widget, y = allocation->y + GTK_CONTAINER (box)->border_width; child_allocation.x = allocation->x + GTK_CONTAINER (box)->border_width; - child_allocation.width = MAX (1, (gint)allocation->width - (gint)GTK_CONTAINER (box)->border_width * 2); + child_allocation.width = MAX (1, (gint) allocation->width - (gint) GTK_CONTAINER (box)->border_width * 2); children = box->children; while (children) @@ -222,7 +223,10 @@ gtk_vbox_size_allocate (GtkWidget *widget, } else { - child_height = child->widget->requisition.height + child->padding * 2; + GtkRequisition child_requisition; + + gtk_widget_get_child_requisition (child->widget, &child_requisition); + child_height = child_requisition.height + child->padding * 2; if (child->expand) { @@ -243,7 +247,10 @@ gtk_vbox_size_allocate (GtkWidget *widget, } else { - child_allocation.height = child->widget->requisition.height; + GtkRequisition child_requisition; + + gtk_widget_get_child_requisition (child->widget, &child_requisition); + child_allocation.height = child_requisition.height; child_allocation.y = y + (child_height - child_allocation.height) / 2; } @@ -263,6 +270,9 @@ gtk_vbox_size_allocate (GtkWidget *widget, if ((child->pack == GTK_PACK_END) && GTK_WIDGET_VISIBLE (child->widget)) { + GtkRequisition child_requisition; + gtk_widget_get_child_requisition (child->widget, &child_requisition); + if (box->homogeneous) { if (nvis_children == 1) @@ -275,7 +285,7 @@ gtk_vbox_size_allocate (GtkWidget *widget, } else { - child_height = child->widget->requisition.height + child->padding * 2; + child_height = child_requisition.height + child->padding * 2; if (child->expand) { @@ -296,7 +306,7 @@ gtk_vbox_size_allocate (GtkWidget *widget, } else { - child_allocation.height = child->widget->requisition.height; + child_allocation.height = child_requisition.height; child_allocation.y = y + (child_height - child_allocation.height) / 2 - child_height; } diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c index 6964206fe1..271e6dc39c 100644 --- a/gtk/gtkviewport.c +++ b/gtk/gtkviewport.c @@ -637,6 +637,7 @@ gtk_viewport_size_request (GtkWidget *widget, { GtkViewport *viewport; GtkBin *bin; + GtkRequisition child_requisition; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_VIEWPORT (widget)); @@ -653,9 +654,9 @@ gtk_viewport_size_request (GtkWidget *widget, if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { - gtk_widget_size_request (bin->child, &bin->child->requisition); - requisition->width += bin->child->requisition.width; - requisition->height += bin->child->requisition.height; + gtk_widget_size_request (bin->child, &child_requisition); + requisition->width += child_requisition.width; + requisition->height += child_requisition.height; } } @@ -719,8 +720,11 @@ gtk_viewport_size_allocate (GtkWidget *widget, if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { + GtkRequisition child_requisition; + gtk_widget_get_child_requisition (bin->child, &child_requisition); + viewport->hadjustment->lower = 0; - viewport->hadjustment->upper = MAX (bin->child->requisition.width, + viewport->hadjustment->upper = MAX (child_requisition.width, child_allocation.width); hval = CLAMP (hval, 0, @@ -728,7 +732,7 @@ gtk_viewport_size_allocate (GtkWidget *widget, viewport->hadjustment->page_size); viewport->vadjustment->lower = 0; - viewport->vadjustment->upper = MAX (bin->child->requisition.height, + viewport->vadjustment->upper = MAX (child_requisition.height, child_allocation.height); vval = CLAMP (vval, 0, diff --git a/gtk/gtkvpaned.c b/gtk/gtkvpaned.c index 15cdc04e29..105257c0b3 100644 --- a/gtk/gtkvpaned.c +++ b/gtk/gtkvpaned.c @@ -96,6 +96,7 @@ gtk_vpaned_size_request (GtkWidget *widget, GtkRequisition *requisition) { GtkPaned *paned; + GtkRequisition child_requisition; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_VPANED (widget)); @@ -107,19 +108,18 @@ gtk_vpaned_size_request (GtkWidget *widget, if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1)) { - gtk_widget_size_request (paned->child1, &paned->child1->requisition); + gtk_widget_size_request (paned->child1, &child_requisition); - requisition->height = paned->child1->requisition.height; - requisition->width = paned->child1->requisition.width; + requisition->height = child_requisition.height; + requisition->width = child_requisition.width; } if (paned->child2 && GTK_WIDGET_VISIBLE (paned->child2)) { - gtk_widget_size_request (paned->child2, &paned->child2->requisition); + gtk_widget_size_request (paned->child2, &child_requisition); - requisition->width = MAX (requisition->width, - paned->child2->requisition.width); - requisition->height += paned->child2->requisition.height; + requisition->width = MAX (requisition->width, child_requisition.width); + requisition->height += child_requisition.height; } requisition->height += GTK_CONTAINER (paned)->border_width * 2 + paned->gutter_size; @@ -131,6 +131,8 @@ gtk_vpaned_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkPaned *paned; + GtkRequisition child1_requisition; + GtkRequisition child2_requisition; GtkAllocation child1_allocation; GtkAllocation child2_allocation; GdkRectangle old_groove_rectangle; @@ -145,12 +147,22 @@ gtk_vpaned_size_allocate (GtkWidget *widget, paned = GTK_PANED (widget); border_width = GTK_CONTAINER (widget)->border_width; + if (paned->child1) + gtk_widget_get_child_requisition (paned->child1, &child1_requisition); + else + child1_requisition.height = 0; + + if (paned->child2) + gtk_widget_get_child_requisition (paned->child2, &child2_requisition); + else + child2_requisition.height = 0; + gtk_paned_compute_position (paned, widget->allocation.height - paned->gutter_size - 2 * border_width, - paned->child1 ? paned->child1->requisition.height : 0, - paned->child2 ? paned->child2->requisition.height : 0); + child1_requisition.height, + child2_requisition.height); /* Move the handle before the children so we don't get extra expose events */ diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index b1d507340d..09794e0d88 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -2346,15 +2346,44 @@ void gtk_widget_size_request (GtkWidget *widget, GtkRequisition *requisition) { - GtkWidgetAuxInfo *aux_info; - g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WIDGET (widget)); +#ifdef G_ENABLE_DEBUG + if (!GTK_WIDGET_TOPLEVEL (widget) && (requisition == &widget->requisition)) + g_warning ("gtk_widget_size_request() called on child widget with widget equal\n to widget->requisition. gtk_widget_set_usize() may not work properly."); +#endif /* G_ENABLE_DEBUG */ + gtk_widget_ref (widget); gtk_widget_ensure_style (widget); gtk_signal_emit (GTK_OBJECT (widget), widget_signals[SIZE_REQUEST], - requisition); + &widget->requisition); + + if (requisition) + gtk_widget_get_child_requisition (widget, requisition); + + gtk_widget_unref (widget); +} + +/***************************************** + * gtk_widget_get_requesition: + * + * arguments: + * + * results: + *****************************************/ + +void +gtk_widget_get_child_requisition (GtkWidget *widget, + GtkRequisition *requisition) +{ + GtkWidgetAuxInfo *aux_info; + + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_WIDGET (widget)); + + *requisition = widget->requisition; + aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), aux_info_key_id); if (aux_info) { @@ -2363,7 +2392,6 @@ gtk_widget_size_request (GtkWidget *widget, if (aux_info->height > 0) requisition->height = aux_info->height; } - gtk_widget_unref (widget); } /***************************************** @@ -3462,7 +3490,7 @@ gtk_widget_set_style_internal (GtkWidget *widget, GtkRequisition old_requisition; old_requisition = widget->requisition; - gtk_widget_size_request (widget, &widget->requisition); + gtk_widget_size_request (widget, NULL); if ((old_requisition.width != widget->requisition.width) || (old_requisition.height != widget->requisition.height)) diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index ac08a6ed95..c547895223 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -456,6 +456,8 @@ void gtk_widget_size_request (GtkWidget *widget, GtkRequisition *requisition); void gtk_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation); +void gtk_widget_get_child_requisition (GtkWidget *widget, + GtkRequisition *requisition); void gtk_widget_add_accelerator (GtkWidget *widget, const gchar *accel_signal, GtkAccelGroup *accel_group, diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index cff0738797..8715ff1aee 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -890,10 +890,12 @@ gtk_window_size_request (GtkWidget *widget, if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { - gtk_widget_size_request (bin->child, &bin->child->requisition); + GtkRequisition child_requisition; + + gtk_widget_size_request (bin->child, &child_requisition); - requisition->width += bin->child->requisition.width; - requisition->height += bin->child->requisition.height; + requisition->width += child_requisition.width; + requisition->height += child_requisition.height; } else { @@ -1320,7 +1322,7 @@ gtk_window_move_resize (GtkWindow *window) if (info && info->width > 0) { - size_changed = size_changed || (width != info->width); + size_changed = size_changed || (width != info->last_width); info->last_width = width; new_width = info->width; } @@ -1332,7 +1334,7 @@ gtk_window_move_resize (GtkWindow *window) if (info && info->height > 0) { - size_changed = size_changed || (height != info->height); + size_changed = size_changed || (height != info->last_height); info->last_height = height; new_height = info->height; } diff --git a/gtk/testgtk.c b/gtk/testgtk.c index d76e0666ab..baced40a84 100644 --- a/gtk/testgtk.c +++ b/gtk/testgtk.c @@ -1571,7 +1571,7 @@ create_handle_box (void) gtk_widget_show (label); handle_box = gtk_handle_box_new (); - gtk_container_add (GTK_CONTAINER (hbox), handle_box); + gtk_box_pack_start (GTK_BOX (hbox), handle_box, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (handle_box), "child_attached", GTK_SIGNAL_FUNC (handle_box_child_signal), @@ -1588,7 +1588,7 @@ create_handle_box (void) gtk_widget_show (toolbar); handle_box = gtk_handle_box_new (); - gtk_container_add (GTK_CONTAINER (hbox), handle_box); + gtk_box_pack_start (GTK_BOX (hbox), handle_box, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (handle_box), "child_attached", GTK_SIGNAL_FUNC (handle_box_child_signal), diff --git a/tests/testgtk.c b/tests/testgtk.c index d76e0666ab..baced40a84 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -1571,7 +1571,7 @@ create_handle_box (void) gtk_widget_show (label); handle_box = gtk_handle_box_new (); - gtk_container_add (GTK_CONTAINER (hbox), handle_box); + gtk_box_pack_start (GTK_BOX (hbox), handle_box, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (handle_box), "child_attached", GTK_SIGNAL_FUNC (handle_box_child_signal), @@ -1588,7 +1588,7 @@ create_handle_box (void) gtk_widget_show (toolbar); handle_box = gtk_handle_box_new (); - gtk_container_add (GTK_CONTAINER (hbox), handle_box); + gtk_box_pack_start (GTK_BOX (hbox), handle_box, FALSE, FALSE, 0); gtk_signal_connect (GTK_OBJECT (handle_box), "child_attached", GTK_SIGNAL_FUNC (handle_box_child_signal), |