Blame gtk/gtktable.c

Packit Service fb6fa5
/* GTK - The GIMP Toolkit
Packit Service fb6fa5
 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * This library is free software; you can redistribute it and/or
Packit Service fb6fa5
 * modify it under the terms of the GNU Lesser General Public
Packit Service fb6fa5
 * License as published by the Free Software Foundation; either
Packit Service fb6fa5
 * version 2 of the License, or (at your option) any later version.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * This library is distributed in the hope that it will be useful,
Packit Service fb6fa5
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service fb6fa5
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
Packit Service fb6fa5
 * Lesser General Public License for more details.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * You should have received a copy of the GNU Lesser General Public
Packit Service fb6fa5
 * License along with this library; if not, write to the
Packit Service fb6fa5
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Packit Service fb6fa5
 * Boston, MA 02111-1307, USA.
Packit Service fb6fa5
 */
Packit Service fb6fa5
Packit Service fb6fa5
/*
Packit Service fb6fa5
 * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
Packit Service fb6fa5
 * file for a list of people on the GTK+ Team.  See the ChangeLog
Packit Service fb6fa5
 * files for a list of changes.  These files are distributed with
Packit Service fb6fa5
 * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
Packit Service fb6fa5
 */
Packit Service fb6fa5
Packit Service fb6fa5
#include "config.h"
Packit Service fb6fa5
#include "gtktable.h"
Packit Service fb6fa5
#include "gtkprivate.h"
Packit Service fb6fa5
#include "gtkintl.h"
Packit Service fb6fa5
#include "gtkalias.h"
Packit Service fb6fa5
Packit Service fb6fa5
enum
Packit Service fb6fa5
{
Packit Service fb6fa5
  PROP_0,
Packit Service fb6fa5
  PROP_N_ROWS,
Packit Service fb6fa5
  PROP_N_COLUMNS,
Packit Service fb6fa5
  PROP_COLUMN_SPACING,
Packit Service fb6fa5
  PROP_ROW_SPACING,
Packit Service fb6fa5
  PROP_HOMOGENEOUS
Packit Service fb6fa5
};
Packit Service fb6fa5
Packit Service fb6fa5
enum
Packit Service fb6fa5
{
Packit Service fb6fa5
  CHILD_PROP_0,
Packit Service fb6fa5
  CHILD_PROP_LEFT_ATTACH,
Packit Service fb6fa5
  CHILD_PROP_RIGHT_ATTACH,
Packit Service fb6fa5
  CHILD_PROP_TOP_ATTACH,
Packit Service fb6fa5
  CHILD_PROP_BOTTOM_ATTACH,
Packit Service fb6fa5
  CHILD_PROP_X_OPTIONS,
Packit Service fb6fa5
  CHILD_PROP_Y_OPTIONS,
Packit Service fb6fa5
  CHILD_PROP_X_PADDING,
Packit Service fb6fa5
  CHILD_PROP_Y_PADDING
Packit Service fb6fa5
};
Packit Service fb6fa5
  
Packit Service fb6fa5
Packit Service fb6fa5
static void gtk_table_finalize	    (GObject	    *object);
Packit Service fb6fa5
static void gtk_table_size_request  (GtkWidget	    *widget,
Packit Service fb6fa5
				     GtkRequisition *requisition);
Packit Service fb6fa5
static void gtk_table_size_allocate (GtkWidget	    *widget,
Packit Service fb6fa5
				     GtkAllocation  *allocation);
Packit Service fb6fa5
static void gtk_table_add	    (GtkContainer   *container,
Packit Service fb6fa5
				     GtkWidget	    *widget);
Packit Service fb6fa5
static void gtk_table_remove	    (GtkContainer   *container,
Packit Service fb6fa5
				     GtkWidget	    *widget);
Packit Service fb6fa5
static void gtk_table_forall	    (GtkContainer   *container,
Packit Service fb6fa5
				     gboolean	     include_internals,
Packit Service fb6fa5
				     GtkCallback     callback,
Packit Service fb6fa5
				     gpointer	     callback_data);
Packit Service fb6fa5
static void gtk_table_get_property  (GObject         *object,
Packit Service fb6fa5
				     guint            prop_id,
Packit Service fb6fa5
				     GValue          *value,
Packit Service fb6fa5
				     GParamSpec      *pspec);
Packit Service fb6fa5
static void gtk_table_set_property  (GObject         *object,
Packit Service fb6fa5
				     guint            prop_id,
Packit Service fb6fa5
				     const GValue    *value,
Packit Service fb6fa5
				     GParamSpec      *pspec);
Packit Service fb6fa5
static void gtk_table_set_child_property (GtkContainer    *container,
Packit Service fb6fa5
					  GtkWidget       *child,
Packit Service fb6fa5
					  guint            property_id,
Packit Service fb6fa5
					  const GValue    *value,
Packit Service fb6fa5
					  GParamSpec      *pspec);
Packit Service fb6fa5
static void gtk_table_get_child_property (GtkContainer    *container,
Packit Service fb6fa5
					  GtkWidget       *child,
Packit Service fb6fa5
					  guint            property_id,
Packit Service fb6fa5
					  GValue          *value,
Packit Service fb6fa5
					  GParamSpec      *pspec);
Packit Service fb6fa5
static GType gtk_table_child_type   (GtkContainer   *container);
Packit Service fb6fa5
Packit Service fb6fa5
Packit Service fb6fa5
static void gtk_table_size_request_init	 (GtkTable *table);
Packit Service fb6fa5
static void gtk_table_size_request_pass1 (GtkTable *table);
Packit Service fb6fa5
static void gtk_table_size_request_pass2 (GtkTable *table);
Packit Service fb6fa5
static void gtk_table_size_request_pass3 (GtkTable *table);
Packit Service fb6fa5
Packit Service fb6fa5
static void gtk_table_size_allocate_init  (GtkTable *table);
Packit Service fb6fa5
static void gtk_table_size_allocate_pass1 (GtkTable *table);
Packit Service fb6fa5
static void gtk_table_size_allocate_pass2 (GtkTable *table);
Packit Service fb6fa5
Packit Service fb6fa5
Packit Service fb6fa5
G_DEFINE_TYPE (GtkTable, gtk_table, GTK_TYPE_CONTAINER)
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_table_class_init (GtkTableClass *class)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GObjectClass *gobject_class = G_OBJECT_CLASS (class);
Packit Service fb6fa5
  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
Packit Service fb6fa5
  GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
Packit Service fb6fa5
  
Packit Service fb6fa5
  gobject_class->finalize = gtk_table_finalize;
Packit Service fb6fa5
Packit Service fb6fa5
  gobject_class->get_property = gtk_table_get_property;
Packit Service fb6fa5
  gobject_class->set_property = gtk_table_set_property;
Packit Service fb6fa5
  
Packit Service fb6fa5
  widget_class->size_request = gtk_table_size_request;
Packit Service fb6fa5
  widget_class->size_allocate = gtk_table_size_allocate;
Packit Service fb6fa5
  
Packit Service fb6fa5
  container_class->add = gtk_table_add;
Packit Service fb6fa5
  container_class->remove = gtk_table_remove;
Packit Service fb6fa5
  container_class->forall = gtk_table_forall;
Packit Service fb6fa5
  container_class->child_type = gtk_table_child_type;
Packit Service fb6fa5
  container_class->set_child_property = gtk_table_set_child_property;
Packit Service fb6fa5
  container_class->get_child_property = gtk_table_get_child_property;
Packit Service fb6fa5
  
Packit Service fb6fa5
Packit Service fb6fa5
  g_object_class_install_property (gobject_class,
Packit Service fb6fa5
                                   PROP_N_ROWS,
Packit Service fb6fa5
                                   g_param_spec_uint ("n-rows",
Packit Service fb6fa5
						     P_("Rows"),
Packit Service fb6fa5
						     P_("The number of rows in the table"),
Packit Service fb6fa5
						     1,
Packit Service fb6fa5
						     65535,
Packit Service fb6fa5
						     1,
Packit Service fb6fa5
						     GTK_PARAM_READWRITE));
Packit Service fb6fa5
  g_object_class_install_property (gobject_class,
Packit Service fb6fa5
                                   PROP_N_COLUMNS,
Packit Service fb6fa5
                                   g_param_spec_uint ("n-columns",
Packit Service fb6fa5
						     P_("Columns"),
Packit Service fb6fa5
						     P_("The number of columns in the table"),
Packit Service fb6fa5
						     1,
Packit Service fb6fa5
						     65535,
Packit Service fb6fa5
						     1,
Packit Service fb6fa5
						     GTK_PARAM_READWRITE));
Packit Service fb6fa5
  g_object_class_install_property (gobject_class,
Packit Service fb6fa5
                                   PROP_ROW_SPACING,
Packit Service fb6fa5
                                   g_param_spec_uint ("row-spacing",
Packit Service fb6fa5
						     P_("Row spacing"),
Packit Service fb6fa5
						     P_("The amount of space between two consecutive rows"),
Packit Service fb6fa5
						     0,
Packit Service fb6fa5
						     65535,
Packit Service fb6fa5
						     0,
Packit Service fb6fa5
						     GTK_PARAM_READWRITE));
