GtkBubbleWindow: allocate CSS borders and paddings

This commit is contained in:
Cosimo Cecchi 2013-03-05 10:55:41 -05:00 committed by Matthias Clasen
parent e1edc998a2
commit 6f1476edd3

View File

@ -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;
child_alloc.x = child_alloc.y = 0;
child_alloc.width = allocation->width;
child_alloc.height = allocation->height;
get_padding_and_border (widget, &border);
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;