Commit d9c92598 authored by Benjamin Otte's avatar Benjamin Otte

Move GtkSizeRequest into GtkWidget

It doesn't make sense to keep them separate as GtkSizeRequest requires a
GtkWidget and GtkWidget implements GtkSizeRequest, so you can never have
one without the other.
It also makes the code a lot easier because no casts are required when
calling functions.

Also, the names would translate to gtk_widget_get_width() and people
agreed that this would be a too generic name, so a "preferred" was added
to the names.

So this patch moves the functions:
gtk_size_request_get_request_mode() => gtk_widget_get_request_mode()
gtk_size_request_get_width() => gtk_widget_get_preferred_width()
gtk_size_request_get_height() => gtk_widget_get_preferred_height()
gtk_size_request_get_size() => gtk_widget_get_preferred_size()
gtk_size_request_get_width_for_height() =>
  gtk_widget_get_preferred_width_for_height()
gtk_size_request_get_height_for_width() =>
  gtk_widget_get_preferred_height_for_width()
... and moves the corresponding vfuncs to the GtkWidgetClass.

The patch also renames the implementations of the vfuncs in widgets to
include the word "preferrred".
parent f52a1fcf
......@@ -391,7 +391,7 @@ gtk_rotated_bin_size_request (GtkWidget *widget,
child_requisition.height = 0;
if (bin->child && gtk_widget_get_visible (bin->child))
gtk_size_request_get_size (GTK_SIZE_REQUEST (bin->child),
gtk_widget_get_preferred_size ( (bin->child),
&child_requisition, NULL);
s = sin (bin->angle);
......@@ -434,8 +434,8 @@ gtk_rotated_bin_size_allocate (GtkWidget *widget,
s = sin (bin->angle);
c = cos (bin->angle);
gtk_size_request_get_size (GTK_SIZE_REQUEST (bin->child),
&child_requisition, NULL);
gtk_widget_get_preferred_size (bin->child,
&child_requisition, NULL);
child_allocation.x = 0;
child_allocation.y = 0;
child_allocation.height = child_requisition.height;
......
......@@ -315,7 +315,7 @@ gtk_mirror_bin_size_request (GtkWidget *widget,
child_requisition.height = 0;
if (bin->child && gtk_widget_get_visible (bin->child))
gtk_size_request_get_size (GTK_SIZE_REQUEST (bin->child),
gtk_widget_get_preferred_size ( (bin->child),
&child_requisition, NULL);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
......@@ -349,8 +349,8 @@ gtk_mirror_bin_size_allocate (GtkWidget *widget,
GtkRequisition child_requisition;
GtkAllocation child_allocation;
gtk_size_request_get_size (GTK_SIZE_REQUEST (bin->child),
&child_requisition, NULL);
gtk_widget_get_preferred_size (bin->child,
&child_requisition, NULL);
child_allocation.x = 0;
child_allocation.y = 0;
child_allocation.height = child_requisition.height;
......
......@@ -135,7 +135,7 @@ main(int argc, char **argv)
gtk_widget_show_all (vbox);
/* Compute the size without the drawing area, so we know how big to make the default size */
gtk_size_request_get_size (GTK_SIZE_REQUEST (vbox),
gtk_widget_get_preferred_size ( (vbox),
&scratch_requisition, NULL);
darea = gtk_drawing_area_new ();
......
......@@ -6290,16 +6290,14 @@ gtk_orientable_get_type
<SECTION>
<FILE>gtksizerequest</FILE>
<TITLE>GtkSizeRequest</TITLE>
GtkSizeRequest
GtkSizeRequestIface
GtkSizeRequestMode
GtkRequestedSize
gtk_size_request_get_height
gtk_size_request_get_width
gtk_size_request_get_height_for_width
gtk_size_request_get_width_for_height
gtk_size_request_get_request_mode
gtk_size_request_get_size
gtk_widget_get_preferred_height
gtk_widget_get_preferred_width
gtk_widget_get_preferred_height_for_width
gtk_widget_get_preferred_width_for_height
gtk_widget_get_request_mode
gtk_widget_get_preferred_size
gtk_distribute_natural_allocation
<SUBSECTION Standard>
......@@ -6310,7 +6308,7 @@ GTK_IS_SIZE_REQUEST
GTK_TYPE_SIZE_REQUEST
<SUBSECTION Private>
gtk_size_request_get_type
gtk_widget_get_type
</SECTION>
<SECTION>
......
......@@ -131,7 +131,6 @@ gtk_separator_menu_item_get_type
gtk_separator_tool_item_get_type
gtk_settings_get_type
gtk_size_group_get_type
gtk_size_request_get_type
gtk_socket_get_type
gtk_spin_button_get_type
gtk_spinner_get_type
......
......@@ -58,7 +58,7 @@ of their children.
<para>
The size requisition phase of the widget layout process operates top-down.
It starts at a top-level widget, typically a #GtkWindow. The top-level widget
asks its child for its size requisition by calling gtk_size_request_get_size().
asks its child for its size requisition by calling gtk_size_request_get_preferred_size().
To determine its requisition, the child asks its own children for their
requisitions and so on. Finally, the top-level widget will get a requisition
back from its child.
......
......@@ -37,7 +37,7 @@ The #GtkFileChooserButton supports the #GtkFileChooserAction<!--
<para>
The #GtkFileChooserButton will ellipsize the label,
and thus will thus request little horizontal space. To give the button
more space, you should call gtk_size_request_get_size(),
more space, you should call gtk_size_request_get_preferred_size(),
gtk_file_chooser_button_set_width_chars(), or pack the button in
such a way that other interface elements give space to the widget.
</para>
......
......@@ -3042,13 +3042,12 @@ gtk_size_group_set_mode
#if IN_HEADER(__GTK_SIZE_REQUEST_H__)
#if IN_FILE(__GTK_SIZE_REQUEST_C__)
gtk_size_request_get_height
gtk_size_request_get_height_for_width
gtk_size_request_get_request_mode
gtk_size_request_get_size
gtk_size_request_get_type G_GNUC_CONST
gtk_size_request_get_width
gtk_size_request_get_width_for_height
gtk_widget_get_preferred_height
gtk_widget_get_preferred_height_for_width
gtk_widget_get_preferred
gtk_widget_get_preferred_size
gtk_widget_get_preferred_width
gtk_widget_get_preferred_width_for_height
#endif
#endif
......
......@@ -125,19 +125,14 @@ static gboolean gtk_accel_label_draw (GtkWidget *widget,
static const gchar *gtk_accel_label_get_string (GtkAccelLabel *accel_label);
static void gtk_accel_label_size_request_init (GtkSizeRequestIface *iface);
static void gtk_accel_label_get_width (GtkSizeRequest *widget,
gint *min_width,
gint *nat_width);
static void gtk_accel_label_get_preferred_width (GtkWidget *widget,
gint *min_width,
gint *nat_width);
#define GTK_ACCEL_LABEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_ACCEL_LABEL, GtkAccelLabelPrivate))
static GtkSizeRequestIface *parent_size_request_iface;
G_DEFINE_TYPE_WITH_CODE (GtkAccelLabel, gtk_accel_label, GTK_TYPE_LABEL,
G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
gtk_accel_label_size_request_init))
G_DEFINE_TYPE (GtkAccelLabel, gtk_accel_label, GTK_TYPE_LABEL)
static void
gtk_accel_label_class_init (GtkAccelLabelClass *class)
......@@ -153,6 +148,7 @@ gtk_accel_label_class_init (GtkAccelLabelClass *class)
object_class->destroy = gtk_accel_label_destroy;
widget_class->draw = gtk_accel_label_draw;
widget_class->get_preferred_width = gtk_accel_label_get_preferred_width;
class->signal_quote1 = g_strdup ("<:");
class->signal_quote2 = g_strdup (":>");
......@@ -349,22 +345,15 @@ gtk_accel_label_get_accel_width (GtkAccelLabel *accel_label)
}
static void
gtk_accel_label_size_request_init (GtkSizeRequestIface *iface)
{
parent_size_request_iface = g_type_interface_peek_parent (iface);
iface->get_width = gtk_accel_label_get_width;
}
static void
gtk_accel_label_get_width (GtkSizeRequest *widget,
gint *min_width,
gint *nat_width)
gtk_accel_label_get_preferred_width (GtkWidget *widget,
gint *min_width,
gint *nat_width)
{
GtkAccelLabel *accel_label = GTK_ACCEL_LABEL (widget);
PangoLayout *layout;
gint width;
parent_size_request_iface->get_width (widget, min_width, nat_width);
GTK_WIDGET_CLASS (gtk_accel_label_parent_class)->get_preferred_width (widget, min_width, nat_width);
layout = gtk_widget_create_pango_layout (GTK_WIDGET (widget),
gtk_accel_label_get_string (accel_label));
......@@ -405,8 +394,7 @@ gtk_accel_label_draw (GtkWidget *widget,
ac_width = gtk_accel_label_get_accel_width (accel_label);
gtk_widget_get_allocation (widget, &allocation);
gtk_size_request_get_size (GTK_SIZE_REQUEST (widget),
&requisition, NULL);
gtk_widget_get_preferred_size (widget, &requisition, NULL);
if (allocation.width >= requisition.width + ac_width)
{
......
......@@ -92,17 +92,14 @@ static void gtk_alignment_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
static void gtk_alignment_size_request_init (GtkSizeRequestIface *iface);
static void gtk_alignment_get_width (GtkSizeRequest *widget,
gint *minimum_size,
gint *natural_size);
static void gtk_alignment_get_height (GtkSizeRequest *widget,
gint *minimum_size,
gint *natural_size);
G_DEFINE_TYPE_WITH_CODE (GtkAlignment, gtk_alignment, GTK_TYPE_BIN,
G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
gtk_alignment_size_request_init))
static void gtk_alignment_get_preferred_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
static void gtk_alignment_get_preferred_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
G_DEFINE_TYPE (GtkAlignment, gtk_alignment, GTK_TYPE_BIN)
static void
gtk_alignment_class_init (GtkAlignmentClass *class)
......@@ -116,7 +113,9 @@ gtk_alignment_class_init (GtkAlignmentClass *class)
gobject_class->set_property = gtk_alignment_set_property;
gobject_class->get_property = gtk_alignment_get_property;
widget_class->size_allocate = gtk_alignment_size_allocate;
widget_class->size_allocate = gtk_alignment_size_allocate;
widget_class->get_preferred_width = gtk_alignment_get_preferred_width;
widget_class->get_preferred_height = gtk_alignment_get_preferred_height;
g_object_class_install_property (gobject_class,
PROP_XALIGN,
......@@ -492,7 +491,7 @@ gtk_alignment_size_allocate (GtkWidget *widget,
GtkAlignmentPrivate *priv = alignment->priv;
GtkBin *bin;
GtkAllocation child_allocation;
GtkWidget *bin_child;
GtkWidget *child;
gint width, height;
guint border_width;
gint padding_horizontal, padding_vertical;
......@@ -503,10 +502,9 @@ gtk_alignment_size_allocate (GtkWidget *widget,
gtk_widget_set_allocation (widget, allocation);
bin = GTK_BIN (widget);
bin_child = gtk_bin_get_child (bin);
if (bin_child && gtk_widget_get_visible (bin_child))
child = gtk_bin_get_child (bin);
if (child && gtk_widget_get_visible (child))
{
GtkSizeRequest *child = GTK_SIZE_REQUEST (bin_child);
gint child_nat_width;
gint child_nat_height;
gint child_width, child_height;
......@@ -519,23 +517,23 @@ gtk_alignment_size_allocate (GtkWidget *widget,
width = MAX (1, allocation->width - padding_horizontal - 2 * border_width);
height = MAX (1, allocation->height - padding_vertical - 2 * border_width);
if (gtk_size_request_get_request_mode (child) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
if (gtk_widget_get_request_mode (child) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
{
gtk_size_request_get_width (child, NULL, &child_nat_width);
gtk_widget_get_preferred_width (child, NULL, &child_nat_width);
child_width = MIN (width, child_nat_width);
gtk_size_request_get_height_for_width (child, child_width, NULL, &child_nat_height);
gtk_widget_get_preferred_height_for_width (child, child_width, NULL, &child_nat_height);
child_height = MIN (height, child_nat_height);
}
else
{
gtk_size_request_get_height (child, NULL, &child_nat_height);
gtk_widget_get_preferred_height (child, NULL, &child_nat_height);
child_height = MIN (height, child_nat_height);
gtk_size_request_get_width_for_height (child, child_height, NULL, &child_nat_width);
gtk_widget_get_preferred_width_for_height (child, child_height, NULL, &child_nat_width);
child_width = MIN (width, child_nat_width);
}
......@@ -561,23 +559,16 @@ gtk_alignment_size_allocate (GtkWidget *widget,
child_allocation.y = priv->yalign * (height - child_allocation.height) + allocation->y + border_width + priv->padding_top;
gtk_widget_size_allocate (bin_child, &child_allocation);
gtk_widget_size_allocate (child, &child_allocation);
}
}
static void
gtk_alignment_size_request_init (GtkSizeRequestIface *iface)
{
iface->get_width = gtk_alignment_get_width;
iface->get_height = gtk_alignment_get_height;
}
static void
gtk_alignment_get_size (GtkSizeRequest *widget,
GtkOrientation orientation,
gint *minimum_size,
gint *natural_size)
gtk_alignment_get_preferred_size (GtkWidget *widget,
GtkOrientation orientation,
gint *minimum_size,
gint *natural_size)
{
GtkAlignment *alignment = GTK_ALIGNMENT (widget);
GtkAlignmentPrivate *priv = alignment->priv;
......@@ -594,14 +585,12 @@ gtk_alignment_get_size (GtkSizeRequest *widget,
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
minimum += (priv->padding_left + priv->padding_right);
gtk_size_request_get_width (GTK_SIZE_REQUEST (child),
&child_min, &child_nat);
gtk_widget_get_preferred_width (child, &child_min, &child_nat);
}
else
{
minimum += (priv->padding_top + priv->padding_bottom);
gtk_size_request_get_height (GTK_SIZE_REQUEST (child),
&child_min, &child_nat);
gtk_widget_get_preferred_height (child, &child_min, &child_nat);
}
natural = minimum;
......@@ -618,19 +607,19 @@ gtk_alignment_get_size (GtkSizeRequest *widget,
}
static void
gtk_alignment_get_width (GtkSizeRequest *widget,
gint *minimum_size,
gint *natural_size)
gtk_alignment_get_preferred_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size)
{
gtk_alignment_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
gtk_alignment_get_preferred_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
}
static void
gtk_alignment_get_height (GtkSizeRequest *widget,
gint *minimum_size,
gint *natural_size)
gtk_alignment_get_preferred_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size)
{
gtk_alignment_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
gtk_alignment_get_preferred_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
}
/**
......
......@@ -77,17 +77,14 @@ static void gtk_arrow_get_property (GObject *object,
static gboolean gtk_arrow_draw (GtkWidget *widget,
cairo_t *cr);
static void gtk_arrow_size_request_init (GtkSizeRequestIface *iface);
static void gtk_arrow_get_width (GtkSizeRequest *widget,
gint *minimum_size,
gint *natural_size);
static void gtk_arrow_get_height (GtkSizeRequest *widget,
gint *minimum_size,
gint *natural_size);
static void gtk_arrow_get_preferred_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
static void gtk_arrow_get_preferred_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
G_DEFINE_TYPE_WITH_CODE (GtkArrow, gtk_arrow, GTK_TYPE_MISC,
G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
gtk_arrow_size_request_init))
G_DEFINE_TYPE (GtkArrow, gtk_arrow, GTK_TYPE_MISC)
static void
......@@ -103,6 +100,8 @@ gtk_arrow_class_init (GtkArrowClass *class)
gobject_class->get_property = gtk_arrow_get_property;
widget_class->draw = gtk_arrow_draw;
widget_class->get_preferred_width = gtk_arrow_get_preferred_width;
widget_class->get_preferred_height = gtk_arrow_get_preferred_height;
g_object_class_install_property (gobject_class,
PROP_ARROW_TYPE,
......@@ -199,16 +198,9 @@ gtk_arrow_init (GtkArrow *arrow)
}
static void
gtk_arrow_size_request_init (GtkSizeRequestIface *iface)
{
iface->get_width = gtk_arrow_get_width;
iface->get_height = gtk_arrow_get_height;
}
static void
gtk_arrow_get_width (GtkSizeRequest *widget,
gint *minimum_size,
gint *natural_size)
gtk_arrow_get_preferred_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size)
{
gint xpad;
......@@ -222,9 +214,9 @@ gtk_arrow_get_width (GtkSizeRequest *widget,
}
static void
gtk_arrow_get_height (GtkSizeRequest *widget,
gint *minimum_size,
gint *natural_size)
gtk_arrow_get_preferred_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size)
{
gint ypad;
......
......@@ -352,8 +352,7 @@ gtk_aspect_frame_compute_child_allocation (GtkFrame *frame,
{
GtkRequisition child_requisition;
gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
&child_requisition, NULL);
gtk_widget_get_preferred_size (child, &child_requisition, NULL);
if (child_requisition.height != 0)
{
ratio = ((gdouble) child_requisition.width /
......
......@@ -1157,13 +1157,13 @@ gtk_assistant_size_request (GtkWidget *widget,
GtkAssistantPage *page = list->data;
gint w, h;
gtk_size_request_get_size (GTK_SIZE_REQUEST (page->page),
&child_requisition, NULL);
gtk_widget_get_preferred_size (page->page,
&child_requisition, NULL);
width = MAX (width, child_requisition.width);
height = MAX (height, child_requisition.height);
gtk_size_request_get_size (GTK_SIZE_REQUEST (page->title),
&child_requisition, NULL);
gtk_widget_get_preferred_size (page->title,
&child_requisition, NULL);
w = child_requisition.width;
h = child_requisition.height;
......@@ -1179,19 +1179,19 @@ gtk_assistant_size_request (GtkWidget *widget,
list = list->next;
}
gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->sidebar_image),
&child_requisition, NULL);
gtk_widget_get_preferred_size (priv->sidebar_image,
&child_requisition, NULL);
width += child_requisition.width;
height = MAX (height, child_requisition.height);
gtk_widget_set_size_request (priv->header_image, header_width, header_height);
gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->header_image),
&child_requisition, NULL);
gtk_widget_get_preferred_size (priv->header_image,
&child_requisition, NULL);
width = MAX (width, header_width) + 2 * header_padding;
height += header_height + 2 * header_padding;
gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->action_area),
&child_requisition, NULL);
gtk_widget_get_preferred_size (priv->action_area,
&child_requisition, NULL);
width = MAX (width, child_requisition.width);
height += child_requisition.height + ACTION_AREA_SPACING;
......@@ -1230,8 +1230,8 @@ gtk_assistant_size_allocate (GtkWidget *widget,
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
/* Header */
gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->header_image),
&header_requisition, NULL);
gtk_widget_get_preferred_size (priv->header_image,
&header_requisition, NULL);
header_allocation.x = border_width + header_padding;
header_allocation.y = border_width + header_padding;
......@@ -1241,8 +1241,8 @@ gtk_assistant_size_allocate (GtkWidget *widget,
gtk_widget_size_allocate (priv->header_image, &header_allocation);
/* Action area */
gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->action_area),
&action_requisition, NULL);
gtk_widget_get_preferred_size (priv->action_area,
&action_requisition, NULL);
child_allocation.x = border_width;
child_allocation.y = allocation->height - border_width - action_requisition.height;
......@@ -1255,8 +1255,8 @@ gtk_assistant_size_allocate (GtkWidget *widget,
gtk_widget_get_allocation (priv->action_area, &action_area_allocation);
/* Sidebar */
gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->sidebar_image),
&sidebar_requisition, NULL);
gtk_widget_get_preferred_size (priv->sidebar_image,
&sidebar_requisition, NULL);
if (rtl)
child_allocation.x = allocation->width - border_width - sidebar_requisition.width;
......
......@@ -451,8 +451,8 @@ gtk_button_box_child_requisition (GtkWidget *widget,
if (gtk_widget_get_visible (child))
{
nchildren += 1;
gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
&child_requisition, NULL);
gtk_widget_get_preferred_size (child,
&child_requisition, NULL);
avg_w += child_requisition.width + ipad_w;
avg_h += child_requisition.height + ipad_h;
}
......@@ -479,8 +479,7 @@ gtk_button_box_child_requisition (GtkWidget *widget,
if (is_secondary)
nsecondaries++;
gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
&child_requisition, NULL);
gtk_widget_get_preferred_size (child, &child_requisition, NULL);
if (homogeneous || (child_requisition.width + ipad_w < avg_w * 1.5))
{
......
......@@ -59,29 +59,27 @@ static void gtk_bin_forall (GtkContainer *container,
static GType gtk_bin_child_type (GtkContainer *container);
static void gtk_bin_size_request_init (GtkSizeRequestIface *iface);
static GtkSizeRequestMode gtk_bin_get_request_mode (GtkSizeRequest *widget);
static void gtk_bin_get_width_for_height (GtkSizeRequest *widget,
gint height,
gint *minimum_width,
gint *natural_width);
static void gtk_bin_get_height_for_width (GtkSizeRequest *widget,
gint width,
gint *minimum_height,
gint *natural_height);
static GtkSizeRequestIface *parent_size_request_iface;
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GtkBin, gtk_bin, GTK_TYPE_CONTAINER,
G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
gtk_bin_size_request_init))
static GtkSizeRequestMode gtk_bin_get_request_mode (GtkWidget *widget);
static void gtk_bin_get_preferred_width_for_height (GtkWidget *widget,
gint height,
gint *minimum_width,
gint *natural_width);
static void gtk_bin_get_preferred_height_for_width (GtkWidget *widget,
gint width,
gint *minimum_height,
gint *natural_height);
G_DEFINE_ABSTRACT_TYPE (GtkBin, gtk_bin, GTK_TYPE_CONTAINER)
static void
gtk_bin_class_init (GtkBinClass *class)
{
GtkContainerClass *container_class;
GtkWidgetClass *widget_class = (GtkWidgetClass*) class;
GtkContainerClass *container_class = (GtkContainerClass*) class;
container_class = (GtkContainerClass*) class;
widget_class->get_request_mode = gtk_bin_get_request_mode;
widget_class->get_preferred_width_for_height = gtk_bin_get_preferred_width_for_height;
widget_class->get_preferred_height_for_width = gtk_bin_get_preferred_height_for_width;
container_class->add = gtk_bin_add;
container_class->remove = gtk_bin_remove;
......@@ -186,56 +184,47 @@ gtk_bin_forall (GtkContainer *container,
* deduce a common code path for the get_width_for_height()/get_height_for_width()
* cases by using the delta of the base size requsts.
*/
static void
gtk_bin_size_request_init (GtkSizeRequestIface *iface)
{
parent_size_request_iface = g_type_interface_peek_parent (iface);
iface->get_request_mode = gtk_bin_get_request_mode;
iface->get_width_for_height = gtk_bin_get_width_for_height;
iface->get_height_for_width = gtk_bin_get_height_for_width;
}
static GtkSizeRequestMode
gtk_bin_get_request_mode (GtkSizeRequest *widget)
gtk_bin_get_request_mode (GtkWidget *widget)
{
GtkBin *bin = GTK_BIN (widget);
GtkBinPrivate *priv = bin->priv;
if (priv->child)
return gtk_size_request_get_request_mode (GTK_SIZE_REQUEST (priv->child));
return gtk_widget_get_request_mode (priv->child);
return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
}
static void
get_child_padding_delta (GtkBin *bin,
gint *delta_h,
gint *delta_v)
get_child_padding_delta (GtkBin *bin,
gint *delta_h,
gint *delta_v)
{
GtkBinPrivate *priv = bin->priv;
gint hmin, vmin, hnat, vnat, child_hmin, child_vmin;
/* we can't use gtk_size_request_get_width() wrapper because we want
* our "original" request, not any external adjustments from
* set_size_request() or whatever. we have to ask for natural also
* because NULL isn't allowed for the direct vfuncs
/* we can't use gtk_widget_get_preferred_width() wrapper
* because we want our "original" request, not any external
* adjustments from set_size_request() or whatever. we have
* to ask for natural also because NULL isn't allowed for the
* direct vfuncs
*/
GTK_SIZE_REQUEST_GET_IFACE (bin)->get_width(GTK_SIZE_REQUEST (bin), &hmin, &hnat);
GTK_SIZE_REQUEST_GET_IFACE (bin)->get_height (GTK_SIZE_REQUEST (bin), &vmin, &vnat);
GTK_WIDGET_GET_CLASS (bin)->get_preferred_width (GTK_WIDGET (bin), &hmin, &hnat);
GTK_WIDGET_GET_CLASS (bin)->get_preferred_height (GTK_WIDGET (bin), &vmin, &vnat);
gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->child), &child_hmin, NULL);
gtk_size_request_get_height (GTK_SIZE_REQUEST (priv->child), &child_vmin, NULL);
gtk_widget_get_preferred_width (priv->child, &child_hmin, NULL);
gtk_widget_get_preferred_height (priv->child, &child_vmin, NULL);
*delta_h = hmin - child_hmin;
*delta_v = vmin - child_vmin;
}
static void
gtk_bin_get_width_for_height (GtkSizeRequest *widget,
gint height,
gint *minimum_width,
gint *natural_width)
gtk_bin_get_preferred_width_for_height (GtkWidget *widget,
gint height,
gint *minimum_width,
gint *natural_width)
{
GtkBin *bin = GTK_BIN (widget);
GtkBinPrivate *priv = bin->priv;
......@@ -245,9 +234,9 @@ gtk_bin_get_width_for_height (GtkSizeRequest *widget,
{
get_child_padding_delta (bin, &hdelta, &vdelta);
gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (priv->child),
height - vdelta,
&child_min, &child_nat);
gtk_widget_get_preferred_width_for_height (priv->child,
height - vdelta,
&child_min, &child_nat);
if (minimum_width)
*minimum_width = child_min + hdelta;
......@@ -256,14 +245,14 @@ gtk_bin_get_width_for_height (GtkSizeRequest *widget,
*natural_width = child_nat + hdelta;
}
else
GTK_SIZE_REQUEST_GET_IFACE (widget)->get_width (widget, minimum_width, natural_width);
GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, minimum_width, natural_width);
}
static void
gtk_bin_get_height_for_width (GtkSizeRequest *widget,
gint width,
gint *minimum_height,
gint *natural_height)
gtk_bin_get_preferred_height_for_width (GtkWidget *widget,
gint width,
gint *minimum_height,
gint *natural_height)
{
GtkBin *bin = GTK_BIN (widget);
GtkBinPrivate *priv = bin->priv;
......@@ -273,9 +262,9 @@ gtk_bin_get_height_for_width (GtkSizeRequest *widget,
{
get_child_padding_delta (bin, &hdelta, &vdelta);
gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (priv->child),
width - hdelta,
&child_min, &child_nat);
gtk_widget_get_preferred_height_for_width (priv->child,
width - hdelta,
&child_min, &child_nat);
if (minimum_height)
*minimum_height = child_min + vdelta;
......@@ -284,7 +273,7 @@ gtk_bin_get_height_for_width (GtkSizeRequest *widget,
*natural_height = child_nat + vdelta;
}
else
GTK_SIZE_REQUEST_GET_IFACE (