Packit Service fb6fa5
  g_object_class_install_property (gobject_class,
Packit Service fb6fa5
                                   PROP_COLUMN_SPACING,
Packit Service fb6fa5
                                   g_param_spec_uint ("column-spacing",
Packit Service fb6fa5
						     P_("Column spacing"),
Packit Service fb6fa5
						     P_("The amount of space between two consecutive columns"),
Packit Service fb6fa5
						     0,
Packit Service fb6fa5
						     65535,
Packit Service fb6fa5
						     0,
Packit Service fb6fa5
						     GTK_PARAM_READWRITE));
Packit Service fb6fa5
  g_object_class_install_property (gobject_class,
Packit Service fb6fa5
                                   PROP_HOMOGENEOUS,
Packit Service fb6fa5
                                   g_param_spec_boolean ("homogeneous",
Packit Service fb6fa5
							 P_("Homogeneous"),
Packit Service fb6fa5
							 P_("If TRUE, the table cells are all the same width/height"),
Packit Service fb6fa5
							 FALSE,
Packit Service fb6fa5
							 GTK_PARAM_READWRITE));
Packit Service fb6fa5
Packit Service fb6fa5
  gtk_container_class_install_child_property (container_class,
Packit Service fb6fa5
					      CHILD_PROP_LEFT_ATTACH,
Packit Service fb6fa5
					      g_param_spec_uint ("left-attach", 
Packit Service fb6fa5
								 P_("Left attachment"), 
Packit Service fb6fa5
								 P_("The column number to attach the left side of the child to"),
Packit Service fb6fa5
								 0, 65535, 0,
Packit Service fb6fa5
								 GTK_PARAM_READWRITE));
Packit Service fb6fa5
  gtk_container_class_install_child_property (container_class,
Packit Service fb6fa5
					      CHILD_PROP_RIGHT_ATTACH,
Packit Service fb6fa5
					      g_param_spec_uint ("right-attach", 
Packit Service fb6fa5
								 P_("Right attachment"), 
Packit Service fb6fa5
								 P_("The column number to attach the right side of a child widget to"),
Packit Service fb6fa5
								 1, 65535, 1,
Packit Service fb6fa5
								 GTK_PARAM_READWRITE));
Packit Service fb6fa5
  gtk_container_class_install_child_property (container_class,
Packit Service fb6fa5
					      CHILD_PROP_TOP_ATTACH,
Packit Service fb6fa5
					      g_param_spec_uint ("top-attach", 
Packit Service fb6fa5
								 P_("Top attachment"), 
Packit Service fb6fa5
								 P_("The row number to attach the top of a child widget to"),
Packit Service fb6fa5
								 0, 65535, 0,
Packit Service fb6fa5
								 GTK_PARAM_READWRITE));
Packit Service fb6fa5
  gtk_container_class_install_child_property (container_class,
Packit Service fb6fa5
					      CHILD_PROP_BOTTOM_ATTACH,
Packit Service fb6fa5
					      g_param_spec_uint ("bottom-attach",
Packit Service fb6fa5
								 P_("Bottom attachment"), 
Packit Service fb6fa5
								 P_("The row number to attach the bottom of the child to"),
Packit Service fb6fa5
								 1, 65535, 1,
Packit Service fb6fa5
								 GTK_PARAM_READWRITE));
Packit Service fb6fa5
  gtk_container_class_install_child_property (container_class,
Packit Service fb6fa5
					      CHILD_PROP_X_OPTIONS,
Packit Service fb6fa5
					      g_param_spec_flags ("x-options", 
Packit Service fb6fa5
								  P_("Horizontal options"), 
Packit Service fb6fa5
								  P_("Options specifying the horizontal behaviour of the child"),
Packit Service fb6fa5
								  GTK_TYPE_ATTACH_OPTIONS, GTK_EXPAND | GTK_FILL,
Packit Service fb6fa5
								  GTK_PARAM_READWRITE));
Packit Service fb6fa5
  gtk_container_class_install_child_property (container_class,
Packit Service fb6fa5
					      CHILD_PROP_Y_OPTIONS,
Packit Service fb6fa5
					      g_param_spec_flags ("y-options", 
Packit Service fb6fa5
								  P_("Vertical options"), 
Packit Service fb6fa5
								  P_("Options specifying the vertical behaviour of the child"),
Packit Service fb6fa5
								  GTK_TYPE_ATTACH_OPTIONS, GTK_EXPAND | GTK_FILL,
Packit Service fb6fa5
								  GTK_PARAM_READWRITE));
Packit Service fb6fa5
  gtk_container_class_install_child_property (container_class,
Packit Service fb6fa5
					      CHILD_PROP_X_PADDING,
Packit Service fb6fa5
					      g_param_spec_uint ("x-padding", 
Packit Service fb6fa5
								 P_("Horizontal padding"), 
Packit Service fb6fa5
								 P_("Extra space to put between the child and its left and right neighbors, in pixels"),
Packit Service fb6fa5
								 0, 65535, 0,
Packit Service fb6fa5
								 GTK_PARAM_READWRITE));
