[patch] gtkbutton.c, gtktext.c - minor bugs




The following patch fixes a problem in gtkbutton.c where a button
with borderwidth != 0 shrinks every time gtk_widget_check_resize
is called. (Because the code subtracted the border width from
the allocation when gtk_button_size_allocate was called.)

There's also a fix for a typo I noticed in gtktext.c.

*** ../../gtk+-orig/gtk/gtkbutton.c	Fri Jun  6 03:02:01 1997
--- ./gtkbutton.c	Thu Jul 24 00:35:31 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))
  	{
***************
*** 450,457 ****
      {
        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))
  	{
***************
*** 513,520 ****
  
        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))
  	{
***************
*** 581,588 ****
      {
        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))
  	{
*** ../../gtk+-orig/gtk/gtktext.c	Fri Jun  6 03:01:49 1997
--- ./gtktext.c	Thu Jul 24 00:41:14 1997
***************
*** 456,462 ****
    if (text->vadj != vadj)
      {
        text->vadj = vadj;
!       gtk_object_ref (GTK_OBJECT (text->hadj));
  
        gtk_signal_connect (GTK_OBJECT (text->vadj), "changed",
  			  (GtkSignalFunc) gtk_text_adjustment,
--- 456,462 ----
    if (text->vadj != vadj)
      {
        text->vadj = vadj;
!       gtk_object_ref (GTK_OBJECT (text->vadj));
  
        gtk_signal_connect (GTK_OBJECT (text->vadj), "changed",
  			  (GtkSignalFunc) gtk_text_adjustment,



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