[gtk+] button: don't use the border values for padding



commit b1d08fe0e9b79939847b1a072284bff6d26bffd7
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Apr 5 15:35:05 2011 -0400

    button: don't use the border values for padding
    
    It's wrong, and makes it impossible to theme the button properly.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=646882

 gtk/gtkbutton.c |   36 +++++++++++-------------------------
 1 files changed, 11 insertions(+), 25 deletions(-)
---
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index ea19b41..ba121b5 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -1476,23 +1476,19 @@ gtk_button_size_allocate (GtkWidget     *widget,
   GtkWidget *child;
   GtkBorder default_border;
   GtkBorder inner_border;
-  GtkBorder *border;
+  GtkBorder padding;
   gint focus_width;
   gint focus_pad;
 
   context = gtk_widget_get_style_context (widget);
   state = gtk_widget_get_state_flags (widget);
 
-  gtk_button_get_props (button, &default_border, NULL, &inner_border, NULL);
+  gtk_button_get_props (button, &default_border, NULL, &inner_border, &padding, NULL);
   gtk_style_context_get_style (context,
                               "focus-line-width", &focus_width,
                               "focus-padding", &focus_pad,
                               NULL);
 
-  gtk_style_context_get (context, state,
-                         "border-width", &border,
-                         NULL);
-
   gtk_widget_set_allocation (widget, allocation);
 
   if (gtk_widget_get_realized (widget))
@@ -1505,18 +1501,18 @@ gtk_button_size_allocate (GtkWidget     *widget,
   child = gtk_bin_get_child (GTK_BIN (button));
   if (child && gtk_widget_get_visible (child))
     {
-      child_allocation.x = allocation->x + inner_border.left + border->left;
-      child_allocation.y = allocation->y + inner_border.top + border->top;
+      child_allocation.x = allocation->x + inner_border.left + padding.left;
+      child_allocation.y = allocation->y + inner_border.top + padding.top;
 
       child_allocation.width =
 	allocation->width -
-	(border->left + border->right) -
+        (padding.left + padding.right) -
 	inner_border.left -
 	inner_border.right;
 
       child_allocation.height = 
 	allocation->height -
-	(border->top + border->bottom) -
+        (padding.top + padding.bottom) -
 	inner_border.top -
 	inner_border.bottom;
 
@@ -1554,8 +1550,6 @@ gtk_button_size_allocate (GtkWidget     *widget,
 
       gtk_widget_size_allocate (child, &child_allocation);
     }
-
-  gtk_border_free (border);
 }
 
 void
@@ -1582,7 +1576,7 @@ _gtk_button_paint (GtkButton          *button,
   gtk_style_context_save (context);
   gtk_style_context_set_state (context, state);
 
-  gtk_button_get_props (button, &default_border, &default_outside_border, NULL, &interior_focus);
+  gtk_button_get_props (button, &default_border, &default_outside_border, NULL, NULL, &interior_focus);
   gtk_style_context_get_style (context,
                                "focus-line-width", &focus_width,
                                "focus-padding", &focus_pad,
@@ -1934,7 +1928,7 @@ gtk_button_get_size (GtkWidget      *widget,
   GtkWidget *child;
   GtkBorder default_border;
   GtkBorder inner_border;
-  GtkBorder *border;
+  GtkBorder padding;
   gint focus_width;
   gint focus_pad;
   gint minimum, natural;
@@ -1942,28 +1936,22 @@ gtk_button_get_size (GtkWidget      *widget,
   context = gtk_widget_get_style_context (widget);
   state = gtk_widget_get_state_flags (widget);
 
-  gtk_button_get_props (button, &default_border, NULL, &inner_border, NULL);
+  gtk_button_get_props (button, &default_border, NULL, &inner_border, &padding, NULL);
   gtk_style_context_get_style (context,
                                "focus-line-width", &focus_width,
                                "focus-padding", &focus_pad,
                                NULL);
 
-  gtk_style_context_get (context, state,
-                         "border-width", &border,
-                         NULL);
-
   if (orientation == GTK_ORIENTATION_HORIZONTAL)
     {
-      minimum = (border->left + border->right +
-		 inner_border.left + inner_border.right);
+      minimum = inner_border.left + inner_border.right + padding.left + padding.right;
 
       if (gtk_widget_get_can_default (GTK_WIDGET (widget)))
 	minimum += default_border.left + default_border.right;
     }
   else
     {
-      minimum = (border->top + border->bottom +
-		 inner_border.top + inner_border.bottom);
+      minimum = inner_border.top + inner_border.bottom + padding.top + padding.bottom;
 
       if (gtk_widget_get_can_default (GTK_WIDGET (widget)))
 	minimum += default_border.top + default_border.bottom;
@@ -1991,8 +1979,6 @@ gtk_button_get_size (GtkWidget      *widget,
 
   if (natural_size)
     *natural_size = natural;
-
-  gtk_border_free (border);
 }
 
 static void 



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