Packit Service fb6fa5
  gtk_container_class_install_child_property (container_class,
Packit Service fb6fa5
					      CHILD_PROP_Y_PADDING,
Packit Service fb6fa5
					      g_param_spec_uint ("y-padding", 
Packit Service fb6fa5
								 P_("Vertical padding"), 
Packit Service fb6fa5
								 P_("Extra space to put between the child and its upper and lower neighbors, in pixels"),
Packit Service fb6fa5
								 0, 65535, 0,
Packit Service fb6fa5
								 GTK_PARAM_READWRITE));
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static GType
Packit Service fb6fa5
gtk_table_child_type (GtkContainer   *container)
Packit Service fb6fa5
{
Packit Service fb6fa5
  return GTK_TYPE_WIDGET;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_table_get_property (GObject      *object,
Packit Service fb6fa5
			guint         prop_id,
Packit Service fb6fa5
			GValue       *value,
Packit Service fb6fa5
			GParamSpec   *pspec)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkTable *table;
Packit Service fb6fa5
Packit Service fb6fa5
  table = GTK_TABLE (object);
Packit Service fb6fa5
Packit Service fb6fa5
  switch (prop_id)
Packit Service fb6fa5
    {
Packit Service fb6fa5
    case PROP_N_ROWS:
Packit Service fb6fa5
      g_value_set_uint (value, table->nrows);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case PROP_N_COLUMNS:
Packit Service fb6fa5
      g_value_set_uint (value, table->ncols);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case PROP_ROW_SPACING:
Packit Service fb6fa5
      g_value_set_uint (value, table->row_spacing);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case PROP_COLUMN_SPACING:
Packit Service fb6fa5
      g_value_set_uint (value, table->column_spacing);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case PROP_HOMOGENEOUS:
Packit Service fb6fa5
      g_value_set_boolean (value, table->homogeneous);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    default:
Packit Service fb6fa5
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_table_set_property (GObject      *object,
Packit Service fb6fa5
			guint         prop_id,
Packit Service fb6fa5
			const GValue *value,
Packit Service fb6fa5
			GParamSpec   *pspec)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkTable *table;
Packit Service fb6fa5
Packit Service fb6fa5
  table = GTK_TABLE (object);
Packit Service fb6fa5
Packit Service fb6fa5
  switch (prop_id)
Packit Service fb6fa5
    {
Packit Service fb6fa5
    case PROP_N_ROWS:
Packit Service fb6fa5
      gtk_table_resize (table, g_value_get_uint (value), table->ncols);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case PROP_N_COLUMNS:
Packit Service fb6fa5
      gtk_table_resize (table, table->nrows, g_value_get_uint (value));
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case PROP_ROW_SPACING:
Packit Service fb6fa5
      gtk_table_set_row_spacings (table, g_value_get_uint (value));
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case PROP_COLUMN_SPACING:
Packit Service fb6fa5
      gtk_table_set_col_spacings (table, g_value_get_uint (value));
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case PROP_HOMOGENEOUS:
Packit Service fb6fa5
      gtk_table_set_homogeneous (table, g_value_get_boolean (value));
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    default:
Packit Service fb6fa5
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_table_set_child_property (GtkContainer    *container,
Packit Service fb6fa5
			      GtkWidget       *child,
Packit Service fb6fa5
			      guint            property_id,
Packit Service fb6fa5
			      const GValue    *value,
Packit Service fb6fa5
			      GParamSpec      *pspec)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkTable *table = GTK_TABLE (container);
Packit Service fb6fa5
  GtkTableChild *table_child;
Packit Service fb6fa5
  GList *list;
Packit Service fb6fa5
Packit Service fb6fa5
  table_child = NULL;
Packit Service fb6fa5
  for (list = table->children; list; list = list->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      table_child = list->data;
Packit Service fb6fa5
Packit Service fb6fa5
      if (table_child->widget == child)
Packit Service fb6fa5
	break;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  if (!list)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
Packit Service fb6fa5
      return;
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  switch (property_id)
Packit Service fb6fa5
    {
Packit Service fb6fa5
    case CHILD_PROP_LEFT_ATTACH:
Packit Service fb6fa5
      table_child->left_attach = g_value_get_uint (value);
Packit Service fb6fa5
      if (table_child->right_attach <= table_child->left_attach)
Packit Service fb6fa5
	table_child->right_attach = table_child->left_attach + 1;
Packit Service fb6fa5
      if (table_child->right_attach >= table->ncols)
Packit Service fb6fa5
	gtk_table_resize (table, table->nrows, table_child->right_attach);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case CHILD_PROP_RIGHT_ATTACH:
Packit Service fb6fa5
      table_child->right_attach = g_value_get_uint (value);
Packit Service fb6fa5
      if (table_child->right_attach <= table_child->left_attach)
Packit Service fb6fa5
	table_child->left_attach = table_child->right_attach - 1;
Packit Service fb6fa5
      if (table_child->right_attach >= table->ncols)
Packit Service fb6fa5
	gtk_table_resize (table, table->nrows, table_child->right_attach);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case CHILD_PROP_TOP_ATTACH:
Packit Service fb6fa5
      table_child->top_attach = g_value_get_uint (value);
Packit Service fb6fa5
      if (table_child->bottom_attach <= table_child->top_attach)
Packit Service fb6fa5
	table_child->bottom_attach = table_child->top_attach + 1;
Packit Service fb6fa5
      if (table_child->bottom_attach >= table->nrows)
Packit Service fb6fa5
	gtk_table_resize (table, table_child->bottom_attach, table->ncols);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case CHILD_PROP_BOTTOM_ATTACH:
Packit Service fb6fa5
      table_child->bottom_attach = g_value_get_uint (value);
Packit Service fb6fa5
      if (table_child->bottom_attach <= table_child->top_attach)
Packit Service fb6fa5
	table_child->top_attach = table_child->bottom_attach - 1;
Packit Service fb6fa5
      if (table_child->bottom_attach >= table->nrows)
Packit Service fb6fa5
	gtk_table_resize (table, table_child->bottom_attach, table->ncols);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case CHILD_PROP_X_OPTIONS:
Packit Service fb6fa5
      table_child->xexpand = (g_value_get_flags (value) & GTK_EXPAND) != 0;
Packit Service fb6fa5
      table_child->xshrink = (g_value_get_flags (value) & GTK_SHRINK) != 0;
Packit Service fb6fa5
      table_child->xfill = (g_value_get_flags (value) & GTK_FILL) != 0;
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case CHILD_PROP_Y_OPTIONS:
Packit Service fb6fa5
      table_child->yexpand = (g_value_get_flags (value) & GTK_EXPAND) != 0;
Packit Service fb6fa5
      table_child->yshrink = (g_value_get_flags (value) & GTK_SHRINK) != 0;
Packit Service fb6fa5
      table_child->yfill = (g_value_get_flags (value) & GTK_FILL) != 0;
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case CHILD_PROP_X_PADDING:
Packit Service fb6fa5
      table_child->xpadding = g_value_get_uint (value);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case CHILD_PROP_Y_PADDING:
Packit Service fb6fa5
      table_child->ypadding = g_value_get_uint (value);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    default:
Packit Service fb6fa5
      GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  if (gtk_widget_get_visible (child) &&
Packit Service fb6fa5
      gtk_widget_get_visible (GTK_WIDGET (table)))
Packit Service fb6fa5
    gtk_widget_queue_resize (child);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_table_get_child_property (GtkContainer    *container,
Packit Service fb6fa5
			      GtkWidget       *child,
Packit Service fb6fa5
			      guint            property_id,
Packit Service fb6fa5
			      GValue          *value,
Packit Service fb6fa5
			      GParamSpec      *pspec)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkTable *table = GTK_TABLE (container);
Packit Service fb6fa5
  GtkTableChild *table_child;
Packit Service fb6fa5
  GList *list;
Packit Service fb6fa5
Packit Service fb6fa5
  table_child = NULL;
Packit Service fb6fa5
  for (list = table->children; list; list = list->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      table_child = list->data;
Packit Service fb6fa5
Packit Service fb6fa5
      if (table_child->widget == child)
Packit Service fb6fa5
	break;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  if (!list)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
Packit Service fb6fa5
      return;
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  switch (property_id)
Packit Service fb6fa5
    {
Packit Service fb6fa5
    case CHILD_PROP_LEFT_ATTACH:
Packit Service fb6fa5
      g_value_set_uint (value, table_child->left_attach);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case CHILD_PROP_RIGHT_ATTACH:
Packit Service fb6fa5
      g_value_set_uint (value, table_child->right_attach);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case CHILD_PROP_TOP_ATTACH:
Packit Service fb6fa5
      g_value_set_uint (value, table_child->top_attach);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case CHILD_PROP_BOTTOM_ATTACH:
Packit Service fb6fa5
      g_value_set_uint (value, table_child->bottom_attach);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case CHILD_PROP_X_OPTIONS:
Packit Service fb6fa5
      g_value_set_flags (value, (table_child->xexpand * GTK_EXPAND |
Packit Service fb6fa5
				 table_child->xshrink * GTK_SHRINK |
Packit Service fb6fa5
				 table_child->xfill * GTK_FILL));
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case CHILD_PROP_Y_OPTIONS:
Packit Service fb6fa5
      g_value_set_flags (value, (table_child->yexpand * GTK_EXPAND |
Packit Service fb6fa5
				 table_child->yshrink * GTK_SHRINK |
Packit Service fb6fa5
				 table_child->yfill * GTK_FILL));
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case CHILD_PROP_X_PADDING:
Packit Service fb6fa5
      g_value_set_uint (value, table_child->xpadding);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case CHILD_PROP_Y_PADDING:
Packit Service fb6fa5
      g_value_set_uint (value, table_child->ypadding);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    default:
Packit Service fb6fa5
      GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_table_init (GtkTable *table)
Packit Service fb6fa5
{
Packit Service fb6fa5
  gtk_widget_set_has_window (GTK_WIDGET (table), FALSE);
Packit Service fb6fa5
  gtk_widget_set_redraw_on_allocate (GTK_WIDGET (table), FALSE);
Packit Service fb6fa5
  
Packit Service fb6fa5
  table->children = NULL;
Packit Service fb6fa5
  table->rows = NULL;
Packit Service fb6fa5
  table->cols = NULL;
Packit Service fb6fa5
  table->nrows = 0;
Packit Service fb6fa5
  table->ncols = 0;
Packit Service fb6fa5
  table->column_spacing = 0;
Packit Service fb6fa5
  table->row_spacing = 0;
Packit Service fb6fa5
  table->homogeneous = FALSE;
Packit Service fb6fa5
Packit Service fb6fa5
  gtk_table_resize (table, 1, 1);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
GtkWidget*
Packit Service fb6fa5
gtk_table_new (guint	rows,
Packit Service fb6fa5
	       guint	columns,
Packit Service fb6fa5
	       gboolean homogeneous)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkTable *table;
Packit Service fb6fa5
Packit Service fb6fa5
  if (rows == 0)
Packit Service fb6fa5
    rows = 1;
Packit Service fb6fa5
  if (columns == 0)
Packit Service fb6fa5
    columns = 1;
Packit Service fb6fa5
  
Packit Service fb6fa5
  table = g_object_new (GTK_TYPE_TABLE, NULL);
Packit Service fb6fa5
  
Packit Service fb6fa5
  table->homogeneous = (homogeneous ? TRUE : FALSE);
Packit Service fb6fa5
Packit Service fb6fa5
  gtk_table_resize (table, rows, columns);
Packit Service fb6fa5
  
Packit Service fb6fa5
  return GTK_WIDGET (table);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_table_resize (GtkTable *table,
Packit Service fb6fa5
		  guint     n_rows,
Packit Service fb6fa5
		  guint     n_cols)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_TABLE (table));
Packit Service fb6fa5
  g_return_if_fail (n_rows > 0 && n_rows <= 65535);
Packit Service fb6fa5
  g_return_if_fail (n_cols > 0 && n_cols <= 65535);
Packit Service fb6fa5
Packit Service fb6fa5
  n_rows = MAX (n_rows, 1);
Packit Service fb6fa5
  n_cols = MAX (n_cols, 1);
Packit Service fb6fa5
Packit Service fb6fa5
  if (n_rows != table->nrows ||
Packit Service fb6fa5
      n_cols != table->ncols)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GList *list;
Packit Service fb6fa5
      
Packit Service fb6fa5
      for (list = table->children; list; list = list->next)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  GtkTableChild *child;
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  child = list->data;
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  n_rows = MAX (n_rows, child->bottom_attach);
Packit Service fb6fa5
	  n_cols = MAX (n_cols, child->right_attach);
Packit Service fb6fa5
	}
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (n_rows != table->nrows)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  guint i;
Packit Service fb6fa5
Packit Service fb6fa5
	  i = table->nrows;
Packit Service fb6fa5
	  table->nrows = n_rows;
Packit Service fb6fa5
	  table->rows = g_realloc (table->rows, table->nrows * sizeof (GtkTableRowCol));
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  for (; i < table->nrows; i++)
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      table->rows[i].requisition = 0;
Packit Service fb6fa5
	      table->rows[i].allocation = 0;
Packit Service fb6fa5
	      table->rows[i].spacing = table->row_spacing;
Packit Service fb6fa5
	      table->rows[i].need_expand = 0;
Packit Service fb6fa5
	      table->rows[i].need_shrink = 0;
Packit Service fb6fa5
	      table->rows[i].expand = 0;
Packit Service fb6fa5
	      table->rows[i].shrink = 0;
Packit Service fb6fa5
	    }
Packit Service fb6fa5
Packit Service fb6fa5
	  g_object_notify (G_OBJECT (table), "n-rows");
Packit Service fb6fa5
	}
Packit Service fb6fa5
Packit Service fb6fa5
      if (n_cols != table->ncols)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  guint i;
Packit Service fb6fa5
Packit Service fb6fa5
	  i = table->ncols;
Packit Service fb6fa5
	  table->ncols = n_cols;
Packit Service fb6fa5
	  table->cols = g_realloc (table->cols, table->ncols * sizeof (GtkTableRowCol));
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  for (; i < table->ncols; i++)
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      table->cols[i].requisition = 0;
Packit Service fb6fa5
	      table->cols[i].allocation = 0;
Packit Service fb6fa5
	      table->cols[i].spacing = table->column_spacing;
Packit Service fb6fa5
	      table->cols[i].need_expand = 0;
Packit Service fb6fa5
	      table->cols[i].need_shrink = 0;
Packit Service fb6fa5
	      table->cols[i].expand = 0;
Packit Service fb6fa5
	      table->cols[i].shrink = 0;
Packit Service fb6fa5
	    }
Packit Service fb6fa5
Packit Service fb6fa5
	  g_object_notify (G_OBJECT (table), "n-columns");
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_table_attach (GtkTable	  *table,
Packit Service fb6fa5
		  GtkWidget	  *child,
Packit Service fb6fa5
		  guint		   left_attach,
Packit Service fb6fa5
		  guint		   right_attach,
Packit Service fb6fa5
		  guint		   top_attach,
Packit Service fb6fa5
		  guint		   bottom_attach,
Packit Service fb6fa5
		  GtkAttachOptions xoptions,
Packit Service fb6fa5
		  GtkAttachOptions yoptions,
Packit Service fb6fa5
		  guint		   xpadding,
Packit Service fb6fa5
		  guint		   ypadding)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkTableChild *table_child;
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_TABLE (table));
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_WIDGET (child));
Packit Service fb6fa5
  g_return_if_fail (child->parent == NULL);
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* g_return_if_fail (left_attach >= 0); */
Packit Service fb6fa5
  g_return_if_fail (left_attach < right_attach);
Packit Service fb6fa5
  /* g_return_if_fail (top_attach >= 0); */
Packit Service fb6fa5
  g_return_if_fail (top_attach < bottom_attach);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (right_attach >= table->ncols)
Packit Service fb6fa5
    gtk_table_resize (table, table->nrows, right_attach);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (bottom_attach >= table->nrows)
Packit Service fb6fa5
    gtk_table_resize (table, bottom_attach, table->ncols);
Packit Service fb6fa5
  
Packit Service fb6fa5
  table_child = g_new (GtkTableChild, 1);
Packit Service fb6fa5
  table_child->widget = child;
Packit Service fb6fa5
  table_child->left_attach = left_attach;
Packit Service fb6fa5
  table_child->right_attach = right_attach;
Packit Service fb6fa5
  table_child->top_attach = top_attach;
Packit Service fb6fa5
  table_child->bottom_attach = bottom_attach;
Packit Service fb6fa5
  table_child->xexpand = (xoptions & GTK_EXPAND) != 0;
Packit Service fb6fa5
  table_child->xshrink = (xoptions & GTK_SHRINK) != 0;
Packit Service fb6fa5
  table_child->xfill = (xoptions & GTK_FILL) != 0;
Packit Service fb6fa5
  table_child->xpadding = xpadding;
Packit Service fb6fa5
  table_child->yexpand = (yoptions & GTK_EXPAND) != 0;
Packit Service fb6fa5
  table_child->yshrink = (yoptions & GTK_SHRINK) != 0;
Packit Service fb6fa5
  table_child->yfill = (yoptions & GTK_FILL) != 0;
Packit Service fb6fa5
  table_child->ypadding = ypadding;
Packit Service fb6fa5
  
Packit Service fb6fa5
  table->children = g_list_prepend (table->children, table_child);
Packit Service fb6fa5
  
Packit Service fb6fa5
  gtk_widget_set_parent (child, GTK_WIDGET (table));
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_table_attach_defaults (GtkTable  *table,
Packit Service fb6fa5
			   GtkWidget *widget,
Packit Service fb6fa5
			   guint      left_attach,
Packit Service fb6fa5
			   guint      right_attach,
Packit Service fb6fa5
			   guint      top_attach,
Packit Service fb6fa5
			   guint      bottom_attach)
Packit Service fb6fa5
{
Packit Service fb6fa5
  gtk_table_attach (table, widget,
Packit Service fb6fa5
		    left_attach, right_attach,
Packit Service fb6fa5
		    top_attach, bottom_attach,
Packit Service fb6fa5
		    GTK_EXPAND | GTK_FILL,
Packit Service fb6fa5
		    GTK_EXPAND | GTK_FILL,
Packit Service fb6fa5
		    0, 0);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_table_set_row_spacing (GtkTable *table,
Packit Service fb6fa5
			   guint     row,
Packit Service fb6fa5
			   guint     spacing)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_TABLE (table));
Packit Service fb6fa5
  g_return_if_fail (row < table->nrows);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (table->rows[row].spacing != spacing)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      table->rows[row].spacing = spacing;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (gtk_widget_get_visible (GTK_WIDGET (table)))
Packit Service fb6fa5
	gtk_widget_queue_resize (GTK_WIDGET (table));
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_table_get_row_spacing:
Packit Service fb6fa5
 * @table: a #GtkTable
Packit Service fb6fa5
 * @row: a row in the table, 0 indicates the first row
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Gets the amount of space between row @row, and
Packit Service fb6fa5
 * row @row + 1. See gtk_table_set_row_spacing().
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Return value: the row spacing
Packit Service fb6fa5
 **/
Packit Service fb6fa5
guint
Packit Service fb6fa5
gtk_table_get_row_spacing (GtkTable *table,
Packit Service fb6fa5
			   guint     row)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_TABLE (table), 0);
