Blame gtk/gtkcontainer.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 <stdarg.h>
Packit Service fb6fa5
#include <string.h>
Packit Service fb6fa5
#include <stdlib.h>
Packit Service fb6fa5
Packit Service fb6fa5
#include "gtkcontainer.h"
Packit Service fb6fa5
#include "gtkbuildable.h"
Packit Service fb6fa5
#include "gtkbuilderprivate.h"
Packit Service fb6fa5
#include "gtkprivate.h"
Packit Service fb6fa5
#include "gtkmain.h"
Packit Service fb6fa5
#include "gtkmarshalers.h"
Packit Service fb6fa5
#include "gtkwindow.h"
Packit Service fb6fa5
#include "gtkintl.h"
Packit Service fb6fa5
#include "gtktoolbar.h"
Packit Service fb6fa5
#include <gobject/gobjectnotifyqueue.c>
Packit Service fb6fa5
#include <gobject/gvaluecollector.h>
Packit Service fb6fa5
#include "gtkalias.h"
Packit Service fb6fa5
Packit Service fb6fa5
Packit Service fb6fa5
enum {
Packit Service fb6fa5
  ADD,
Packit Service fb6fa5
  REMOVE,
Packit Service fb6fa5
  CHECK_RESIZE,
Packit Service fb6fa5
  SET_FOCUS_CHILD,
Packit Service fb6fa5
  LAST_SIGNAL
Packit Service fb6fa5
};
Packit Service fb6fa5
Packit Service fb6fa5
enum {
Packit Service fb6fa5
  PROP_0,
Packit Service fb6fa5
  PROP_BORDER_WIDTH,
Packit Service fb6fa5
  PROP_RESIZE_MODE,
Packit Service fb6fa5
  PROP_CHILD
Packit Service fb6fa5
};
Packit Service fb6fa5
Packit Service fb6fa5
#define PARAM_SPEC_PARAM_ID(pspec)              ((pspec)->param_id)
Packit Service fb6fa5
#define PARAM_SPEC_SET_PARAM_ID(pspec, id)      ((pspec)->param_id = (id))
Packit Service fb6fa5
Packit Service fb6fa5
Packit Service fb6fa5
/* --- prototypes --- */
Packit Service fb6fa5
static void     gtk_container_base_class_init      (GtkContainerClass *klass);
Packit Service fb6fa5
static void     gtk_container_base_class_finalize  (GtkContainerClass *klass);
Packit Service fb6fa5
static void     gtk_container_class_init           (GtkContainerClass *klass);
Packit Service fb6fa5
static void     gtk_container_init                 (GtkContainer      *container);
Packit Service fb6fa5
static void     gtk_container_destroy              (GtkObject         *object);
Packit Service fb6fa5
static void     gtk_container_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_container_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_container_add_unimplemented    (GtkContainer      *container,
Packit Service fb6fa5
						    GtkWidget         *widget);
Packit Service fb6fa5
static void     gtk_container_remove_unimplemented (GtkContainer      *container,
Packit Service fb6fa5
						    GtkWidget         *widget);
Packit Service fb6fa5
static void     gtk_container_real_check_resize    (GtkContainer      *container);
Packit Service fb6fa5
static gboolean gtk_container_focus                (GtkWidget         *widget,
Packit Service fb6fa5
						    GtkDirectionType   direction);
Packit Service fb6fa5
static void     gtk_container_real_set_focus_child (GtkContainer      *container,
Packit Service fb6fa5
						    GtkWidget         *widget);
Packit Service fb6fa5
Packit Service fb6fa5
static gboolean gtk_container_focus_move           (GtkContainer      *container,
Packit Service fb6fa5
						    GList             *children,
Packit Service fb6fa5
						    GtkDirectionType   direction);
Packit Service fb6fa5
static void     gtk_container_children_callback    (GtkWidget         *widget,
Packit Service fb6fa5
						    gpointer           client_data);
Packit Service fb6fa5
static void     gtk_container_show_all             (GtkWidget         *widget);
Packit Service fb6fa5
static void     gtk_container_hide_all             (GtkWidget         *widget);
Packit Service fb6fa5
static gint     gtk_container_expose               (GtkWidget         *widget,
Packit Service fb6fa5
						    GdkEventExpose    *event);
Packit Service fb6fa5
static void     gtk_container_map                  (GtkWidget         *widget);
Packit Service fb6fa5
static void     gtk_container_unmap                (GtkWidget         *widget);
Packit Service fb6fa5
Packit Service fb6fa5
static gchar* gtk_container_child_default_composite_name (GtkContainer *container,
Packit Service fb6fa5
							  GtkWidget    *child);
Packit Service fb6fa5
Packit Service fb6fa5
/* GtkBuildable */
Packit Service fb6fa5
static void gtk_container_buildable_init           (GtkBuildableIface *iface);
Packit Service fb6fa5
static void gtk_container_buildable_add_child      (GtkBuildable *buildable,
Packit Service fb6fa5
						    GtkBuilder   *builder,
Packit Service fb6fa5
						    GObject      *child,
Packit Service fb6fa5
						    const gchar  *type);
Packit Service fb6fa5
static gboolean gtk_container_buildable_custom_tag_start (GtkBuildable  *buildable,
Packit Service fb6fa5
							  GtkBuilder    *builder,
Packit Service fb6fa5
							  GObject       *child,
Packit Service fb6fa5
							  const gchar   *tagname,
Packit Service fb6fa5
							  GMarkupParser *parser,
Packit Service fb6fa5
							  gpointer      *data);
Packit Service fb6fa5
static void    gtk_container_buildable_custom_tag_end (GtkBuildable *buildable,
Packit Service fb6fa5
						       GtkBuilder   *builder,
Packit Service fb6fa5
						       GObject      *child,
Packit Service fb6fa5
						       const gchar  *tagname,
Packit Service fb6fa5
						       gpointer     *data);
