[gtk+/touch-selections] GtkBubbleWindow: allocate CSS borders and paddings



commit 314fdec2b2bbc70250da837d587f03705158fddd
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Mar 5 10:55:41 2013 -0500

    GtkBubbleWindow: allocate CSS borders and paddings

 gtk/gtkbubblewindow.c |   41 +++++++++++++++++++++++++++++++++++++----
 1 files changed, 37 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkbubblewindow.c b/gtk/gtkbubblewindow.c
index 82e294a..454c630 100644
--- a/gtk/gtkbubblewindow.c
+++ b/gtk/gtkbubblewindow.c
@@ -446,6 +446,25 @@ gtk_bubble_window_draw (GtkWidget *widget,
 }
 
 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,
                                        gint      *natural_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;


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