summaryrefslogtreecommitdiff
path: root/gtk/gtkscrolledwindow.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>1999-02-10 02:35:09 +0000
committerOwen Taylor <otaylor@src.gnome.org>1999-02-10 02:35:09 +0000
commitd1bda8d56232ff0431796add4029e129f877fd6a (patch)
tree63c722c3ed4b8a886242bc78ae78dae1811c6b3a /gtk/gtkscrolledwindow.c
parent84d9f5f9a13d52cd91bffc6230445d1e0ac73431 (diff)
downloadgtk+-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.
Diffstat (limited to 'gtk/gtkscrolledwindow.c')
-rw-r--r--gtk/gtkscrolledwindow.c53
1 files changed, 36 insertions, 17 deletions
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;