]> Pileus Git - ~andy/gtk/commitdiff
button: don't use the border values for padding
authorCosimo Cecchi <cosimoc@gnome.org>
Tue, 5 Apr 2011 19:35:05 +0000 (15:35 -0400)
committerCosimo Cecchi <cosimoc@gnome.org>
Tue, 12 Apr 2011 21:14:31 +0000 (17:14 -0400)
It's wrong, and makes it impossible to theme the button properly.

https://bugzilla.gnome.org/show_bug.cgi?id=646882

gtk/gtkbutton.c

index ea19b4180210d38c6895548694ab1509e9f6b708..ba121b5e6271dce6efaafe80e8cc263271e198fb 100644 (file)
@@ -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