]> Pileus Git - ~andy/gtk/commitdiff
GtkBubbleWindow: allocate CSS borders and paddings
authorCosimo Cecchi <cosimoc@gnome.org>
Tue, 5 Mar 2013 15:55:41 +0000 (10:55 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 5 Mar 2013 21:48:01 +0000 (16:48 -0500)
gtk/gtkbubblewindow.c

index 82e294a6badf68fa761889b21971440995cc7f6e..454c63020e40f8cd1320708547e964f69a47c2df 100644 (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;
+
+      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;