[patch] Fixes to gtktable and gtkwindow




This patch corrects two problems:

1) When the negotiated size of a GtkWindow changes, the window manager
   hints aren't reset, so resizing behavior can be incorrect.

2) gtktable.c used to change its child's widgets allocation directly:
   this caused the problems where labels, etc., would be drawn
   multiple times slightly offset.

Regards,
                                        Owen

*** gtktable.c.old	Fri Aug  1 13:35:20 1997
--- gtktable.c	Fri Aug  1 13:36:45 1997
***************
*** 47,53 ****
  static void gtk_table_size_allocate_init  (GtkTable *table);
  static void gtk_table_size_allocate_pass1 (GtkTable *table);
  static void gtk_table_size_allocate_pass2 (GtkTable *table);
- static void gtk_table_size_allocate_pass3 (GtkTable *table);
  
  
  static GtkContainerClass *parent_class = NULL;
--- 47,52 ----
***************
*** 484,490 ****
    gtk_table_size_allocate_init (table);
    gtk_table_size_allocate_pass1 (table);
    gtk_table_size_allocate_pass2 (table);
-   gtk_table_size_allocate_pass3 (table);
  }
  
  static void
--- 483,488 ----
***************
*** 1100,1105 ****
--- 1098,1104 ----
    gint max_height;
    gint x, y;
    gint row, col;
+   GtkAllocation allocation;
  
    children = table->children;
    while (children)
***************
*** 1142,1183 ****
  
            if (child->xfill)
              {
!               child->widget->allocation.width = max_width - child->xpadding * 2;
!               child->widget->allocation.x = x + (max_width - child->widget->allocation.width) / 2;
              }
            else
              {
!               child->widget->allocation.width = child->widget->requisition.width;
!               child->widget->allocation.x = x + (max_width - child->widget->allocation.width) / 2;
              }
  
            if (child->yfill)
              {
!               child->widget->allocation.height = max_height - child->ypadding * 2;
!               child->widget->allocation.y = y + (max_height - child->widget->allocation.height) / 2;
              }
            else
              {
!               child->widget->allocation.height = child->widget->requisition.height;
!               child->widget->allocation.y = y + (max_height - child->widget->allocation.height) / 2;
              }
-         }
-     }
- }
- 
- static void
- gtk_table_size_allocate_pass3 (GtkTable *table)
- {
-   GtkTableChild *child;
-   GList *children;
  
!   children = table->children;
!   while (children)
!     {
!       child = children->data;
!       children = children->next;
! 
!       if (GTK_WIDGET_VISIBLE (child->widget))
!         gtk_widget_size_allocate (child->widget, &child->widget->allocation);
      }
  }
--- 1141,1167 ----
  
            if (child->xfill)
              {
!               allocation.width = max_width - child->xpadding * 2;
!               allocation.x = x + (max_width - allocation.width) / 2;
              }
            else
              {
!               allocation.width = child->widget->requisition.width;
!               allocation.x = x + (max_width - allocation.width) / 2;
              }
  
            if (child->yfill)
              {
!               allocation.height = max_height - child->ypadding * 2;
!               allocation.y = y + (max_height - allocation.height) / 2;
              }
            else
              {
!               allocation.height = child->widget->requisition.height;
!               allocation.y = y + (max_height - allocation.height) / 2;
              }
  
! 	  gtk_widget_size_allocate (child->widget, &allocation);
!         }
      }
  }
*** gtkwindow.c.old	Fri Aug  1 12:12:36 1997
--- gtkwindow.c	Fri Aug  1 12:19:19 1997
***************
*** 921,928 ****
--- 921,937 ----
      {
        window = GTK_WINDOW (widget);
  
+       /* Remember old size, so know if we have to reset hints */
+       width = widget->requisition.width;
+       height = widget->requisition.height;
+ 
        gtk_widget_size_request (widget, &widget->requisition);
  
+       if (GTK_WIDGET_MAPPED (widget) &&
+ 	  (width != widget->requisition.width ||
+ 	   height != widget->requisition.width))
+ 	gtk_window_set_hints (widget, &widget->requisition);
+       
        width = widget->requisition.width;
        height = widget->requisition.height;
  
*** gtkruler.c.old	Fri Aug  1 13:39:28 1997
--- gtkruler.c	Fri Aug  1 13:40:13 1997
***************
*** 218,223 ****
--- 218,224 ----
    g_return_if_fail (GTK_IS_RULER (widget));
  
    ruler = GTK_RULER (widget);
+   widget->allocation = *allocation;
  
    if (GTK_WIDGET_REALIZED (widget))
      {




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