Packit Service fb6fa5
  g_return_val_if_fail (row < table->nrows - 1, 0);
Packit Service fb6fa5
 
Packit Service fb6fa5
  return table->rows[row].spacing;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_table_set_col_spacing (GtkTable *table,
Packit Service fb6fa5
			   guint     column,
Packit Service fb6fa5
			   guint     spacing)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_TABLE (table));
Packit Service fb6fa5
  g_return_if_fail (column < table->ncols);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (table->cols[column].spacing != spacing)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      table->cols[column].spacing = spacing;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (gtk_widget_get_visible (GTK_WIDGET (table)))
Packit Service fb6fa5
	gtk_widget_queue_resize (GTK_WIDGET (table));
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_table_get_col_spacing:
Packit Service fb6fa5
 * @table: a #GtkTable
Packit Service fb6fa5
 * @column: a column in the table, 0 indicates the first column
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Gets the amount of space between column @col, and
Packit Service fb6fa5
 * column @col + 1. See gtk_table_set_col_spacing().
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Return value: the column spacing
Packit Service fb6fa5
 **/
Packit Service fb6fa5
guint
Packit Service fb6fa5
gtk_table_get_col_spacing (GtkTable *table,
Packit Service fb6fa5
			   guint     column)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_TABLE (table), 0);
Packit Service fb6fa5
  g_return_val_if_fail (column < table->ncols, 0);
Packit Service fb6fa5
Packit Service fb6fa5
  return table->cols[column].spacing;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_table_set_row_spacings (GtkTable *table,
Packit Service fb6fa5
			    guint     spacing)
Packit Service fb6fa5
{
Packit Service fb6fa5
  guint row;
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_TABLE (table));
Packit Service fb6fa5
  
Packit Service fb6fa5
  table->row_spacing = spacing;
Packit Service fb6fa5
  for (row = 0; row < table->nrows; row++)
Packit Service fb6fa5
    table->rows[row].spacing = spacing;
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (gtk_widget_get_visible (GTK_WIDGET (table)))
Packit Service fb6fa5
    gtk_widget_queue_resize (GTK_WIDGET (table));
Packit Service fb6fa5
Packit Service fb6fa5
  g_object_notify (G_OBJECT (table), "row-spacing");
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_table_get_default_row_spacing:
Packit Service fb6fa5
 * @table: a #GtkTable
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Gets the default row spacing for the table. This is
Packit Service fb6fa5
 * the spacing that will be used for newly added rows.
Packit Service fb6fa5
 * (See gtk_table_set_row_spacings())
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Return value: the default row spacing
Packit Service fb6fa5
 **/
Packit Service fb6fa5
guint
Packit Service fb6fa5
gtk_table_get_default_row_spacing (GtkTable *table)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_TABLE (table), 0);
Packit Service fb6fa5
Packit Service fb6fa5
  return table->row_spacing;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_table_set_col_spacings (GtkTable *table,
Packit Service fb6fa5
			    guint     spacing)
Packit Service fb6fa5
{
Packit Service fb6fa5
  guint col;
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_TABLE (table));
Packit Service fb6fa5
  
Packit Service fb6fa5
  table->column_spacing = spacing;
Packit Service fb6fa5
  for (col = 0; col < table->ncols; col++)
Packit Service fb6fa5
    table->cols[col].spacing = spacing;
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (gtk_widget_get_visible (GTK_WIDGET (table)))
Packit Service fb6fa5
    gtk_widget_queue_resize (GTK_WIDGET (table));
Packit Service fb6fa5
Packit Service fb6fa5
  g_object_notify (G_OBJECT (table), "column-spacing");
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_table_get_default_col_spacing:
Packit Service fb6fa5
 * @table: a #GtkTable
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Gets the default column spacing for the table. This is
Packit Service fb6fa5
 * the spacing that will be used for newly added columns.
