[patch] Shrinking buttons




This is a pretty big patch to fix a small problem:

Namely, in gtk_button.c, the border width is subtracted from the
stored allocation. However, in several other places, size_allocate
is called with the widgets current allocation, resulting in the border
being subtracted off twice (three times ...) The change below is
simply not to subtract off the border, which means computing much of
the geometry a bit differently.

Regards,
                                        Owen

*** gtk+owt-071997/gtk/gtkbutton.c	Sat Jul 19 21:44:33 1997
--- gtk+owt-081197/gtk/gtkbutton.c	Mon Jul 28 13:06:32 1997
***************
*** 392,414 ****
  {
    GtkButton *button;
    GtkAllocation child_allocation;
  
    g_return_if_fail (widget != NULL);
    g_return_if_fail (GTK_IS_BUTTON (widget));
    g_return_if_fail (allocation != NULL);
  
    widget->allocation = *allocation;
!   widget->allocation.x += GTK_CONTAINER (widget)->border_width;
!   widget->allocation.y += GTK_CONTAINER (widget)->border_width;
!   widget->allocation.width -= GTK_CONTAINER (widget)->border_width * 2;
!   widget->allocation.height -= GTK_CONTAINER (widget)->border_width * 2;
  
    if (GTK_WIDGET_REALIZED (widget))
      gdk_window_move_resize (widget->window,
! 			    widget->allocation.x,
! 			    widget->allocation.y,
! 			    widget->allocation.width,
! 			    widget->allocation.height);
  
    button = GTK_BUTTON (widget);
  
--- 392,412 ----
  {
    GtkButton *button;
    GtkAllocation child_allocation;
+   gint border_width;
  
    g_return_if_fail (widget != NULL);
    g_return_if_fail (GTK_IS_BUTTON (widget));
    g_return_if_fail (allocation != NULL);
  
    widget->allocation = *allocation;
!   border_width = GTK_CONTAINER (widget)->border_width;
  
    if (GTK_WIDGET_REALIZED (widget))
      gdk_window_move_resize (widget->window,
! 			    widget->allocation.x + border_width,
! 			    widget->allocation.y + border_width,
! 			    widget->allocation.width - border_width * 2,
! 			    widget->allocation.height - border_width * 2);
  
    button = GTK_BUTTON (widget);
  
***************
*** 417,424 ****
        child_allocation.x = (CHILD_SPACING + GTK_WIDGET (widget)->style->klass->xthickness);
        child_allocation.y = (CHILD_SPACING + GTK_WIDGET (widget)->style->klass->ythickness);
  
!       child_allocation.width = widget->allocation.width - child_allocation.x * 2;
!       child_allocation.height = widget->allocation.height - child_allocation.y * 2;
  
        if (GTK_WIDGET_CAN_DEFAULT (button))
  	{
--- 415,424 ----
        child_allocation.x = (CHILD_SPACING + GTK_WIDGET (widget)->style->klass->xthickness);
        child_allocation.y = (CHILD_SPACING + GTK_WIDGET (widget)->style->klass->ythickness);
  
!       child_allocation.width = widget->allocation.width - child_allocation.x * 2 -
! 	                         border_width * 2;
!       child_allocation.height = widget->allocation.height - child_allocation.y * 2 -
! 	                          border_width * 2;
  
        if (GTK_WIDGET_CAN_DEFAULT (button))
  	{
***************
*** 451,458 ****
      {
        restrict.x = GTK_WIDGET (widget)->style->klass->xthickness;
        restrict.y = GTK_WIDGET (widget)->style->klass->ythickness;
!       restrict.width = (GTK_WIDGET (widget)->allocation.width - restrict.x * 2);
!       restrict.height = (GTK_WIDGET (widget)->allocation.height - restrict.y * 2);
  
        if (GTK_WIDGET_CAN_DEFAULT (widget))
  	{
--- 451,460 ----
      {
        restrict.x = GTK_WIDGET (widget)->style->klass->xthickness;
        restrict.y = GTK_WIDGET (widget)->style->klass->ythickness;
!       restrict.width = (GTK_WIDGET (widget)->allocation.width - restrict.x * 2 -
! 			GTK_CONTAINER (widget)->border_width * 2);
!       restrict.height = (GTK_WIDGET (widget)->allocation.height - restrict.y * 2 -
! 			 GTK_CONTAINER (widget)->border_width * 2);
  
        if (GTK_WIDGET_CAN_DEFAULT (widget))
  	{
***************
*** 518,525 ****
  
        x = 0;
        y = 0;
!       width = widget->allocation.width;
!       height = widget->allocation.height;
  
        if (GTK_WIDGET_CAN_DEFAULT (widget))
  	{
--- 520,527 ----
  
        x = 0;
        y = 0;
!       width = widget->allocation.width - GTK_CONTAINER (widget)->border_width * 2;
!       height = widget->allocation.height - GTK_CONTAINER (widget)->border_width * 2; 
  
        if (GTK_WIDGET_CAN_DEFAULT (widget))
  	{
***************
*** 590,597 ****
      {
        x = 0;
        y = 0;
!       width = widget->allocation.width;
!       height = widget->allocation.height;
  
        if (GTK_WIDGET_HAS_DEFAULT (widget))
  	{
--- 592,599 ----
      {
        x = 0;
        y = 0;
!       width = widget->allocation.width - GTK_CONTAINER (widget)->border_width * 2;
!       height = widget->allocation.height - GTK_CONTAINER (widget)->border_width * 2; 
  
        if (GTK_WIDGET_HAS_DEFAULT (widget))
  	{



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