From 6f1476edd3fbe31259e59ca3f03a01bf0f8ff67b Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Tue, 5 Mar 2013 10:55:41 -0500 Subject: [PATCH] GtkBubbleWindow: allocate CSS borders and paddings --- gtk/gtkbubblewindow.c | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/gtk/gtkbubblewindow.c b/gtk/gtkbubblewindow.c index 82e294a6b..454c63020 100644 --- a/gtk/gtkbubblewindow.c +++ b/gtk/gtkbubblewindow.c @@ -445,6 +445,25 @@ gtk_bubble_window_draw (GtkWidget *widget, return TRUE; } +static void +get_padding_and_border (GtkWidget *widget, + GtkBorder *border) +{ + GtkStyleContext *context; + GtkStateFlags state; + GtkBorder tmp; + + context = gtk_widget_get_style_context (widget); + state = gtk_widget_get_state_flags (widget); + + gtk_style_context_get_padding (context, state, border); + gtk_style_context_get_border (context, state, &tmp); + border->top += tmp.top; + border->right += tmp.right; + border->bottom += tmp.bottom; + border->left += tmp.left; +} + static void gtk_bubble_window_get_preferred_width (GtkWidget *widget, gint *minimum_width, @@ -453,6 +472,7 @@ gtk_bubble_window_get_preferred_width (GtkWidget *widget, GtkBubbleWindowPrivate *priv; GtkWidget *child; gint min, nat; + GtkBorder border; priv = GTK_BUBBLE_WINDOW (widget)->priv; child = gtk_bin_get_child (GTK_BIN (widget)); @@ -461,6 +481,10 @@ gtk_bubble_window_get_preferred_width (GtkWidget *widget, if (child) gtk_widget_get_preferred_width (child, &min, &nat); + get_padding_and_border (widget, &border); + min += border.left + border.right; + nat += border.left + border.right; + if (!POS_IS_VERTICAL (priv->final_position)) { min += TAIL_HEIGHT; @@ -482,13 +506,18 @@ gtk_bubble_window_get_preferred_height (GtkWidget *widget, GtkBubbleWindowPrivate *priv; GtkWidget *child; gint min, nat; + GtkBorder border; priv = GTK_BUBBLE_WINDOW (widget)->priv; child = gtk_bin_get_child (GTK_BIN (widget)); min = nat = 0; if (child) - gtk_widget_get_preferred_height (child, &min, &nat); + gtk_widget_get_preferred_height (child, &min, &nat); + + get_padding_and_border (widget, &border); + min += border.top + border.bottom; + nat += border.top + border.bottom; if (POS_IS_VERTICAL (priv->final_position)) { @@ -517,10 +546,14 @@ gtk_bubble_window_size_allocate (GtkWidget *widget, if (child) { GtkAllocation child_alloc; + GtkBorder border; + + get_padding_and_border (widget, &border); - child_alloc.x = child_alloc.y = 0; - child_alloc.width = allocation->width; - child_alloc.height = allocation->height; + child_alloc.x = border.left; + child_alloc.y = border.top; + child_alloc.width = allocation->width - border.left - border.right; + child_alloc.height = allocation->height - border.top - border.bottom; if (POS_IS_VERTICAL (priv->final_position)) child_alloc.height -= TAIL_HEIGHT; -- 2.43.2