Packit Service fb6fa5
Packit Service fb6fa5
Packit Service fb6fa5
/* --- variables --- */
Packit Service fb6fa5
static const gchar           vadjustment_key[] = "gtk-vadjustment";
Packit Service fb6fa5
static guint                 vadjustment_key_id = 0;
Packit Service fb6fa5
static const gchar           hadjustment_key[] = "gtk-hadjustment";
Packit Service fb6fa5
static guint                 hadjustment_key_id = 0;
Packit Service fb6fa5
static GSList	            *container_resize_queue = NULL;
Packit Service fb6fa5
static guint                 container_signals[LAST_SIGNAL] = { 0 };
Packit Service fb6fa5
static GtkWidgetClass       *parent_class = NULL;
Packit Service fb6fa5
extern GParamSpecPool       *_gtk_widget_child_property_pool;
Packit Service fb6fa5
extern GObjectNotifyContext *_gtk_widget_child_property_notify_context;
Packit Service fb6fa5
static GtkBuildableIface    *parent_buildable_iface;
Packit Service fb6fa5
Packit Service fb6fa5
Packit Service fb6fa5
/* --- functions --- */
Packit Service fb6fa5
GType
Packit Service fb6fa5
gtk_container_get_type (void)
Packit Service fb6fa5
{
Packit Service fb6fa5
  static GType container_type = 0;
Packit Service fb6fa5
Packit Service fb6fa5
  if (!container_type)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      const GTypeInfo container_info =
Packit Service fb6fa5
      {
Packit Service fb6fa5
	sizeof (GtkContainerClass),
Packit Service fb6fa5
	(GBaseInitFunc) gtk_container_base_class_init,
Packit Service fb6fa5
	(GBaseFinalizeFunc) gtk_container_base_class_finalize,
Packit Service fb6fa5
	(GClassInitFunc) gtk_container_class_init,
Packit Service fb6fa5
	NULL        /* class_finalize */,
Packit Service fb6fa5
	NULL        /* class_data */,
Packit Service fb6fa5
	sizeof (GtkContainer),
Packit Service fb6fa5
	0           /* n_preallocs */,
Packit Service fb6fa5
	(GInstanceInitFunc) gtk_container_init,
Packit Service fb6fa5
	NULL,       /* value_table */
Packit Service fb6fa5
      };
Packit Service fb6fa5
Packit Service fb6fa5
      const GInterfaceInfo buildable_info =
Packit Service fb6fa5
      {
Packit Service fb6fa5
	(GInterfaceInitFunc) gtk_container_buildable_init,
Packit Service fb6fa5
	NULL,
Packit Service fb6fa5
	NULL
Packit Service fb6fa5
      };
Packit Service fb6fa5
Packit Service fb6fa5
      container_type =
Packit Service fb6fa5
	g_type_register_static (GTK_TYPE_WIDGET, I_("GtkContainer"), 
Packit Service fb6fa5
				&container_info, G_TYPE_FLAG_ABSTRACT);
Packit Service fb6fa5
Packit Service fb6fa5
      g_type_add_interface_static (container_type,
Packit Service fb6fa5
				   GTK_TYPE_BUILDABLE,
Packit Service fb6fa5
				   &buildable_info);
Packit Service fb6fa5
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  return container_type;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_container_base_class_init (GtkContainerClass *class)
Packit Service fb6fa5
{
Packit Service fb6fa5
  /* reset instance specifc class fields that don't get inherited */
Packit Service fb6fa5
  class->set_child_property = NULL;
Packit Service fb6fa5
  class->get_child_property = NULL;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_container_base_class_finalize (GtkContainerClass *class)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GList *list, *node;
Packit Service fb6fa5
Packit Service fb6fa5
  list = g_param_spec_pool_list_owned (_gtk_widget_child_property_pool, G_OBJECT_CLASS_TYPE (class));
Packit Service fb6fa5
  for (node = list; node; node = node->next)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GParamSpec *pspec = node->data;
Packit Service fb6fa5
Packit Service fb6fa5
      g_param_spec_pool_remove (_gtk_widget_child_property_pool, pspec);
Packit Service fb6fa5
      PARAM_SPEC_SET_PARAM_ID (pspec, 0);
Packit Service fb6fa5
      g_param_spec_unref (pspec);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  g_list_free (list);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_container_class_init (GtkContainerClass *class)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GObjectClass *gobject_class = G_OBJECT_CLASS (class);
Packit Service fb6fa5
  GtkObjectClass *object_class = GTK_OBJECT_CLASS (class);
Packit Service fb6fa5
  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
Packit Service fb6fa5
Packit Service fb6fa5
  parent_class = g_type_class_peek_parent (class);
Packit Service fb6fa5
Packit Service fb6fa5
  vadjustment_key_id = g_quark_from_static_string (vadjustment_key);
Packit Service fb6fa5
  hadjustment_key_id = g_quark_from_static_string (hadjustment_key);
Packit Service fb6fa5
  
Packit Service fb6fa5
  gobject_class->set_property = gtk_container_set_property;
Packit Service fb6fa5
  gobject_class->get_property = gtk_container_get_property;
Packit Service fb6fa5
Packit Service fb6fa5
  object_class->destroy = gtk_container_destroy;
Packit Service fb6fa5
Packit Service fb6fa5
  widget_class->show_all = gtk_container_show_all;
Packit Service fb6fa5
  widget_class->hide_all = gtk_container_hide_all;
Packit Service fb6fa5
  widget_class->expose_event = gtk_container_expose;
Packit Service fb6fa5
  widget_class->map = gtk_container_map;
Packit Service fb6fa5
  widget_class->unmap = gtk_container_unmap;
Packit Service fb6fa5
  widget_class->focus = gtk_container_focus;
Packit Service fb6fa5
  
Packit Service fb6fa5
  class->add = gtk_container_add_unimplemented;
Packit Service fb6fa5
  class->remove = gtk_container_remove_unimplemented;
Packit Service fb6fa5
  class->check_resize = gtk_container_real_check_resize;
Packit Service fb6fa5
  class->forall = NULL;
Packit Service fb6fa5
  class->set_focus_child = gtk_container_real_set_focus_child;
Packit Service fb6fa5
  class->child_type = NULL;
Packit Service fb6fa5
  class->composite_name = gtk_container_child_default_composite_name;
Packit Service fb6fa5
Packit Service fb6fa5
  g_object_class_install_property (gobject_class,
Packit Service fb6fa5
                                   PROP_RESIZE_MODE,
Packit Service fb6fa5
                                   g_param_spec_enum ("resize-mode",
Packit Service fb6fa5
                                                      P_("Resize mode"),
Packit Service fb6fa5
                                                      P_("Specify how resize events are handled"),
Packit Service fb6fa5
                                                      GTK_TYPE_RESIZE_MODE,
Packit Service fb6fa5
                                                      GTK_RESIZE_PARENT,
Packit Service fb6fa5
                                                      GTK_PARAM_READWRITE));
Packit Service fb6fa5
  g_object_class_install_property (gobject_class,
Packit Service fb6fa5
                                   PROP_BORDER_WIDTH,
Packit Service fb6fa5
                                   g_param_spec_uint ("border-width",
Packit Service fb6fa5
                                                      P_("Border width"),
Packit Service fb6fa5
                                                      P_("The width of the empty border outside the containers children"),
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_CHILD,
Packit Service fb6fa5
                                   g_param_spec_object ("child",
Packit Service fb6fa5
                                                      P_("Child"),
Packit Service fb6fa5
                                                      P_("Can be used to add a new child to the container"),
Packit Service fb6fa5
                                                      GTK_TYPE_WIDGET,
Packit Service fb6fa5
						      GTK_PARAM_WRITABLE));
Packit Service fb6fa5
  container_signals[ADD] =
Packit Service fb6fa5
    g_signal_new (I_("add"),
Packit Service fb6fa5
		  G_OBJECT_CLASS_TYPE (object_class),
Packit Service fb6fa5
		  G_SIGNAL_RUN_FIRST,
Packit Service fb6fa5
		  G_STRUCT_OFFSET (GtkContainerClass, add),
Packit Service fb6fa5
		  NULL, NULL,
Packit Service fb6fa5
		  _gtk_marshal_VOID__OBJECT,
Packit Service fb6fa5
		  G_TYPE_NONE, 1,
Packit Service fb6fa5
		  GTK_TYPE_WIDGET);
Packit Service fb6fa5
  container_signals[REMOVE] =
Packit Service fb6fa5
    g_signal_new (I_("remove"),
Packit Service fb6fa5
		  G_OBJECT_CLASS_TYPE (object_class),
Packit Service fb6fa5
		  G_SIGNAL_RUN_FIRST,
Packit Service fb6fa5
		  G_STRUCT_OFFSET (GtkContainerClass, remove),
Packit Service fb6fa5
		  NULL, NULL,
Packit Service fb6fa5
		  _gtk_marshal_VOID__OBJECT,
Packit Service fb6fa5
		  G_TYPE_NONE, 1,
Packit Service fb6fa5
		  GTK_TYPE_WIDGET);
Packit Service fb6fa5
  container_signals[CHECK_RESIZE] =
Packit Service fb6fa5
    g_signal_new (I_("check-resize"),
Packit Service fb6fa5
		  G_OBJECT_CLASS_TYPE (object_class),
Packit Service fb6fa5
		  G_SIGNAL_RUN_LAST,
Packit Service fb6fa5
		  G_STRUCT_OFFSET (GtkContainerClass, check_resize),
Packit Service fb6fa5
		  NULL, NULL,
Packit Service fb6fa5
		  _gtk_marshal_VOID__VOID,
Packit Service fb6fa5
		  G_TYPE_NONE, 0);
Packit Service fb6fa5
  container_signals[SET_FOCUS_CHILD] =
Packit Service fb6fa5
    g_signal_new (I_("set-focus-child"),
Packit Service fb6fa5
		  G_OBJECT_CLASS_TYPE (object_class),
Packit Service fb6fa5
		  G_SIGNAL_RUN_FIRST,
Packit Service fb6fa5
		  G_STRUCT_OFFSET (GtkContainerClass, set_focus_child),
Packit Service fb6fa5
		  NULL, NULL,
Packit Service fb6fa5
		  _gtk_marshal_VOID__OBJECT,
Packit Service fb6fa5
		  G_TYPE_NONE, 1,
Packit Service fb6fa5
		  GTK_TYPE_WIDGET);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_container_buildable_init (GtkBuildableIface *iface)
Packit Service fb6fa5
{
Packit Service fb6fa5
  parent_buildable_iface = g_type_interface_peek_parent (iface);
Packit Service fb6fa5
  iface->add_child = gtk_container_buildable_add_child;
Packit Service fb6fa5
  iface->custom_tag_start = gtk_container_buildable_custom_tag_start;
Packit Service fb6fa5
  iface->custom_tag_end = gtk_container_buildable_custom_tag_end;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_container_buildable_add_child (GtkBuildable  *buildable,
Packit Service fb6fa5
				   GtkBuilder    *builder,
Packit Service fb6fa5
				   GObject       *child,
Packit Service fb6fa5
				   const gchar   *type)
Packit Service fb6fa5
{
Packit Service fb6fa5
  if (type)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GTK_BUILDER_WARN_INVALID_CHILD_TYPE (buildable, type);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else if (GTK_IS_WIDGET (child) && GTK_WIDGET (child)->parent == NULL)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      gtk_container_add (GTK_CONTAINER (buildable), GTK_WIDGET (child));
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    g_warning ("Cannot add an object of type %s to a container of type %s", 
Packit Service fb6fa5
	       g_type_name (G_OBJECT_TYPE (child)), g_type_name (G_OBJECT_TYPE (buildable)));
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_container_buildable_set_child_property (GtkContainer *container,
Packit Service fb6fa5
					    GtkBuilder   *builder,
Packit Service fb6fa5
					    GtkWidget    *child,
Packit Service fb6fa5
					    gchar        *name,
Packit Service fb6fa5
					    const gchar  *value)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GParamSpec *pspec;
Packit Service fb6fa5
  GValue gvalue = { 0, };
Packit Service fb6fa5
  GError *error = NULL;
Packit Service fb6fa5
  
Packit Service fb6fa5
  pspec = gtk_container_class_find_child_property
Packit Service fb6fa5
    (G_OBJECT_GET_CLASS (container), name);
Packit Service fb6fa5
  if (!pspec)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      g_warning ("%s does not have a property called %s",
Packit Service fb6fa5
		 g_type_name (G_OBJECT_TYPE (container)), name);
Packit Service fb6fa5
      return;
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  if (!gtk_builder_value_from_string (builder, pspec, value, &gvalue, &error))
Packit Service fb6fa5
    {
Packit Service fb6fa5
      g_warning ("Could not read property %s:%s with value %s of type %s: %s",
Packit Service fb6fa5
		 g_type_name (G_OBJECT_TYPE (container)),
Packit Service fb6fa5
		 name,
Packit Service fb6fa5
		 value,
Packit Service fb6fa5
		 g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
Packit Service fb6fa5
		 error->message);
Packit Service fb6fa5
      g_error_free (error);
Packit Service fb6fa5
      return;
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  gtk_container_child_set_property (container, child, name, &gvalue);
Packit Service fb6fa5
  g_value_unset (&gvalue);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
typedef struct {
Packit Service fb6fa5
  GtkBuilder   *builder;
Packit Service fb6fa5
  GtkContainer *container;
Packit Service fb6fa5
  GtkWidget    *child;
Packit Service fb6fa5
  gchar        *child_prop_name;
Packit Service fb6fa5
  gchar        *context;
Packit Service fb6fa5
  gboolean     translatable;
Packit Service fb6fa5
} PackingPropertiesData;
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
attributes_start_element (GMarkupParseContext *context,
Packit Service fb6fa5
			  const gchar         *element_name,
Packit Service fb6fa5
			  const gchar        **names,
Packit Service fb6fa5
			  const gchar        **values,
Packit Service fb6fa5
			  gpointer             user_data,
Packit Service fb6fa5
			  GError             **error)
Packit Service fb6fa5
{
Packit Service fb6fa5
  PackingPropertiesData *parser_data = (PackingPropertiesData*)user_data;
Packit Service fb6fa5
  guint i;
Packit Service fb6fa5
Packit Service fb6fa5
  if (strcmp (element_name, "property") == 0)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      for (i = 0; names[i]; i++)
Packit Service fb6fa5
	if (strcmp (names[i], "name") == 0)
Packit Service fb6fa5
	  parser_data->child_prop_name = g_strdup (values[i]);
Packit Service fb6fa5
	else if (strcmp (names[i], "translatable") == 0)
Packit Service fb6fa5
	  {
Packit Service fb6fa5
	    if (!_gtk_builder_boolean_from_string (values[1],
Packit Service fb6fa5
						   &parser_data->translatable,
Packit Service fb6fa5
						   error))
Packit Service fb6fa5
	      return;
Packit Service fb6fa5
	  }
Packit Service fb6fa5
	else if (strcmp (names[i], "comments") == 0)
Packit Service fb6fa5
	  ; /* for translators */
Packit Service fb6fa5
	else if (strcmp (names[i], "context") == 0)
Packit Service fb6fa5
	  parser_data->context = g_strdup (values[1]);
Packit Service fb6fa5
	else
Packit Service fb6fa5
	  g_warning ("Unsupported attribute for GtkContainer Child "
Packit Service fb6fa5
		     "property: %s\n", names[i]);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else if (strcmp (element_name, "packing") == 0)
Packit Service fb6fa5
    return;
Packit Service fb6fa5
  else
Packit Service fb6fa5
    g_warning ("Unsupported tag for GtkContainer: %s\n", element_name);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
attributes_text_element (GMarkupParseContext *context,
Packit Service fb6fa5
			 const gchar         *text,
Packit Service fb6fa5
			 gsize                text_len,
Packit Service fb6fa5
			 gpointer             user_data,
Packit Service fb6fa5
			 GError             **error)
Packit Service fb6fa5
{
Packit Service fb6fa5
  PackingPropertiesData *parser_data = (PackingPropertiesData*)user_data;
Packit Service fb6fa5
  gchar* value;
Packit Service fb6fa5
Packit Service fb6fa5
  if (!parser_data->child_prop_name)
Packit Service fb6fa5
    return;
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (parser_data->translatable && text_len)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      const gchar* domain;
Packit Service fb6fa5
      domain = gtk_builder_get_translation_domain (parser_data->builder);
Packit Service fb6fa5
      
Packit Service fb6fa5
      value = _gtk_builder_parser_translate (domain,
Packit Service fb6fa5
					     parser_data->context,
Packit Service fb6fa5
					     text);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    {
Packit Service fb6fa5
      value = g_strdup (text);
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  gtk_container_buildable_set_child_property (parser_data->container,
Packit Service fb6fa5
					      parser_data->builder,
Packit Service fb6fa5
					      parser_data->child,
Packit Service fb6fa5
					      parser_data->child_prop_name,
Packit Service fb6fa5
					      value);
Packit Service fb6fa5
Packit Service fb6fa5
  g_free (parser_data->child_prop_name);
Packit Service fb6fa5
  g_free (parser_data->context);
Packit Service fb6fa5
  g_free (value);
Packit Service fb6fa5
  parser_data->child_prop_name = NULL;
Packit Service fb6fa5
  parser_data->context = NULL;
Packit Service fb6fa5
  parser_data->translatable = FALSE;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static const GMarkupParser attributes_parser =
Packit Service fb6fa5
  {
Packit Service fb6fa5
    attributes_start_element,
Packit Service fb6fa5
    NULL,
Packit Service fb6fa5
    attributes_text_element,
Packit Service fb6fa5
  };
Packit Service fb6fa5
Packit Service fb6fa5
static gboolean
Packit Service fb6fa5
gtk_container_buildable_custom_tag_start (GtkBuildable  *buildable,
Packit Service fb6fa5
					  GtkBuilder    *builder,
Packit Service fb6fa5
					  GObject       *child,
Packit Service fb6fa5
					  const gchar   *tagname,
Packit Service fb6fa5
					  GMarkupParser *parser,
Packit Service fb6fa5
					  gpointer      *data)
Packit Service fb6fa5
{
Packit Service fb6fa5
  PackingPropertiesData *parser_data;
Packit Service fb6fa5
Packit Service fb6fa5
  if (parent_buildable_iface->custom_tag_start (buildable, builder, child,
Packit Service fb6fa5
						tagname, parser, data))
Packit Service fb6fa5
    return TRUE;
Packit Service fb6fa5
Packit Service fb6fa5
  if (child && strcmp (tagname, "packing") == 0)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      parser_data = g_slice_new0 (PackingPropertiesData);
Packit Service fb6fa5
      parser_data->builder = builder;
Packit Service fb6fa5
      parser_data->container = GTK_CONTAINER (buildable);
Packit Service fb6fa5
      parser_data->child = GTK_WIDGET (child);
Packit Service fb6fa5
      parser_data->child_prop_name = NULL;
Packit Service fb6fa5
Packit Service fb6fa5
      *parser = attributes_parser;
Packit Service fb6fa5
      *data = parser_data;
Packit Service fb6fa5
      return TRUE;
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  return FALSE;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_container_buildable_custom_tag_end (GtkBuildable *buildable,
Packit Service fb6fa5
					GtkBuilder   *builder,
Packit Service fb6fa5
					GObject      *child,
Packit Service fb6fa5
					const gchar  *tagname,
Packit Service fb6fa5
					gpointer     *data)
Packit Service fb6fa5
{
Packit Service fb6fa5
  if (strcmp (tagname, "packing") == 0)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      g_slice_free (PackingPropertiesData, (gpointer)data);
Packit Service fb6fa5
      return;
Packit Service fb6fa5
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  if (parent_buildable_iface->custom_tag_end)
Packit Service fb6fa5
    parent_buildable_iface->custom_tag_end (buildable, builder,
Packit Service fb6fa5
					    child, tagname, data);
Packit Service fb6fa5
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_child_type: 
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Returns the type of the children supported by the container.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Note that this may return %G_TYPE_NONE to indicate that no more
Packit Service fb6fa5
 * children can be added, e.g. for a #GtkPaned which already has two 
Packit Service fb6fa5
 * children.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Return value: a #GType.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
GType
Packit Service fb6fa5
gtk_container_child_type (GtkContainer *container)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GType slot;
Packit Service fb6fa5
  GtkContainerClass *class;
Packit Service fb6fa5
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_CONTAINER (container), 0);
Packit Service fb6fa5
Packit Service fb6fa5
  class = GTK_CONTAINER_GET_CLASS (container);
Packit Service fb6fa5
  if (class->child_type)
Packit Service fb6fa5
    slot = class->child_type (container);
Packit Service fb6fa5
  else
Packit Service fb6fa5
    slot = G_TYPE_NONE;
Packit Service fb6fa5
Packit Service fb6fa5
  return slot;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/* --- GtkContainer child property mechanism --- */
Packit Service fb6fa5
static inline void
Packit Service fb6fa5
container_get_child_property (GtkContainer *container,
Packit Service fb6fa5
			      GtkWidget    *child,
Packit Service fb6fa5
			      GParamSpec   *pspec,
Packit Service fb6fa5
			      GValue       *value)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkContainerClass *class = g_type_class_peek (pspec->owner_type);
Packit Service fb6fa5
  
Packit Service fb6fa5
  class->get_child_property (container, child, PARAM_SPEC_PARAM_ID (pspec), value, pspec);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static inline void
Packit Service fb6fa5
container_set_child_property (GtkContainer       *container,
Packit Service fb6fa5
			      GtkWidget		 *child,
Packit Service fb6fa5
			      GParamSpec         *pspec,
Packit Service fb6fa5
			      const GValue       *value,
Packit Service fb6fa5
			      GObjectNotifyQueue *nqueue)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GValue tmp_value = { 0, };
Packit Service fb6fa5
  GtkContainerClass *class = g_type_class_peek (pspec->owner_type);
Packit Service fb6fa5
Packit Service fb6fa5
  /* provide a copy to work from, convert (if necessary) and validate */
Packit Service fb6fa5
  g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
Packit Service fb6fa5
  if (!g_value_transform (value, &tmp_value))
Packit Service fb6fa5
    g_warning ("unable to set child property `%s' of type `%s' from value of type `%s'",
Packit Service fb6fa5
	       pspec->name,
Packit Service fb6fa5
	       g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
Packit Service fb6fa5
	       G_VALUE_TYPE_NAME (value));
Packit Service fb6fa5
  else if (g_param_value_validate (pspec, &tmp_value) && !(pspec->flags & G_PARAM_LAX_VALIDATION))
Packit Service fb6fa5
    {
Packit Service fb6fa5
      gchar *contents = g_strdup_value_contents (value);
Packit Service fb6fa5
Packit Service fb6fa5
      g_warning ("value \"%s\" of type `%s' is invalid for property `%s' of type `%s'",
Packit Service fb6fa5
		 contents,
Packit Service fb6fa5
		 G_VALUE_TYPE_NAME (value),
Packit Service fb6fa5
		 pspec->name,
Packit Service fb6fa5
		 g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
Packit Service fb6fa5
      g_free (contents);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    {
Packit Service fb6fa5
      class->set_child_property (container, child, PARAM_SPEC_PARAM_ID (pspec), &tmp_value, pspec);
Packit Service fb6fa5
      g_object_notify_queue_add (G_OBJECT (child), nqueue, pspec);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  g_value_unset (&tmp_value);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_child_get_valist:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 * @child: a widget which is a child of @container
Packit Service fb6fa5
 * @first_property_name: the name of the first property to get
Packit Service fb6fa5
 * @var_args: return location for the first property, followed 
Packit Service fb6fa5
 *     optionally by more name/return location pairs, followed by %NULL
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Gets the values of one or more child properties for @child and @container.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_child_get_valist (GtkContainer *container,
Packit Service fb6fa5
				GtkWidget    *child,
Packit Service fb6fa5
				const gchar  *first_property_name,
Packit Service fb6fa5
				va_list       var_args)
Packit Service fb6fa5
{
Packit Service fb6fa5
  const gchar *name;
Packit Service fb6fa5
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_WIDGET (child));
Packit Service fb6fa5
  g_return_if_fail (child->parent == GTK_WIDGET (container));
Packit Service fb6fa5
Packit Service fb6fa5
  g_object_ref (container);
Packit Service fb6fa5
  g_object_ref (child);
Packit Service fb6fa5
Packit Service fb6fa5
  name = first_property_name;
Packit Service fb6fa5
  while (name)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GValue value = { 0, };
Packit Service fb6fa5
      GParamSpec *pspec;
Packit Service fb6fa5
      gchar *error;
Packit Service fb6fa5
Packit Service fb6fa5
      pspec = g_param_spec_pool_lookup (_gtk_widget_child_property_pool,
Packit Service fb6fa5
					name,
Packit Service fb6fa5
					G_OBJECT_TYPE (container),
Packit Service fb6fa5
					TRUE);
Packit Service fb6fa5
      if (!pspec)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  g_warning ("%s: container class `%s' has no child property named `%s'",
Packit Service fb6fa5
		     G_STRLOC,
Packit Service fb6fa5
		     G_OBJECT_TYPE_NAME (container),
Packit Service fb6fa5
		     name);
Packit Service fb6fa5
	  break;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      if (!(pspec->flags & G_PARAM_READABLE))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  g_warning ("%s: child property `%s' of container class `%s' is not readable",
Packit Service fb6fa5
		     G_STRLOC,
Packit Service fb6fa5
		     pspec->name,
Packit Service fb6fa5
		     G_OBJECT_TYPE_NAME (container));
Packit Service fb6fa5
	  break;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
Packit Service fb6fa5
      container_get_child_property (container, child, pspec, &value);
Packit Service fb6fa5
      G_VALUE_LCOPY (&value, var_args, 0, &error);
Packit Service fb6fa5
      if (error)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  g_warning ("%s: %s", G_STRLOC, error);
Packit Service fb6fa5
	  g_free (error);
Packit Service fb6fa5
	  g_value_unset (&value);
Packit Service fb6fa5
	  break;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      g_value_unset (&value);
Packit Service fb6fa5
      name = va_arg (var_args, gchar*);
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  g_object_unref (child);
Packit Service fb6fa5
  g_object_unref (container);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_child_get_property:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 * @child: a widget which is a child of @container
Packit Service fb6fa5
 * @property_name: the name of the property to get
Packit Service fb6fa5
 * @value: a location to return the value
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Gets the value of a child property for @child and @container.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_child_get_property (GtkContainer *container,
Packit Service fb6fa5
				  GtkWidget    *child,
Packit Service fb6fa5
				  const gchar  *property_name,
Packit Service fb6fa5
				  GValue       *value)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GParamSpec *pspec;
Packit Service fb6fa5
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_WIDGET (child));
Packit Service fb6fa5
  g_return_if_fail (child->parent == GTK_WIDGET (container));
Packit Service fb6fa5
  g_return_if_fail (property_name != NULL);
Packit Service fb6fa5
  g_return_if_fail (G_IS_VALUE (value));
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_object_ref (container);
Packit Service fb6fa5
  g_object_ref (child);
Packit Service fb6fa5
  pspec = g_param_spec_pool_lookup (_gtk_widget_child_property_pool, property_name,
Packit Service fb6fa5
				    G_OBJECT_TYPE (container), TRUE);
Packit Service fb6fa5
  if (!pspec)
Packit Service fb6fa5
    g_warning ("%s: container class `%s' has no child property named `%s'",
Packit Service fb6fa5
	       G_STRLOC,
Packit Service fb6fa5
	       G_OBJECT_TYPE_NAME (container),
Packit Service fb6fa5
	       property_name);
Packit Service fb6fa5
  else if (!(pspec->flags & G_PARAM_READABLE))
Packit Service fb6fa5
    g_warning ("%s: child property `%s' of container class `%s' is not readable",
Packit Service fb6fa5
	       G_STRLOC,
Packit Service fb6fa5
	       pspec->name,
Packit Service fb6fa5
	       G_OBJECT_TYPE_NAME (container));
Packit Service fb6fa5
  else
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GValue *prop_value, tmp_value = { 0, };
Packit Service fb6fa5
Packit Service fb6fa5
      /* auto-conversion of the callers value type
Packit Service fb6fa5
       */
Packit Service fb6fa5
      if (G_VALUE_TYPE (value) == G_PARAM_SPEC_VALUE_TYPE (pspec))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  g_value_reset (value);
Packit Service fb6fa5
	  prop_value = value;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      else if (!g_value_type_transformable (G_PARAM_SPEC_VALUE_TYPE (pspec), G_VALUE_TYPE (value)))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  g_warning ("can't retrieve child property `%s' of type `%s' as value of type `%s'",
Packit Service fb6fa5
		     pspec->name,
Packit Service fb6fa5
		     g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
Packit Service fb6fa5
		     G_VALUE_TYPE_NAME (value));
Packit Service fb6fa5
	  g_object_unref (child);
Packit Service fb6fa5
	  g_object_unref (container);
Packit Service fb6fa5
	  return;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      else
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
Packit Service fb6fa5
	  prop_value = &tmp_value;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      container_get_child_property (container, child, pspec, prop_value);
Packit Service fb6fa5
      if (prop_value != value)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  g_value_transform (prop_value, value);
Packit Service fb6fa5
	  g_value_unset (&tmp_value);
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
  g_object_unref (child);
Packit Service fb6fa5
  g_object_unref (container);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_child_set_valist:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 * @child: a widget which is a child of @container
Packit Service fb6fa5
 * @first_property_name: the name of the first property to set
Packit Service fb6fa5
 * @var_args: a %NULL-terminated list of property names and values, starting
Packit Service fb6fa5
 *           with @first_prop_name
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Sets one or more child properties for @child and @container.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_child_set_valist (GtkContainer *container,
Packit Service fb6fa5
				GtkWidget    *child,
Packit Service fb6fa5
				const gchar  *first_property_name,
Packit Service fb6fa5
				va_list       var_args)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GObjectNotifyQueue *nqueue;
Packit Service fb6fa5
  const gchar *name;
Packit Service fb6fa5
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_WIDGET (child));
Packit Service fb6fa5
  g_return_if_fail (child->parent == GTK_WIDGET (container));
Packit Service fb6fa5
Packit Service fb6fa5
  g_object_ref (container);
Packit Service fb6fa5
  g_object_ref (child);
Packit Service fb6fa5
Packit Service fb6fa5
  nqueue = g_object_notify_queue_freeze (G_OBJECT (child), _gtk_widget_child_property_notify_context);
Packit Service fb6fa5
  name = first_property_name;
Packit Service fb6fa5
  while (name)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GValue value = { 0, };
Packit Service fb6fa5
      gchar *error = NULL;
Packit Service fb6fa5
      GParamSpec *pspec = g_param_spec_pool_lookup (_gtk_widget_child_property_pool,
Packit Service fb6fa5
						    name,
Packit Service fb6fa5
						    G_OBJECT_TYPE (container),
Packit Service fb6fa5
						    TRUE);
Packit Service fb6fa5
      if (!pspec)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  g_warning ("%s: container class `%s' has no child property named `%s'",
Packit Service fb6fa5
		     G_STRLOC,
Packit Service fb6fa5
		     G_OBJECT_TYPE_NAME (container),
Packit Service fb6fa5
		     name);
Packit Service fb6fa5
	  break;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      if (!(pspec->flags & G_PARAM_WRITABLE))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  g_warning ("%s: child property `%s' of container class `%s' is not writable",
Packit Service fb6fa5
		     G_STRLOC,
Packit Service fb6fa5
		     pspec->name,
Packit Service fb6fa5
		     G_OBJECT_TYPE_NAME (container));
Packit Service fb6fa5
	  break;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
Packit Service fb6fa5
      G_VALUE_COLLECT (&value, var_args, 0, &error);
Packit Service fb6fa5
      if (error)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  g_warning ("%s: %s", G_STRLOC, error);
Packit Service fb6fa5
	  g_free (error);
Packit Service fb6fa5
Packit Service fb6fa5
	  /* we purposely leak the value here, it might not be
Packit Service fb6fa5
	   * in a sane state if an error condition occoured
Packit Service fb6fa5
	   */
Packit Service fb6fa5
	  break;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      container_set_child_property (container, child, pspec, &value, nqueue);
Packit Service fb6fa5
      g_value_unset (&value);
Packit Service fb6fa5
      name = va_arg (var_args, gchar*);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  g_object_notify_queue_thaw (G_OBJECT (child), nqueue);
Packit Service fb6fa5
Packit Service fb6fa5
  g_object_unref (container);
Packit Service fb6fa5
  g_object_unref (child);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_child_set_property:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 * @child: a widget which is a child of @container
Packit Service fb6fa5
 * @property_name: the name of the property to set
Packit Service fb6fa5
 * @value: the value to set the property to
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Sets a child property for @child and @container.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_child_set_property (GtkContainer *container,
Packit Service fb6fa5
				  GtkWidget    *child,
Packit Service fb6fa5
				  const gchar  *property_name,
Packit Service fb6fa5
				  const GValue *value)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GObjectNotifyQueue *nqueue;
Packit Service fb6fa5
  GParamSpec *pspec;
Packit Service fb6fa5
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_WIDGET (child));
Packit Service fb6fa5
  g_return_if_fail (child->parent == GTK_WIDGET (container));
Packit Service fb6fa5
  g_return_if_fail (property_name != NULL);
Packit Service fb6fa5
  g_return_if_fail (G_IS_VALUE (value));
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_object_ref (container);
Packit Service fb6fa5
  g_object_ref (child);
Packit Service fb6fa5
Packit Service fb6fa5
  nqueue = g_object_notify_queue_freeze (G_OBJECT (child), _gtk_widget_child_property_notify_context);
Packit Service fb6fa5
  pspec = g_param_spec_pool_lookup (_gtk_widget_child_property_pool, property_name,
Packit Service fb6fa5
				    G_OBJECT_TYPE (container), TRUE);
Packit Service fb6fa5
  if (!pspec)
Packit Service fb6fa5
    g_warning ("%s: container class `%s' has no child property named `%s'",
Packit Service fb6fa5
	       G_STRLOC,
Packit Service fb6fa5
	       G_OBJECT_TYPE_NAME (container),
Packit Service fb6fa5
	       property_name);
Packit Service fb6fa5
  else if (!(pspec->flags & G_PARAM_WRITABLE))
Packit Service fb6fa5
    g_warning ("%s: child property `%s' of container class `%s' is not writable",
Packit Service fb6fa5
	       G_STRLOC,
Packit Service fb6fa5
	       pspec->name,
Packit Service fb6fa5
	       G_OBJECT_TYPE_NAME (container));
Packit Service fb6fa5
  else
Packit Service fb6fa5
    {
Packit Service fb6fa5
      container_set_child_property (container, child, pspec, value, nqueue);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  g_object_notify_queue_thaw (G_OBJECT (child), nqueue);
Packit Service fb6fa5
  g_object_unref (container);
Packit Service fb6fa5
  g_object_unref (child);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_add_with_properties:
Packit Service fb6fa5
 * @container: a #GtkContainer 
Packit Service fb6fa5
 * @widget: a widget to be placed inside @container 
Packit Service fb6fa5
 * @first_prop_name: the name of the first child property to set 
Packit Service fb6fa5
 * @Varargs: a %NULL-terminated list of property names and values, starting
Packit Service fb6fa5
 *           with @first_prop_name
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Adds @widget to @container, setting child properties at the same time.
Packit Service fb6fa5
 * See gtk_container_add() and gtk_container_child_set() for more details.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_add_with_properties (GtkContainer *container,
Packit Service fb6fa5
				   GtkWidget    *widget,
Packit Service fb6fa5
				   const gchar  *first_prop_name,
Packit Service fb6fa5
				   ...)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_WIDGET (widget));
Packit Service fb6fa5
  g_return_if_fail (widget->parent == NULL);
Packit Service fb6fa5
Packit Service fb6fa5
  g_object_ref (container);
Packit Service fb6fa5
  g_object_ref (widget);
Packit Service fb6fa5
  gtk_widget_freeze_child_notify (widget);
Packit Service fb6fa5
Packit Service fb6fa5
  g_signal_emit (container, container_signals[ADD], 0, widget);
Packit Service fb6fa5
  if (widget->parent)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      va_list var_args;
Packit Service fb6fa5
Packit Service fb6fa5
      va_start (var_args, first_prop_name);
Packit Service fb6fa5
      gtk_container_child_set_valist (container, widget, first_prop_name, var_args);
Packit Service fb6fa5
      va_end (var_args);
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  gtk_widget_thaw_child_notify (widget);
Packit Service fb6fa5
  g_object_unref (widget);
Packit Service fb6fa5
  g_object_unref (container);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_child_set:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 * @child: a widget which is a child of @container
Packit Service fb6fa5
 * @first_prop_name: the name of the first property to set
Packit Service fb6fa5
 * @Varargs: a %NULL-terminated list of property names and values, starting
Packit Service fb6fa5
 *           with @first_prop_name
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Sets one or more child properties for @child and @container.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_child_set (GtkContainer      *container,
Packit Service fb6fa5
			 GtkWidget         *child,
Packit Service fb6fa5
			 const gchar       *first_prop_name,
Packit Service fb6fa5
			 ...)
Packit Service fb6fa5
{
Packit Service fb6fa5
  va_list var_args;
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_WIDGET (child));
Packit Service fb6fa5
  g_return_if_fail (child->parent == GTK_WIDGET (container));
Packit Service fb6fa5
Packit Service fb6fa5
  va_start (var_args, first_prop_name);
Packit Service fb6fa5
  gtk_container_child_set_valist (container, child, first_prop_name, var_args);
Packit Service fb6fa5
  va_end (var_args);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_child_get:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 * @child: a widget which is a child of @container
Packit Service fb6fa5
 * @first_prop_name: the name of the first property to get
Packit Service fb6fa5
 * @Varargs: return location for the first property, followed 
Packit Service fb6fa5
 *     optionally by more name/return location pairs, followed by %NULL
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Gets the values of one or more child properties for @child and @container.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_child_get (GtkContainer      *container,
Packit Service fb6fa5
			 GtkWidget         *child,
Packit Service fb6fa5
			 const gchar       *first_prop_name,
Packit Service fb6fa5
			 ...)
Packit Service fb6fa5
{
Packit Service fb6fa5
  va_list var_args;
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_WIDGET (child));
Packit Service fb6fa5
  g_return_if_fail (child->parent == GTK_WIDGET (container));
Packit Service fb6fa5
Packit Service fb6fa5
  va_start (var_args, first_prop_name);
Packit Service fb6fa5
  gtk_container_child_get_valist (container, child, first_prop_name, var_args);
Packit Service fb6fa5
  va_end (var_args);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_class_install_child_property:
Packit Service fb6fa5
 * @cclass: a #GtkContainerClass
Packit Service fb6fa5
 * @property_id: the id for the property
Packit Service fb6fa5
 * @pspec: the #GParamSpec for the property
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Installs a child property on a container class. 
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_class_install_child_property (GtkContainerClass *cclass,
Packit Service fb6fa5
					    guint              property_id,
Packit Service fb6fa5
					    GParamSpec        *pspec)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER_CLASS (cclass));
Packit Service fb6fa5
  g_return_if_fail (G_IS_PARAM_SPEC (pspec));
Packit Service fb6fa5
  if (pspec->flags & G_PARAM_WRITABLE)
Packit Service fb6fa5
    g_return_if_fail (cclass->set_child_property != NULL);
Packit Service fb6fa5
  if (pspec->flags & G_PARAM_READABLE)
Packit Service fb6fa5
    g_return_if_fail (cclass->get_child_property != NULL);
Packit Service fb6fa5
  g_return_if_fail (property_id > 0);
Packit Service fb6fa5
  g_return_if_fail (PARAM_SPEC_PARAM_ID (pspec) == 0);  /* paranoid */
Packit Service fb6fa5
  if (pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY))
Packit Service fb6fa5
    g_return_if_fail ((pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)) == 0);
Packit Service fb6fa5
Packit Service fb6fa5
  if (g_param_spec_pool_lookup (_gtk_widget_child_property_pool, pspec->name, G_OBJECT_CLASS_TYPE (cclass), FALSE))
Packit Service fb6fa5
    {
Packit Service fb6fa5
      g_warning (G_STRLOC ": class `%s' already contains a child property named `%s'",
Packit Service fb6fa5
		 G_OBJECT_CLASS_NAME (cclass),
Packit Service fb6fa5
		 pspec->name);
Packit Service fb6fa5
      return;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  g_param_spec_ref (pspec);
Packit Service fb6fa5
  g_param_spec_sink (pspec);
Packit Service fb6fa5
  PARAM_SPEC_SET_PARAM_ID (pspec, property_id);
Packit Service fb6fa5
  g_param_spec_pool_insert (_gtk_widget_child_property_pool, pspec, G_OBJECT_CLASS_TYPE (cclass));
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_class_find_child_property:
Packit Service fb6fa5
 * @cclass: (type GtkContainerClass): a #GtkContainerClass
Packit Service fb6fa5
 * @property_name: the name of the child property to find
Packit Service fb6fa5
 * @returns: (transfer none): the #GParamSpec of the child property or
Packit Service fb6fa5
 *           %NULL if @class has no child property with that name.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Finds a child property of a container class by name.
Packit Service fb6fa5
 */
Packit Service fb6fa5
GParamSpec*
Packit Service fb6fa5
gtk_container_class_find_child_property (GObjectClass *cclass,
Packit Service fb6fa5
					 const gchar  *property_name)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_CONTAINER_CLASS (cclass), NULL);
Packit Service fb6fa5
  g_return_val_if_fail (property_name != NULL, NULL);
Packit Service fb6fa5
Packit Service fb6fa5
  return g_param_spec_pool_lookup (_gtk_widget_child_property_pool,
Packit Service fb6fa5
				   property_name,
Packit Service fb6fa5
				   G_OBJECT_CLASS_TYPE (cclass),
Packit Service fb6fa5
				   TRUE);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_class_list_child_properties:
Packit Service fb6fa5
 * @cclass: (type GtkContainerClass): a #GtkContainerClass
Packit Service fb6fa5
 * @n_properties: location to return the number of child properties found
Packit Service fb6fa5
 * @returns: (array length=n_properties) (transfer container):  a newly 
Packit Service fb6fa5
 *           allocated %NULL-terminated array of #GParamSpec*. 
Packit Service fb6fa5
 *           The array must be freed with g_free().
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Returns all child properties of a container class.
Packit Service fb6fa5
 */
Packit Service fb6fa5
GParamSpec**
Packit Service fb6fa5
gtk_container_class_list_child_properties (GObjectClass *cclass,
Packit Service fb6fa5
					   guint        *n_properties)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GParamSpec **pspecs;
Packit Service fb6fa5
  guint n;
Packit Service fb6fa5
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_CONTAINER_CLASS (cclass), NULL);
Packit Service fb6fa5
Packit Service fb6fa5
  pspecs = g_param_spec_pool_list (_gtk_widget_child_property_pool,
Packit Service fb6fa5
				   G_OBJECT_CLASS_TYPE (cclass),
Packit Service fb6fa5
				   &n);
Packit Service fb6fa5
  if (n_properties)
Packit Service fb6fa5
    *n_properties = n;
Packit Service fb6fa5
Packit Service fb6fa5
  return pspecs;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_container_add_unimplemented (GtkContainer     *container,
Packit Service fb6fa5
				 GtkWidget        *widget)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_warning ("GtkContainerClass::add not implemented for `%s'", g_type_name (G_TYPE_FROM_INSTANCE (container)));
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_container_remove_unimplemented (GtkContainer     *container,
Packit Service fb6fa5
				    GtkWidget        *widget)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_warning ("GtkContainerClass::remove not implemented for `%s'", g_type_name (G_TYPE_FROM_INSTANCE (container)));
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_container_init (GtkContainer *container)
Packit Service fb6fa5
{
Packit Service fb6fa5
  container->focus_child = NULL;
Packit Service fb6fa5
  container->border_width = 0;
Packit Service fb6fa5
  container->need_resize = FALSE;
Packit Service fb6fa5
  container->resize_mode = GTK_RESIZE_PARENT;
Packit Service fb6fa5
  container->reallocate_redraws = FALSE;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_container_destroy (GtkObject *object)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkContainer *container = GTK_CONTAINER (object);
Packit Service fb6fa5
Packit Service fb6fa5
  if (GTK_CONTAINER_RESIZE_PENDING (container))
Packit Service fb6fa5
    _gtk_container_dequeue_resize_handler (container);
Packit Service fb6fa5
Packit Service fb6fa5
  if (container->focus_child)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      g_object_unref (container->focus_child);
Packit Service fb6fa5
      container->focus_child = NULL;
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  /* do this before walking child widgets, to avoid
Packit Service fb6fa5
   * removing children from focus chain one by one.
Packit Service fb6fa5
   */
Packit Service fb6fa5
  if (container->has_focus_chain)
Packit Service fb6fa5
    gtk_container_unset_focus_chain (container);
Packit Service fb6fa5
Packit Service fb6fa5
  gtk_container_foreach (container, (GtkCallback) gtk_widget_destroy, NULL);
Packit Service fb6fa5
Packit Service fb6fa5
  GTK_OBJECT_CLASS (parent_class)->destroy (object);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_container_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
  GtkContainer *container = GTK_CONTAINER (object);
Packit Service fb6fa5
Packit Service fb6fa5
  switch (prop_id)
Packit Service fb6fa5
    {
Packit Service fb6fa5
    case PROP_BORDER_WIDTH:
Packit Service fb6fa5
      gtk_container_set_border_width (container, g_value_get_uint (value));
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case PROP_RESIZE_MODE:
Packit Service fb6fa5
      gtk_container_set_resize_mode (container, g_value_get_enum (value));
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case PROP_CHILD:
Packit Service fb6fa5
      gtk_container_add (container, GTK_WIDGET (g_value_get_object (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_container_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
  GtkContainer *container = GTK_CONTAINER (object);
Packit Service fb6fa5
  
Packit Service fb6fa5
  switch (prop_id)
Packit Service fb6fa5
    {
Packit Service fb6fa5
    case PROP_BORDER_WIDTH:
Packit Service fb6fa5
      g_value_set_uint (value, container->border_width);
Packit Service fb6fa5
      break;
Packit Service fb6fa5
    case PROP_RESIZE_MODE:
Packit Service fb6fa5
      g_value_set_enum (value, container->resize_mode);
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
/**
Packit Service fb6fa5
 * gtk_container_set_border_width:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 * @border_width: amount of blank space to leave <emphasis>outside</emphasis> 
Packit Service fb6fa5
 *   the container. Valid values are in the range 0-65535 pixels.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Sets the border width of the container.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * The border width of a container is the amount of space to leave
Packit Service fb6fa5
 * around the outside of the container. The only exception to this is
Packit Service fb6fa5
 * #GtkWindow; because toplevel windows can't leave space outside,
Packit Service fb6fa5
 * they leave the space inside. The border is added on all sides of
Packit Service fb6fa5
 * the container. To add space to only one side, one approach is to
Packit Service fb6fa5
 * create a #GtkAlignment widget, call gtk_widget_set_size_request()
Packit Service fb6fa5
 * to give it a size, and place it on the side of the container as
Packit Service fb6fa5
 * a spacer.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_set_border_width (GtkContainer *container,
Packit Service fb6fa5
				guint         border_width)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
Packit Service fb6fa5
  if (container->border_width != border_width)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      container->border_width = border_width;
Packit Service fb6fa5
      g_object_notify (G_OBJECT (container), "border-width");
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (gtk_widget_get_realized (GTK_WIDGET (container)))
Packit Service fb6fa5
	gtk_widget_queue_resize (GTK_WIDGET (container));
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_get_border_width:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Retrieves the border width of the container. See
Packit Service fb6fa5
 * gtk_container_set_border_width().
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Return value: the current border width
Packit Service fb6fa5
 **/
Packit Service fb6fa5
guint
Packit Service fb6fa5
gtk_container_get_border_width (GtkContainer *container)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_CONTAINER (container), 0);
Packit Service fb6fa5
Packit Service fb6fa5
  return container->border_width;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_add:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 * @widget: a widget to be placed inside @container
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Adds @widget to @container. Typically used for simple containers
Packit Service fb6fa5
 * such as #GtkWindow, #GtkFrame, or #GtkButton; for more complicated
Packit Service fb6fa5
 * layout containers such as #GtkBox or #GtkTable, this function will
Packit Service fb6fa5
 * pick default packing parameters that may not be correct.  So
Packit Service fb6fa5
 * consider functions such as gtk_box_pack_start() and
Packit Service fb6fa5
 * gtk_table_attach() as an alternative to gtk_container_add() in
Packit Service fb6fa5
 * those cases. A widget may be added to only one container at a time;
Packit Service fb6fa5
 * you can't place the same widget inside two different containers.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_add (GtkContainer *container,
Packit Service fb6fa5
		   GtkWidget    *widget)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_WIDGET (widget));
Packit Service fb6fa5
Packit Service fb6fa5
  if (widget->parent != NULL)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      g_warning ("Attempting to add a widget with type %s to a container of "
Packit Service fb6fa5
                 "type %s, but the widget is already inside a container of type %s, "
Packit Service fb6fa5
                 "the GTK+ FAQ at http://library.gnome.org/devel/gtk-faq/stable/ "
Packit Service fb6fa5
                 "explains how to reparent a widget.",
Packit Service fb6fa5
                 g_type_name (G_OBJECT_TYPE (widget)),
Packit Service fb6fa5
                 g_type_name (G_OBJECT_TYPE (container)),
Packit Service fb6fa5
                 g_type_name (G_OBJECT_TYPE (widget->parent)));
Packit Service fb6fa5
      return;
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  g_signal_emit (container, container_signals[ADD], 0, widget);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_remove:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 * @widget: a current child of @container
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Removes @widget from @container. @widget must be inside @container.
Packit Service fb6fa5
 * Note that @container will own a reference to @widget, and that this
Packit Service fb6fa5
 * may be the last reference held; so removing a widget from its
Packit Service fb6fa5
 * container can destroy that widget. If you want to use @widget
Packit Service fb6fa5
 * again, you need to add a reference to it while it's not inside
Packit Service fb6fa5
 * a container, using g_object_ref(). If you don't want to use @widget
Packit Service fb6fa5
 * again it's usually more efficient to simply destroy it directly
Packit Service fb6fa5
 * using gtk_widget_destroy() since this will remove it from the
Packit Service fb6fa5
 * container and help break any circular reference count cycles.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_remove (GtkContainer *container,
Packit Service fb6fa5
		      GtkWidget    *widget)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_WIDGET (widget));
Packit Service fb6fa5
Packit Service fb6fa5
  /* When using the deprecated API of the toolbar, it is possible
Packit Service fb6fa5
   * to legitimately call this function with a widget that is not
Packit Service fb6fa5
   * a direct child of the container.
Packit Service fb6fa5
   */
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_TOOLBAR (container) ||
Packit Service fb6fa5
		    widget->parent == GTK_WIDGET (container));
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_signal_emit (container, container_signals[REMOVE], 0, widget);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
void
Packit Service fb6fa5
_gtk_container_dequeue_resize_handler (GtkContainer *container)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
  g_return_if_fail (GTK_CONTAINER_RESIZE_PENDING (container));
Packit Service fb6fa5
Packit Service fb6fa5
  container_resize_queue = g_slist_remove (container_resize_queue, container);
Packit Service fb6fa5
  GTK_PRIVATE_UNSET_FLAG (container, GTK_RESIZE_PENDING);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_set_resize_mode:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 * @resize_mode: the new resize mode
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Sets the resize mode for the container.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * The resize mode of a container determines whether a resize request 
Packit Service fb6fa5
 * will be passed to the container's parent, queued for later execution
Packit Service fb6fa5
 * or executed immediately.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_set_resize_mode (GtkContainer  *container,
Packit Service fb6fa5
			       GtkResizeMode  resize_mode)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
  g_return_if_fail (resize_mode <= GTK_RESIZE_IMMEDIATE);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (gtk_widget_is_toplevel (GTK_WIDGET (container)) &&
Packit Service fb6fa5
      resize_mode == GTK_RESIZE_PARENT)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      resize_mode = GTK_RESIZE_QUEUE;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (container->resize_mode != resize_mode)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      container->resize_mode = resize_mode;
Packit Service fb6fa5
      
Packit Service fb6fa5
      gtk_widget_queue_resize (GTK_WIDGET (container));
Packit Service fb6fa5
      g_object_notify (G_OBJECT (container), "resize-mode");
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_get_resize_mode:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Returns the resize mode for the container. See
Packit Service fb6fa5
 * gtk_container_set_resize_mode ().
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Return value: the current resize mode
Packit Service fb6fa5
 **/
Packit Service fb6fa5
GtkResizeMode
Packit Service fb6fa5
gtk_container_get_resize_mode (GtkContainer *container)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_CONTAINER (container), GTK_RESIZE_PARENT);
Packit Service fb6fa5
Packit Service fb6fa5
  return container->resize_mode;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_set_reallocate_redraws:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 * @needs_redraws: the new value for the container's @reallocate_redraws flag
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Sets the @reallocate_redraws flag of the container to the given value.
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Containers requesting reallocation redraws get automatically
Packit Service fb6fa5
 * redrawn if any of their children changed allocation. 
Packit Service fb6fa5
 **/ 
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_set_reallocate_redraws (GtkContainer *container,
Packit Service fb6fa5
				      gboolean      needs_redraws)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
Packit Service fb6fa5
  container->reallocate_redraws = needs_redraws ? TRUE : FALSE;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static GtkContainer*
Packit Service fb6fa5
gtk_container_get_resize_container (GtkContainer *container)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkWidget *widget = GTK_WIDGET (container);
Packit Service fb6fa5
Packit Service fb6fa5
  while (widget->parent)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      widget = widget->parent;
Packit Service fb6fa5
      if (GTK_IS_RESIZE_CONTAINER (widget))
Packit Service fb6fa5
	break;
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  return GTK_IS_RESIZE_CONTAINER (widget) ? (GtkContainer*) widget : NULL;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static gboolean
Packit Service fb6fa5
gtk_container_idle_sizer (gpointer data)
Packit Service fb6fa5
{
Packit Service fb6fa5
  /* we may be invoked with a container_resize_queue of NULL, because
Packit Service fb6fa5
   * queue_resize could have been adding an extra idle function while
Packit Service fb6fa5
   * the queue still got processed. we better just ignore such case
Packit Service fb6fa5
   * than trying to explicitely work around them with some extra flags,
Packit Service fb6fa5
   * since it doesn't cause any actual harm.
Packit Service fb6fa5
   */
Packit Service fb6fa5
  while (container_resize_queue)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GSList *slist;
Packit Service fb6fa5
      GtkWidget *widget;
Packit Service fb6fa5
Packit Service fb6fa5
      slist = container_resize_queue;
Packit Service fb6fa5
      container_resize_queue = slist->next;
Packit Service fb6fa5
      widget = slist->data;
Packit Service fb6fa5
      g_slist_free_1 (slist);
Packit Service fb6fa5
Packit Service fb6fa5
      GTK_PRIVATE_UNSET_FLAG (widget, GTK_RESIZE_PENDING);
Packit Service fb6fa5
      gtk_container_check_resize (GTK_CONTAINER (widget));
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  gdk_window_process_all_updates ();
Packit Service fb6fa5
Packit Service fb6fa5
  return FALSE;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
void
Packit Service fb6fa5
_gtk_container_queue_resize (GtkContainer *container)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkContainer *resize_container;
Packit Service fb6fa5
  GtkWidget *widget;
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
Packit Service fb6fa5
  widget = GTK_WIDGET (container);
Packit Service fb6fa5
  resize_container = gtk_container_get_resize_container (container);
Packit Service fb6fa5
  
Packit Service fb6fa5
  while (TRUE)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GTK_PRIVATE_SET_FLAG (widget, GTK_ALLOC_NEEDED);
Packit Service fb6fa5
      GTK_PRIVATE_SET_FLAG (widget, GTK_REQUEST_NEEDED);
Packit Service fb6fa5
      if ((resize_container && widget == GTK_WIDGET (resize_container)) ||
Packit Service fb6fa5
	  !widget->parent)
Packit Service fb6fa5
	break;
Packit Service fb6fa5
      
Packit Service fb6fa5
      widget = widget->parent;
Packit Service fb6fa5
    }
Packit Service fb6fa5
      
Packit Service fb6fa5
  if (resize_container)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      if (gtk_widget_get_visible (GTK_WIDGET (resize_container)) &&
Packit Service fb6fa5
          (gtk_widget_is_toplevel (GTK_WIDGET (resize_container)) ||
Packit Service fb6fa5
           gtk_widget_get_realized (GTK_WIDGET (resize_container))))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  switch (resize_container->resize_mode)
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	    case GTK_RESIZE_QUEUE:
Packit Service fb6fa5
	      if (!GTK_CONTAINER_RESIZE_PENDING (resize_container))
Packit Service fb6fa5
		{
Packit Service fb6fa5
		  GTK_PRIVATE_SET_FLAG (resize_container, GTK_RESIZE_PENDING);
Packit Service fb6fa5
		  if (container_resize_queue == NULL)
Packit Service fb6fa5
		    gdk_threads_add_idle_full (GTK_PRIORITY_RESIZE,
Packit Service fb6fa5
				     gtk_container_idle_sizer,
Packit Service fb6fa5
				     NULL, NULL);
Packit Service fb6fa5
		  container_resize_queue = g_slist_prepend (container_resize_queue, resize_container);
Packit Service fb6fa5
		}
Packit Service fb6fa5
	      break;
Packit Service fb6fa5
Packit Service fb6fa5
	    case GTK_RESIZE_IMMEDIATE:
Packit Service fb6fa5
	      gtk_container_check_resize (resize_container);
Packit Service fb6fa5
	      break;
Packit Service fb6fa5
Packit Service fb6fa5
	    case GTK_RESIZE_PARENT:
Packit Service fb6fa5
	      g_assert_not_reached ();
Packit Service fb6fa5
	      break;
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	}
Packit Service fb6fa5
      else
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  /* we need to let hidden resize containers know that something
Packit Service fb6fa5
	   * changed while they where hidden (currently only evaluated by
Packit Service fb6fa5
	   * toplevels).
Packit Service fb6fa5
	   */
Packit Service fb6fa5
	  resize_container->need_resize = TRUE;
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_check_resize (GtkContainer *container)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_signal_emit (container, container_signals[CHECK_RESIZE], 0);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_container_real_check_resize (GtkContainer *container)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkWidget *widget = GTK_WIDGET (container);
Packit Service fb6fa5
  GtkRequisition requisition;
Packit Service fb6fa5
  
Packit Service fb6fa5
  gtk_widget_size_request (widget, &requisition);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (requisition.width > widget->allocation.width ||
Packit Service fb6fa5
      requisition.height > widget->allocation.height)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      if (GTK_IS_RESIZE_CONTAINER (container))
Packit Service fb6fa5
	gtk_widget_size_allocate (GTK_WIDGET (container),
Packit Service fb6fa5
				  &GTK_WIDGET (container)->allocation);
Packit Service fb6fa5
      else
Packit Service fb6fa5
	gtk_widget_queue_resize (widget);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    {
Packit Service fb6fa5
      gtk_container_resize_children (container);
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/* The container hasn't changed size but one of its children
Packit Service fb6fa5
 *  queued a resize request. Which means that the allocation
Packit Service fb6fa5
 *  is not sufficient for the requisition of some child.
Packit Service fb6fa5
 *  We've already performed a size request at this point,
Packit Service fb6fa5
 *  so we simply need to reallocate and let the allocation
Packit Service fb6fa5
 *  trickle down via GTK_WIDGET_ALLOC_NEEDED flags. 
Packit Service fb6fa5
 */
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_resize_children (GtkContainer *container)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkWidget *widget;
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* resizing invariants:
Packit Service fb6fa5
   * toplevels have *always* resize_mode != GTK_RESIZE_PARENT set.
Packit Service fb6fa5
   * containers that have an idle sizer pending must be flagged with
Packit Service fb6fa5
   * RESIZE_PENDING.
Packit Service fb6fa5
   */
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
Packit Service fb6fa5
  widget = GTK_WIDGET (container);
Packit Service fb6fa5
  gtk_widget_size_allocate (widget, &widget->allocation);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_forall:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 * @callback: a callback
Packit Service fb6fa5
 * @callback_data: callback user data
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Invokes @callback on each child of @container, including children
Packit Service fb6fa5
 * that are considered "internal" (implementation details of the
Packit Service fb6fa5
 * container). "Internal" children generally weren't added by the user
Packit Service fb6fa5
 * of the container, but were added by the container implementation
Packit Service fb6fa5
 * itself.  Most applications should use gtk_container_foreach(),
Packit Service fb6fa5
 * rather than gtk_container_forall().
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_forall (GtkContainer *container,
Packit Service fb6fa5
		      GtkCallback   callback,
Packit Service fb6fa5
		      gpointer      callback_data)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkContainerClass *class;
Packit Service fb6fa5
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
  g_return_if_fail (callback != NULL);
Packit Service fb6fa5
Packit Service fb6fa5
  class = GTK_CONTAINER_GET_CLASS (container);
Packit Service fb6fa5
Packit Service fb6fa5
  if (class->forall)
Packit Service fb6fa5
    class->forall (container, TRUE, callback, callback_data);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_foreach:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 * @callback: (scope call):  a callback
Packit Service fb6fa5
 * @callback_data: callback user data
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Invokes @callback on each non-internal child of @container. See
Packit Service fb6fa5
 * gtk_container_forall() for details on what constitutes an
Packit Service fb6fa5
 * "internal" child.  Most applications should use
Packit Service fb6fa5
 * gtk_container_foreach(), rather than gtk_container_forall().
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_foreach (GtkContainer *container,
Packit Service fb6fa5
		       GtkCallback   callback,
Packit Service fb6fa5
		       gpointer      callback_data)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkContainerClass *class;
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
  g_return_if_fail (callback != NULL);
Packit Service fb6fa5
Packit Service fb6fa5
  class = GTK_CONTAINER_GET_CLASS (container);
Packit Service fb6fa5
Packit Service fb6fa5
  if (class->forall)
Packit Service fb6fa5
    class->forall (container, FALSE, callback, callback_data);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
typedef struct _GtkForeachData	GtkForeachData;
Packit Service fb6fa5
struct _GtkForeachData
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkObject         *container;
Packit Service fb6fa5
  GtkCallbackMarshal callback;
Packit Service fb6fa5
  gpointer           callback_data;
Packit Service fb6fa5
};
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_container_foreach_unmarshal (GtkWidget *child,
Packit Service fb6fa5
				 gpointer data)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkForeachData *fdata = (GtkForeachData*) data;
Packit Service fb6fa5
  GtkArg args[2];
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* first argument */
Packit Service fb6fa5
  args[0].name = NULL;
Packit Service fb6fa5
  args[0].type = G_TYPE_FROM_INSTANCE (child);
Packit Service fb6fa5
  GTK_VALUE_OBJECT (args[0]) = GTK_OBJECT (child);
Packit Service fb6fa5
  
Packit Service fb6fa5
  /* location for return value */
Packit Service fb6fa5
  args[1].name = NULL;
Packit Service fb6fa5
  args[1].type = G_TYPE_NONE;
Packit Service fb6fa5
  
Packit Service fb6fa5
  fdata->callback (fdata->container, fdata->callback_data, 1, args);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_foreach_full (GtkContainer       *container,
Packit Service fb6fa5
			    GtkCallback         callback,
Packit Service fb6fa5
			    GtkCallbackMarshal  marshal,
Packit Service fb6fa5
			    gpointer            callback_data,
Packit Service fb6fa5
			    GDestroyNotify      notify)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
Packit Service fb6fa5
  if (marshal)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GtkForeachData fdata;
Packit Service fb6fa5
  
Packit Service fb6fa5
      fdata.container     = GTK_OBJECT (container);
Packit Service fb6fa5
      fdata.callback      = marshal;
Packit Service fb6fa5
      fdata.callback_data = callback_data;
Packit Service fb6fa5
Packit Service fb6fa5
      gtk_container_foreach (container, gtk_container_foreach_unmarshal, &fdata);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    {
Packit Service fb6fa5
      g_return_if_fail (callback != NULL);
Packit Service fb6fa5
Packit Service fb6fa5
      gtk_container_foreach (container, callback, &callback_data);
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  if (notify)
Packit Service fb6fa5
    notify (callback_data);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_set_focus_child:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 * @child: (allow-none): a #GtkWidget, or %NULL
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Sets, or unsets if @child is %NULL, the focused child of @container.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * This function emits the GtkContainer::set_focus_child signal of
Packit Service fb6fa5
 * @container. Implementations of #GtkContainer can override the
Packit Service fb6fa5
 * default behaviour by overriding the class closure of this signal.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * This is function is mostly meant to be used by widgets. Applications can use
Packit Service fb6fa5
 * gtk_widget_grab_focus() to manualy set the focus to a specific widget.
Packit Service fb6fa5
 */
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_set_focus_child (GtkContainer *container,
Packit Service fb6fa5
			       GtkWidget    *child)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
  if (child)
Packit Service fb6fa5
    g_return_if_fail (GTK_IS_WIDGET (child));
Packit Service fb6fa5
Packit Service fb6fa5
  g_signal_emit (container, container_signals[SET_FOCUS_CHILD], 0, child);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_get_focus_child:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Returns the current focus child widget inside @container. This is not the
Packit Service fb6fa5
 * currently focused widget. That can be obtained by calling
Packit Service fb6fa5
 * gtk_window_get_focus().
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Returns: (transfer none): The child widget which will receive the
Packit Service fb6fa5
 *          focus inside @container when the @conatiner is focussed,
Packit Service fb6fa5
 *          or %NULL if none is set.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Since: 2.14
Packit Service fb6fa5
 **/
Packit Service fb6fa5
GtkWidget *
Packit Service fb6fa5
gtk_container_get_focus_child (GtkContainer *container)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
Packit Service fb6fa5
Packit Service fb6fa5
  return container->focus_child;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_get_children:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Returns the container's non-internal children. See
Packit Service fb6fa5
 * gtk_container_forall() for details on what constitutes an "internal" child.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Return value: (element-type GtkWidget) (transfer container): a newly-allocated list of the container's non-internal children.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
GList*
Packit Service fb6fa5
gtk_container_get_children (GtkContainer *container)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GList *children = NULL;
Packit Service fb6fa5
Packit Service fb6fa5
  gtk_container_foreach (container,
Packit Service fb6fa5
			 gtk_container_children_callback,
Packit Service fb6fa5
			 &children);
Packit Service fb6fa5
Packit Service fb6fa5
  return g_list_reverse (children);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_container_child_position_callback (GtkWidget *widget,
Packit Service fb6fa5
				       gpointer   client_data)
Packit Service fb6fa5
{
Packit Service fb6fa5
  struct {
Packit Service fb6fa5
    GtkWidget *child;
Packit Service fb6fa5
    guint i;
Packit Service fb6fa5
    guint index;
Packit Service fb6fa5
  } *data = client_data;
Packit Service fb6fa5
Packit Service fb6fa5
  data->i++;
Packit Service fb6fa5
  if (data->child == widget)
Packit Service fb6fa5
    data->index = data->i;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static gchar*
Packit Service fb6fa5
gtk_container_child_default_composite_name (GtkContainer *container,
Packit Service fb6fa5
					    GtkWidget    *child)
Packit Service fb6fa5
{
Packit Service fb6fa5
  struct {
Packit Service fb6fa5
    GtkWidget *child;
Packit Service fb6fa5
    guint i;
Packit Service fb6fa5
    guint index;
Packit Service fb6fa5
  } data;
Packit Service fb6fa5
  gchar *name;
Packit Service fb6fa5
Packit Service fb6fa5
  /* fallback implementation */
Packit Service fb6fa5
  data.child = child;
Packit Service fb6fa5
  data.i = 0;
Packit Service fb6fa5
  data.index = 0;
Packit Service fb6fa5
  gtk_container_forall (container,
Packit Service fb6fa5
			gtk_container_child_position_callback,
Packit Service fb6fa5
			&data);
Packit Service fb6fa5
  
Packit Service fb6fa5
  name = g_strdup_printf ("%s-%u",
Packit Service fb6fa5
			  g_type_name (G_TYPE_FROM_INSTANCE (child)),
Packit Service fb6fa5
			  data.index);
Packit Service fb6fa5
Packit Service fb6fa5
  return name;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
gchar*
Packit Service fb6fa5
_gtk_container_child_composite_name (GtkContainer *container,
Packit Service fb6fa5
				    GtkWidget    *child)
Packit Service fb6fa5
{
Packit Service fb6fa5
  gboolean composite_child;
Packit Service fb6fa5
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_WIDGET (child), NULL);
Packit Service fb6fa5
  g_return_val_if_fail (child->parent == GTK_WIDGET (container), NULL);
Packit Service fb6fa5
Packit Service fb6fa5
  g_object_get (child, "composite-child", &composite_child, NULL);
Packit Service fb6fa5
  if (composite_child)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      static GQuark quark_composite_name = 0;
Packit Service fb6fa5
      gchar *name;
Packit Service fb6fa5
Packit Service fb6fa5
      if (!quark_composite_name)
Packit Service fb6fa5
	quark_composite_name = g_quark_from_static_string ("gtk-composite-name");
Packit Service fb6fa5
Packit Service fb6fa5
      name = g_object_get_qdata (G_OBJECT (child), quark_composite_name);
Packit Service fb6fa5
      if (!name)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  GtkContainerClass *class;
Packit Service fb6fa5
Packit Service fb6fa5
	  class = GTK_CONTAINER_GET_CLASS (container);
Packit Service fb6fa5
	  if (class->composite_name)
Packit Service fb6fa5
	    name = class->composite_name (container, child);
Packit Service fb6fa5
	}
Packit Service fb6fa5
      else
Packit Service fb6fa5
	name = g_strdup (name);
Packit Service fb6fa5
Packit Service fb6fa5
      return name;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  return NULL;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_container_real_set_focus_child (GtkContainer     *container,
Packit Service fb6fa5
				    GtkWidget        *child)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
  g_return_if_fail (child == NULL || GTK_IS_WIDGET (child));
Packit Service fb6fa5
Packit Service fb6fa5
  if (child != container->focus_child)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      if (container->focus_child)
Packit Service fb6fa5
	g_object_unref (container->focus_child);
Packit Service fb6fa5
Packit Service fb6fa5
      container->focus_child = child;
Packit Service fb6fa5
Packit Service fb6fa5
      if (container->focus_child)
Packit Service fb6fa5
	g_object_ref (container->focus_child);
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  /* Check for h/v adjustments and scroll to show the focus child if possible */
Packit Service fb6fa5
  if (container->focus_child)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GtkAdjustment *hadj;
Packit Service fb6fa5
      GtkAdjustment *vadj;
Packit Service fb6fa5
      GtkWidget *focus_child;
Packit Service fb6fa5
      gint x, y;
Packit Service fb6fa5
Packit Service fb6fa5
      hadj = g_object_get_qdata (G_OBJECT (container), hadjustment_key_id);   
Packit Service fb6fa5
      vadj = g_object_get_qdata (G_OBJECT (container), vadjustment_key_id);
Packit Service fb6fa5
      if (hadj || vadj) 
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  focus_child = container->focus_child;
Packit Service fb6fa5
	  while (GTK_IS_CONTAINER (focus_child) && 
Packit Service fb6fa5
		 GTK_CONTAINER (focus_child)->focus_child)
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      focus_child = GTK_CONTAINER (focus_child)->focus_child;
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	  
Packit Service fb6fa5
           if (!gtk_widget_translate_coordinates (focus_child, container->focus_child,
Packit Service fb6fa5
                                                  0, 0, &x, &y))
Packit Service fb6fa5
             return;
Packit Service fb6fa5
Packit Service fb6fa5
	   x += container->focus_child->allocation.x;
Packit Service fb6fa5
	   y += container->focus_child->allocation.y;
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  if (vadj)
Packit Service fb6fa5
	    gtk_adjustment_clamp_page (vadj, y, y + focus_child->allocation.height);
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  if (hadj)
Packit Service fb6fa5
	    gtk_adjustment_clamp_page (hadj, x, x + focus_child->allocation.width);
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static GList*
Packit Service fb6fa5
get_focus_chain (GtkContainer *container)
Packit Service fb6fa5
{
Packit Service fb6fa5
  return g_object_get_data (G_OBJECT (container), "gtk-container-focus-chain");
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/* same as gtk_container_get_children, except it includes internals
Packit Service fb6fa5
 */
Packit Service fb6fa5
static GList *
Packit Service fb6fa5
gtk_container_get_all_children (GtkContainer *container)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GList *children = NULL;
Packit Service fb6fa5
Packit Service fb6fa5
  gtk_container_forall (container,
Packit Service fb6fa5
			 gtk_container_children_callback,
Packit Service fb6fa5
			 &children);
Packit Service fb6fa5
Packit Service fb6fa5
  return children;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static gboolean
Packit Service fb6fa5
gtk_container_focus (GtkWidget        *widget,
Packit Service fb6fa5
                     GtkDirectionType  direction)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GList *children;
Packit Service fb6fa5
  GList *sorted_children;
Packit Service fb6fa5
  gint return_val;
Packit Service fb6fa5
  GtkContainer *container;
Packit Service fb6fa5
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_CONTAINER (widget), FALSE);
Packit Service fb6fa5
Packit Service fb6fa5
  container = GTK_CONTAINER (widget);
Packit Service fb6fa5
Packit Service fb6fa5
  return_val = FALSE;
Packit Service fb6fa5
Packit Service fb6fa5
  if (gtk_widget_get_can_focus (widget))
Packit Service fb6fa5
    {
Packit Service fb6fa5
      if (!gtk_widget_has_focus (widget))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  gtk_widget_grab_focus (widget);
Packit Service fb6fa5
	  return_val = TRUE;
Packit Service fb6fa5
	}
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    {
Packit Service fb6fa5
      /* Get a list of the containers children, allowing focus
Packit Service fb6fa5
       * chain to override.
Packit Service fb6fa5
       */
Packit Service fb6fa5
      if (container->has_focus_chain)
Packit Service fb6fa5
	children = g_list_copy (get_focus_chain (container));
Packit Service fb6fa5
      else
Packit Service fb6fa5
	children = gtk_container_get_all_children (container);
Packit Service fb6fa5
Packit Service fb6fa5
      if (container->has_focus_chain &&
Packit Service fb6fa5
	  (direction == GTK_DIR_TAB_FORWARD ||
Packit Service fb6fa5
	   direction == GTK_DIR_TAB_BACKWARD))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  sorted_children = g_list_copy (children);
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  if (direction == GTK_DIR_TAB_BACKWARD)
Packit Service fb6fa5
	    sorted_children = g_list_reverse (sorted_children);
Packit Service fb6fa5
	}
Packit Service fb6fa5
      else
Packit Service fb6fa5
	sorted_children = _gtk_container_focus_sort (container, children, direction, NULL);
Packit Service fb6fa5
      
Packit Service fb6fa5
      return_val = gtk_container_focus_move (container, sorted_children, direction);
Packit Service fb6fa5
Packit Service fb6fa5
      g_list_free (sorted_children);
Packit Service fb6fa5
      g_list_free (children);
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  return return_val;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static gint
Packit Service fb6fa5
tab_compare (gconstpointer a,
Packit Service fb6fa5
	     gconstpointer b,
Packit Service fb6fa5
	     gpointer      data)
Packit Service fb6fa5
{
Packit Service fb6fa5
  const GtkWidget *child1 = a;
Packit Service fb6fa5
  const GtkWidget *child2 = b;
Packit Service fb6fa5
  GtkTextDirection text_direction = GPOINTER_TO_INT (data);
Packit Service fb6fa5
Packit Service fb6fa5
  gint y1 = child1->allocation.y + child1->allocation.height / 2;
Packit Service fb6fa5
  gint y2 = child2->allocation.y + child2->allocation.height / 2;
Packit Service fb6fa5
Packit Service fb6fa5
  if (y1 == y2)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      gint x1 = child1->allocation.x + child1->allocation.width / 2;
Packit Service fb6fa5
      gint x2 = child2->allocation.x + child2->allocation.width / 2;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (text_direction == GTK_TEXT_DIR_RTL) 
Packit Service fb6fa5
	return (x1 < x2) ? 1 : ((x1 == x2) ? 0 : -1);
Packit Service fb6fa5
      else
Packit Service fb6fa5
	return (x1 < x2) ? -1 : ((x1 == x2) ? 0 : 1);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    return (y1 < y2) ? -1 : 1;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static GList *
Packit Service fb6fa5
gtk_container_focus_sort_tab (GtkContainer     *container,
Packit Service fb6fa5
			      GList            *children,
Packit Service fb6fa5
			      GtkDirectionType  direction,
Packit Service fb6fa5
			      GtkWidget        *old_focus)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkTextDirection text_direction = gtk_widget_get_direction (GTK_WIDGET (container));
Packit Service fb6fa5
  children = g_list_sort_with_data (children, tab_compare, GINT_TO_POINTER (text_direction));
Packit Service fb6fa5
Packit Service fb6fa5
  /* if we are going backwards then reverse the order
Packit Service fb6fa5
   *  of the children.
Packit Service fb6fa5
   */
Packit Service fb6fa5
  if (direction == GTK_DIR_TAB_BACKWARD)
Packit Service fb6fa5
    children = g_list_reverse (children);
Packit Service fb6fa5
Packit Service fb6fa5
  return children;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/* Get coordinates of @widget's allocation with respect to
Packit Service fb6fa5
 * allocation of @container.
Packit Service fb6fa5
 */
Packit Service fb6fa5
static gboolean
Packit Service fb6fa5
get_allocation_coords (GtkContainer  *container,
Packit Service fb6fa5
		       GtkWidget     *widget,
Packit Service fb6fa5
		       GdkRectangle  *allocation)
Packit Service fb6fa5
{
Packit Service fb6fa5
  *allocation = widget->allocation;
Packit Service fb6fa5
Packit Service fb6fa5
  return gtk_widget_translate_coordinates (widget, GTK_WIDGET (container),
Packit Service fb6fa5
					   0, 0, &allocation->x, &allocation->y);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/* Look for a child in @children that is intermediate between
Packit Service fb6fa5
 * the focus widget and container. This widget, if it exists,
Packit Service fb6fa5
 * acts as the starting widget for focus navigation.
Packit Service fb6fa5
 */
Packit Service fb6fa5
static GtkWidget *
Packit Service fb6fa5
find_old_focus (GtkContainer *container,
Packit Service fb6fa5
		GList        *children)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GList *tmp_list = children;
Packit Service fb6fa5
  while (tmp_list)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GtkWidget *child = tmp_list->data;
Packit Service fb6fa5
      GtkWidget *widget = child;
Packit Service fb6fa5
Packit Service fb6fa5
      while (widget && widget != (GtkWidget *)container)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  GtkWidget *parent = widget->parent;
Packit Service fb6fa5
	  if (parent && ((GtkContainer *)parent)->focus_child != widget)
Packit Service fb6fa5
	    goto next;
Packit Service fb6fa5
Packit Service fb6fa5
	  widget = parent;
Packit Service fb6fa5
	}
Packit Service fb6fa5
Packit Service fb6fa5
      return child;
Packit Service fb6fa5
Packit Service fb6fa5
    next:
Packit Service fb6fa5
      tmp_list = tmp_list->next;
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  return NULL;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static gboolean
Packit Service fb6fa5
old_focus_coords (GtkContainer *container,
Packit Service fb6fa5
		  GdkRectangle *old_focus_rect)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkWidget *widget = GTK_WIDGET (container);
Packit Service fb6fa5
  GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
Packit Service fb6fa5
Packit Service fb6fa5
  if (GTK_IS_WINDOW (toplevel) && GTK_WINDOW (toplevel)->focus_widget)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GtkWidget *old_focus = GTK_WINDOW (toplevel)->focus_widget;
Packit Service fb6fa5
      
Packit Service fb6fa5
      return get_allocation_coords (container, old_focus, old_focus_rect);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    return FALSE;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
typedef struct _CompareInfo CompareInfo;
Packit Service fb6fa5
Packit Service fb6fa5
struct _CompareInfo
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkContainer *container;
Packit Service fb6fa5
  gint x;
Packit Service fb6fa5
  gint y;
Packit Service fb6fa5
  gboolean reverse;
Packit Service fb6fa5
};
Packit Service fb6fa5
Packit Service fb6fa5
static gint
Packit Service fb6fa5
up_down_compare (gconstpointer a,
Packit Service fb6fa5
		 gconstpointer b,
Packit Service fb6fa5
		 gpointer      data)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GdkRectangle allocation1;
Packit Service fb6fa5
  GdkRectangle allocation2;
Packit Service fb6fa5
  CompareInfo *compare = data;
Packit Service fb6fa5
  gint y1, y2;
Packit Service fb6fa5
Packit Service fb6fa5
  get_allocation_coords (compare->container, (GtkWidget *)a, &allocation1);
Packit Service fb6fa5
  get_allocation_coords (compare->container, (GtkWidget *)b, &allocation2);
Packit Service fb6fa5
Packit Service fb6fa5
  y1 = allocation1.y + allocation1.height / 2;
Packit Service fb6fa5
  y2 = allocation2.y + allocation2.height / 2;
Packit Service fb6fa5
Packit Service fb6fa5
  if (y1 == y2)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      gint x1 = abs (allocation1.x + allocation1.width / 2 - compare->x);
Packit Service fb6fa5
      gint x2 = abs (allocation2.x + allocation2.width / 2 - compare->x);
Packit Service fb6fa5
Packit Service fb6fa5
      if (compare->reverse)
Packit Service fb6fa5
	return (x1 < x2) ? 1 : ((x1 == x2) ? 0 : -1);
Packit Service fb6fa5
      else
Packit Service fb6fa5
	return (x1 < x2) ? -1 : ((x1 == x2) ? 0 : 1);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    return (y1 < y2) ? -1 : 1;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static GList *
Packit Service fb6fa5
gtk_container_focus_sort_up_down (GtkContainer     *container,
Packit Service fb6fa5
				  GList            *children,
Packit Service fb6fa5
				  GtkDirectionType  direction,
Packit Service fb6fa5
				  GtkWidget        *old_focus)
Packit Service fb6fa5
{
Packit Service fb6fa5
  CompareInfo compare;
Packit Service fb6fa5
  GList *tmp_list;
Packit Service fb6fa5
  GdkRectangle old_allocation;
Packit Service fb6fa5
Packit Service fb6fa5
  compare.container = container;
Packit Service fb6fa5
  compare.reverse = (direction == GTK_DIR_UP);
Packit Service fb6fa5
Packit Service fb6fa5
  if (!old_focus)
Packit Service fb6fa5
      old_focus = find_old_focus (container, children);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (old_focus && get_allocation_coords (container, old_focus, &old_allocation))
Packit Service fb6fa5
    {
Packit Service fb6fa5
      gint compare_x1;
Packit Service fb6fa5
      gint compare_x2;
Packit Service fb6fa5
      gint compare_y;
Packit Service fb6fa5
Packit Service fb6fa5
      /* Delete widgets from list that don't match minimum criteria */
Packit Service fb6fa5
Packit Service fb6fa5
      compare_x1 = old_allocation.x;
Packit Service fb6fa5
      compare_x2 = old_allocation.x + old_allocation.width;
Packit Service fb6fa5
Packit Service fb6fa5
      if (direction == GTK_DIR_UP)
Packit Service fb6fa5
	compare_y = old_allocation.y;
Packit Service fb6fa5
      else
Packit Service fb6fa5
	compare_y = old_allocation.y + old_allocation.height;
Packit Service fb6fa5
      
Packit Service fb6fa5
      tmp_list = children;
Packit Service fb6fa5
      while (tmp_list)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  GtkWidget *child = tmp_list->data;
Packit Service fb6fa5
	  GList *next = tmp_list->next;
Packit Service fb6fa5
	  gint child_x1, child_x2;
Packit Service fb6fa5
	  GdkRectangle child_allocation;
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  if (child != old_focus)
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      if (get_allocation_coords (container, child, &child_allocation))
Packit Service fb6fa5
		{
Packit Service fb6fa5
		  child_x1 = child_allocation.x;
Packit Service fb6fa5
		  child_x2 = child_allocation.x + child_allocation.width;
Packit Service fb6fa5
		  
Packit Service fb6fa5
		  if ((child_x2 <= compare_x1 || child_x1 >= compare_x2) /* No horizontal overlap */ ||
Packit Service fb6fa5
		      (direction == GTK_DIR_DOWN && child_allocation.y + child_allocation.height < compare_y) || /* Not below */
Packit Service fb6fa5
		      (direction == GTK_DIR_UP && child_allocation.y > compare_y)) /* Not above */
Packit Service fb6fa5
		    {
Packit Service fb6fa5
		      children = g_list_delete_link (children, tmp_list);
Packit Service fb6fa5
		    }
Packit Service fb6fa5
		}
Packit Service fb6fa5
	      else
Packit Service fb6fa5
		children = g_list_delete_link (children, tmp_list);
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  tmp_list = next;
Packit Service fb6fa5
	}
Packit Service fb6fa5
Packit Service fb6fa5
      compare.x = (compare_x1 + compare_x2) / 2;
Packit Service fb6fa5
      compare.y = old_allocation.y + old_allocation.height / 2;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    {
Packit Service fb6fa5
      /* No old focus widget, need to figure out starting x,y some other way
Packit Service fb6fa5
       */
Packit Service fb6fa5
      GtkWidget *widget = GTK_WIDGET (container);
Packit Service fb6fa5
      GdkRectangle old_focus_rect;
Packit Service fb6fa5
Packit Service fb6fa5
      if (old_focus_coords (container, &old_focus_rect))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  compare.x = old_focus_rect.x + old_focus_rect.width / 2;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      else
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  if (!gtk_widget_get_has_window (widget))
Packit Service fb6fa5
	    compare.x = widget->allocation.x + widget->allocation.width / 2;
Packit Service fb6fa5
	  else
Packit Service fb6fa5
	    compare.x = widget->allocation.width / 2;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (!gtk_widget_get_has_window (widget))
Packit Service fb6fa5
	compare.y = (direction == GTK_DIR_DOWN) ? widget->allocation.y : widget->allocation.y + widget->allocation.height;
Packit Service fb6fa5
      else
Packit Service fb6fa5
	compare.y = (direction == GTK_DIR_DOWN) ? 0 : + widget->allocation.height;
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  children = g_list_sort_with_data (children, up_down_compare, &compare);
Packit Service fb6fa5
Packit Service fb6fa5
  if (compare.reverse)
Packit Service fb6fa5
    children = g_list_reverse (children);
Packit Service fb6fa5
Packit Service fb6fa5
  return children;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static gint
Packit Service fb6fa5
left_right_compare (gconstpointer a,
Packit Service fb6fa5
		    gconstpointer b,
Packit Service fb6fa5
		    gpointer      data)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GdkRectangle allocation1;
Packit Service fb6fa5
  GdkRectangle allocation2;
Packit Service fb6fa5
  CompareInfo *compare = data;
Packit Service fb6fa5
  gint x1, x2;
Packit Service fb6fa5
Packit Service fb6fa5
  get_allocation_coords (compare->container, (GtkWidget *)a, &allocation1);
Packit Service fb6fa5
  get_allocation_coords (compare->container, (GtkWidget *)b, &allocation2);
Packit Service fb6fa5
Packit Service fb6fa5
  x1 = allocation1.x + allocation1.width / 2;
Packit Service fb6fa5
  x2 = allocation2.x + allocation2.width / 2;
Packit Service fb6fa5
Packit Service fb6fa5
  if (x1 == x2)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      gint y1 = abs (allocation1.y + allocation1.height / 2 - compare->y);
Packit Service fb6fa5
      gint y2 = abs (allocation2.y + allocation2.height / 2 - compare->y);
Packit Service fb6fa5
Packit Service fb6fa5
      if (compare->reverse)
Packit Service fb6fa5
	return (y1 < y2) ? 1 : ((y1 == y2) ? 0 : -1);
Packit Service fb6fa5
      else
Packit Service fb6fa5
	return (y1 < y2) ? -1 : ((y1 == y2) ? 0 : 1);
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    return (x1 < x2) ? -1 : 1;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static GList *
Packit Service fb6fa5
gtk_container_focus_sort_left_right (GtkContainer     *container,
Packit Service fb6fa5
				     GList            *children,
Packit Service fb6fa5
				     GtkDirectionType  direction,
Packit Service fb6fa5
				     GtkWidget        *old_focus)
Packit Service fb6fa5
{
Packit Service fb6fa5
  CompareInfo compare;
Packit Service fb6fa5
  GList *tmp_list;
Packit Service fb6fa5
  GdkRectangle old_allocation;
Packit Service fb6fa5
Packit Service fb6fa5
  compare.container = container;
Packit Service fb6fa5
  compare.reverse = (direction == GTK_DIR_LEFT);
Packit Service fb6fa5
Packit Service fb6fa5
  if (!old_focus)
Packit Service fb6fa5
    old_focus = find_old_focus (container, children);
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (old_focus && get_allocation_coords (container, old_focus, &old_allocation))
Packit Service fb6fa5
    {
Packit Service fb6fa5
      gint compare_y1;
Packit Service fb6fa5
      gint compare_y2;
Packit Service fb6fa5
      gint compare_x;
Packit Service fb6fa5
      
Packit Service fb6fa5
      /* Delete widgets from list that don't match minimum criteria */
Packit Service fb6fa5
Packit Service fb6fa5
      compare_y1 = old_allocation.y;
Packit Service fb6fa5
      compare_y2 = old_allocation.y + old_allocation.height;
Packit Service fb6fa5
Packit Service fb6fa5
      if (direction == GTK_DIR_LEFT)
Packit Service fb6fa5
	compare_x = old_allocation.x;
Packit Service fb6fa5
      else
Packit Service fb6fa5
	compare_x = old_allocation.x + old_allocation.width;
Packit Service fb6fa5
      
Packit Service fb6fa5
      tmp_list = children;
Packit Service fb6fa5
      while (tmp_list)
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  GtkWidget *child = tmp_list->data;
Packit Service fb6fa5
	  GList *next = tmp_list->next;
Packit Service fb6fa5
	  gint child_y1, child_y2;
Packit Service fb6fa5
	  GdkRectangle child_allocation;
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  if (child != old_focus)
Packit Service fb6fa5
	    {
Packit Service fb6fa5
	      if (get_allocation_coords (container, child, &child_allocation))
Packit Service fb6fa5
		{
Packit Service fb6fa5
		  child_y1 = child_allocation.y;
Packit Service fb6fa5
		  child_y2 = child_allocation.y + child_allocation.height;
Packit Service fb6fa5
		  
Packit Service fb6fa5
		  if ((child_y2 <= compare_y1 || child_y1 >= compare_y2) /* No vertical overlap */ ||
Packit Service fb6fa5
		      (direction == GTK_DIR_RIGHT && child_allocation.x + child_allocation.width < compare_x) || /* Not to left */
Packit Service fb6fa5
		      (direction == GTK_DIR_LEFT && child_allocation.x > compare_x)) /* Not to right */
Packit Service fb6fa5
		    {
Packit Service fb6fa5
		      children = g_list_delete_link (children, tmp_list);
Packit Service fb6fa5
		    }
Packit Service fb6fa5
		}
Packit Service fb6fa5
	      else
Packit Service fb6fa5
		children = g_list_delete_link (children, tmp_list);
Packit Service fb6fa5
	    }
Packit Service fb6fa5
	  
Packit Service fb6fa5
	  tmp_list = next;
Packit Service fb6fa5
	}
Packit Service fb6fa5
Packit Service fb6fa5
      compare.y = (compare_y1 + compare_y2) / 2;
Packit Service fb6fa5
      compare.x = old_allocation.x + old_allocation.width / 2;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  else
Packit Service fb6fa5
    {
Packit Service fb6fa5
      /* No old focus widget, need to figure out starting x,y some other way
Packit Service fb6fa5
       */
Packit Service fb6fa5
      GtkWidget *widget = GTK_WIDGET (container);
Packit Service fb6fa5
      GdkRectangle old_focus_rect;
Packit Service fb6fa5
Packit Service fb6fa5
      if (old_focus_coords (container, &old_focus_rect))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  compare.y = old_focus_rect.y + old_focus_rect.height / 2;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      else
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  if (!gtk_widget_get_has_window (widget))
Packit Service fb6fa5
	    compare.y = widget->allocation.y + widget->allocation.height / 2;
Packit Service fb6fa5
	  else
Packit Service fb6fa5
	    compare.y = widget->allocation.height / 2;
Packit Service fb6fa5
	}
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (!gtk_widget_get_has_window (widget))
Packit Service fb6fa5
	compare.x = (direction == GTK_DIR_RIGHT) ? widget->allocation.x : widget->allocation.x + widget->allocation.width;
Packit Service fb6fa5
      else
Packit Service fb6fa5
	compare.x = (direction == GTK_DIR_RIGHT) ? 0 : widget->allocation.width;
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  children = g_list_sort_with_data (children, left_right_compare, &compare);
Packit Service fb6fa5
Packit Service fb6fa5
  if (compare.reverse)
Packit Service fb6fa5
    children = g_list_reverse (children);
Packit Service fb6fa5
Packit Service fb6fa5
  return children;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_focus_sort:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 * @children:  a list of descendents of @container (they don't
Packit Service fb6fa5
 *             have to be direct children)
Packit Service fb6fa5
 * @direction: focus direction
Packit Service fb6fa5
 * @old_focus: (allow-none): widget to use for the starting position, or %NULL
Packit Service fb6fa5
 *             to determine this automatically.
Packit Service fb6fa5
 *             (Note, this argument isn't used for GTK_DIR_TAB_*,
Packit Service fb6fa5
 *              which is the only @direction we use currently,
Packit Service fb6fa5
 *              so perhaps this argument should be removed)
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Sorts @children in the correct order for focusing with
Packit Service fb6fa5
 * direction type @direction.
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Return value: a copy of @children, sorted in correct focusing order,
Packit Service fb6fa5
 *   with children that aren't suitable for focusing in this direction
Packit Service fb6fa5
 *   removed.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
GList *
Packit Service fb6fa5
_gtk_container_focus_sort (GtkContainer     *container,
Packit Service fb6fa5
			   GList            *children,
Packit Service fb6fa5
			   GtkDirectionType  direction,
Packit Service fb6fa5
			   GtkWidget        *old_focus)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GList *visible_children = NULL;
Packit Service fb6fa5
Packit Service fb6fa5
  while (children)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      if (gtk_widget_get_realized (children->data))
Packit Service fb6fa5
	visible_children = g_list_prepend (visible_children, children->data);
Packit Service fb6fa5
      children = children->next;
Packit Service fb6fa5
    }
Packit Service fb6fa5
  
Packit Service fb6fa5
  switch (direction)
Packit Service fb6fa5
    {
Packit Service fb6fa5
    case GTK_DIR_TAB_FORWARD:
Packit Service fb6fa5
    case GTK_DIR_TAB_BACKWARD:
Packit Service fb6fa5
      return gtk_container_focus_sort_tab (container, visible_children, direction, old_focus);
Packit Service fb6fa5
    case GTK_DIR_UP:
Packit Service fb6fa5
    case GTK_DIR_DOWN:
Packit Service fb6fa5
      return gtk_container_focus_sort_up_down (container, visible_children, direction, old_focus);
Packit Service fb6fa5
    case GTK_DIR_LEFT:
Packit Service fb6fa5
    case GTK_DIR_RIGHT:
Packit Service fb6fa5
      return gtk_container_focus_sort_left_right (container, visible_children, direction, old_focus);
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  g_assert_not_reached ();
Packit Service fb6fa5
Packit Service fb6fa5
  return NULL;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static gboolean
Packit Service fb6fa5
gtk_container_focus_move (GtkContainer     *container,
Packit Service fb6fa5
			  GList            *children,
Packit Service fb6fa5
			  GtkDirectionType  direction)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkWidget *focus_child;
Packit Service fb6fa5
  GtkWidget *child;
Packit Service fb6fa5
Packit Service fb6fa5
  focus_child = container->focus_child;
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)
Packit Service fb6fa5
	continue;
Packit Service fb6fa5
      
Packit Service fb6fa5
      if (focus_child)
Packit Service fb6fa5
        {
Packit Service fb6fa5
          if (focus_child == child)
Packit Service fb6fa5
            {
Packit Service fb6fa5
              focus_child = NULL;
Packit Service fb6fa5
Packit Service fb6fa5
		if (gtk_widget_child_focus (child, direction))
Packit Service fb6fa5
		  return TRUE;
Packit Service fb6fa5
            }
Packit Service fb6fa5
        }
Packit Service fb6fa5
      else if (gtk_widget_is_drawable (child) &&
Packit Service fb6fa5
               gtk_widget_is_ancestor (child, GTK_WIDGET (container)))
Packit Service fb6fa5
        {
Packit Service fb6fa5
          if (gtk_widget_child_focus (child, direction))
Packit Service fb6fa5
            return TRUE;
Packit Service fb6fa5
        }
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  return FALSE;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_container_children_callback (GtkWidget *widget,
Packit Service fb6fa5
				 gpointer   client_data)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GList **children;
Packit Service fb6fa5
Packit Service fb6fa5
  children = (GList**) client_data;
Packit Service fb6fa5
  *children = g_list_prepend (*children, widget);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
chain_widget_destroyed (GtkWidget *widget,
Packit Service fb6fa5
                        gpointer   user_data)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkContainer *container;
Packit Service fb6fa5
  GList *chain;
Packit Service fb6fa5
  
Packit Service fb6fa5
  container = GTK_CONTAINER (user_data);
Packit Service fb6fa5
Packit Service fb6fa5
  chain = g_object_get_data (G_OBJECT (container),
Packit Service fb6fa5
                             "gtk-container-focus-chain");
Packit Service fb6fa5
Packit Service fb6fa5
  chain = g_list_remove (chain, widget);
Packit Service fb6fa5
Packit Service fb6fa5
  g_signal_handlers_disconnect_by_func (widget,
Packit Service fb6fa5
                                        chain_widget_destroyed,
Packit Service fb6fa5
                                        user_data);
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_object_set_data (G_OBJECT (container),
Packit Service fb6fa5
                     I_("gtk-container-focus-chain"),
Packit Service fb6fa5
                     chain);  
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_set_focus_chain:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 * @focusable_widgets: (transfer none) (element-type GtkWidget):
Packit Service fb6fa5
 *     the new focus chain
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Sets a focus chain, overriding the one computed automatically by GTK+.
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * In principle each widget in the chain should be a descendant of the 
Packit Service fb6fa5
 * container, but this is not enforced by this method, since it's allowed 
Packit Service fb6fa5
 * to set the focus chain before you pack the widgets, or have a widget 
Packit Service fb6fa5
 * in the chain that isn't always packed. The necessary checks are done 
Packit Service fb6fa5
 * when the focus chain is actually traversed.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_set_focus_chain (GtkContainer *container,
Packit Service fb6fa5
                               GList        *focusable_widgets)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GList *chain;
Packit Service fb6fa5
  GList *tmp_list;
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (container->has_focus_chain)
Packit Service fb6fa5
    gtk_container_unset_focus_chain (container);
Packit Service fb6fa5
Packit Service fb6fa5
  container->has_focus_chain = TRUE;
Packit Service fb6fa5
  
Packit Service fb6fa5
  chain = NULL;
Packit Service fb6fa5
  tmp_list = focusable_widgets;
Packit Service fb6fa5
  while (tmp_list != NULL)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      g_return_if_fail (GTK_IS_WIDGET (tmp_list->data));
Packit Service fb6fa5
      
Packit Service fb6fa5
      /* In principle each widget in the chain should be a descendant
Packit Service fb6fa5
       * of the container, but we don't want to check that here, it's
Packit Service fb6fa5
       * expensive and also it's allowed to set the focus chain before
Packit Service fb6fa5
       * you pack the widgets, or have a widget in the chain that isn't
Packit Service fb6fa5
       * always packed. So we check for ancestor during actual traversal.
Packit Service fb6fa5
       */
Packit Service fb6fa5
Packit Service fb6fa5
      chain = g_list_prepend (chain, tmp_list->data);
Packit Service fb6fa5
Packit Service fb6fa5
      g_signal_connect (tmp_list->data,
Packit Service fb6fa5
                        "destroy",
Packit Service fb6fa5
                        G_CALLBACK (chain_widget_destroyed),
Packit Service fb6fa5
                        container);
Packit Service fb6fa5
      
Packit Service fb6fa5
      tmp_list = g_list_next (tmp_list);
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  chain = g_list_reverse (chain);
Packit Service fb6fa5
  
Packit Service fb6fa5
  g_object_set_data (G_OBJECT (container),
Packit Service fb6fa5
                     I_("gtk-container-focus-chain"),
Packit Service fb6fa5
                     chain);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_get_focus_chain:
Packit Service fb6fa5
 * @container:         a #GtkContainer
Packit Service fb6fa5
 * @focusable_widgets: (element-type GtkWidget) (out) (transfer container): location
Packit Service fb6fa5
 *                     to store the focus chain of the
Packit Service fb6fa5
 *                     container, or %NULL. You should free this list
Packit Service fb6fa5
 *                     using g_list_free() when you are done with it, however
Packit Service fb6fa5
 *                     no additional reference count is added to the
Packit Service fb6fa5
 *                     individual widgets in the focus chain.
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Retrieves the focus chain of the container, if one has been
Packit Service fb6fa5
 * set explicitly. If no focus chain has been explicitly
Packit Service fb6fa5
 * set, GTK+ computes the focus chain based on the positions
Packit Service fb6fa5
 * of the children. In that case, GTK+ stores %NULL in
Packit Service fb6fa5
 * @focusable_widgets and returns %FALSE.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Return value: %TRUE if the focus chain of the container 
Packit Service fb6fa5
 * has been set explicitly.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
gboolean
Packit Service fb6fa5
gtk_container_get_focus_chain (GtkContainer *container,
Packit Service fb6fa5
			       GList       **focus_chain)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_CONTAINER (container), FALSE);
Packit Service fb6fa5
Packit Service fb6fa5
  if (focus_chain)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      if (container->has_focus_chain)
Packit Service fb6fa5
	*focus_chain = g_list_copy (get_focus_chain (container));
Packit Service fb6fa5
      else
Packit Service fb6fa5
	*focus_chain = NULL;
Packit Service fb6fa5
    }
Packit Service fb6fa5
Packit Service fb6fa5
  return container->has_focus_chain;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_unset_focus_chain:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Removes a focus chain explicitly set with gtk_container_set_focus_chain().
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_unset_focus_chain (GtkContainer  *container)
Packit Service fb6fa5
{  
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
Packit Service fb6fa5
  if (container->has_focus_chain)
Packit Service fb6fa5
    {
Packit Service fb6fa5
      GList *chain;
Packit Service fb6fa5
      GList *tmp_list;
Packit Service fb6fa5
      
Packit Service fb6fa5
      chain = get_focus_chain (container);
Packit Service fb6fa5
      
Packit Service fb6fa5
      container->has_focus_chain = FALSE;
Packit Service fb6fa5
      
Packit Service fb6fa5
      g_object_set_data (G_OBJECT (container), 
Packit Service fb6fa5
                         I_("gtk-container-focus-chain"),
Packit Service fb6fa5
                         NULL);
Packit Service fb6fa5
Packit Service fb6fa5
      tmp_list = chain;
Packit Service fb6fa5
      while (tmp_list != NULL)
Packit Service fb6fa5
        {
Packit Service fb6fa5
          g_signal_handlers_disconnect_by_func (tmp_list->data,
Packit Service fb6fa5
                                                chain_widget_destroyed,
Packit Service fb6fa5
                                                container);
Packit Service fb6fa5
          
Packit Service fb6fa5
          tmp_list = g_list_next (tmp_list);
Packit Service fb6fa5
        }
Packit Service fb6fa5
Packit Service fb6fa5
      g_list_free (chain);
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_set_focus_vadjustment:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 * @adjustment: an adjustment which should be adjusted when the focus 
Packit Service fb6fa5
 *   is moved among the descendents of @container
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Hooks up an adjustment to focus handling in a container, so when a 
Packit Service fb6fa5
 * child of the container is focused, the adjustment is scrolled to 
Packit Service fb6fa5
 * show that widget. This function sets the vertical alignment. See 
Packit Service fb6fa5
 * gtk_scrolled_window_get_vadjustment() for a typical way of obtaining 
Packit Service fb6fa5
 * the adjustment and gtk_container_set_focus_hadjustment() for setting
Packit Service fb6fa5
 * the horizontal adjustment.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * The adjustments have to be in pixel units and in the same coordinate 
Packit Service fb6fa5
 * system as the allocation for immediate children of the container. 
Packit Service fb6fa5
 */
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_set_focus_vadjustment (GtkContainer  *container,
Packit Service fb6fa5
				     GtkAdjustment *adjustment)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
  if (adjustment)
Packit Service fb6fa5
    g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
Packit Service fb6fa5
Packit Service fb6fa5
  if (adjustment)
Packit Service fb6fa5
    g_object_ref (adjustment);
Packit Service fb6fa5
Packit Service fb6fa5
  g_object_set_qdata_full (G_OBJECT (container),
Packit Service fb6fa5
			   vadjustment_key_id,
Packit Service fb6fa5
			   adjustment,
Packit Service fb6fa5
			   g_object_unref);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_get_focus_vadjustment:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Retrieves the vertical focus adjustment for the container. See
Packit Service fb6fa5
 * gtk_container_set_focus_vadjustment().
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Return value: (transfer none): the vertical focus adjustment, or %NULL if
Packit Service fb6fa5
 *   none has been set.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
GtkAdjustment *
Packit Service fb6fa5
gtk_container_get_focus_vadjustment (GtkContainer *container)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkAdjustment *vadjustment;
Packit Service fb6fa5
    
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
Packit Service fb6fa5
Packit Service fb6fa5
  vadjustment = g_object_get_qdata (G_OBJECT (container), vadjustment_key_id);
Packit Service fb6fa5
Packit Service fb6fa5
  return vadjustment;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_set_focus_hadjustment:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 * @adjustment: an adjustment which should be adjusted when the focus is 
Packit Service fb6fa5
 *   moved among the descendents of @container
Packit Service fb6fa5
 * 
Packit Service fb6fa5
 * Hooks up an adjustment to focus handling in a container, so when a child 
Packit Service fb6fa5
 * of the container is focused, the adjustment is scrolled to show that 
Packit Service fb6fa5
 * widget. This function sets the horizontal alignment. 
Packit Service fb6fa5
 * See gtk_scrolled_window_get_hadjustment() for a typical way of obtaining 
Packit Service fb6fa5
 * the adjustment and gtk_container_set_focus_vadjustment() for setting
Packit Service fb6fa5
 * the vertical adjustment.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * The adjustments have to be in pixel units and in the same coordinate 
Packit Service fb6fa5
 * system as the allocation for immediate children of the container. 
Packit Service fb6fa5
 */
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_set_focus_hadjustment (GtkContainer  *container,
Packit Service fb6fa5
				     GtkAdjustment *adjustment)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
  if (adjustment)
Packit Service fb6fa5
    g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
Packit Service fb6fa5
Packit Service fb6fa5
  if (adjustment)
Packit Service fb6fa5
    g_object_ref (adjustment);
Packit Service fb6fa5
Packit Service fb6fa5
  g_object_set_qdata_full (G_OBJECT (container),
Packit Service fb6fa5
			   hadjustment_key_id,
Packit Service fb6fa5
			   adjustment,
Packit Service fb6fa5
			   g_object_unref);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_get_focus_hadjustment:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Retrieves the horizontal focus adjustment for the container. See
Packit Service fb6fa5
 * gtk_container_set_focus_hadjustment ().
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Return value: (transfer none): the horizontal focus adjustment, or %NULL if
Packit Service fb6fa5
 *   none has been set.
Packit Service fb6fa5
 **/
Packit Service fb6fa5
GtkAdjustment *
Packit Service fb6fa5
gtk_container_get_focus_hadjustment (GtkContainer *container)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GtkAdjustment *hadjustment;
Packit Service fb6fa5
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
Packit Service fb6fa5
Packit Service fb6fa5
  hadjustment = g_object_get_qdata (G_OBJECT (container), hadjustment_key_id);
Packit Service fb6fa5
Packit Service fb6fa5
  return hadjustment;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_container_show_all (GtkWidget *widget)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (widget));
Packit Service fb6fa5
Packit Service fb6fa5
  gtk_container_foreach (GTK_CONTAINER (widget),
Packit Service fb6fa5
			 (GtkCallback) gtk_widget_show_all,
Packit Service fb6fa5
			 NULL);
Packit Service fb6fa5
  gtk_widget_show (widget);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_container_hide_all (GtkWidget *widget)
Packit Service fb6fa5
{
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (widget));
Packit Service fb6fa5
Packit Service fb6fa5
  gtk_widget_hide (widget);
Packit Service fb6fa5
  gtk_container_foreach (GTK_CONTAINER (widget),
Packit Service fb6fa5
			 (GtkCallback) gtk_widget_hide_all,
Packit Service fb6fa5
			 NULL);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_container_expose_child (GtkWidget *child,
Packit Service fb6fa5
			    gpointer   client_data)
Packit Service fb6fa5
{
Packit Service fb6fa5
  struct {
Packit Service fb6fa5
    GtkWidget *container;
Packit Service fb6fa5
    GdkEventExpose *event;
Packit Service fb6fa5
  } *data = client_data;
Packit Service fb6fa5
  
Packit Service fb6fa5
  gtk_container_propagate_expose (GTK_CONTAINER (data->container),
Packit Service fb6fa5
				  child,
Packit Service fb6fa5
				  data->event);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static gint 
Packit Service fb6fa5
gtk_container_expose (GtkWidget      *widget,
Packit Service fb6fa5
		      GdkEventExpose *event)
Packit Service fb6fa5
{
Packit Service fb6fa5
  struct {
Packit Service fb6fa5
    GtkWidget *container;
Packit Service fb6fa5
    GdkEventExpose *event;
Packit Service fb6fa5
  } data;
Packit Service fb6fa5
Packit Service fb6fa5
  g_return_val_if_fail (GTK_IS_CONTAINER (widget), FALSE);
Packit Service fb6fa5
  g_return_val_if_fail (event != NULL, FALSE);
Packit Service fb6fa5
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (gtk_widget_is_drawable (widget))
Packit Service fb6fa5
    {
Packit Service fb6fa5
      data.container = widget;
Packit Service fb6fa5
      data.event = event;
Packit Service fb6fa5
      
Packit Service fb6fa5
      gtk_container_forall (GTK_CONTAINER (widget),
Packit Service fb6fa5
			    gtk_container_expose_child,
Packit Service fb6fa5
			    &data);
Packit Service fb6fa5
    }   
Packit Service fb6fa5
  
Packit Service fb6fa5
  return FALSE;
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_container_map_child (GtkWidget *child,
Packit Service fb6fa5
			 gpointer   client_data)
Packit Service fb6fa5
{
Packit Service fb6fa5
  if (gtk_widget_get_visible (child) &&
Packit Service fb6fa5
      GTK_WIDGET_CHILD_VISIBLE (child) &&
Packit Service fb6fa5
      !gtk_widget_get_mapped (child))
Packit Service fb6fa5
    gtk_widget_map (child);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_container_map (GtkWidget *widget)
Packit Service fb6fa5
{
Packit Service fb6fa5
  gtk_widget_set_mapped (widget, TRUE);
Packit Service fb6fa5
Packit Service fb6fa5
  gtk_container_forall (GTK_CONTAINER (widget),
Packit Service fb6fa5
			gtk_container_map_child,
Packit Service fb6fa5
			NULL);
Packit Service fb6fa5
Packit Service fb6fa5
  if (gtk_widget_get_has_window (widget))
Packit Service fb6fa5
    gdk_window_show (widget->window);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
static void
Packit Service fb6fa5
gtk_container_unmap (GtkWidget *widget)
Packit Service fb6fa5
{
Packit Service fb6fa5
  gtk_widget_set_mapped (widget, FALSE);
Packit Service fb6fa5
Packit Service fb6fa5
  if (gtk_widget_get_has_window (widget))
Packit Service fb6fa5
    gdk_window_hide (widget->window);
Packit Service fb6fa5
  else
Packit Service fb6fa5
    gtk_container_forall (GTK_CONTAINER (widget),
Packit Service fb6fa5
			  (GtkCallback)gtk_widget_unmap,
Packit Service fb6fa5
			  NULL);
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
/**
Packit Service fb6fa5
 * gtk_container_propagate_expose:
Packit Service fb6fa5
 * @container: a #GtkContainer
Packit Service fb6fa5
 * @child: a child of @container
Packit Service fb6fa5
 * @event: a expose event sent to container
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * When a container receives an expose event, it must send synthetic
Packit Service fb6fa5
 * expose events to all children that don't have their own #GdkWindows.
Packit Service fb6fa5
 * This function provides a convenient way of doing this. A container,
Packit Service fb6fa5
 * when it receives an expose event, calls gtk_container_propagate_expose()
Packit Service fb6fa5
 * once for each child, passing in the event the container received.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * gtk_container_propagate_expose() takes care of deciding whether
Packit Service fb6fa5
 * an expose event needs to be sent to the child, intersecting
Packit Service fb6fa5
 * the event's area with the child area, and sending the event.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * In most cases, a container can simply either simply inherit the
Packit Service fb6fa5
 * #GtkWidget::expose implementation from #GtkContainer, or, do some drawing
Packit Service fb6fa5
 * and then chain to the ::expose implementation from #GtkContainer.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 * Note that the ::expose-event signal has been replaced by a ::draw
Packit Service fb6fa5
 * signal in GTK+ 3, and consequently, gtk_container_propagate_expose()
Packit Service fb6fa5
 * has been replaced by gtk_container_propagate_draw().
Packit Service fb6fa5
 * The <link linkend="http://library.gnome.org/devel/gtk3/3.0/gtk-migrating-2-to-3.html">GTK+ 3 migration guide</link>
Packit Service fb6fa5
 * for hints on how to port from ::expose-event to ::draw.
Packit Service fb6fa5
 *
Packit Service fb6fa5
 **/
Packit Service fb6fa5
void
Packit Service fb6fa5
gtk_container_propagate_expose (GtkContainer   *container,
Packit Service fb6fa5
				GtkWidget      *child,
Packit Service fb6fa5
				GdkEventExpose *event)
Packit Service fb6fa5
{
Packit Service fb6fa5
  GdkEvent *child_event;
Packit Service fb6fa5
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_CONTAINER (container));
Packit Service fb6fa5
  g_return_if_fail (GTK_IS_WIDGET (child));
Packit Service fb6fa5
  g_return_if_fail (event != NULL);
Packit Service fb6fa5
Packit Service fb6fa5
  g_assert (child->parent == GTK_WIDGET (container));
Packit Service fb6fa5
  
Packit Service fb6fa5
  if (gtk_widget_is_drawable (child) &&
Packit Service fb6fa5
      !gtk_widget_get_has_window (child) &&
Packit Service fb6fa5
      (child->window == event->window))
Packit Service fb6fa5
    {
Packit Service fb6fa5
      child_event = gdk_event_new (GDK_EXPOSE);
Packit Service fb6fa5
      child_event->expose = *event;
Packit Service fb6fa5
      g_object_ref (child_event->expose.window);
Packit Service fb6fa5
Packit Service fb6fa5
      child_event->expose.region = gtk_widget_region_intersect (child, event->region);
Packit Service fb6fa5
      if (!gdk_region_empty (child_event->expose.region))
Packit Service fb6fa5
	{
Packit Service fb6fa5
	  gdk_region_get_clipbox (child_event->expose.region, &child_event->expose.area);
Packit Service fb6fa5
	  gtk_widget_send_expose (child, child_event);
Packit Service fb6fa5
	}
Packit Service fb6fa5
      gdk_event_free (child_event);
Packit Service fb6fa5
    }
Packit Service fb6fa5
}
Packit Service fb6fa5
Packit Service fb6fa5
#define __GTK_CONTAINER_C__
Packit Service fb6fa5
#include "gtkaliasdef.c"