summaryrefslogtreecommitdiff
path: root/gtk/gtkexpander.c
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2018-03-06 17:36:04 +0100
committerTimm Bäder <mail@baedert.org>2018-03-06 18:12:49 +0100
commitf5e290517a5d1b1430b3489570d2e0a06a2746c1 (patch)
tree8d2afc8d523e33ffb6cc5e3cd39248976856e03d /gtk/gtkexpander.c
parent7dc4669d014607c6f8f7acc9ca91dd76a41e38ed (diff)
downloadgtk+-f5e290517a5d1b1430b3489570d2e0a06a2746c1.tar.gz
expander: fix sizes in resize_toplevel
We can't use gtk_widget_get_allocation for either non-anchored widgets (which happens with the child widget when the expander is unexpanded) nor toplevel windows since that will include the window decorations. Fixes #70 in gtk4
Diffstat (limited to 'gtk/gtkexpander.c')
-rw-r--r--gtk/gtkexpander.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/gtk/gtkexpander.c b/gtk/gtkexpander.c
index 48ab8c50fa..4b7fb14909 100644
--- a/gtk/gtkexpander.c
+++ b/gtk/gtkexpander.c
@@ -723,31 +723,24 @@ gtk_expander_resize_toplevel (GtkExpander *expander)
{
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (expander));
- if (toplevel && gtk_widget_get_realized (toplevel))
+ if (toplevel && GTK_IS_WINDOW (toplevel) &&
+ gtk_widget_get_realized (toplevel))
{
- GtkAllocation toplevel_allocation;
- GtkAllocation child_allocation;
+ int toplevel_width, toplevel_height;
+ int child_height;
- gtk_widget_get_allocation (toplevel, &toplevel_allocation);
- gtk_widget_get_allocation (child, &child_allocation);
+ gtk_widget_measure (child, GTK_ORIENTATION_VERTICAL, -1,
+ &child_height, NULL, NULL, NULL);
+ gtk_window_get_size (GTK_WINDOW (toplevel), &toplevel_width, &toplevel_height);
if (priv->expanded)
- {
- GtkRequisition child_requisition;
-
- gtk_widget_measure (child, GTK_ORIENTATION_VERTICAL, child_allocation.width,
- &child_requisition.height, NULL, NULL, NULL);
-
- toplevel_allocation.height += child_requisition.height;
- }
+ toplevel_height += child_height;
else
- {
- toplevel_allocation.height -= child_allocation.height;
- }
+ toplevel_height -= child_height;
gtk_window_resize (GTK_WINDOW (toplevel),
- toplevel_allocation.width,
- toplevel_allocation.height);
+ toplevel_width,
+ toplevel_height);
}
}
}