Packit Service fb6fa5
 * (See gtk_table_set_col_spacings())
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Return value: the default column spacing
Packit Service fb6fa5
 **/
Packit Service fb6fa5
guint
Packit Service fb6fa5
gtk_table_get_default_col_spacing (GtkTable *table)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_TABLE (table), 0);
Packit Service fb6fa5
Packit Service fb6fa5
  return table->column_spacing;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_table_set_homogeneous (GtkTable *table,
Packit Service fb6fa5
			   gboolean  homogeneous)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_TABLE (table));
Packit Service fb6fa5
Packit Service fb6fa5
  homogeneous = (homogeneous != 0);
Packit Service fb6fa5
  if (homogeneous != table->homogeneous)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      table->homogeneous = homogeneous;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (gtk_widget_get_visible (GTK_WIDGET (table)))
Packit Service fb6fa5
	gtk_widget_queue_resize (GTK_WIDGET (table));
Packit Service fb6fa5
Packit Service fb6fa5
      g_object_notify (G_OBJECT (table), "homogeneous");
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_table_get_homogeneous:
Packit Service fb6fa5
 * @table: a #GtkTable
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Returns whether the table cells are all constrained to the same
Packit Service fb6fa5
 * width and height. (See gtk_table_set_homogenous ())
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Return value: %TRUE if the cells are all constrained to the same size
Packit Service fb6fa5
 **/
Packit Service fb6fa5
gboolean
Packit Service fb6fa5
gtk_table_get_homogeneous (GtkTable *table)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_TABLE (table), FALSE);
Packit Service fb6fa5
Packit Service fb6fa5
  return table->homogeneous;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_table_get_size:
Packit Service fb6fa5
 * @table: a #GtkTable
Packit Service fb6fa5
 * @rows: (out) (allow-none): return location for the number of
Packit Service fb6fa5
 *   rows, or %NULL
Packit Service fb6fa5
 * @columns: (out) (allow-none): return location for the number
Packit Service fb6fa5
 *   of columns, or %NULL
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Returns the number of rows and columns in the table.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Since: 2.22
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_table_get_size (GtkTable *table,
Packit Service fb6fa5
                    guint    *rows,
Packit Service fb6fa5
                    guint    *columns)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_TABLE (table));
Packit Service fb6fa5
Packit Service fb6fa5
  if (rows)
Packit Service fb6fa5
    *rows = table->nrows;
Packit Service fb6fa5
Packit Service fb6fa5
  if (columns)
Packit Service fb6fa5
    *columns = table->ncols;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_table_finalize (GObject *object)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkTable *table = GTK_TABLE (object);
Packit Service fb6fa5
Packit Service fb6fa5
  g_free (table->rows);
Packit Service fb6fa5
  g_free (table->cols);
Packit Service fb6fa5
  
Packit Service fb6fa5
  G_OBJECT_CLASS (gtk_table_parent_class)->finalize (object);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_table_size_request (GtkWidget      *widget,
Packit Service fb6fa5
			GtkRequisition *requisition)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkTable *table = GTK_TABLE (widget);
Packit Service fb6fa5
  gint row, col;
Packit Service fb6fa5
Packit Service fb6fa5
  requisition->width = 0;
Packit Service fb6fa5
  requisition->height = 0;
Packit Service fb6fa5
  
Packit Service fb6fa5
  gtk_table_size_request_init (table);
Packit Service fb6fa5
  gtk_table_size_request_pass1 (table);
Packit Service fb6fa5
  gtk_table_size_request_pass2 (table);
Packit Service fb6fa5
  gtk_table_size_request_pass3 (table);
Packit Service fb6fa5
  gtk_table_size_request_pass2 (table);
Packit Service fb6fa5
  
Packit Service fb6fa5
  for (col = 0; col < table->ncols; col++)
Packit Service fb6fa5
    requisition->width += table->cols[col].requisition;
Packit Service fb6fa5
  for (col = 0; col + 1 < table->ncols; col++)
Packit Service fb6fa5
    requisition->width += table->cols[col].spacing;
Packit Service fb6fa5
  
Packit Service fb6fa5
  for (row = 0; row < table->nrows; row++)
Packit Service fb6fa5
    requisition->height += table->rows[row].requisition;
Packit Service fb6fa5
  for (row = 0; row + 1 < table->nrows; row++)
Packit Service fb6fa5
    requisition->height += table->rows[row].spacing;
Packit Service fb6fa5
  
Packit Service fb6fa5
  requisition->width += GTK_CONTAINER (table)->border_width * 2;
Packit Service fb6fa5
  requisition->height += GTK_CONTAINER (table)->border_width * 2;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_table_size_allocate (GtkWidget     *widget,
Packit Service fb6fa5
			 GtkAllocation *allocation)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkTable *table = GTK_TABLE (widget);
Packit Service fb6fa5
Packit Service fb6fa5
  widget->allocation = *allocation;
Packit Service fb6fa5
Packit Service fb6fa5
  gtk_table_size_allocate_init (table);
Packit Service fb6fa5
  gtk_table_size_allocate_pass1 (table);
Packit Service fb6fa5
  gtk_table_size_allocate_pass2 (table);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_table_add (GtkContainer *container,
Packit Service fb6fa5
	       GtkWidget    *widget)
