[gtk+] popover: Fix hfw/wfh size request



commit 2c04941c5cca73740fe7b6ae3c49e5b4ab195c71
Author: Timm Bäder <mail baedert org>
Date:   Thu Sep 1 15:16:58 2016 +0200

    popover: Fix hfw/wfh size request
    
    Since we're using _get_rect_coords in size-allocate when allocating the
    size of the child widget, use the newly introduced _get_rect_for_size to
    calculate the difference between the passed size_for and the one we're
    supposed to pass on to the child widget.

 gtk/gtkpopover.c |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index a311486..2e2f818 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -1309,8 +1309,8 @@ gtk_popover_get_preferred_width_for_height (GtkWidget *widget,
                                             gint      *natural_width)
 {
   GtkPopover *popover = GTK_POPOVER (widget);
-  GtkPopoverPrivate *priv = popover->priv;
   GtkWidget *child;
+  GdkRectangle child_rect;
   gint min, nat, extra, minimal_size;
   gint child_height;
   GtkBorder border, margin;
@@ -1318,10 +1318,9 @@ gtk_popover_get_preferred_width_for_height (GtkWidget *widget,
   child = gtk_bin_get_child (GTK_BIN (widget));
   min = nat = 0;
 
-  child_height = height;
+  gtk_popover_get_rect_for_size (popover, 0, height, &child_rect);
+  child_height = child_rect.height;
 
-  if (POS_IS_VERTICAL (priv->preferred_position))
-    child_height -= TAIL_HEIGHT;
 
   get_padding_and_border (widget, &border);
   get_margin (widget, &margin);
@@ -1380,8 +1379,8 @@ gtk_popover_get_preferred_height_for_width (GtkWidget *widget,
                                             gint      *natural_height)
 {
   GtkPopover *popover = GTK_POPOVER (widget);
-  GtkPopoverPrivate *priv = popover->priv;
   GtkWidget *child;
+  GdkRectangle child_rect;
   gint min, nat, extra, minimal_size;
   gint child_width;
   GtkBorder border, margin;
@@ -1389,13 +1388,12 @@ gtk_popover_get_preferred_height_for_width (GtkWidget *widget,
   child = gtk_bin_get_child (GTK_BIN (widget));
   min = nat = 0;
 
-  child_width = width;
-
-  if (!POS_IS_VERTICAL (priv->preferred_position))
-    child_width -= TAIL_HEIGHT;
-
   get_padding_and_border (widget, &border);
   get_margin (widget, &margin);
+
+  gtk_popover_get_rect_for_size (popover, width, 0, &child_rect);
+  child_width = child_rect.width;
+
   child_width -= border.left + border.right;
   minimal_size = get_minimal_size (popover, GTK_ORIENTATION_VERTICAL);
   if (child)


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