*
*/
+/*
+ * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+
#include "gtkpacker.h"
GtkWidget *child);
static void gtk_packer_remove (GtkContainer *container,
GtkWidget *widget);
-static void gtk_packer_foreach (GtkContainer *container,
+static void gtk_packer_forall (GtkContainer *container,
+ gboolean include_internals,
GtkCallback callback,
gpointer callback_data);
static void gtk_packer_set_arg (GtkObject *object,
if (!packer_type)
{
- GtkTypeInfo packer_info =
+ static const GtkTypeInfo packer_info =
{
"GtkPacker",
sizeof (GtkPacker),
sizeof (GtkPackerClass),
(GtkClassInitFunc) gtk_packer_class_init,
(GtkObjectInitFunc) gtk_packer_init,
- /* reversed_1 */ NULL,
- /* reversed_2 */ NULL,
+ /* reserved_1 */ NULL,
+ /* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
container_class->add = gtk_packer_container_add;
container_class->remove = gtk_packer_remove;
- container_class->foreach = gtk_packer_foreach;
+ container_class->forall = gtk_packer_forall;
container_class->child_type = gtk_packer_child_type;
container_class->get_child_arg = gtk_packer_get_child_arg;
container_class->set_child_arg = gtk_packer_set_child_arg;
static void
gtk_packer_init (GtkPacker *packer)
{
- GTK_WIDGET_SET_FLAGS (packer, GTK_NO_WINDOW | GTK_BASIC);
+ GTK_WIDGET_SET_FLAGS (packer, GTK_NO_WINDOW);
packer->children = NULL;
packer->spacing = 0;
packer->spacing = spacing;
gtk_widget_queue_resize (GTK_WIDGET (packer));
}
-};
+}
GtkWidget*
gtk_packer_new (void)
gtk_widget_set_parent (child, GTK_WIDGET (packer));
- if (GTK_WIDGET_VISIBLE (GTK_WIDGET (packer)))
+ if (GTK_WIDGET_REALIZED (child->parent))
+ gtk_widget_realize (child);
+
+ if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
{
- if (GTK_WIDGET_REALIZED (GTK_WIDGET (packer)) &&
- !GTK_WIDGET_REALIZED (child))
- gtk_widget_realize (child);
-
- if (GTK_WIDGET_MAPPED (GTK_WIDGET (packer)) &&
- !GTK_WIDGET_MAPPED (child))
- gtk_widget_map (child);
- }
+ if (GTK_WIDGET_MAPPED (child->parent))
+ gtk_widget_map (child);
- if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (packer))
- gtk_widget_queue_resize (child);
-
+ gtk_widget_queue_resize (child);
+ }
}
void
gtk_widget_set_parent (child, GTK_WIDGET (packer));
- if (GTK_WIDGET_VISIBLE (GTK_WIDGET (packer)))
+ if (GTK_WIDGET_REALIZED (child->parent))
+ gtk_widget_realize (child);
+
+ if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
{
- if (GTK_WIDGET_REALIZED (GTK_WIDGET (packer)) &&
- !GTK_WIDGET_REALIZED (child))
- gtk_widget_realize (child);
-
- if (GTK_WIDGET_MAPPED (GTK_WIDGET (packer)) &&
- !GTK_WIDGET_MAPPED (child))
- gtk_widget_map (child);
+ if (GTK_WIDGET_MAPPED (child->parent))
+ gtk_widget_map (child);
+
+ gtk_widget_queue_resize (child);
}
-
- if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (packer))
- gtk_widget_queue_resize (child);
-
}
void
-gtk_packer_configure (GtkPacker *packer,
- GtkWidget *child,
- GtkSideType side,
- GtkAnchorType anchor,
- GtkPackerOptions options,
- guint border_width,
- guint pad_x,
- guint pad_y,
- guint i_pad_x,
- guint i_pad_y)
+gtk_packer_set_child_packing (GtkPacker *packer,
+ GtkWidget *child,
+ GtkSideType side,
+ GtkAnchorType anchor,
+ GtkPackerOptions options,
+ guint border_width,
+ guint pad_x,
+ guint pad_y,
+ guint i_pad_x,
+ guint i_pad_y)
{
GList *list;
GtkPackerChild *pchild;
list = g_list_next(list);
}
- g_warning ("gtk_packer_configure(): couldn't find child `%s' amongst the packer's children", gtk_type_name (GTK_OBJECT_TYPE (child)));
-
+ g_warning ("couldn't find child `%s' amongst the packer's children", gtk_type_name (GTK_OBJECT_TYPE (child)));
}
void
}
static void
-gtk_packer_draw (GtkWidget *widget, GdkRectangle *area)
+gtk_packer_draw (GtkWidget *widget,
+ GdkRectangle *area)
{
GtkPacker *packer;
GtkPackerChild *child;
}
static gint
-gtk_packer_expose (GtkWidget *widget, GdkEventExpose *event)
+gtk_packer_expose (GtkWidget *widget,
+ GdkEventExpose *event)
{
GtkPacker *packer;
GtkPackerChild *child;
}
static void
-gtk_packer_size_request (GtkWidget *widget, GtkRequisition *requisition)
+gtk_packer_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
{
GtkPacker *packer;
GtkContainer *container;
if (GTK_WIDGET_VISIBLE (child->widget))
{
- gtk_widget_size_request (child->widget, &child->widget->requisition);
+ GtkRequisition child_requisition;
+
+ gtk_widget_size_request (child->widget, &child_requisition);
- if((child->side == GTK_SIDE_TOP) || (child->side == GTK_SIDE_BOTTOM))
+ if ((child->side == GTK_SIDE_TOP) || (child->side == GTK_SIDE_BOTTOM))
{
maxWidth = MAX (maxWidth,
- (child->widget->requisition.width +
+ (child_requisition.width +
2 * child->border_width +
child->pad_x + child->i_pad_x +
width));
- height += (child->widget->requisition.height +
+ height += (child_requisition.height +
2 * child->border_width +
child->pad_y + child->i_pad_y);
}
else
{
maxHeight = MAX (maxHeight,
- (child->widget->requisition.height +
+ (child_requisition.height +
2 * child->border_width +
child->pad_y + child->i_pad_y +
height));
- width += (child->widget->requisition.width +
+ width += (child_requisition.width +
2 * child->border_width +
child->pad_x + child->i_pad_x);
}
}
static gint
-YExpansion (GList *children, gint cavityHeight)
+YExpansion (GList *children,
+ gint cavityHeight)
{
GList *list;
GtkPackerChild *child;
list = children;
while (list != NULL)
{
+ GtkRequisition child_requisition;
+
child = list->data;
widget = child->widget;
- childHeight = (widget->requisition.height +
+ gtk_widget_get_child_requisition (widget, &child_requisition);
+
+ childHeight = (child_requisition.height +
2 * child->border_width +
child->i_pad_y +
child->pad_y);
}
static gint
-XExpansion (GList *children, gint cavityWidth)
+XExpansion (GList *children,
+ gint cavityWidth)
{
GList *list;
GtkPackerChild *child;
list = children;
while (list != NULL)
{
+ GtkRequisition child_requisition;
+
child = list->data;
widget = child->widget;
- childWidth = (widget->requisition.width +
+ gtk_widget_get_child_requisition (widget, &child_requisition);
+
+ childWidth = (child_requisition.width +
2 * child->border_width +
child->i_pad_x +
child->pad_x);
if (curExpand < minExpand)
minExpand = curExpand;
return (minExpand < 0) ? 0 : minExpand;
-};
+}
static void
-gtk_packer_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
+gtk_packer_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
{
GtkPacker *packer;
GtkContainer *container;
list = g_list_first (packer->children);
while (list != NULL)
{
+ GtkRequisition child_requisition;
+
child = list->data;
+ gtk_widget_get_child_requisition (child->widget, &child_requisition);
if ((child->side == GTK_SIDE_TOP) || (child->side == GTK_SIDE_BOTTOM))
{
frameWidth = cavityWidth;
- frameHeight = (child->widget->requisition.height +
+ frameHeight = (child_requisition.height +
2 * child->border_width +
child->pad_y +
child->i_pad_y);
else
{
frameHeight = cavityHeight;
- frameWidth = (child->widget->requisition.width +
+ frameWidth = (child_requisition.width +
2 * child->border_width +
child->pad_x +
child->i_pad_x);
borderX = child->pad_x + 2 * child->border_width;
borderY = child->pad_y + 2 * child->border_width;
- width = (child->widget->requisition.width +
+ width = (child_requisition.width +
2 * child->border_width +
child->i_pad_x);
if ((child->options & GTK_FILL_X) || (width > (frameWidth - borderX)))
width = frameWidth - borderX;
- height = (child->widget->requisition.height +
+ height = (child_requisition.height +
2 * child->border_width +
child->i_pad_y);
if ((child->options & GTK_FILL_Y) || (height > (frameHeight - borderY)))
}
static void
-gtk_packer_foreach (GtkContainer *container,
- GtkCallback callback,
- gpointer callback_data)
+gtk_packer_forall (GtkContainer *container,
+ gboolean include_internals,
+ GtkCallback callback,
+ gpointer callback_data)
{
GtkPacker *packer;
GtkPackerChild *child;
packer = GTK_PACKER (container);
- children = g_list_first(packer->children);
+ children = g_list_first (packer->children);
while (children != NULL)
{
child = children->data;