Packit Service fb6fa5
{
Packit Service fb6fa5
  gtk_table_attach_defaults (GTK_TABLE (container), widget, 0, 1, 0, 1);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_table_remove (GtkContainer *container,
Packit Service fb6fa5
		  GtkWidget    *widget)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkTable *table = GTK_TABLE (container);
Packit Service fb6fa5
  GtkTableChild *child;
Packit Service fb6fa5
  GtkWidget *widget_container = GTK_WIDGET (container);
Packit Service fb6fa5
  GList *children;
Packit Service fb6fa5
Packit Service fb6fa5
  children = table->children;
Packit Service fb6fa5
  
Packit Service fb6fa5
  while (children)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      child = children->data;
Packit Service fb6fa5
      children = children->next;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (child->widget == widget)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  gboolean was_visible = gtk_widget_get_visible (widget);
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  gtk_widget_unparent (widget);
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  table->children = g_list_remove (table->children, child);
Packit Service fb6fa5
	  g_free (child);
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  if (was_visible && gtk_widget_get_visible (widget_container))
Packit Service fb6fa5
	    gtk_widget_queue_resize (widget_container);
Packit Service fb6fa5
	  break;
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_table_forall (GtkContainer *container,
Packit Service fb6fa5
		  gboolean	include_internals,
Packit Service fb6fa5
		  GtkCallback	callback,
Packit Service fb6fa5
		  gpointer	callback_data)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkTable *table = GTK_TABLE (container);
Packit Service fb6fa5
  GtkTableChild *child;
Packit Service fb6fa5
  GList *children;
Packit Service fb6fa5
Packit Service fb6fa5
  children = table->children;
Packit Service fb6fa5
  
Packit Service fb6fa5
  while (children)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      child = children->data;
Packit Service fb6fa5
      children = children->next;
Packit Service fb6fa5
      
Packit Service fb6fa5
      (* callback) (child->widget, callback_data);
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_table_size_request_init (GtkTable *table)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkTableChild *child;
Packit Service fb6fa5
  GList *children;
Packit Service fb6fa5
  gint row, col;
Packit Service fb6fa5
  
Packit Service fb6fa5
  for (row = 0; row < table->nrows; row++)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      table->rows[row].requisition = 0;
Packit Service fb6fa5
      table->rows[row].expand = FALSE;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  for (col = 0; col < table->ncols; col++)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      table->cols[col].requisition = 0;
Packit Service fb6fa5
      table->cols[col].expand = FALSE;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  children = table->children;
Packit Service fb6fa5
  while (children)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      child = children->data;
Packit Service fb6fa5
      children = children->next;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (gtk_widget_get_visible (child->widget))
Packit Service fb6fa5
	gtk_widget_size_request (child->widget, NULL);
Packit Service fb6fa5
Packit Service fb6fa5
      if (child->left_attach == (child->right_attach - 1) && child->xexpand)
Packit Service fb6fa5
	table->cols[child->left_attach].expand = TRUE;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (child->top_attach == (child->bottom_attach - 1) && child->yexpand)
Packit Service fb6fa5
	table->rows[child->top_attach].expand = TRUE;
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_table_size_request_pass1 (GtkTable *table)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkTableChild *child;
Packit Service fb6fa5
  GList *children;
Packit Service fb6fa5
  gint width;
Packit Service fb6fa5
  gint height;
Packit Service fb6fa5
  
Packit Service fb6fa5
  children = table->children;
Packit Service fb6fa5
  while (children)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      child = children->data;
Packit Service fb6fa5
      children = children->next;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (gtk_widget_get_visible (child->widget))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  GtkRequisition child_requisition;
Packit Service fb6fa5
	  gtk_widget_get_child_requisition (child->widget, &child_requisition);
Packit Service fb6fa5
Packit Service fb6fa5
	  /* Child spans a single column.
Packit Service fb6fa5
	   */
Packit Service fb6fa5
	  if (child->left_attach == (child->right_attach - 1))
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      width = child_requisition.width + child->xpadding * 2;
Packit Service fb6fa5
	      table->cols[child->left_attach].requisition = MAX (table->cols[child->left_attach].requisition, width);
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  /* Child spans a single row.
Packit Service fb6fa5
	   */
Packit Service fb6fa5
	  if (child->top_attach == (child->bottom_attach - 1))
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      height = child_requisition.height + child->ypadding * 2;
Packit Service fb6fa5
	      table->rows[child->top_attach].requisition = MAX (table->rows[child->top_attach].requisition, height);
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_table_size_request_pass2 (GtkTable *table)
Packit Service fb6fa5
{
Packit Service fb6fa5
  gint max_width;
Packit Service fb6fa5
  gint max_height;
Packit Service fb6fa5
  gint row, col;
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (table->homogeneous)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      max_width = 0;
Packit Service fb6fa5
      max_height = 0;
Packit Service fb6fa5
      
Packit Service fb6fa5
      for (col = 0; col < table->ncols; col++)
Packit Service fb6fa5
	max_width = MAX (max_width, table->cols[col].requisition);
Packit Service fb6fa5
      for (row = 0; row < table->nrows; row++)
Packit Service fb6fa5
	max_height = MAX (max_height, table->rows[row].requisition);
Packit Service fb6fa5
      
Packit Service fb6fa5
      for (col = 0; col < table->ncols; col++)
Packit Service fb6fa5
	table->cols[col].requisition = max_width;
Packit Service fb6fa5
      for (row = 0; row < table->nrows; row++)
Packit Service fb6fa5
	table->rows[row].requisition = max_height;
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_table_size_request_pass3 (GtkTable *table)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkTableChild *child;
Packit Service fb6fa5
  GList *children;
Packit Service fb6fa5
  gint width, height;
Packit Service fb6fa5
  gint row, col;
Packit Service fb6fa5
  gint extra;
Packit Service fb6fa5
  
Packit Service fb6fa5
  children = table->children;
Packit Service fb6fa5
  while (children)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      child = children->data;
Packit Service fb6fa5
      children = children->next;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (gtk_widget_get_visible (child->widget))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  /* Child spans multiple columns.
Packit Service fb6fa5
	   */
Packit Service fb6fa5
	  if (child->left_attach != (child->right_attach - 1))
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      GtkRequisition child_requisition;
Packit Service fb6fa5
Packit Service fb6fa5
	      gtk_widget_get_child_requisition (child->widget, &child_requisition);
Packit Service fb6fa5
	      
Packit Service fb6fa5
	      /* Check and see if there is already enough space
Packit Service fb6fa5
	       *  for the child.
Packit Service fb6fa5
	       */
Packit Service fb6fa5
	      width = 0;
Packit Service fb6fa5
	      for (col = child->left_attach; col < child->right_attach; col++)
Packit Service fb6fa5
		{
Packit Service fb6fa5
		  width += table->cols[col].requisition;
Packit Service fb6fa5
		  if ((col + 1) < child->right_attach)
Packit Service fb6fa5
		    width += table->cols[col].spacing;
Packit Service fb6fa5
		}
Packit Service fb6fa5
	      
Packit Service fb6fa5
	      /* If we need to request more space for this child to fill
Packit Service fb6fa5
	       *  its requisition, then divide up the needed space amongst the
Packit Service fb6fa5
	       *  columns it spans, favoring expandable columns if any.
Packit Service fb6fa5
	       */
Packit Service fb6fa5
	      if (width < child_requisition.width + child->xpadding * 2)
Packit Service fb6fa5
		{
Packit Service fb6fa5
		  gint n_expand = 0;
Packit Service fb6fa5
		  gboolean force_expand = FALSE;
Packit Service fb6fa5
		  
Packit Service fb6fa5
		  width = child_requisition.width + child->xpadding * 2 - width;
Packit Service fb6fa5
Packit Service fb6fa5
		  for (col = child->left_attach; col < child->right_attach; col++)
Packit Service fb6fa5
		    if (table->cols[col].expand)
Packit Service fb6fa5
		      n_expand++;
Packit Service fb6fa5
Packit Service fb6fa5
		  if (n_expand == 0)
Packit Service fb6fa5
		    {
Packit Service fb6fa5
		      n_expand = (child->right_attach - child->left_attach);
Packit Service fb6fa5
		      force_expand = TRUE;
Packit Service fb6fa5
		    }
Packit Service fb6fa5
		    
Packit Service fb6fa5
		  for (col = child->left_attach; col < child->right_attach; col++)
Packit Service fb6fa5
		    if (force_expand || table->cols[col].expand)
Packit Service fb6fa5
		      {
Packit Service fb6fa5
			extra = width / n_expand;
Packit Service fb6fa5
			table->cols[col].requisition += extra;
Packit Service fb6fa5
			width -= extra;
Packit Service fb6fa5
			n_expand--;
Packit Service fb6fa5
		      }
Packit Service fb6fa5
		}
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  /* Child spans multiple rows.
Packit Service fb6fa5
	   */
Packit Service fb6fa5
	  if (child->top_attach != (child->bottom_attach - 1))
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      GtkRequisition child_requisition;
Packit Service fb6fa5
Packit Service fb6fa5
	      gtk_widget_get_child_requisition (child->widget, &child_requisition);
Packit Service fb6fa5
Packit Service fb6fa5
	      /* Check and see if there is already enough space
Packit Service fb6fa5
	       *  for the child.
Packit Service fb6fa5
	       */
Packit Service fb6fa5
	      height = 0;
Packit Service fb6fa5
	      for (row = child->top_attach; row < child->bottom_attach; row++)
Packit Service fb6fa5
		{
Packit Service fb6fa5
		  height += table->rows[row].requisition;
Packit Service fb6fa5
		  if ((row + 1) < child->bottom_attach)
Packit Service fb6fa5
		    height += table->rows[row].spacing;
Packit Service fb6fa5
		}
Packit Service fb6fa5
	      
Packit Service fb6fa5
	      /* If we need to request more space for this child to fill
Packit Service fb6fa5
	       *  its requisition, then divide up the needed space amongst the
Packit Service fb6fa5
	       *  rows it spans, favoring expandable rows if any.
Packit Service fb6fa5
	       */
Packit Service fb6fa5
	      if (height < child_requisition.height + child->ypadding * 2)
Packit Service fb6fa5
		{
Packit Service fb6fa5
		  gint n_expand = 0;
Packit Service fb6fa5
		  gboolean force_expand = FALSE;
Packit Service fb6fa5
		  
Packit Service fb6fa5
		  height = child_requisition.height + child->ypadding * 2 - height;
Packit Service fb6fa5
		  
Packit Service fb6fa5
		  for (row = child->top_attach; row < child->bottom_attach; row++)
Packit Service fb6fa5
		    {
Packit Service fb6fa5
		      if (table->rows[row].expand)
Packit Service fb6fa5
			n_expand++;
Packit Service fb6fa5
		    }
Packit Service fb6fa5
Packit Service fb6fa5
		  if (n_expand == 0)
Packit Service fb6fa5
		    {
Packit Service fb6fa5
		      n_expand = (child->bottom_attach - child->top_attach);
Packit Service fb6fa5
		      force_expand = TRUE;
Packit Service fb6fa5
		    }
Packit Service fb6fa5
		    
Packit Service fb6fa5
		  for (row = child->top_attach; row < child->bottom_attach; row++)
Packit Service fb6fa5
		    if (force_expand || table->rows[row].expand)
Packit Service fb6fa5
		      {
Packit Service fb6fa5
			extra = height / n_expand;
Packit Service fb6fa5
			table->rows[row].requisition += extra;
Packit Service fb6fa5
			height -= extra;
Packit Service fb6fa5
			n_expand--;
Packit Service fb6fa5
		      }
Packit Service fb6fa5
		}
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_table_size_allocate_init (GtkTable *table)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkTableChild *child;
Packit Service fb6fa5
  GList *children;
Packit Service fb6fa5
  gint row, col;
Packit Service fb6fa5
  gint has_expand;
Packit Service fb6fa5
  gint has_shrink;
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* Initialize the rows and cols.
Packit Service fb6fa5
   *  By default, rows and cols do not expand and do shrink.
Packit Service fb6fa5
   *  Those values are modified by the children that occupy
Packit Service fb6fa5
   *  the rows and cols.
Packit Service fb6fa5
   */
Packit Service fb6fa5
  for (col = 0; col < table->ncols; col++)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      table->cols[col].allocation = table->cols[col].requisition;
Packit Service fb6fa5
      table->cols[col].need_expand = FALSE;
Packit Service fb6fa5
      table->cols[col].need_shrink = TRUE;
Packit Service fb6fa5
      table->cols[col].expand = FALSE;
Packit Service fb6fa5
      table->cols[col].shrink = TRUE;
Packit Service fb6fa5
      table->cols[col].empty = TRUE;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  for (row = 0; row < table->nrows; row++)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      table->rows[row].allocation = table->rows[row].requisition;
Packit Service fb6fa5
      table->rows[row].need_expand = FALSE;
Packit Service fb6fa5
      table->rows[row].need_shrink = TRUE;
Packit Service fb6fa5
      table->rows[row].expand = FALSE;
Packit Service fb6fa5
      table->rows[row].shrink = TRUE;
Packit Service fb6fa5
      table->rows[row].empty = TRUE;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* Loop over all the children and adjust the row and col values
Packit Service fb6fa5
   *  based on whether the children want to be allowed to expand
Packit Service fb6fa5
   *  or shrink. This loop handles children that occupy a single
Packit Service fb6fa5
   *  row or column.
Packit Service fb6fa5
   */
Packit Service fb6fa5
  children = table->children;
Packit Service fb6fa5
  while (children)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      child = children->data;
Packit Service fb6fa5
      children = children->next;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (gtk_widget_get_visible (child->widget))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  if (child->left_attach == (child->right_attach - 1))
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      if (child->xexpand)
Packit Service fb6fa5
		table->cols[child->left_attach].expand = TRUE;
Packit Service fb6fa5
	      
Packit Service fb6fa5
	      if (!child->xshrink)
Packit Service fb6fa5
		table->cols[child->left_attach].shrink = FALSE;
Packit Service fb6fa5
	      
Packit Service fb6fa5
	      table->cols[child->left_attach].empty = FALSE;
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  if (child->top_attach == (child->bottom_attach - 1))
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      if (child->yexpand)
Packit Service fb6fa5
		table->rows[child->top_attach].expand = TRUE;
Packit Service fb6fa5
	      
Packit Service fb6fa5
	      if (!child->yshrink)
Packit Service fb6fa5
		table->rows[child->top_attach].shrink = FALSE;
Packit Service fb6fa5
Packit Service fb6fa5
	      table->rows[child->top_attach].empty = FALSE;
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* Loop over all the children again and this time handle children
Packit Service fb6fa5
   *  which span multiple rows or columns.
Packit Service fb6fa5
   */
Packit Service fb6fa5
  children = table->children;
Packit Service fb6fa5
  while (children)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      child = children->data;
Packit Service fb6fa5
      children = children->next;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (gtk_widget_get_visible (child->widget))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  if (child->left_attach != (child->right_attach - 1))
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      for (col = child->left_attach; col < child->right_attach; col++)
Packit Service fb6fa5
		table->cols[col].empty = FALSE;
Packit Service fb6fa5
Packit Service fb6fa5
	      if (child->xexpand)
Packit Service fb6fa5
		{
Packit Service fb6fa5
		  has_expand = FALSE;
Packit Service fb6fa5
		  for (col = child->left_attach; col < child->right_attach; col++)
Packit Service fb6fa5
		    if (table->cols[col].expand)
Packit Service fb6fa5
		      {
Packit Service fb6fa5
			has_expand = TRUE;
Packit Service fb6fa5
			break;
Packit Service fb6fa5
		      }
Packit Service fb6fa5
		  
Packit Service fb6fa5
		  if (!has_expand)
Packit Service fb6fa5
		    for (col = child->left_attach; col < child->right_attach; col++)
Packit Service fb6fa5
		      table->cols[col].need_expand = TRUE;
Packit Service fb6fa5
		}
Packit Service fb6fa5
	      
Packit Service fb6fa5
	      if (!child->xshrink)
Packit Service fb6fa5
		{
Packit Service fb6fa5
		  has_shrink = TRUE;
Packit Service fb6fa5
		  for (col = child->left_attach; col < child->right_attach; col++)
Packit Service fb6fa5
		    if (!table->cols[col].shrink)
Packit Service fb6fa5
		      {
Packit Service fb6fa5
			has_shrink = FALSE;
Packit Service fb6fa5
			break;
Packit Service fb6fa5
		      }
Packit Service fb6fa5
		  
Packit Service fb6fa5
		  if (has_shrink)
Packit Service fb6fa5
		    for (col = child->left_attach; col < child->right_attach; col++)
Packit Service fb6fa5
		      table->cols[col].need_shrink = FALSE;
Packit Service fb6fa5
		}
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  if (child->top_attach != (child->bottom_attach - 1))
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      for (row = child->top_attach; row < child->bottom_attach; row++)
Packit Service fb6fa5
		table->rows[row].empty = FALSE;
Packit Service fb6fa5
Packit Service fb6fa5
	      if (child->yexpand)
Packit Service fb6fa5
		{
Packit Service fb6fa5
		  has_expand = FALSE;
Packit Service fb6fa5
		  for (row = child->top_attach; row < child->bottom_attach; row++)
Packit Service fb6fa5
		    if (table->rows[row].expand)
Packit Service fb6fa5
		      {
Packit Service fb6fa5
			has_expand = TRUE;
Packit Service fb6fa5
			break;
Packit Service fb6fa5
		      }
Packit Service fb6fa5
		  
Packit Service fb6fa5
		  if (!has_expand)
Packit Service fb6fa5
		    for (row = child->top_attach; row < child->bottom_attach; row++)
Packit Service fb6fa5
		      table->rows[row].need_expand = TRUE;
Packit Service fb6fa5
		}
Packit Service fb6fa5
	      
Packit Service fb6fa5
	      if (!child->yshrink)
Packit Service fb6fa5
		{
Packit Service fb6fa5
		  has_shrink = TRUE;
Packit Service fb6fa5
		  for (row = child->top_attach; row < child->bottom_attach; row++)
Packit Service fb6fa5
		    if (!table->rows[row].shrink)
Packit Service fb6fa5
		      {
Packit Service fb6fa5
			has_shrink = FALSE;
Packit Service fb6fa5
			break;
Packit Service fb6fa5
		      }
Packit Service fb6fa5
		  
Packit Service fb6fa5
		  if (has_shrink)
Packit Service fb6fa5
		    for (row = child->top_attach; row < child->bottom_attach; row++)
Packit Service fb6fa5
		      table->rows[row].need_shrink = FALSE;
Packit Service fb6fa5
		}
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* Loop over the columns and set the expand and shrink values
Packit Service fb6fa5
   *  if the column can be expanded or shrunk.
Packit Service fb6fa5
   */
Packit Service fb6fa5
  for (col = 0; col < table->ncols; col++)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      if (table->cols[col].empty)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  table->cols[col].expand = FALSE;
Packit Service fb6fa5
	  table->cols[col].shrink = FALSE;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      else
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  if (table->cols[col].need_expand)
Packit Service fb6fa5
	    table->cols[col].expand = TRUE;
Packit Service fb6fa5
	  if (!table->cols[col].need_shrink)
Packit Service fb6fa5
	    table->cols[col].shrink = FALSE;
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* Loop over the rows and set the expand and shrink values
Packit Service fb6fa5
   *  if the row can be expanded or shrunk.
Packit Service fb6fa5
   */
Packit Service fb6fa5
  for (row = 0; row < table->nrows; row++)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      if (table->rows[row].empty)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  table->rows[row].expand = FALSE;
Packit Service fb6fa5
	  table->rows[row].shrink = FALSE;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      else
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  if (table->rows[row].need_expand)
Packit Service fb6fa5
	    table->rows[row].expand = TRUE;
Packit Service fb6fa5
	  if (!table->rows[row].need_shrink)
Packit Service fb6fa5
	    table->rows[row].shrink = FALSE;
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_table_size_allocate_pass1 (GtkTable *table)
Packit Service fb6fa5
{
Packit Service fb6fa5
  gint real_width;
Packit Service fb6fa5
  gint real_height;
Packit Service fb6fa5
  gint width, height;
Packit Service fb6fa5
  gint row, col;
Packit Service fb6fa5
  gint nexpand;
Packit Service fb6fa5
  gint nshrink;
Packit Service fb6fa5
  gint extra;
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* If we were allocated more space than we requested
Packit Service fb6fa5
   *  then we have to expand any expandable rows and columns
Packit Service fb6fa5
   *  to fill in the extra space.
Packit Service fb6fa5
   */
Packit Service fb6fa5
  
Packit Service fb6fa5
  real_width = GTK_WIDGET (table)->allocation.width - GTK_CONTAINER (table)->border_width * 2;
Packit Service fb6fa5
  real_height = GTK_WIDGET (table)->allocation.height - GTK_CONTAINER (table)->border_width * 2;
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (table->homogeneous)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      if (!table->children)
Packit Service fb6fa5
	nexpand = 1;
Packit Service fb6fa5
      else
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  nexpand = 0;
Packit Service fb6fa5
	  for (col = 0; col < table->ncols; col++)
Packit Service fb6fa5
	    if (table->cols[col].expand)
Packit Service fb6fa5
	      {
Packit Service fb6fa5
		nexpand += 1;
Packit Service fb6fa5
		break;
Packit Service fb6fa5
	      }
Packit Service fb6fa5
	}
Packit Service fb6fa5
      if (nexpand)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  width = real_width;
Packit Service fb6fa5
	  for (col = 0; col + 1 < table->ncols; col++)
Packit Service fb6fa5
	    width -= table->cols[col].spacing;
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  for (col = 0; col < table->ncols; col++)
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      extra = width / (table->ncols - col);
Packit Service fb6fa5
	      table->cols[col].allocation = MAX (1, extra);
Packit Service fb6fa5
	      width -= extra;
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    {
Packit Service fb6fa5
      width = 0;
Packit Service fb6fa5
      nexpand = 0;
Packit Service fb6fa5
      nshrink = 0;
Packit Service fb6fa5
      
Packit Service fb6fa5
      for (col = 0; col < table->ncols; col++)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  width += table->cols[col].requisition;
Packit Service fb6fa5
	  if (table->cols[col].expand)
Packit Service fb6fa5
	    nexpand += 1;
Packit Service fb6fa5
	  if (table->cols[col].shrink)
Packit Service fb6fa5
	    nshrink += 1;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      for (col = 0; col + 1 < table->ncols; col++)
Packit Service fb6fa5
	width += table->cols[col].spacing;
Packit Service fb6fa5
      
Packit Service fb6fa5
      /* Check to see if we were allocated more width than we requested.
Packit Service fb6fa5
       */
Packit Service fb6fa5
      if ((width < real_width) && (nexpand >= 1))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  width = real_width - width;
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  for (col = 0; col < table->ncols; col++)
Packit Service fb6fa5
	    if (table->cols[col].expand)
Packit Service fb6fa5
	      {
Packit Service fb6fa5
		extra = width / nexpand;
Packit Service fb6fa5
		table->cols[col].allocation += extra;
Packit Service fb6fa5
		
Packit Service fb6fa5
		width -= extra;
Packit Service fb6fa5
		nexpand -= 1;
Packit Service fb6fa5
	      }
Packit Service fb6fa5
	}
Packit Service fb6fa5
      
Packit Service fb6fa5
      /* Check to see if we were allocated less width than we requested,
Packit Service fb6fa5
       * then shrink until we fit the size give.
Packit Service fb6fa5
       */
Packit Service fb6fa5
      if (width > real_width)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  gint total_nshrink = nshrink;
Packit Service fb6fa5
Packit Service fb6fa5
	  extra = width - real_width;
Packit Service fb6fa5
	  while (total_nshrink > 0 && extra > 0)
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      nshrink = total_nshrink;
Packit Service fb6fa5
	      for (col = 0; col < table->ncols; col++)
Packit Service fb6fa5
		if (table->cols[col].shrink)
Packit Service fb6fa5
		  {
Packit Service fb6fa5
		    gint allocation = table->cols[col].allocation;
Packit Service fb6fa5
Packit Service fb6fa5
		    table->cols[col].allocation = MAX (1, (gint) table->cols[col].allocation - extra / nshrink);
Packit Service fb6fa5
		    extra -= allocation - table->cols[col].allocation;
Packit Service fb6fa5
		    nshrink -= 1;
Packit Service fb6fa5
		    if (table->cols[col].allocation < 2)
Packit Service fb6fa5
		      {
Packit Service fb6fa5
			total_nshrink -= 1;
Packit Service fb6fa5
			table->cols[col].shrink = FALSE;
Packit Service fb6fa5
		      }
Packit Service fb6fa5
		  }
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (table->homogeneous)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      if (!table->children)
Packit Service fb6fa5
	nexpand = 1;
Packit Service fb6fa5
      else
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  nexpand = 0;
Packit Service fb6fa5
	  for (row = 0; row < table->nrows; row++)
Packit Service fb6fa5
	    if (table->rows[row].expand)
Packit Service fb6fa5
	      {
Packit Service fb6fa5
		nexpand += 1;
Packit Service fb6fa5
		break;
Packit Service fb6fa5
	      }
Packit Service fb6fa5
	}
Packit Service fb6fa5
      if (nexpand)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  height = real_height;
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  for (row = 0; row + 1 < table->nrows; row++)
Packit Service fb6fa5
	    height -= table->rows[row].spacing;
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  for (row = 0; row < table->nrows; row++)
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      extra = height / (table->nrows - row);
Packit Service fb6fa5
	      table->rows[row].allocation = MAX (1, extra);
Packit Service fb6fa5
	      height -= extra;
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    {
Packit Service fb6fa5
      height = 0;
Packit Service fb6fa5
      nexpand = 0;
Packit Service fb6fa5
      nshrink = 0;
Packit Service fb6fa5
      
Packit Service fb6fa5
      for (row = 0; row < table->nrows; row++)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  height += table->rows[row].requisition;
Packit Service fb6fa5
	  if (table->rows[row].expand)
Packit Service fb6fa5
	    nexpand += 1;
Packit Service fb6fa5
	  if (table->rows[row].shrink)
Packit Service fb6fa5
	    nshrink += 1;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      for (row = 0; row + 1 < table->nrows; row++)
Packit Service fb6fa5
	height += table->rows[row].spacing;
Packit Service fb6fa5
      
Packit Service fb6fa5
      /* Check to see if we were allocated more height than we requested.
Packit Service fb6fa5
       */
Packit Service fb6fa5
      if ((height < real_height) && (nexpand >= 1))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  height = real_height - height;
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  for (row = 0; row < table->nrows; row++)
Packit Service fb6fa5
	    if (table->rows[row].expand)
Packit Service fb6fa5
	      {
Packit Service fb6fa5
		extra = height / nexpand;
Packit Service fb6fa5
		table->rows[row].allocation += extra;
Packit Service fb6fa5
		
Packit Service fb6fa5
		height -= extra;
Packit Service fb6fa5
		nexpand -= 1;
Packit Service fb6fa5
	      }
Packit Service fb6fa5
	}
Packit Service fb6fa5
      
Packit Service fb6fa5
      /* Check to see if we were allocated less height than we requested.
Packit Service fb6fa5
       * then shrink until we fit the size give.
Packit Service fb6fa5
       */
Packit Service fb6fa5
      if (height > real_height)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  gint total_nshrink = nshrink;
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  extra = height - real_height;
Packit Service fb6fa5
	  while (total_nshrink > 0 && extra > 0)
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      nshrink = total_nshrink;
Packit Service fb6fa5
	      for (row = 0; row < table->nrows; row++)
Packit Service fb6fa5
		if (table->rows[row].shrink)
Packit Service fb6fa5
		  {
Packit Service fb6fa5
		    gint allocation = table->rows[row].allocation;
Packit Service fb6fa5
		    
Packit Service fb6fa5
		    table->rows[row].allocation = MAX (1, (gint) table->rows[row].allocation - extra / nshrink);
Packit Service fb6fa5
		    extra -= allocation - table->rows[row].allocation;
Packit Service fb6fa5
		    nshrink -= 1;
Packit Service fb6fa5
		    if (table->rows[row].allocation < 2)
Packit Service fb6fa5
		      {
Packit Service fb6fa5
			total_nshrink -= 1;
Packit Service fb6fa5
			table->rows[row].shrink = FALSE;
Packit Service fb6fa5
		      }
Packit Service fb6fa5
		  }
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_table_size_allocate_pass2 (GtkTable *table)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkTableChild *child;
Packit Service fb6fa5
  GList *children;
Packit Service fb6fa5
  gint max_width;
Packit Service fb6fa5
  gint max_height;
Packit Service fb6fa5
  gint x, y;
Packit Service fb6fa5
  gint row, col;
Packit Service fb6fa5
  GtkAllocation allocation;
Packit Service fb6fa5
  GtkWidget *widget = GTK_WIDGET (table);
Packit Service fb6fa5
  
Packit Service fb6fa5
  children = table->children;
Packit Service fb6fa5
  while (children)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      child = children->data;
Packit Service fb6fa5
      children = children->next;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (gtk_widget_get_visible (child->widget))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  GtkRequisition child_requisition;
Packit Service fb6fa5
	  gtk_widget_get_child_requisition (child->widget, &child_requisition);
Packit Service fb6fa5
Packit Service fb6fa5
	  x = GTK_WIDGET (table)->allocation.x + GTK_CONTAINER (table)->border_width;
Packit Service fb6fa5
	  y = GTK_WIDGET (table)->allocation.y + GTK_CONTAINER (table)->border_width;
Packit Service fb6fa5
	  max_width = 0;
Packit Service fb6fa5
	  max_height = 0;
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  for (col = 0; col < child->left_attach; col++)
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      x += table->cols[col].allocation;
Packit Service fb6fa5
	      x += table->cols[col].spacing;
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  for (col = child->left_attach; col < child->right_attach; col++)
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      max_width += table->cols[col].allocation;
Packit Service fb6fa5
	      if ((col + 1) < child->right_attach)
Packit Service fb6fa5
		max_width += table->cols[col].spacing;
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  for (row = 0; row < child->top_attach; row++)
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      y += table->rows[row].allocation;
Packit Service fb6fa5
	      y += table->rows[row].spacing;
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  for (row = child->top_attach; row < child->bottom_attach; row++)
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      max_height += table->rows[row].allocation;
Packit Service fb6fa5
	      if ((row + 1) < child->bottom_attach)
Packit Service fb6fa5
		max_height += table->rows[row].spacing;
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  if (child->xfill)
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      allocation.width = MAX (1, max_width - (gint)child->xpadding * 2);
Packit Service fb6fa5
	      allocation.x = x + (max_width - allocation.width) / 2;
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	  else
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      allocation.width = child_requisition.width;
Packit Service fb6fa5
	      allocation.x = x + (max_width - allocation.width) / 2;
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  if (child->yfill)
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      allocation.height = MAX (1, max_height - (gint)child->ypadding * 2);
Packit Service fb6fa5
	      allocation.y = y + (max_height - allocation.height) / 2;
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	  else
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      allocation.height = child_requisition.height;
Packit Service fb6fa5
	      allocation.y = y + (max_height - allocation.height) / 2;
Packit Service fb6fa5
	    }
Packit Service fb6fa5
Packit Service fb6fa5
	  if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
Packit Service fb6fa5
	    allocation.x = widget->allocation.x + widget->allocation.width
Packit Service fb6fa5
	      - (allocation.x - widget->allocation.x) - allocation.width;
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  gtk_widget_size_allocate (child->widget, &allocation);
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
#define __GTK_TABLE_C__
Packit Service fb6fa5
#include "gtkaliasdef.c"