[gtk+/rendering-cleanup-next: 189/199] Move GtkSizeRequest into GtkWidget
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/rendering-cleanup-next: 189/199] Move GtkSizeRequest into GtkWidget
- Date: Thu, 23 Sep 2010 21:34:59 +0000 (UTC)
commit a3242fa5c09d3f0488dba7648813b353ff79fc69
Author: Benjamin Otte <otte redhat com>
Date: Tue Sep 21 16:35:17 2010 +0200
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".
demos/gtk-demo/offscreen_window.c | 6 +-
demos/gtk-demo/offscreen_window2.c | 6 +-
demos/testpixbuf-scale.c | 2 +-
docs/reference/gtk/gtk3-sections.txt | 16 +-
docs/reference/gtk/tmpl/gtkcontainer.sgml | 2 +-
docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml | 2 +-
gtk/gtk.symbols | 13 +-
gtk/gtkaccellabel.c | 31 +---
gtk/gtkalignment.c | 79 ++++-----
gtk/gtkarrow.c | 38 ++---
gtk/gtkaspectframe.c | 3 +-
gtk/gtkassistant.c | 22 ++--
gtk/gtkbbox.c | 5 +-
gtk/gtkbin.c | 103 +++++-------
gtk/gtkbox.c | 150 ++++++++---------
gtk/gtkbutton.c | 38 ++---
gtk/gtkcellrendereraccel.c | 2 +-
gtk/gtkcellrenderertext.c | 2 +-
gtk/gtkcellview.c | 86 +++++------
gtk/gtkcheckbutton.c | 6 +-
gtk/gtkcolorsel.c | 4 +-
gtk/gtkcombobox.c | 125 +++++++--------
gtk/gtkcontainer.c | 2 +-
gtk/gtkentry.c | 9 +-
gtk/gtkentrycompletion.c | 4 +-
gtk/gtkeventbox.c | 2 +-
gtk/gtkexpander.c | 117 ++++++-------
gtk/gtkfilechooserdefault.c | 12 +-
gtk/gtkfilechooserdialog.c | 8 +-
gtk/gtkfilechooserentry.c | 2 +-
gtk/gtkfixed.c | 8 +-
gtk/gtkfontsel.c | 6 +-
gtk/gtkframe.c | 109 ++++++-------
gtk/gtkhandlebox.c | 11 +-
gtk/gtkiconview.c | 2 +-
gtk/gtkimagemenuitem.c | 9 +-
gtk/gtklabel.c | 103 ++++++-------
gtk/gtklayout.c | 7 +-
gtk/gtklinkbutton.c | 2 +-
gtk/gtkmenu.c | 80 ++++-----
gtk/gtkmenubar.c | 8 +-
gtk/gtkmenuitem.c | 71 ++++-----
gtk/gtkmenutoolbutton.c | 6 +-
gtk/gtknotebook.c | 28 ++--
gtk/gtkoffscreenwindow.c | 4 +-
gtk/gtkpaned.c | 11 +-
gtk/gtkpathbar.c | 23 +--
gtk/gtkprintoperation-win32.c | 2 +-
gtk/gtkprivate.h | 2 +-
gtk/gtkrecentchooserdefault.c | 6 +-
gtk/gtkscrolledwindow.c | 103 ++++++-------
gtk/gtksizegroup.c | 7 +-
gtk/gtksizerequest.c | 154 ++++++++----------
gtk/gtksizerequest.h | 59 +-------
gtk/gtksocket.c | 2 +-
gtk/gtkspinbutton.c | 15 +-
gtk/gtkspinner.c | 35 ++--
gtk/gtkstatusicon.c | 4 +-
gtk/gtktable.c | 18 +-
gtk/gtktextlayout.c | 3 +-
gtk/gtktextview.c | 19 +--
gtk/gtktoolbar.c | 23 ++--
gtk/gtktoolitem.c | 2 +-
gtk/gtktoolitemgroup.c | 36 ++--
gtk/gtktoolpalette.c | 4 +-
gtk/gtktooltip.c | 4 +-
gtk/gtktreeview.c | 27 ++--
gtk/gtkviewport.c | 75 ++++-----
gtk/gtkwidget.c | 78 ++++-----
gtk/gtkwidget.h | 38 +++++
gtk/gtkwin32embedwidget.c | 2 +-
gtk/gtkwindow.c | 55 +++----
gtk/gtkwrapbox.c | 183 ++++++++++-----------
modules/input/gtkimcontextxim.c | 2 +-
tests/gtkoffscreenbox.c | 12 +-
tests/testellipsise.c | 3 +-
tests/testgtk.c | 2 +-
77 files changed, 1059 insertions(+), 1301 deletions(-)
---
diff --git a/demos/gtk-demo/offscreen_window.c b/demos/gtk-demo/offscreen_window.c
index 96fd8d4..410f524 100644
--- a/demos/gtk-demo/offscreen_window.c
+++ b/demos/gtk-demo/offscreen_window.c
@@ -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;
diff --git a/demos/gtk-demo/offscreen_window2.c b/demos/gtk-demo/offscreen_window2.c
index b623e30..c03d8c0 100644
--- a/demos/gtk-demo/offscreen_window2.c
+++ b/demos/gtk-demo/offscreen_window2.c
@@ -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;
diff --git a/demos/testpixbuf-scale.c b/demos/testpixbuf-scale.c
index 85134c8..8051fa5 100644
--- a/demos/testpixbuf-scale.c
+++ b/demos/testpixbuf-scale.c
@@ -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 ();
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index 8ad9ab8..6ea7ccc 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -6300,16 +6300,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>
@@ -6320,7 +6318,7 @@ GTK_IS_SIZE_REQUEST
GTK_TYPE_SIZE_REQUEST
<SUBSECTION Private>
-gtk_size_request_get_type
+gtk_widget_get_type
</SECTION>
<SECTION>
diff --git a/docs/reference/gtk/tmpl/gtkcontainer.sgml b/docs/reference/gtk/tmpl/gtkcontainer.sgml
index ea2ff05..3d0f2fb 100644
--- a/docs/reference/gtk/tmpl/gtkcontainer.sgml
+++ b/docs/reference/gtk/tmpl/gtkcontainer.sgml
@@ -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.
diff --git a/docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml b/docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml
index 4f33819..f50edf4 100644
--- a/docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml
+++ b/docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml
@@ -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>
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 226dbd6..c808718 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -3043,13 +3043,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
diff --git a/gtk/gtkaccellabel.c b/gtk/gtkaccellabel.c
index ffaeed8..b436d83 100644
--- a/gtk/gtkaccellabel.c
+++ b/gtk/gtkaccellabel.c
@@ -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,7 +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),
+ gtk_widget_get_preferred_size ( (widget),
&requisition, NULL);
if (allocation.width >= requisition.width + ac_width)
diff --git a/gtk/gtkalignment.c b/gtk/gtkalignment.c
index 9a85a91..44adfa1 100644
--- a/gtk/gtkalignment.c
+++ b/gtk/gtkalignment.c
@@ -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);
}
/**
diff --git a/gtk/gtkarrow.c b/gtk/gtkarrow.c
index 2b93803..801afaf 100644
--- a/gtk/gtkarrow.c
+++ b/gtk/gtkarrow.c
@@ -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;
diff --git a/gtk/gtkaspectframe.c b/gtk/gtkaspectframe.c
index 8eac437..dbeedcd 100644
--- a/gtk/gtkaspectframe.c
+++ b/gtk/gtkaspectframe.c
@@ -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 /
diff --git a/gtk/gtkassistant.c b/gtk/gtkassistant.c
index 2a16a22..ef22b72 100644
--- a/gtk/gtkassistant.c
+++ b/gtk/gtkassistant.c
@@ -1157,12 +1157,12 @@ gtk_assistant_size_request (GtkWidget *widget,
GtkAssistantPage *page = list->data;
gint w, h;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (page->page),
+ 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),
+ gtk_widget_get_preferred_size ( (page->title),
&child_requisition, NULL);
w = child_requisition.width;
h = child_requisition.height;
@@ -1179,18 +1179,18 @@ gtk_assistant_size_request (GtkWidget *widget,
list = list->next;
}
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->sidebar_image),
+ 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),
+ 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),
+ 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;
diff --git a/gtk/gtkbbox.c b/gtk/gtkbbox.c
index a5ffe3e..297d823 100644
--- a/gtk/gtkbbox.c
+++ b/gtk/gtkbbox.c
@@ -451,7 +451,7 @@ gtk_button_box_child_requisition (GtkWidget *widget,
if (gtk_widget_get_visible (child))
{
nchildren += 1;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
+ 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))
{
diff --git a/gtk/gtkbin.c b/gtk/gtkbin.c
index b550009..2e2cde6 100644
--- a/gtk/gtkbin.c
+++ b/gtk/gtkbin.c
@@ -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 (widget)->get_height (widget, minimum_height, natural_height);
+ GTK_WIDGET_GET_CLASS (widget)->get_preferred_height (widget, minimum_height, natural_height);
}
diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c
index 2f931f3..e8310c5 100644
--- a/gtk/gtkbox.c
+++ b/gtk/gtkbox.c
@@ -171,30 +171,25 @@ static void gtk_box_get_child_property (GtkContainer *container,
static GType gtk_box_child_type (GtkContainer *container);
-static void gtk_box_size_request_init (GtkSizeRequestIface *iface);
-static GtkSizeRequestMode gtk_box_get_request_mode (GtkSizeRequest *widget);
-static void gtk_box_get_width (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_box_get_height (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_box_get_width_for_height (GtkSizeRequest *widget,
- gint height,
- gint *minimum_width,
- gint *natural_width);
-static void gtk_box_get_height_for_width (GtkSizeRequest *widget,
- gint width,
- gint *minimum_height,
- gint *natural_height);
-
-static GtkSizeRequestIface *parent_size_request_iface;
+static GtkSizeRequestMode gtk_box_get_request_mode (GtkWidget *widget);
+static void gtk_box_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_box_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_box_get_preferred_width_for_height (GtkWidget *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width);
+static void gtk_box_get_preferred_height_for_width (GtkWidget *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height);
G_DEFINE_TYPE_WITH_CODE (GtkBox, gtk_box, GTK_TYPE_CONTAINER,
G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE,
- NULL)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
- gtk_box_size_request_init));
+ NULL))
static void
gtk_box_class_init (GtkBoxClass *class)
@@ -206,7 +201,12 @@ gtk_box_class_init (GtkBoxClass *class)
object_class->set_property = gtk_box_set_property;
object_class->get_property = gtk_box_get_property;
- widget_class->size_allocate = gtk_box_size_allocate;
+ widget_class->size_allocate = gtk_box_size_allocate;
+ widget_class->get_request_mode = gtk_box_get_request_mode;
+ widget_class->get_preferred_width = gtk_box_get_preferred_width;
+ widget_class->get_preferred_height = gtk_box_get_preferred_height;
+ widget_class->get_preferred_height_for_width = gtk_box_get_preferred_height_for_width;
+ widget_class->get_preferred_width_for_height = gtk_box_get_preferred_width_for_height;
container_class->add = gtk_box_add;
container_class->remove = gtk_box_remove;
@@ -446,15 +446,15 @@ gtk_box_size_allocate (GtkWidget *widget,
continue;
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (child->widget),
- allocation->height,
- &sizes[i].minimum_size,
- &sizes[i].natural_size);
+ gtk_widget_get_preferred_width_for_height (child->widget,
+ allocation->height,
+ &sizes[i].minimum_size,
+ &sizes[i].natural_size);
else
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child->widget),
- allocation->width,
- &sizes[i].minimum_size,
- &sizes[i].natural_size);
+ gtk_widget_get_preferred_height_for_width (child->widget,
+ allocation->width,
+ &sizes[i].minimum_size,
+ &sizes[i].natural_size);
/* Assert the api is working properly */
@@ -802,20 +802,8 @@ gtk_box_pack (GtkBox *box,
}
-static void
-gtk_box_size_request_init (GtkSizeRequestIface *iface)
-{
- parent_size_request_iface = g_type_interface_peek_parent (iface);
-
- iface->get_request_mode = gtk_box_get_request_mode;
- iface->get_width = gtk_box_get_width;
- iface->get_height = gtk_box_get_height;
- iface->get_height_for_width = gtk_box_get_height_for_width;
- iface->get_width_for_height = gtk_box_get_width_for_height;
-}
-
static GtkSizeRequestMode
-gtk_box_get_request_mode (GtkSizeRequest *widget)
+gtk_box_get_request_mode (GtkWidget *widget)
{
GtkBoxPrivate *private = GTK_BOX (widget)->priv;
@@ -824,10 +812,10 @@ gtk_box_get_request_mode (GtkSizeRequest *widget)
}
static void
-gtk_box_get_size (GtkSizeRequest *widget,
- GtkOrientation orientation,
- gint *minimum_size,
- gint *natural_size)
+gtk_box_get_size (GtkWidget *widget,
+ GtkOrientation orientation,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkBox *box;
GtkBoxPrivate *private;
@@ -851,11 +839,11 @@ gtk_box_get_size (GtkSizeRequest *widget,
gint child_minimum, child_natural;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_size_request_get_width (GTK_SIZE_REQUEST (child->widget),
- &child_minimum, &child_natural);
+ gtk_widget_get_preferred_width (child->widget,
+ &child_minimum, &child_natural);
else
- gtk_size_request_get_height (GTK_SIZE_REQUEST (child->widget),
- &child_minimum, &child_natural);
+ gtk_widget_get_preferred_height (child->widget,
+ &child_minimum, &child_natural);
if (private->orientation == orientation)
{
@@ -905,17 +893,17 @@ gtk_box_get_size (GtkSizeRequest *widget,
}
static void
-gtk_box_get_width (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_box_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
gtk_box_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
}
static void
-gtk_box_get_height (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_box_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
gtk_box_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
}
@@ -954,13 +942,13 @@ gtk_box_compute_size_for_opposing_orientation (GtkBox *box,
if (gtk_widget_get_visible (child->widget))
{
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_size_request_get_width (GTK_SIZE_REQUEST (child->widget),
- &sizes[i].minimum_size,
- &sizes[i].natural_size);
+ gtk_widget_get_preferred_width (child->widget,
+ &sizes[i].minimum_size,
+ &sizes[i].natural_size);
else
- gtk_size_request_get_height (GTK_SIZE_REQUEST (child->widget),
- &sizes[i].minimum_size,
- &sizes[i].natural_size);
+ gtk_widget_get_preferred_height (child->widget,
+ &sizes[i].minimum_size,
+ &sizes[i].natural_size);
/* Assert the api is working properly */
if (sizes[i].minimum_size < 0)
@@ -1074,11 +1062,11 @@ gtk_box_compute_size_for_opposing_orientation (GtkBox *box,
/* Assign the child's position. */
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child->widget),
- child_size, &child_minimum, &child_natural);
+ gtk_widget_get_preferred_height_for_width (child->widget,
+ child_size, &child_minimum, &child_natural);
else /* (private->orientation == GTK_ORIENTATION_VERTICAL) */
- gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (child->widget),
- child_size, &child_minimum, &child_natural);
+ gtk_widget_get_preferred_width_for_height (child->widget,
+ child_size, &child_minimum, &child_natural);
computed_minimum = MAX (computed_minimum, child_minimum);
@@ -1115,11 +1103,11 @@ gtk_box_compute_size_for_orientation (GtkBox *box,
{
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (child->widget),
- avail_size, &child_size, &child_natural);
+ gtk_widget_get_preferred_width_for_height (child->widget,
+ avail_size, &child_size, &child_natural);
else
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child->widget),
- avail_size, &child_size, &child_natural);
+ gtk_widget_get_preferred_height_for_width (child->widget,
+ avail_size, &child_size, &child_natural);
child_size += child->padding * 2;
@@ -1156,13 +1144,13 @@ gtk_box_compute_size_for_orientation (GtkBox *box,
}
static void
-gtk_box_get_width_for_height (GtkSizeRequest *widget,
- gint height,
- gint *minimum_width,
- gint *natural_width)
+gtk_box_get_preferred_width_for_height (GtkWidget *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width)
{
GtkBox *box = GTK_BOX (widget);
- GtkBoxPrivate *private = box->priv;
+ GtkBoxPrivate *private = box->priv;
if (private->orientation == GTK_ORIENTATION_VERTICAL)
gtk_box_compute_size_for_opposing_orientation (box, height, minimum_width, natural_width);
@@ -1171,13 +1159,13 @@ gtk_box_get_width_for_height (GtkSizeRequest *widget,
}
static void
-gtk_box_get_height_for_width (GtkSizeRequest *widget,
- gint width,
- gint *minimum_height,
- gint *natural_height)
+gtk_box_get_preferred_height_for_width (GtkWidget *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height)
{
GtkBox *box = GTK_BOX (widget);
- GtkBoxPrivate *private = box->priv;
+ GtkBoxPrivate *private = box->priv;
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
gtk_box_compute_size_for_opposing_orientation (box, width, minimum_height, natural_height);
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index 6c18456..e36e8e8 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -172,11 +172,10 @@ static void gtk_button_set_related_action (GtkButton *button,
static void gtk_button_set_use_action_appearance (GtkButton *button,
gboolean use_appearance);
-static void gtk_button_size_request_init (GtkSizeRequestIface *iface);
-static void gtk_button_get_width (GtkSizeRequest *widget,
+static void gtk_button_get_preferred_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
-static void gtk_button_get_height (GtkSizeRequest *widget,
+static void gtk_button_get_preferred_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
@@ -184,9 +183,7 @@ static guint button_signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE_WITH_CODE (GtkButton, gtk_button, GTK_TYPE_BIN,
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE,
- gtk_button_activatable_interface_init)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
- gtk_button_size_request_init))
+ gtk_button_activatable_interface_init))
static void
gtk_button_class_init (GtkButtonClass *klass)
@@ -208,6 +205,8 @@ gtk_button_class_init (GtkButtonClass *klass)
object_class->destroy = gtk_button_destroy;
+ widget_class->get_preferred_width = gtk_button_get_preferred_width;
+ widget_class->get_preferred_height = gtk_button_get_preferred_height;
widget_class->screen_changed = gtk_button_screen_changed;
widget_class->realize = gtk_button_realize;
widget_class->unrealize = gtk_button_unrealize;
@@ -1891,14 +1890,7 @@ gtk_button_finish_activate (GtkButton *button,
static void
-gtk_button_size_request_init (GtkSizeRequestIface *iface)
-{
- iface->get_width = gtk_button_get_width;
- iface->get_height = gtk_button_get_height;
-}
-
-static void
-gtk_button_get_size (GtkSizeRequest *widget,
+gtk_button_get_size (GtkWidget *widget,
GtkOrientation orientation,
gint *minimum_size,
gint *natural_size)
@@ -1946,11 +1938,9 @@ gtk_button_get_size (GtkSizeRequest *widget,
gint child_min, child_nat;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_size_request_get_width (GTK_SIZE_REQUEST (child),
- &child_min, &child_nat);
+ gtk_widget_get_preferred_width (child, &child_min, &child_nat);
else
- gtk_size_request_get_height (GTK_SIZE_REQUEST (child),
- &child_min, &child_nat);
+ gtk_widget_get_preferred_height (child, &child_min, &child_nat);
minimum += child_min;
natural += child_nat;
@@ -1964,17 +1954,17 @@ gtk_button_get_size (GtkSizeRequest *widget,
}
static void
-gtk_button_get_width (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_button_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
gtk_button_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
}
static void
-gtk_button_get_height (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_button_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
gtk_button_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
}
diff --git a/gtk/gtkcellrendereraccel.c b/gtk/gtkcellrendereraccel.c
index 45c1793..e12648d 100644
--- a/gtk/gtkcellrendereraccel.c
+++ b/gtk/gtkcellrendereraccel.c
@@ -417,7 +417,7 @@ gtk_cell_renderer_accel_get_size (GtkCellRenderer *cell,
if (priv->sizing_label == NULL)
priv->sizing_label = gtk_label_new (_("New accelerator..."));
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->sizing_label),
+ gtk_widget_get_preferred_size ( (priv->sizing_label),
&requisition, NULL);
GTK_CELL_RENDERER_CLASS (gtk_cell_renderer_accel_parent_class)->get_size (cell, widget, cell_area,
diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c
index 756b055..674ae1b 100644
--- a/gtk/gtkcellrenderertext.c
+++ b/gtk/gtkcellrenderertext.c
@@ -1920,7 +1920,7 @@ gtk_cell_renderer_text_start_editing (GtkCellRenderer *cell,
gtk_editable_select_region (GTK_EDITABLE (priv->entry), 0, -1);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->entry),
+ gtk_widget_get_preferred_size ( (priv->entry),
&requisition, NULL);
if (requisition.height < cell_area->height)
{
diff --git a/gtk/gtkcellview.c b/gtk/gtkcellview.c
index 49905ad..fbe1a5c 100644
--- a/gtk/gtkcellview.c
+++ b/gtk/gtkcellview.c
@@ -24,9 +24,9 @@
#include "gtkintl.h"
#include "gtkcellrenderertext.h"
#include "gtkcellrendererpixbuf.h"
-#include "gtksizerequest.h"
#include "gtkcellsizerequest.h"
#include "gtkprivate.h"
+#include "gtksizerequest.h"
#include <gobject/gmarshal.h>
#include "gtkbuildable.h"
@@ -121,18 +121,17 @@ static void gtk_cell_view_buildable_custom_tag_end (GtkBuildable
const gchar *tagname,
gpointer *data);
-static void gtk_cell_view_size_request_init (GtkSizeRequestIface *iface);
-static void gtk_cell_view_get_width (GtkSizeRequest *widget,
+static void gtk_cell_view_get_preferred_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
-static void gtk_cell_view_get_height (GtkSizeRequest *widget,
+static void gtk_cell_view_get_preferred_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
-static void gtk_cell_view_get_width_for_height (GtkSizeRequest *widget,
+static void gtk_cell_view_get_preferred_width_for_height (GtkWidget *widget,
gint avail_size,
gint *minimum_size,
gint *natural_size);
-static void gtk_cell_view_get_height_for_width (GtkSizeRequest *widget,
+static void gtk_cell_view_get_preferred_height_for_width (GtkWidget *widget,
gint avail_size,
gint *minimum_size,
gint *natural_size);
@@ -153,9 +152,7 @@ G_DEFINE_TYPE_WITH_CODE (GtkCellView, gtk_cell_view, GTK_TYPE_WIDGET,
G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_LAYOUT,
gtk_cell_view_cell_layout_init)
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
- gtk_cell_view_buildable_init)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
- gtk_cell_view_size_request_init))
+ gtk_cell_view_buildable_init))
static void
@@ -168,8 +165,12 @@ gtk_cell_view_class_init (GtkCellViewClass *klass)
gobject_class->set_property = gtk_cell_view_set_property;
gobject_class->finalize = gtk_cell_view_finalize;
- widget_class->draw = gtk_cell_view_draw;
- widget_class->size_allocate = gtk_cell_view_size_allocate;
+ widget_class->draw = gtk_cell_view_draw;
+ widget_class->size_allocate = gtk_cell_view_size_allocate;
+ widget_class->get_preferred_width = gtk_cell_view_get_preferred_width;
+ widget_class->get_preferred_height = gtk_cell_view_get_preferred_height;
+ widget_class->get_preferred_width_for_height = gtk_cell_view_get_preferred_width_for_height;
+ widget_class->get_preferred_height_for_width = gtk_cell_view_get_preferred_height_for_width;
/* properties */
g_object_class_install_property (gobject_class,
@@ -1051,13 +1052,13 @@ gtk_cell_view_get_desired_width_of_row (GtkCellView *cell_view,
cell_view->priv->displayed_row =
gtk_tree_row_reference_new (cell_view->priv->model, path);
- gtk_cell_view_get_width (GTK_SIZE_REQUEST (cell_view), minimum_size, natural_size);
+ gtk_cell_view_get_preferred_width (GTK_WIDGET (cell_view), minimum_size, natural_size);
gtk_tree_row_reference_free (cell_view->priv->displayed_row);
cell_view->priv->displayed_row = tmp;
/* Restore active size (this will restore the cellrenderer info->width/requested_width's) */
- gtk_cell_view_get_width (GTK_SIZE_REQUEST (cell_view), NULL, NULL);
+ gtk_cell_view_get_preferred_width (GTK_WIDGET (cell_view), NULL, NULL);
}
@@ -1093,13 +1094,13 @@ gtk_cell_view_get_desired_height_for_width_of_row (GtkCellView *cell_view,
gtk_tree_row_reference_new (cell_view->priv->model, path);
/* Then get the collective height_for_width based on the cached values */
- gtk_cell_view_get_height_for_width (GTK_SIZE_REQUEST (cell_view), avail_size, minimum_size, natural_size);
+ gtk_cell_view_get_preferred_height_for_width (GTK_WIDGET (cell_view), avail_size, minimum_size, natural_size);
gtk_tree_row_reference_free (cell_view->priv->displayed_row);
cell_view->priv->displayed_row = tmp;
/* Restore active size (this will restore the cellrenderer info->width/requested_width's) */
- gtk_cell_view_get_width (GTK_SIZE_REQUEST (cell_view), NULL, NULL);
+ gtk_cell_view_get_preferred_width (GTK_WIDGET (cell_view), NULL, NULL);
}
/**
@@ -1192,18 +1193,9 @@ gtk_cell_view_buildable_custom_tag_end (GtkBuildable *buildable,
}
static void
-gtk_cell_view_size_request_init (GtkSizeRequestIface *iface)
-{
- iface->get_width = gtk_cell_view_get_width;
- iface->get_height = gtk_cell_view_get_height;
- iface->get_width_for_height = gtk_cell_view_get_width_for_height;
- iface->get_height_for_width = gtk_cell_view_get_height_for_width;
-}
-
-static void
-gtk_cell_view_get_width (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_cell_view_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
GList *list;
gint cell_min, cell_nat;
@@ -1230,7 +1222,7 @@ gtk_cell_view_get_width (GtkSizeRequest *widget,
}
gtk_cell_size_request_get_width (GTK_CELL_SIZE_REQUEST (info->cell),
- GTK_WIDGET (cellview), &cell_min, &cell_nat);
+ GTK_WIDGET (cellview), &cell_min, &cell_nat);
info->requested_width = cell_min;
info->natural_width = cell_nat;
@@ -1250,34 +1242,34 @@ gtk_cell_view_get_width (GtkSizeRequest *widget,
}
static void
-gtk_cell_view_get_height (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_cell_view_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
gint minimum_width;
/* CellViews only need to respond to height-for-width mode (cellview is pretty much
* an implementation detail of GtkComboBox) */
- gtk_cell_view_get_width (widget, &minimum_width, NULL);
- gtk_cell_view_get_height_for_width (widget, minimum_width, minimum_size, natural_size);
+ gtk_cell_view_get_preferred_width (widget, &minimum_width, NULL);
+ gtk_cell_view_get_preferred_height_for_width (widget, minimum_width, minimum_size, natural_size);
}
static void
-gtk_cell_view_get_width_for_height (GtkSizeRequest *widget,
- gint for_size,
- gint *minimum_size,
- gint *natural_size)
+gtk_cell_view_get_preferred_width_for_height (GtkWidget *widget,
+ gint for_size,
+ gint *minimum_size,
+ gint *natural_size)
{
/* CellViews only need to respond to height-for-width mode (cellview is pretty much
* an implementation detail of GtkComboBox) */
- gtk_cell_view_get_width (widget, minimum_size, natural_size);
+ gtk_cell_view_get_preferred_width (widget, minimum_size, natural_size);
}
static void
-gtk_cell_view_get_height_for_width (GtkSizeRequest *widget,
- gint for_size,
- gint *minimum_size,
- gint *natural_size)
+gtk_cell_view_get_preferred_height_for_width (GtkWidget *widget,
+ gint for_size,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkCellView *cellview = GTK_CELL_VIEW (widget);
GList *list;
@@ -1306,9 +1298,9 @@ gtk_cell_view_get_height_for_width (GtkSizeRequest *widget,
GtkRequestedSize requested;
gtk_cell_size_request_get_width (GTK_CELL_SIZE_REQUEST (info->cell),
- GTK_WIDGET (cellview),
- &requested.minimum_size,
- &requested.natural_size);
+ GTK_WIDGET (cellview),
+ &requested.minimum_size,
+ &requested.natural_size);
requested.data = info;
g_array_append_val (array, requested);
@@ -1362,8 +1354,8 @@ gtk_cell_view_get_height_for_width (GtkSizeRequest *widget,
/* Get the height for the real width of this cell */
gtk_cell_size_request_get_height_for_width (GTK_CELL_SIZE_REQUEST (info->cell),
- GTK_WIDGET (widget),
- cell_width, &cell_minimum, &cell_natural);
+ GTK_WIDGET (widget),
+ cell_width, &cell_minimum, &cell_natural);
minimum = MAX (minimum, cell_minimum);
natural = MAX (natural, cell_natural);
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c
index 1fdaa04..6fcf5f0 100644
--- a/gtk/gtkcheckbutton.c
+++ b/gtk/gtkcheckbutton.c
@@ -29,7 +29,6 @@
#include "gtkcheckbutton.h"
#include "gtklabel.h"
-#include "gtksizerequest.h"
#include "gtkprivate.h"
#include "gtkintl.h"
@@ -230,7 +229,7 @@ gtk_check_button_size_request (GtkWidget *widget,
{
GtkRequisition child_requisition;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
+ gtk_widget_get_preferred_size ( (child),
&child_requisition, NULL);
requisition->width += child_requisition.width + indicator_spacing;
@@ -286,8 +285,7 @@ gtk_check_button_size_allocate (GtkWidget *widget,
GtkRequisition child_requisition;
guint border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (child, &child_requisition, NULL);
child_allocation.width = MIN (child_requisition.width,
allocation->width -
diff --git a/gtk/gtkcolorsel.c b/gtk/gtkcolorsel.c
index 64aae7a..d9b55de 100644
--- a/gtk/gtkcolorsel.c
+++ b/gtk/gtkcolorsel.c
@@ -1352,8 +1352,8 @@ popup_position_func (GtkMenu *menu,
gdk_window_get_origin (gtk_widget_get_window (widget),
&root_x, &root_y);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (menu),
- &req, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu),
+ &req, NULL);
gtk_widget_get_allocation (widget, &allocation);
/* Put corner of menu centered on color cell */
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index 2add2d9..13af274 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -38,7 +38,6 @@
#include "gtktreeselection.h"
#include "gtkvseparator.h"
#include "gtkwindow.h"
-#include "gtksizerequest.h"
#include "gtkprivate.h"
#include <gdk/gdkkeysyms.h>
@@ -467,18 +466,17 @@ static void gtk_combo_box_buildable_custom_tag_end (GtkBuildable *bui
static void gtk_combo_box_start_editing (GtkCellEditable *cell_editable,
GdkEvent *event);
-static void gtk_combo_box_size_request_init (GtkSizeRequestIface *iface);
-static void gtk_combo_box_get_width (GtkSizeRequest *widget,
+static void gtk_combo_box_get_preferred_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
-static void gtk_combo_box_get_height (GtkSizeRequest *widget,
+static void gtk_combo_box_get_preferred_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
-static void gtk_combo_box_get_width_for_height (GtkSizeRequest *widget,
+static void gtk_combo_box_get_preferred_width_for_height (GtkWidget *widget,
gint avail_size,
gint *minimum_size,
gint *natural_size);
-static void gtk_combo_box_get_height_for_width (GtkSizeRequest *widget,
+static void gtk_combo_box_get_preferred_height_for_width (GtkWidget *widget,
gint avail_size,
gint *minimum_size,
gint *natural_size);
@@ -490,9 +488,7 @@ G_DEFINE_TYPE_WITH_CODE (GtkComboBox, gtk_combo_box, GTK_TYPE_BIN,
G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_EDITABLE,
gtk_combo_box_cell_editable_init)
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
- gtk_combo_box_buildable_init)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
- gtk_combo_box_size_request_init))
+ gtk_combo_box_buildable_init))
/* common */
@@ -520,6 +516,10 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
widget_class->grab_focus = gtk_combo_box_grab_focus;
widget_class->style_set = gtk_combo_box_style_set;
widget_class->state_changed = gtk_combo_box_state_changed;
+ widget_class->get_preferred_width = gtk_combo_box_get_preferred_width;
+ widget_class->get_preferred_height = gtk_combo_box_get_preferred_height;
+ widget_class->get_preferred_height_for_width = gtk_combo_box_get_preferred_height_for_width;
+ widget_class->get_preferred_width_for_height = gtk_combo_box_get_preferred_width_for_height;
gtk_object_class = (GtkObjectClass *)klass;
gtk_object_class->destroy = gtk_combo_box_destroy;
@@ -1529,8 +1529,8 @@ gtk_combo_box_menu_position_below (GtkMenu *menu,
if (GTK_SHADOW_NONE != combo_box->priv->shadow_type)
sx -= gtk_widget_get_style (GTK_WIDGET (combo_box))->xthickness;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (menu),
- &req, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu),
+ &req, NULL);
if (gtk_widget_get_direction (GTK_WIDGET (combo_box)) == GTK_TEXT_DIR_LTR)
*x = sx;
@@ -1589,7 +1589,7 @@ gtk_combo_box_menu_position_over (GtkMenu *menu,
menu_xpos = allocation.x;
menu_ypos = allocation.y + allocation.height / 2 - 2;
- gtk_size_request_get_width (GTK_SIZE_REQUEST (menu), &menu_width, NULL);
+ gtk_widget_get_preferred_width (GTK_WIDGET (menu), &menu_width, NULL);
if (active != NULL)
{
@@ -1706,7 +1706,7 @@ gtk_combo_box_list_position (GtkComboBox *combo_box,
hpolicy = vpolicy = GTK_POLICY_NEVER;
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
hpolicy, vpolicy);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->scrolled_window),
+ gtk_widget_get_preferred_size ( (priv->scrolled_window),
&popup_req, NULL);
if (popup_req.width > *width)
@@ -1714,7 +1714,7 @@ gtk_combo_box_list_position (GtkComboBox *combo_box,
hpolicy = GTK_POLICY_ALWAYS;
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
hpolicy, vpolicy);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->scrolled_window),
+ gtk_widget_get_preferred_size ( (priv->scrolled_window),
&popup_req, NULL);
}
@@ -1891,7 +1891,7 @@ gtk_combo_box_menu_popup (GtkComboBox *combo_box,
gtk_widget_get_allocation (GTK_WIDGET (combo_box), &allocation);
width = allocation.width;
gtk_widget_set_size_request (priv->popup_widget, -1, -1);
- gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->popup_widget), &min_width, NULL);
+ gtk_widget_get_preferred_width (priv->popup_widget, &min_width, NULL);
gtk_widget_set_size_request (priv->popup_widget,
MAX (width, min_width), -1);
@@ -2171,7 +2171,7 @@ gtk_combo_box_update_requested_width (GtkComboBox *combo_box,
}
#define GTK_COMBO_BOX_SIZE_ALLOCATE_BUTTON \
- gtk_size_request_get_size (GTK_SIZE_REQUEST (combo_box->priv->button), \
+ gtk_widget_get_preferred_size ( (combo_box->priv->button), \
&req, NULL); \
\
if (is_rtl) \
@@ -2258,7 +2258,7 @@ gtk_combo_box_size_allocate (GtkWidget *widget,
/* handle the children */
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->arrow),
+ gtk_widget_get_preferred_size ( (priv->arrow),
&req, NULL);
child.width = req.width;
if (!is_rtl)
@@ -2268,7 +2268,7 @@ gtk_combo_box_size_allocate (GtkWidget *widget,
gtk_widget_size_allocate (priv->arrow, &child);
if (is_rtl)
child.x += req.width;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->separator),
+ gtk_widget_get_preferred_size ( (priv->separator),
&req, NULL);
child.width = req.width;
if (!is_rtl)
@@ -2303,7 +2303,7 @@ gtk_combo_box_size_allocate (GtkWidget *widget,
gtk_widget_get_allocation (GTK_WIDGET (combo_box), &combo_box_allocation);
width = combo_box_allocation.width;
gtk_widget_set_size_request (priv->popup_widget, -1, -1);
- gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->popup_widget), &min_width, NULL);
+ gtk_widget_get_preferred_width (priv->popup_widget, &min_width, NULL);
gtk_widget_set_size_request (priv->popup_widget,
MAX (width, min_width), -1);
}
@@ -2912,7 +2912,7 @@ gtk_cell_view_menu_item_new (GtkComboBox *combo_box,
gtk_tree_path_free (path);
gtk_combo_box_sync_cells (combo_box, GTK_CELL_LAYOUT (cell_view));
- gtk_size_request_get_size (GTK_SIZE_REQUEST (cell_view),
+ gtk_widget_get_preferred_size ( (cell_view),
&req, NULL);
gtk_widget_show (cell_view);
@@ -5954,15 +5954,6 @@ gtk_combo_box_buildable_custom_tag_end (GtkBuildable *buildable,
static void
-gtk_combo_box_size_request_init (GtkSizeRequestIface *iface)
-{
- iface->get_width = gtk_combo_box_get_width;
- iface->get_height = gtk_combo_box_get_height;
- iface->get_height_for_width = gtk_combo_box_get_height_for_width;
- iface->get_width_for_height = gtk_combo_box_get_width_for_height;
-}
-
-static void
gtk_combo_box_remeasure (GtkComboBox *combo_box)
{
GtkComboBoxPrivate *priv = combo_box->priv;
@@ -6010,8 +6001,8 @@ gtk_combo_box_measure_height_for_width (GtkComboBox *combo_box,
child = gtk_bin_get_child (GTK_BIN (combo_box));
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child), avail_width,
- &child_min, &child_nat);
+ gtk_widget_get_preferred_height_for_width (child, avail_width,
+ &child_min, &child_nat);
if (!priv->model ||
!gtk_tree_model_get_iter_first (priv->model, &iter))
@@ -6047,9 +6038,9 @@ gtk_combo_box_measure_height_for_width (GtkComboBox *combo_box,
static void
-gtk_combo_box_get_width (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_combo_box_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
GtkComboBoxPrivate *priv = combo_box->priv;
@@ -6066,7 +6057,7 @@ gtk_combo_box_get_width (GtkSizeRequest *widget,
child = gtk_bin_get_child (GTK_BIN (widget));
/* common */
- gtk_size_request_get_width (GTK_SIZE_REQUEST (child), &child_min, &child_nat);
+ gtk_widget_get_preferred_width (child, &child_min, &child_nat);
gtk_combo_box_remeasure (combo_box);
child_min = MAX (child_min, priv->minimum_width);
@@ -6102,8 +6093,8 @@ gtk_combo_box_get_width (GtkSizeRequest *widget,
border_width = gtk_container_get_border_width (GTK_CONTAINER (combo_box));
xthickness = gtk_widget_get_style (priv->button)->xthickness;
- gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->separator), &sep_width, NULL);
- gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->arrow), &arrow_width, NULL);
+ gtk_widget_get_preferred_width (priv->separator, &sep_width, NULL);
+ gtk_widget_get_preferred_width (priv->arrow, &arrow_width, NULL);
xpad = 2*(border_width + xthickness + focus_width + focus_pad);
@@ -6114,8 +6105,8 @@ gtk_combo_box_get_width (GtkSizeRequest *widget,
{
gint but_width, but_nat_width;
- gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->button),
- &but_width, &but_nat_width);
+ gtk_widget_get_preferred_width (priv->button,
+ &but_width, &but_nat_width);
minimum_width = child_min + but_width;
natural_width = child_nat + but_nat_width;
@@ -6146,8 +6137,8 @@ gtk_combo_box_get_width (GtkSizeRequest *widget,
}
/* the button */
- gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->button),
- &button_width, &button_nat_width);
+ gtk_widget_get_preferred_width (priv->button,
+ &button_width, &button_nat_width);
minimum_width += button_width;
natural_width += button_nat_width;
@@ -6169,35 +6160,35 @@ gtk_combo_box_get_width (GtkSizeRequest *widget,
}
static void
-gtk_combo_box_get_height (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_combo_box_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
gint min_width;
/* Combo box is height-for-width only
* (so we always just reserve enough height for the minimum width) */
- GTK_SIZE_REQUEST_GET_IFACE (widget)->get_width (widget, &min_width, NULL);
- GTK_SIZE_REQUEST_GET_IFACE (widget)->get_height_for_width (widget, min_width, minimum_size, natural_size);
+ GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, &min_width, NULL);
+ GTK_WIDGET_GET_CLASS (widget)->get_preferred_height_for_width (widget, min_width, minimum_size, natural_size);
}
static void
-gtk_combo_box_get_width_for_height (GtkSizeRequest *widget,
- gint avail_size,
- gint *minimum_size,
- gint *natural_size)
+gtk_combo_box_get_preferred_width_for_height (GtkWidget *widget,
+ gint avail_size,
+ gint *minimum_size,
+ gint *natural_size)
{
/* Combo box is height-for-width only
* (so we assume we always reserved enough height for the minimum width) */
- GTK_SIZE_REQUEST_GET_IFACE (widget)->get_width (widget, minimum_size, natural_size);
+ GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, minimum_size, natural_size);
}
static void
-gtk_combo_box_get_height_for_width (GtkSizeRequest *widget,
- gint avail_size,
- gint *minimum_size,
- gint *natural_size)
+gtk_combo_box_get_preferred_height_for_width (GtkWidget *widget,
+ gint avail_size,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
GtkComboBoxPrivate *priv = combo_box->priv;
@@ -6232,12 +6223,12 @@ gtk_combo_box_get_height_for_width (GtkSizeRequest *widget,
xthickness = button_style->xthickness;
ythickness = button_style->ythickness;
- gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->separator), &sep_width, NULL);
- gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->arrow), &arrow_width, NULL);
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (priv->separator),
- sep_width, &sep_height, NULL);
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (priv->arrow),
- arrow_width, &arrow_height, NULL);
+ gtk_widget_get_preferred_width (priv->separator, &sep_width, NULL);
+ gtk_widget_get_preferred_width (priv->arrow, &arrow_width, NULL);
+ gtk_widget_get_preferred_height_for_width (priv->separator,
+ sep_width, &sep_height, NULL);
+ gtk_widget_get_preferred_height_for_width (priv->arrow,
+ arrow_width, &arrow_height, NULL);
xpad = 2*(border_width + xthickness + focus_width + focus_pad);
ypad = 2*(border_width + ythickness + focus_width + focus_pad);
@@ -6258,9 +6249,9 @@ gtk_combo_box_get_height_for_width (GtkSizeRequest *widget,
/* there is a custom child widget inside (no priv->cell_view) */
gint but_width, but_height;
- gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->button), &but_width, NULL);
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (priv->button),
- but_width, &but_height, NULL);
+ gtk_widget_get_preferred_width (priv->button, &but_width, NULL);
+ gtk_widget_get_preferred_height_for_width (priv->button,
+ but_width, &but_height, NULL);
size -= but_width;
@@ -6276,9 +6267,9 @@ gtk_combo_box_get_height_for_width (GtkSizeRequest *widget,
gint but_width, but_height;
gint xpad = 0, ypad = 0;
- gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->button), &but_width, NULL);
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (priv->button),
- but_width, &but_height, NULL);
+ gtk_widget_get_preferred_width (priv->button, &but_width, NULL);
+ gtk_widget_get_preferred_height_for_width (priv->button,
+ but_width, &but_height, NULL);
if (priv->cell_view_frame && priv->has_frame)
{
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index 7cecb10..43074fc 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -1486,7 +1486,7 @@ gtk_container_real_check_resize (GtkContainer *container)
GtkAllocation allocation;
GtkRequisition requisition;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget),
+ gtk_widget_get_preferred_size ( (widget),
&requisition, NULL);
gtk_widget_get_allocation (widget, &allocation);
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 27442bc..6214dee 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -53,7 +53,6 @@
#include "gtkseparatormenuitem.h"
#include "gtkselection.h"
#include "gtksettings.h"
-#include "gtksizerequest.h"
#include "gtkspinbutton.h"
#include "gtkstock.h"
#include "gtktextutil.h"
@@ -2986,8 +2985,7 @@ gtk_entry_get_text_area_size (GtkEntry *entry,
gint frame_height;
gint xborder, yborder;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget),
- &requisition, NULL);
+ gtk_widget_get_preferred_size (widget, &requisition, NULL);
gtk_widget_get_allocation (widget, &allocation);
_gtk_entry_get_borders (entry, &xborder, &yborder);
@@ -3041,8 +3039,7 @@ get_widget_window_size (GtkEntry *entry,
GtkRequisition requisition;
GtkWidget *widget = GTK_WIDGET (entry);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget),
- &requisition, NULL);
+ gtk_widget_get_preferred_size (widget, &requisition, NULL);
gtk_widget_get_allocation (widget, &allocation);
if (x)
@@ -8501,7 +8498,7 @@ popup_position_func (GtkMenu *menu,
gtk_menu_set_monitor (menu, monitor_num);
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (entry->popup_menu),
+ gtk_widget_get_preferred_size ( (entry->popup_menu),
&menu_req, NULL);
height = gdk_window_get_height (entry->text_area);
gtk_entry_get_cursor_locations (entry, CURSOR_STANDARD, &strong_x, NULL);
diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c
index 0e48e85..6910a83 100644
--- a/gtk/gtkentrycompletion.c
+++ b/gtk/gtkentrycompletion.c
@@ -1453,9 +1453,9 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
else
gtk_widget_hide (completion->priv->action_view);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (completion->priv->popup_window),
+ gtk_widget_get_preferred_size ( (completion->priv->popup_window),
&popup_req, NULL);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (completion->priv->entry),
+ gtk_widget_get_preferred_size ( (completion->priv->entry),
&entry_req, NULL);
if (x < monitor.x)
diff --git a/gtk/gtkeventbox.c b/gtk/gtkeventbox.c
index 081f698..fe8f913 100644
--- a/gtk/gtkeventbox.c
+++ b/gtk/gtkeventbox.c
@@ -501,7 +501,7 @@ gtk_event_box_size_request (GtkWidget *widget,
{
GtkRequisition child_requisition;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
+ gtk_widget_get_preferred_size ( (child),
&child_requisition, NULL);
requisition->width += child_requisition.width;
diff --git a/gtk/gtkexpander.c b/gtk/gtkexpander.c
index 4e38c87..a42fcef 100644
--- a/gtk/gtkexpander.c
+++ b/gtk/gtkexpander.c
@@ -27,7 +27,6 @@
#include "gtklabel.h"
#include "gtkbuildable.h"
-#include "gtksizerequest.h"
#include "gtkcontainer.h"
#include "gtkmarshalers.h"
#include "gtkmain.h"
@@ -134,28 +133,25 @@ static void gtk_expander_buildable_add_child (GtkBuildable *buildable,
const gchar *type);
-/* GtkSizeRequest */
-static void gtk_expander_size_request_init (GtkSizeRequestIface *iface);
-static void gtk_expander_get_width (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_expander_get_height (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_expander_get_height_for_width (GtkSizeRequest *layout,
- gint width,
- gint *minimum_height,
- gint *natural_height);
-static void gtk_expander_get_width_for_height (GtkSizeRequest *layout,
- gint width,
- gint *minimum_height,
- gint *natural_height);
+/* GtkWidget */
+static void gtk_expander_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_expander_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_expander_get_preferred_height_for_width (GtkWidget *layout,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height);
+static void gtk_expander_get_preferred_width_for_height (GtkWidget *layout,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height);
G_DEFINE_TYPE_WITH_CODE (GtkExpander, gtk_expander, GTK_TYPE_BIN,
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
- gtk_expander_buildable_init)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
- gtk_expander_size_request_init))
+ gtk_expander_buildable_init))
static void
gtk_expander_class_init (GtkExpanderClass *klass)
@@ -190,6 +186,10 @@ gtk_expander_class_init (GtkExpanderClass *klass)
widget_class->state_changed = gtk_expander_state_changed;
widget_class->drag_motion = gtk_expander_drag_motion;
widget_class->drag_leave = gtk_expander_drag_leave;
+ widget_class->get_preferred_width = gtk_expander_get_preferred_width;
+ widget_class->get_preferred_height = gtk_expander_get_preferred_height;
+ widget_class->get_preferred_height_for_width = gtk_expander_get_preferred_height_for_width;
+ widget_class->get_preferred_width_for_height = gtk_expander_get_preferred_width_for_height;
container_class->add = gtk_expander_add;
container_class->remove = gtk_expander_remove;
@@ -451,8 +451,8 @@ gtk_expander_realize (GtkWidget *widget)
{
GtkRequisition label_requisition;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->label_widget),
- &label_requisition, NULL);
+ gtk_widget_get_preferred_size (priv->label_widget,
+ &label_requisition, NULL);
label_height = label_requisition.height;
}
else
@@ -620,7 +620,7 @@ gtk_expander_size_allocate (GtkWidget *widget,
gint natural_label_width;
gboolean ltr;
- gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->label_widget), NULL, &natural_label_width);
+ gtk_widget_get_preferred_width (priv->label_widget, NULL, &natural_label_width);
if (priv->label_fill)
label_allocation.width = allocation->width - label_xpad;
@@ -630,8 +630,8 @@ gtk_expander_size_allocate (GtkWidget *widget,
/* We distribute the minimum height to the label widget and prioritize
* the child widget giving it the remaining height */
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (priv->label_widget),
- label_allocation.width, &label_height, NULL);
+ gtk_widget_get_preferred_height_for_width (priv->label_widget,
+ label_allocation.width, &label_height, NULL);
ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL;
@@ -1272,19 +1272,10 @@ gtk_expander_activate (GtkExpander *expander)
}
-static void
-gtk_expander_size_request_init (GtkSizeRequestIface *iface)
-{
- iface->get_width = gtk_expander_get_width;
- iface->get_height = gtk_expander_get_height;
- iface->get_height_for_width = gtk_expander_get_height_for_width;
- iface->get_width_for_height = gtk_expander_get_width_for_height;
-}
-
static void
-gtk_expander_get_width (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_expander_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkExpander *expander;
GtkWidget *child;
@@ -1318,8 +1309,8 @@ gtk_expander_get_width (GtkSizeRequest *widget,
{
gint label_min, label_nat;
- gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->label_widget),
- &label_min, &label_nat);
+ gtk_widget_get_preferred_width (priv->label_widget,
+ &label_min, &label_nat);
*minimum_size += label_min;
*natural_size += label_nat;
@@ -1329,8 +1320,8 @@ gtk_expander_get_width (GtkSizeRequest *widget,
{
gint child_min, child_nat;
- gtk_size_request_get_width (GTK_SIZE_REQUEST (child),
- &child_min, &child_nat);
+ gtk_widget_get_preferred_width (child,
+ &child_min, &child_nat);
*minimum_size = MAX (*minimum_size, child_min);
*natural_size = MAX (*natural_size, child_nat);
@@ -1342,9 +1333,9 @@ gtk_expander_get_width (GtkSizeRequest *widget,
}
static void
-gtk_expander_get_height (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_expander_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkExpander *expander;
GtkWidget *child;
@@ -1378,8 +1369,8 @@ gtk_expander_get_height (GtkSizeRequest *widget,
{
gint label_min, label_nat;
- gtk_size_request_get_height (GTK_SIZE_REQUEST (priv->label_widget),
- &label_min, &label_nat);
+ gtk_widget_get_preferred_height (priv->label_widget,
+ &label_min, &label_nat);
*minimum_size += label_min;
*natural_size += label_nat;
@@ -1399,8 +1390,8 @@ gtk_expander_get_height (GtkSizeRequest *widget,
{
gint child_min, child_nat;
- gtk_size_request_get_height (GTK_SIZE_REQUEST (child),
- &child_min, &child_nat);
+ gtk_widget_get_preferred_height (child,
+ &child_min, &child_nat);
*minimum_size += child_min + priv->spacing;
*natural_size += child_nat + priv->spacing;
@@ -1412,10 +1403,10 @@ gtk_expander_get_height (GtkSizeRequest *widget,
}
static void
-gtk_expander_get_height_for_width (GtkSizeRequest *widget,
- gint width,
- gint *minimum_height,
- gint *natural_height)
+gtk_expander_get_preferred_height_for_width (GtkWidget *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height)
{
GtkExpander *expander;
GtkWidget *child;
@@ -1452,9 +1443,9 @@ gtk_expander_get_height_for_width (GtkSizeRequest *widget,
{
gint label_min, label_nat;
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (priv->label_widget),
- MAX (width - label_xpad, 1),
- &label_min, &label_nat);
+ gtk_widget_get_preferred_height_for_width (priv->label_widget,
+ MAX (width - label_xpad, 1),
+ &label_min, &label_nat);
*minimum_height += label_min;
*natural_height += label_nat;
@@ -1474,9 +1465,9 @@ gtk_expander_get_height_for_width (GtkSizeRequest *widget,
{
gint child_min, child_nat;
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child),
- MAX (width - 2 * border_width, 1),
- &child_min, &child_nat);
+ gtk_widget_get_preferred_height_for_width (child,
+ MAX (width - 2 * border_width, 1),
+ &child_min, &child_nat);
*minimum_height += child_min + priv->spacing;
*natural_height += child_nat + priv->spacing;
@@ -1487,12 +1478,12 @@ gtk_expander_get_height_for_width (GtkSizeRequest *widget,
}
static void
-gtk_expander_get_width_for_height (GtkSizeRequest *widget,
- gint height,
- gint *minimum_width,
- gint *natural_width)
+gtk_expander_get_preferred_width_for_height (GtkWidget *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width)
{
- 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);
}
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index 16ecddd..9898dcc 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -4109,8 +4109,8 @@ popup_position_func (GtkMenu *menu,
gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (menu),
- &req, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu),
+ &req, NULL);
gtk_widget_get_allocation (widget, &allocation);
*x += (allocation.width - req.width) / 2;
@@ -7852,7 +7852,7 @@ gtk_file_chooser_default_get_default_size (GtkFileChooserEmbed *chooser_embed,
impl->preview_widget &&
gtk_widget_get_visible (impl->preview_widget))
{
- gtk_size_request_get_size (GTK_SIZE_REQUEST (impl->preview_box),
+ gtk_widget_get_preferred_size ( (impl->preview_box),
&req, NULL);
*default_width += PREVIEW_HBOX_SPACING + req.width;
}
@@ -7860,15 +7860,15 @@ gtk_file_chooser_default_get_default_size (GtkFileChooserEmbed *chooser_embed,
if (impl->extra_widget &&
gtk_widget_get_visible (impl->extra_widget))
{
- gtk_size_request_get_size (GTK_SIZE_REQUEST (impl->extra_align),
+ gtk_widget_get_preferred_size ( (impl->extra_align),
&req, NULL);
*default_height += gtk_box_get_spacing (GTK_BOX (chooser_embed)) + req.height;
}
}
else
{
- gtk_size_request_get_size (GTK_SIZE_REQUEST (impl),
- &req, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (impl),
+ &req, NULL);
*default_width = req.width;
*default_height = req.height;
}
diff --git a/gtk/gtkfilechooserdialog.c b/gtk/gtkfilechooserdialog.c
index bcc8c3b..9408fa4 100644
--- a/gtk/gtkfilechooserdialog.c
+++ b/gtk/gtkfilechooserdialog.c
@@ -199,10 +199,10 @@ file_chooser_widget_default_size_changed (GtkWidget *widget,
{
/* Force a size request of everything before we start. This will make sure
* that widget->requisition is meaningful. */
- gtk_size_request_get_size (GTK_SIZE_REQUEST (dialog),
- &req, NULL);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget),
- &widget_req, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (dialog),
+ &req, NULL);
+ gtk_widget_get_preferred_size (widget,
+ &widget_req, NULL);
}
_gtk_file_chooser_embed_get_default_size (GTK_FILE_CHOOSER_EMBED (priv->widget),
diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c
index 50050c2..3399a6b 100644
--- a/gtk/gtkfilechooserentry.c
+++ b/gtk/gtkfilechooserentry.c
@@ -1023,7 +1023,7 @@ show_completion_feedback_window (GtkFileChooserEntry *chooser_entry)
GtkAllocation entry_allocation;
int feedback_x, feedback_y;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (chooser_entry->completion_feedback_window),
+ gtk_widget_get_preferred_size ( (chooser_entry->completion_feedback_window),
&feedback_req, NULL);
gdk_window_get_origin (gtk_widget_get_window (widget), &entry_x, &entry_y);
diff --git a/gtk/gtkfixed.c b/gtk/gtkfixed.c
index 86a92c2..860ba46 100644
--- a/gtk/gtkfixed.c
+++ b/gtk/gtkfixed.c
@@ -28,8 +28,6 @@
#include "gtkfixed.h"
-#include "gtksizerequest.h"
-
#include "gtkprivate.h"
#include "gtkintl.h"
@@ -351,7 +349,7 @@ gtk_fixed_size_request (GtkWidget *widget,
if (gtk_widget_get_visible (child->widget))
{
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child->widget),
+ gtk_widget_get_preferred_size ( (child->widget),
&child_requisition, NULL);
requisition->height = MAX (requisition->height,
@@ -402,8 +400,8 @@ gtk_fixed_size_allocate (GtkWidget *widget,
if (gtk_widget_get_visible (child->widget))
{
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child->widget),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (child->widget,
+ &child_requisition, NULL);
child_allocation.x = child->x + border_width;
child_allocation.y = child->y + border_width;
diff --git a/gtk/gtkfontsel.c b/gtk/gtkfontsel.c
index 21f05ac..394ff45 100644
--- a/gtk/gtkfontsel.c
+++ b/gtk/gtkfontsel.c
@@ -59,7 +59,6 @@
#include "gtkintl.h"
#include "gtkaccessible.h"
#include "gtkbuildable.h"
-#include "gtksizerequest.h"
#include "gtkprivate.h"
struct _GtkFontSelectionPrivate
@@ -1173,8 +1172,7 @@ gtk_font_selection_update_preview (GtkFontSelection *fontsel)
GtkWidget *preview_entry = priv->preview_entry;
const gchar *text;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (preview_entry),
- &old_requisition, NULL);
+ gtk_widget_get_preferred_size (preview_entry, &old_requisition, NULL);
rc_style = gtk_rc_style_new ();
rc_style->font_desc = gtk_font_selection_get_font_description (fontsel);
@@ -1182,7 +1180,7 @@ gtk_font_selection_update_preview (GtkFontSelection *fontsel)
gtk_widget_modify_style (preview_entry, rc_style);
g_object_unref (rc_style);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (preview_entry), &new_requisition, NULL);
+ gtk_widget_get_preferred_size (preview_entry, &new_requisition, NULL);
/* We don't ever want to be over MAX_PREVIEW_HEIGHT pixels high. */
new_height = CLAMP (new_requisition.height, INITIAL_PREVIEW_HEIGHT, MAX_PREVIEW_HEIGHT);
diff --git a/gtk/gtkframe.c b/gtk/gtkframe.c
index 5a8d20b..3390e47 100644
--- a/gtk/gtkframe.c
+++ b/gtk/gtkframe.c
@@ -31,7 +31,7 @@
#include "gtkprivate.h"
#include "gtkintl.h"
#include "gtkbuildable.h"
-#include "gtksizerequest.h"
+
#define LABEL_PAD 1
#define LABEL_SIDE_PAD 2
@@ -90,18 +90,17 @@ static void gtk_frame_buildable_add_child (GtkBuildable *buildable,
GObject *child,
const gchar *type);
-static void gtk_frame_size_request_init (GtkSizeRequestIface *iface);
-static void gtk_frame_get_width (GtkSizeRequest *widget,
+static void gtk_frame_get_preferred_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
-static void gtk_frame_get_height (GtkSizeRequest *widget,
+static void gtk_frame_get_preferred_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
-static void gtk_frame_get_height_for_width (GtkSizeRequest *layout,
+static void gtk_frame_get_preferred_height_for_width(GtkWidget *layout,
gint width,
gint *minimum_height,
gint *natural_height);
-static void gtk_frame_get_width_for_height (GtkSizeRequest *layout,
+static void gtk_frame_get_preferred_width_for_height(GtkWidget *layout,
gint width,
gint *minimum_height,
gint *natural_height);
@@ -109,9 +108,7 @@ static void gtk_frame_get_width_for_height (GtkSizeRequest *layout
G_DEFINE_TYPE_WITH_CODE (GtkFrame, gtk_frame, GTK_TYPE_BIN,
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
- gtk_frame_buildable_init)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
- gtk_frame_size_request_init))
+ gtk_frame_buildable_init))
static void
gtk_frame_class_init (GtkFrameClass *class)
@@ -170,8 +167,12 @@ gtk_frame_class_init (GtkFrameClass *class)
GTK_TYPE_WIDGET,
GTK_PARAM_READWRITE));
- widget_class->draw = gtk_frame_draw;
- widget_class->size_allocate = gtk_frame_size_allocate;
+ widget_class->draw = gtk_frame_draw;
+ widget_class->size_allocate = gtk_frame_size_allocate;
+ widget_class->get_preferred_width = gtk_frame_get_preferred_width;
+ widget_class->get_preferred_height = gtk_frame_get_preferred_height;
+ widget_class->get_preferred_height_for_width = gtk_frame_get_preferred_height_for_width;
+ widget_class->get_preferred_width_for_height = gtk_frame_get_preferred_width_for_height;
container_class->remove = gtk_frame_remove;
container_class->forall = gtk_frame_forall;
@@ -681,12 +682,12 @@ gtk_frame_size_allocate (GtkWidget *widget,
else
xalign = 1 - priv->label_xalign;
- gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->label_widget), NULL, &nat_width);
+ gtk_widget_get_preferred_width (priv->label_widget, NULL, &nat_width);
width = new_allocation.width - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD;
width = MIN (width, nat_width);
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (priv->label_widget), width,
- &height, NULL);
+ gtk_widget_get_preferred_height_for_width (priv->label_widget, width,
+ &height, NULL);
priv->label_allocation.x = priv->child_allocation.x + LABEL_SIDE_PAD +
@@ -732,7 +733,7 @@ gtk_frame_real_compute_child_allocation (GtkFrame *frame,
{
gint nat_width, width, height;
- gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->label_widget), NULL, &nat_width);
+ gtk_widget_get_preferred_width (priv->label_widget, NULL, &nat_width);
width = allocation.width;
width -= 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
@@ -740,8 +741,8 @@ gtk_frame_real_compute_child_allocation (GtkFrame *frame,
width = MIN (width, nat_width);
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (priv->label_widget), width,
- &height, NULL);
+ gtk_widget_get_preferred_height_for_width (priv->label_widget, width,
+ &height, NULL);
top_margin = MAX (height, style->ythickness);
}
@@ -759,10 +760,10 @@ gtk_frame_real_compute_child_allocation (GtkFrame *frame,
}
static void
-gtk_frame_get_size (GtkSizeRequest *request,
- GtkOrientation orientation,
- gint *minimum_size,
- gint *natural_size)
+gtk_frame_get_preferred_size (GtkWidget *request,
+ GtkOrientation orientation,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkFrame *frame = GTK_FRAME (request);
GtkFramePrivate *priv = frame->priv;
@@ -780,15 +781,15 @@ gtk_frame_get_size (GtkSizeRequest *request,
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
- gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->label_widget),
- &child_min, &child_nat);
+ gtk_widget_get_preferred_width (priv->label_widget,
+ &child_min, &child_nat);
minimum = child_min + 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
natural = child_nat + 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
}
else
{
- gtk_size_request_get_height (GTK_SIZE_REQUEST (priv->label_widget),
- &child_min, &child_nat);
+ gtk_widget_get_preferred_height (priv->label_widget,
+ &child_min, &child_nat);
minimum = MAX (0, child_min - style->ythickness);
natural = MAX (0, child_nat - style->ythickness);
}
@@ -804,15 +805,15 @@ gtk_frame_get_size (GtkSizeRequest *request,
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
- gtk_size_request_get_width (GTK_SIZE_REQUEST (child),
- &child_min, &child_nat);
+ gtk_widget_get_preferred_width (child,
+ &child_min, &child_nat);
minimum = MAX (minimum, child_min);
natural = MAX (natural, child_nat);
}
else
{
- gtk_size_request_get_height (GTK_SIZE_REQUEST (child),
- &child_min, &child_nat);
+ gtk_widget_get_preferred_height (child,
+ &child_min, &child_nat);
minimum += child_min;
natural += child_nat;
}
@@ -839,27 +840,27 @@ gtk_frame_get_size (GtkSizeRequest *request,
}
static void
-gtk_frame_get_width (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_frame_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_frame_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
+ gtk_frame_get_preferred_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
}
static void
-gtk_frame_get_height (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_frame_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_frame_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
+ gtk_frame_get_preferred_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
}
static void
-gtk_frame_get_height_for_width (GtkSizeRequest *request,
- gint width,
- gint *minimum_height,
- gint *natural_height)
+gtk_frame_get_preferred_height_for_width (GtkWidget *request,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height)
{
GtkWidget *widget = GTK_WIDGET (request);
GtkWidget *child;
@@ -882,8 +883,8 @@ gtk_frame_get_height_for_width (GtkSizeRequest *request,
if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
{
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (priv->label_widget),
- label_width, &child_min, &child_nat);
+ gtk_widget_get_preferred_height_for_width (priv->label_widget,
+ label_width, &child_min, &child_nat);
minimum += child_min;
natural += child_nat;
}
@@ -891,8 +892,8 @@ gtk_frame_get_height_for_width (GtkSizeRequest *request,
child = gtk_bin_get_child (bin);
if (child && gtk_widget_get_visible (child))
{
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child),
- width, &child_min, &child_nat);
+ gtk_widget_get_preferred_height_for_width (child,
+ width, &child_min, &child_nat);
minimum += child_min;
natural += child_nat;
}
@@ -905,19 +906,11 @@ gtk_frame_get_height_for_width (GtkSizeRequest *request,
}
static void
-gtk_frame_get_width_for_height (GtkSizeRequest *widget,
- gint height,
- gint *minimum_width,
- gint *natural_width)
+gtk_frame_get_preferred_width_for_height (GtkWidget *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width)
{
- 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_frame_size_request_init (GtkSizeRequestIface *iface)
-{
- iface->get_width = gtk_frame_get_width;
- iface->get_height = gtk_frame_get_height;
- iface->get_height_for_width = gtk_frame_get_height_for_width;
- iface->get_width_for_height = gtk_frame_get_width_for_height;
-}
diff --git a/gtk/gtkhandlebox.c b/gtk/gtkhandlebox.c
index d1eba05..2126672 100644
--- a/gtk/gtkhandlebox.c
+++ b/gtk/gtkhandlebox.c
@@ -32,7 +32,6 @@
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtkwindow.h"
-#include "gtksizerequest.h"
#include "gtkprivate.h"
#include "gtkintl.h"
@@ -448,7 +447,7 @@ gtk_handle_box_realize (GtkWidget *widget)
if (child)
gtk_widget_set_parent_window (child, priv->bin_window);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), &requisition, NULL);
+ gtk_widget_get_preferred_size (widget, &requisition, NULL);
attributes.x = 0;
attributes.y = 0;
@@ -575,7 +574,7 @@ gtk_handle_box_size_request (GtkWidget *widget,
*/
if (child)
{
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
+ gtk_widget_get_preferred_size ( (child),
&child_requisition, NULL);
}
else
@@ -642,8 +641,7 @@ gtk_handle_box_size_allocate (GtkWidget *widget,
if (child)
{
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (child, &child_requisition, NULL);
}
else
{
@@ -1348,8 +1346,7 @@ gtk_handle_box_motion (GtkWidget *widget,
if (child)
{
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (child, &child_requisition, NULL);
}
else
{
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index efa7ae5..bd2e1de 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -1450,7 +1450,7 @@ gtk_icon_view_size_request (GtkWidget *widget,
tmp_list = tmp_list->next;
if (gtk_widget_get_visible (child->widget))
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child->widget),
+ gtk_widget_get_preferred_size ( (child->widget),
&child_requisition, NULL);
}
}
diff --git a/gtk/gtkimagemenuitem.c b/gtk/gtkimagemenuitem.c
index 2a90305..4933ad5 100644
--- a/gtk/gtkimagemenuitem.c
+++ b/gtk/gtkimagemenuitem.c
@@ -36,7 +36,6 @@
#include "gtkcontainer.h"
#include "gtkwindow.h"
#include "gtkactivatable.h"
-#include "gtksizerequest.h"
#include "gtkintl.h"
#include "gtkprivate.h"
@@ -346,8 +345,7 @@ gtk_image_menu_item_toggle_size_request (GtkMenuItem *menu_item,
GtkRequisition image_requisition;
guint toggle_spacing;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->image),
- &image_requisition, NULL);
+ gtk_widget_get_preferred_size (priv->image, &image_requisition, NULL);
gtk_widget_style_get (GTK_WIDGET (menu_item),
"toggle-spacing", &toggle_spacing,
@@ -442,7 +440,7 @@ gtk_image_menu_item_size_request (GtkWidget *widget,
{
GtkRequisition child_requisition;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->image),
+ gtk_widget_get_preferred_size ( (priv->image),
&child_requisition, NULL);
child_width = child_requisition.width;
@@ -501,8 +499,7 @@ gtk_image_menu_item_size_allocate (GtkWidget *widget,
* come up with a solution that's really better.
*/
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->image),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL);
gtk_widget_get_allocation (widget, &widget_allocation);
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 15ecef8..f9e7109 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -49,7 +49,6 @@
#include "gtkimage.h"
#include "gtkshow.h"
#include "gtktooltip.h"
-#include "gtksizerequest.h"
#include "gtkprivate.h"
@@ -331,30 +330,27 @@ static void gtk_label_get_link_colors (GtkWidget *widget,
static void emit_activate_link (GtkLabel *label,
GtkLabelLink *link);
-static void gtk_label_size_request_init (GtkSizeRequestIface *iface);
-static GtkSizeRequestMode gtk_label_get_request_mode (GtkSizeRequest *widget);
-static void gtk_label_get_width (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_label_get_height (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_label_get_width_for_height (GtkSizeRequest *widget,
- gint height,
- gint *minimum_width,
- gint *natural_width);
-static void gtk_label_get_height_for_width (GtkSizeRequest *widget,
- gint width,
- gint *minimum_height,
- gint *natural_height);
+static GtkSizeRequestMode gtk_label_get_request_mode (GtkWidget *widget);
+static void gtk_label_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_label_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_label_get_preferred_width_for_height (GtkWidget *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width);
+static void gtk_label_get_preferred_height_for_width (GtkWidget *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height);
static GtkBuildableIface *buildable_parent_iface = NULL;
G_DEFINE_TYPE_WITH_CODE (GtkLabel, gtk_label, GTK_TYPE_MISC,
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
- gtk_label_buildable_interface_init)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
- gtk_label_size_request_init));
+ gtk_label_buildable_interface_init))
static void
add_move_binding (GtkBindingSet *binding_set,
@@ -414,6 +410,11 @@ gtk_label_class_init (GtkLabelClass *class)
widget_class->grab_focus = gtk_label_grab_focus;
widget_class->popup_menu = gtk_label_popup_menu;
widget_class->focus = gtk_label_focus;
+ widget_class->get_request_mode = gtk_label_get_request_mode;
+ widget_class->get_preferred_width = gtk_label_get_preferred_width;
+ widget_class->get_preferred_height = gtk_label_get_preferred_height;
+ widget_class->get_preferred_width_for_height = gtk_label_get_preferred_width_for_height;
+ widget_class->get_preferred_height_for_width = gtk_label_get_preferred_height_for_width;
class->move_cursor = gtk_label_move_cursor;
class->copy_clipboard = gtk_label_copy_clipboard;
@@ -3353,20 +3354,10 @@ get_single_line_height (GtkWidget *widget,
return ascent + descent;
}
-static void
-gtk_label_size_request_init (GtkSizeRequestIface *iface)
-{
- iface->get_request_mode = gtk_label_get_request_mode;
- iface->get_width = gtk_label_get_width;
- iface->get_height = gtk_label_get_height;
- iface->get_width_for_height = gtk_label_get_width_for_height;
- iface->get_height_for_width = gtk_label_get_height_for_width;
-}
-
static GtkSizeRequestMode
-gtk_label_get_request_mode (GtkSizeRequest *layout)
+gtk_label_get_request_mode (GtkWidget *widget)
{
- GtkLabel *label = GTK_LABEL (layout);
+ GtkLabel *label = GTK_LABEL (widget);
gdouble angle = gtk_label_get_angle (label);
if (angle == 90 || angle == 270)
@@ -3419,10 +3410,10 @@ get_size_for_allocation (GtkLabel *label,
}
static void
-gtk_label_get_size (GtkSizeRequest *widget,
- GtkOrientation orientation,
- gint *minimum_size,
- gint *natural_size)
+gtk_label_get_preferred_size (GtkWidget *widget,
+ GtkOrientation orientation,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkLabel *label = GTK_LABEL (widget);
GtkLabelPrivate *priv = label->priv;
@@ -3567,26 +3558,26 @@ gtk_label_get_size (GtkSizeRequest *widget,
static void
-gtk_label_get_width (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_label_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_label_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
+ gtk_label_get_preferred_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
}
static void
-gtk_label_get_height (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_label_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_label_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
+ gtk_label_get_preferred_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
}
static void
-gtk_label_get_width_for_height (GtkSizeRequest *widget,
- gint height,
- gint *minimum_width,
- gint *natural_width)
+gtk_label_get_preferred_width_for_height (GtkWidget *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width)
{
GtkLabel *label = GTK_LABEL (widget);
GtkLabelPrivate *priv = label->priv;
@@ -3611,14 +3602,14 @@ gtk_label_get_width_for_height (GtkSizeRequest *widget,
*natural_width += xpad * 2;
}
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_label_get_height_for_width (GtkSizeRequest *widget,
- gint width,
- gint *minimum_height,
- gint *natural_height)
+gtk_label_get_preferred_height_for_width (GtkWidget *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height)
{
GtkLabel *label = GTK_LABEL (widget);
GtkLabelPrivate *priv = label->priv;
@@ -3643,7 +3634,7 @@ gtk_label_get_height_for_width (GtkSizeRequest *widget,
*natural_height += ypad * 2;
}
else
- GTK_SIZE_REQUEST_GET_IFACE (widget)->get_height (widget, minimum_height, natural_height);
+ GTK_WIDGET_GET_CLASS (widget)->get_preferred_height (widget, minimum_height, natural_height);
}
static void
@@ -6127,8 +6118,8 @@ popup_position_func (GtkMenu *menu,
*x += allocation.x;
*y += allocation.y;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (menu),
- &req, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu),
+ &req, NULL);
gtk_widget_get_allocation (widget, &allocation);
diff --git a/gtk/gtklayout.c b/gtk/gtklayout.c
index c16d345..20da0e8 100644
--- a/gtk/gtklayout.c
+++ b/gtk/gtklayout.c
@@ -34,8 +34,6 @@
#include "gdkconfig.h"
-#include "gtksizerequest.h"
-
#include "gtkprivate.h"
#include "gtkintl.h"
#include "gtkmarshalers.h"
@@ -993,7 +991,7 @@ gtk_layout_size_request (GtkWidget *widget,
tmp_list = tmp_list->next;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child->widget),
+ gtk_widget_get_preferred_size ( (child->widget),
&child_requisition, NULL);
}
}
@@ -1126,8 +1124,7 @@ gtk_layout_allocate_child (GtkLayout *layout,
allocation.x = child->x;
allocation.y = child->y;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child->widget),
- &requisition, NULL);
+ gtk_widget_get_preferred_size (child->widget, &requisition, NULL);
allocation.width = requisition.width;
allocation.height = requisition.height;
diff --git a/gtk/gtklinkbutton.c b/gtk/gtklinkbutton.c
index 85de592..5cee706 100644
--- a/gtk/gtklinkbutton.c
+++ b/gtk/gtklinkbutton.c
@@ -365,7 +365,7 @@ popup_position_func (GtkMenu *menu,
gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->popup_menu),
+ gtk_widget_get_preferred_size ( (priv->popup_menu),
&req, NULL);
gtk_widget_get_allocation (widget, &allocation);
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index 8e036a6..705a74a 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -41,7 +41,6 @@
#include "gtkhbox.h"
#include "gtkvscrollbar.h"
#include "gtksettings.h"
-#include "gtksizerequest.h"
#include "gtkprivate.h"
#include "gtkintl.h"
@@ -258,17 +257,16 @@ static gboolean gtk_menu_real_can_activate_accel (GtkWidget *widget,
static void _gtk_menu_refresh_accel_paths (GtkMenu *menu,
gboolean group_changed);
-static void gtk_menu_size_request_init (GtkSizeRequestIface *iface);
-static void gtk_menu_get_width (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_menu_get_height (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_menu_get_height_for_width (GtkSizeRequest *widget,
- gint for_size,
- gint *minimum_size,
- gint *natural_size);
+static void gtk_menu_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_menu_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_menu_get_preferred_height_for_width (GtkWidget *widget,
+ gint for_size,
+ gint *minimum_size,
+ gint *natural_size);
static const gchar attach_data_key[] = "gtk-menu-attach-data";
@@ -281,9 +279,7 @@ gtk_menu_get_private (GtkMenu *menu)
return G_TYPE_INSTANCE_GET_PRIVATE (menu, GTK_TYPE_MENU, GtkMenuPrivate);
}
-G_DEFINE_TYPE_WITH_CODE (GtkMenu, gtk_menu, GTK_TYPE_MENU_SHELL,
- G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
- gtk_menu_size_request_init))
+G_DEFINE_TYPE (GtkMenu, gtk_menu, GTK_TYPE_MENU_SHELL)
static void
menu_queue_resize (GtkMenu *menu)
@@ -490,6 +486,9 @@ gtk_menu_class_init (GtkMenuClass *class)
widget_class->focus = gtk_menu_focus;
widget_class->can_activate_accel = gtk_menu_real_can_activate_accel;
widget_class->grab_notify = gtk_menu_grab_notify;
+ widget_class->get_preferred_width = gtk_menu_get_preferred_width;
+ widget_class->get_preferred_height = gtk_menu_get_preferred_height;
+ widget_class->get_preferred_height_for_width = gtk_menu_get_preferred_height_for_width;
container_class->remove = gtk_menu_remove;
container_class->get_child_property = gtk_menu_get_child_property;
@@ -1625,7 +1624,7 @@ gtk_menu_popup_for_device (GtkMenu *menu,
/* Instead of trusting the menu position function to queue a resize when the
* menu goes out of bounds, invalidate the cached size here. */
gtk_widget_queue_resize (GTK_WIDGET (menu));
- gtk_size_request_get_size (GTK_SIZE_REQUEST (menu->toplevel), &tmp_request, NULL);
+ gtk_widget_get_preferred_size (menu->toplevel, &tmp_request, NULL);
tmp_allocation.width = tmp_request.width;
tmp_allocation.height = tmp_request.height;
@@ -2053,7 +2052,7 @@ gtk_menu_set_tearoff_hints (GtkMenu *menu,
{
GtkRequisition requisition;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (menu->tearoff_scrollbar),
+ gtk_widget_get_preferred_size ( (menu->tearoff_scrollbar),
&requisition, NULL);
width += requisition.width;
}
@@ -2202,8 +2201,8 @@ gtk_menu_set_tearoff_state (GtkMenu *menu,
/* Update menu->requisition
*/
- gtk_size_request_get_size (GTK_SIZE_REQUEST (menu),
- NULL, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu),
+ NULL, NULL);
gtk_menu_set_tearoff_hints (menu, gdk_window_get_width (gtk_widget_get_window (GTK_WIDGET (menu))));
@@ -2602,8 +2601,8 @@ calculate_line_heights (GtkMenu *menu,
part = avail_width / (r - l);
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child), part,
- &child_min, &child_nat);
+ gtk_widget_get_preferred_height_for_width (child, part,
+ &child_min, &child_nat);
gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child), &toggle_size);
@@ -3014,19 +3013,10 @@ gtk_menu_show (GtkWidget *widget)
}
-
-static void
-gtk_menu_size_request_init (GtkSizeRequestIface *iface)
-{
- iface->get_width = gtk_menu_get_width;
- iface->get_height = gtk_menu_get_height;
- iface->get_height_for_width = gtk_menu_get_height_for_width;
-}
-
static void
-gtk_menu_get_width (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_menu_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkMenu *menu;
GtkMenuShell *menu_shell;
@@ -3074,7 +3064,7 @@ gtk_menu_get_width (GtkSizeRequest *widget,
*/
GTK_MENU_ITEM (child)->show_submenu_indicator = TRUE;
- gtk_size_request_get_width (GTK_SIZE_REQUEST (child), &child_min, &child_nat);
+ gtk_widget_get_preferred_width (child, &child_min, &child_nat);
gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child), &toggle_size);
max_toggle_size = MAX (max_toggle_size, toggle_size);
@@ -3139,22 +3129,22 @@ gtk_menu_get_width (GtkSizeRequest *widget,
}
static void
-gtk_menu_get_height (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_menu_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
gint min_width;
/* Menus are height-for-width only, just return the height for the minimum width */
- GTK_SIZE_REQUEST_GET_IFACE (widget)->get_width (widget, &min_width, NULL);
- GTK_SIZE_REQUEST_GET_IFACE (widget)->get_height_for_width (widget, min_width, minimum_size, natural_size);
+ GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, &min_width, NULL);
+ GTK_WIDGET_GET_CLASS (widget)->get_preferred_height_for_width (widget, min_width, minimum_size, natural_size);
}
static void
-gtk_menu_get_height_for_width (GtkSizeRequest *widget,
- gint for_size,
- gint *minimum_size,
- gint *natural_size)
+gtk_menu_get_preferred_height_for_width (GtkWidget *widget,
+ gint for_size,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkMenu *menu = GTK_MENU (widget);
GtkMenuPrivate *private = gtk_menu_get_private (menu);
@@ -4525,7 +4515,7 @@ gtk_menu_position (GtkMenu *menu)
/* Get the minimum height for minimum width to figure out
* the right place to popup the menu.
*/
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), &requisition, NULL);
+ gtk_widget_get_preferred_size (widget, &requisition, NULL);
if (pointer_screen != screen)
{
@@ -5444,7 +5434,7 @@ child_at (GtkMenu *menu,
{
GtkRequisition child_requisition;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (children->data),
+ gtk_widget_get_preferred_size ( (children->data),
&child_requisition, NULL);
if (_gtk_menu_item_is_selectable (children->data) &&
diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c
index dcca19d..f0245cd 100644
--- a/gtk/gtkmenubar.c
+++ b/gtk/gtkmenubar.c
@@ -309,7 +309,7 @@ gtk_menu_bar_size_request (GtkWidget *widget,
gint toggle_size;
GTK_MENU_ITEM (child)->show_submenu_indicator = FALSE;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
+ gtk_widget_get_preferred_size ( (child),
&child_requisition, NULL);
gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
&toggle_size);
@@ -427,8 +427,7 @@ gtk_menu_bar_size_allocate (GtkWidget *widget,
gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
&toggle_size);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (child, &child_requisition, NULL);
if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
@@ -478,8 +477,7 @@ gtk_menu_bar_size_allocate (GtkWidget *widget,
gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
&toggle_size);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (child, &child_requisition, NULL);
if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c
index ad97bfb..8a0529b 100644
--- a/gtk/gtkmenuitem.c
+++ b/gtk/gtkmenuitem.c
@@ -37,7 +37,6 @@
#include "gtkprivate.h"
#include "gtkbuildable.h"
#include "gtkactivatable.h"
-#include "gtksizerequest.h"
#include "gtkintl.h"
@@ -127,17 +126,16 @@ static void gtk_real_menu_item_set_label (GtkMenuItem *menu_item,
const gchar *label);
static G_CONST_RETURN gchar * gtk_real_menu_item_get_label (GtkMenuItem *menu_item);
-static void gtk_menu_item_size_request_init (GtkSizeRequestIface *iface);
-static void gtk_menu_item_get_width (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_menu_item_get_height (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_menu_item_get_height_for_width (GtkSizeRequest *widget,
- gint for_size,
- gint *minimum_size,
- gint *natural_size);
+static void gtk_menu_item_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_menu_item_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_menu_item_get_preferred_height_for_width (GtkWidget *widget,
+ gint for_size,
+ gint *minimum_size,
+ gint *natural_size);
static void gtk_menu_item_buildable_interface_init (GtkBuildableIface *iface);
static void gtk_menu_item_buildable_add_child (GtkBuildable *buildable,
@@ -170,9 +168,7 @@ G_DEFINE_TYPE_WITH_CODE (GtkMenuItem, gtk_menu_item, GTK_TYPE_BIN,
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
gtk_menu_item_buildable_interface_init)
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE,
- gtk_menu_item_activatable_interface_init)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
- gtk_menu_item_size_request_init))
+ gtk_menu_item_activatable_interface_init))
#define GET_PRIVATE(object) \
(G_TYPE_INSTANCE_GET_PRIVATE ((object), GTK_TYPE_MENU_ITEM, GtkMenuItemPrivate))
@@ -204,6 +200,9 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass)
widget_class->mnemonic_activate = gtk_menu_item_mnemonic_activate;
widget_class->parent_set = gtk_menu_item_parent_set;
widget_class->can_activate_accel = gtk_menu_item_can_activate_accel;
+ widget_class->get_preferred_width = gtk_menu_item_get_preferred_width;
+ widget_class->get_preferred_height = gtk_menu_item_get_preferred_height;
+ widget_class->get_preferred_height_for_width = gtk_menu_item_get_preferred_height_for_width;
container_class->forall = gtk_menu_item_forall;
@@ -660,17 +659,9 @@ get_minimum_width (GtkWidget *widget)
}
static void
-gtk_menu_item_size_request_init (GtkSizeRequestIface *iface)
-{
- iface->get_width = gtk_menu_item_get_width;
- iface->get_height = gtk_menu_item_get_height;
- iface->get_height_for_width = gtk_menu_item_get_height_for_width;
-}
-
-static void
-gtk_menu_item_get_width (GtkSizeRequest *request,
- gint *minimum_size,
- gint *natural_size)
+gtk_menu_item_get_preferred_width (GtkWidget *request,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkMenuItem *menu_item;
GtkBin *bin;
@@ -720,7 +711,7 @@ gtk_menu_item_get_width (GtkSizeRequest *request,
{
gint child_min, child_nat;
- gtk_size_request_get_width (GTK_SIZE_REQUEST (child), &child_min, &child_nat);
+ gtk_widget_get_preferred_width (child, &child_min, &child_nat);
if (menu_item->submenu && menu_item->show_submenu_indicator)
{
@@ -762,9 +753,9 @@ gtk_menu_item_get_width (GtkSizeRequest *request,
}
static void
-gtk_menu_item_get_height (GtkSizeRequest *request,
- gint *minimum_size,
- gint *natural_size)
+gtk_menu_item_get_preferred_height (GtkWidget *request,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkMenuItem *menu_item;
GtkBin *bin;
@@ -816,7 +807,7 @@ gtk_menu_item_get_height (GtkSizeRequest *request,
{
gint child_min, child_nat;
- gtk_size_request_get_height (GTK_SIZE_REQUEST (child), &child_min, &child_nat);
+ gtk_widget_get_preferred_height (child, &child_min, &child_nat);
min_height += child_min;
nat_height += child_nat;
@@ -863,10 +854,10 @@ gtk_menu_item_get_height (GtkSizeRequest *request,
}
static void
-gtk_menu_item_get_height_for_width (GtkSizeRequest *request,
- gint for_size,
- gint *minimum_size,
- gint *natural_size)
+gtk_menu_item_get_preferred_height_for_width (GtkWidget *request,
+ gint for_size,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkMenuItem *menu_item;
GtkBin *bin;
@@ -941,7 +932,10 @@ gtk_menu_item_get_height_for_width (GtkSizeRequest *request,
avail_size -= arrow_spacing;
}
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child), avail_size, &child_min, &child_nat);
+ gtk_widget_get_preferred_height_for_width (child,
+ avail_size,
+ &child_min,
+ &child_nat);
min_height += child_min;
nat_height += child_nat;
@@ -1392,8 +1386,7 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
child_allocation.x += allocation->x;
child_allocation.y += allocation->y;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (child, &child_requisition, NULL);
if (menu_item->submenu && menu_item->show_submenu_indicator)
{
if (direction == GTK_TEXT_DIR_RTL)
@@ -1999,7 +1992,7 @@ gtk_menu_item_position_menu (GtkMenu *menu,
direction = gtk_widget_get_direction (widget);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (menu), &requisition, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu), &requisition, NULL);
twidth = requisition.width;
theight = requisition.height;
diff --git a/gtk/gtkmenutoolbutton.c b/gtk/gtkmenutoolbutton.c
index fdf7aa1..79ba487 100644
--- a/gtk/gtkmenutoolbutton.c
+++ b/gtk/gtkmenutoolbutton.c
@@ -270,8 +270,8 @@ menu_position_func (GtkMenu *menu,
GdkScreen *screen;
GdkWindow *window;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->menu),
- &menu_req, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (priv->menu),
+ &menu_req, NULL);
orientation = gtk_tool_item_get_orientation (GTK_TOOL_ITEM (button));
direction = gtk_widget_get_direction (widget);
@@ -311,7 +311,7 @@ menu_position_func (GtkMenu *menu,
else
{
gdk_window_get_origin (GTK_BUTTON (priv->arrow_button)->event_window, x, y);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->arrow_button),
+ gtk_widget_get_preferred_size ( (priv->arrow_button),
&req, NULL);
gtk_widget_get_allocation (priv->arrow_button, &arrow_allocation);
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 62d80e3..d0bb6f2 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -38,7 +38,6 @@
#include "gtkmenu.h"
#include "gtkmenuitem.h"
#include "gtklabel.h"
-#include "gtksizerequest.h"
#include "gtkintl.h"
#include "gtkmarshalers.h"
#include "gtkbindings.h"
@@ -1850,8 +1849,8 @@ gtk_notebook_size_request (GtkWidget *widget,
if (gtk_widget_get_visible (page->child))
{
vis_pages++;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (page->child),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (page->child,
+ &child_requisition, NULL);
requisition->width = MAX (requisition->width,
child_requisition.width);
@@ -1908,8 +1907,8 @@ gtk_notebook_size_request (GtkWidget *widget,
if (!gtk_widget_get_visible (page->tab_label))
gtk_widget_show (page->tab_label);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (page->tab_label),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (page->tab_label,
+ &child_requisition, NULL);
page->requisition.width = child_requisition.width + 2 * style->xthickness;
page->requisition.height = child_requisition.height + 2 * style->ythickness;
@@ -1944,8 +1943,8 @@ gtk_notebook_size_request (GtkWidget *widget,
{
if (priv->action_widget[i])
{
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->action_widget[i]),
- &action_widget_requisition[i], NULL);
+ gtk_widget_get_preferred_size (priv->action_widget[i],
+ &action_widget_requisition[i], NULL);
action_widget_requisition[i].width += style->xthickness;
action_widget_requisition[i].height += style->ythickness;
}
@@ -2197,8 +2196,8 @@ gtk_notebook_size_allocate (GtkWidget *widget,
widget_allocation.y = allocation->y + border_width;
is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->action_widget[i]),
- &requisition, NULL);
+ gtk_widget_get_preferred_size (priv->action_widget[i],
+ &requisition, NULL);
switch (tab_pos)
{
@@ -2672,8 +2671,8 @@ popup_position_func (GtkMenu *menu,
gdk_window_get_origin (gtk_widget_get_window (w), x, y);
gtk_widget_get_allocation (w, &allocation);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (menu),
- &requisition, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu),
+ &requisition, NULL);
if (gtk_widget_get_direction (w) == GTK_TEXT_DIR_RTL)
*x += allocation.x + allocation.width - requisition.width;
@@ -3258,8 +3257,8 @@ on_drag_icon_draw (GtkWidget *widget,
notebook = GTK_WIDGET (data);
child = gtk_bin_get_child (GTK_BIN (widget));
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget),
- &requisition, NULL);
+ gtk_widget_get_preferred_size (widget,
+ &requisition, NULL);
gap_pos = get_tab_gap_pos (GTK_NOTEBOOK (notebook));
gtk_paint_extension (gtk_widget_get_style (notebook),
@@ -5837,8 +5836,7 @@ gtk_notebook_page_allocate (GtkNotebook *notebook,
xthickness = style->xthickness;
ythickness = style->ythickness;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (page->tab_label),
- &tab_requisition, NULL);
+ gtk_widget_get_preferred_size (page->tab_label, &tab_requisition, NULL);
gtk_widget_style_get (widget,
"focus-line-width", &focus_width,
"tab-curvature", &tab_curvature,
diff --git a/gtk/gtkoffscreenwindow.c b/gtk/gtkoffscreenwindow.c
index 3a426f3..40a917c 100644
--- a/gtk/gtkoffscreenwindow.c
+++ b/gtk/gtkoffscreenwindow.c
@@ -71,7 +71,7 @@ gtk_offscreen_window_size_request (GtkWidget *widget,
{
GtkRequisition child_req;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
+ gtk_widget_get_preferred_size ( (child),
&child_req, NULL);
requisition->width += child_req.width;
@@ -173,7 +173,7 @@ gtk_offscreen_window_resize (GtkWidget *widget)
GtkAllocation allocation = { 0, 0 };
GtkRequisition requisition;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget),
+ gtk_widget_get_preferred_size ( (widget),
&requisition, NULL);
allocation.width = requisition.width;
diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c
index f33954a..e19f8ac 100644
--- a/gtk/gtkpaned.c
+++ b/gtk/gtkpaned.c
@@ -33,7 +33,6 @@
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtkorientable.h"
-#include "gtksizerequest.h"
#include "gtkwindow.h"
#include "gtkprivate.h"
@@ -805,7 +804,7 @@ gtk_paned_size_request (GtkWidget *widget,
if (priv->child1 && gtk_widget_get_visible (priv->child1))
{
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->child1),
+ gtk_widget_get_preferred_size ( (priv->child1),
&child_requisition, NULL);
requisition->height = child_requisition.height;
@@ -814,7 +813,7 @@ gtk_paned_size_request (GtkWidget *widget,
if (priv->child2 && gtk_widget_get_visible (priv->child2))
{
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->child2),
+ gtk_widget_get_preferred_size ( (priv->child2),
&child_requisition, NULL);
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
@@ -889,10 +888,8 @@ gtk_paned_size_allocate (GtkWidget *widget,
gtk_widget_style_get (widget, "handle-size", &handle_size, NULL);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->child1),
- &child1_requisition, NULL);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->child2),
- &child2_requisition, NULL);
+ gtk_widget_get_preferred_size (priv->child1, &child1_requisition, NULL);
+ gtk_widget_get_preferred_size (priv->child2, &child2_requisition, NULL);
old_handle_pos = priv->handle_pos;
diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c
index ad03d77..60e27b2 100644
--- a/gtk/gtkpathbar.c
+++ b/gtk/gtkpathbar.c
@@ -36,7 +36,6 @@
#include "gtkhbox.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
-#include "gtksizerequest.h"
enum {
@@ -334,7 +333,7 @@ gtk_path_bar_size_request (GtkWidget *widget,
for (list = path_bar->button_list; list; list = list->next)
{
button_data = BUTTON_DATA (list->data);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (button_data->button),
+ gtk_widget_get_preferred_size ( (button_data->button),
&child_requisition, NULL);
if (button_data->type == NORMAL_BUTTON)
@@ -354,9 +353,9 @@ gtk_path_bar_size_request (GtkWidget *widget,
if (path_bar->button_list && path_bar->button_list->next != NULL)
requisition->width += (path_bar->spacing + path_bar->slider_width) * 2;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (path_bar->up_slider_button),
+ gtk_widget_get_preferred_size ( (path_bar->up_slider_button),
&child_requisition, NULL);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (path_bar->down_slider_button),
+ gtk_widget_get_preferred_size ( (path_bar->down_slider_button),
&child_requisition, NULL);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
@@ -500,8 +499,7 @@ gtk_path_bar_size_allocate (GtkWidget *widget,
{
child = BUTTON_DATA (list->data)->button;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (child, &child_requisition, NULL);
width += child_requisition.width + path_bar->spacing;
if (list == path_bar->fake_root)
@@ -531,8 +529,8 @@ gtk_path_bar_size_allocate (GtkWidget *widget,
* button, then count backwards.
*/
/* Count down the path chain towards the end. */
- gtk_size_request_get_size (GTK_SIZE_REQUEST (BUTTON_DATA (first_button->data)->button),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (BUTTON_DATA (first_button->data)->button,
+ &child_requisition, NULL);
width = child_requisition.width;
list = first_button->prev;
@@ -540,8 +538,7 @@ gtk_path_bar_size_allocate (GtkWidget *widget,
{
child = BUTTON_DATA (list->data)->button;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (child, &child_requisition, NULL);
if (width + child_requisition.width +
path_bar->spacing + slider_space > allocation_width)
@@ -560,8 +557,7 @@ gtk_path_bar_size_allocate (GtkWidget *widget,
{
child = BUTTON_DATA (first_button->next->data)->button;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (child, &child_requisition, NULL);
if (width + child_requisition.width + path_bar->spacing + slider_space > allocation_width)
{
@@ -608,8 +604,7 @@ gtk_path_bar_size_allocate (GtkWidget *widget,
button_data = BUTTON_DATA (list->data);
child = button_data->button;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (child, &child_requisition, NULL);
child_allocation.width = MIN (child_requisition.width,
allocation_width - (path_bar->spacing + path_bar->slider_width) * 2);
diff --git a/gtk/gtkprintoperation-win32.c b/gtk/gtkprintoperation-win32.c
index 6630019..0995b85 100644
--- a/gtk/gtkprintoperation-win32.c
+++ b/gtk/gtkprintoperation-win32.c
@@ -1411,7 +1411,7 @@ create_application_page (GtkPrintOperation *op)
const char *tab_label;
/* Make the template the size of the custom widget size request */
- gtk_size_request_get_size (GTK_SIZE_REQUEST (op->priv->custom_widget),
+ gtk_widget_get_preferred_size ( (op->priv->custom_widget),
&requisition, NULL);
base_units = GetDialogBaseUnits ();
diff --git a/gtk/gtkprivate.h b/gtk/gtkprivate.h
index 8fa1c9b..53c073c 100644
--- a/gtk/gtkprivate.h
+++ b/gtk/gtkprivate.h
@@ -115,7 +115,7 @@ gboolean _gtk_fnmatch (const char *pattern,
#endif
-/* With GtkSizeRequest, a widget may be requested
+/* With GtkWidget , a widget may be requested
* its width for 2 or maximum 3 heights in one resize
* (Note this define is limited by the bitfield sizes
* defined on the SizeRequestCache structure).
diff --git a/gtk/gtkrecentchooserdefault.c b/gtk/gtkrecentchooserdefault.c
index 59170fe..11ae23f 100644
--- a/gtk/gtkrecentchooserdefault.c
+++ b/gtk/gtkrecentchooserdefault.c
@@ -946,7 +946,7 @@ set_default_size (GtkRecentChooserDefault *impl)
height = (impl->icon_size + font_size) * NUM_LINES;
/* Use at least the requisition size... */
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget),
+ gtk_widget_get_preferred_size ( (widget),
&req, NULL);
width = MAX (width, req.width);
height = MAX (height, req.height);
@@ -1849,8 +1849,8 @@ popup_position_func (GtkMenu *menu,
gdk_window_get_origin (gtk_widget_get_window (widget),
x, y);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (menu),
- &req, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu),
+ &req, NULL);
gtk_widget_get_allocation (widget, &allocation);
*x += (allocation.width - req.width) / 2;
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index af6ab23..89eef78 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -28,7 +28,6 @@
#include <math.h>
#include <gdk/gdkkeysyms.h>
#include "gtkbindings.h"
-#include "gtksizerequest.h"
#include "gtkmarshalers.h"
#include "gtkscrolledwindow.h"
#include "gtkwindow.h"
@@ -151,27 +150,24 @@ static void gtk_scrolled_window_adjustment_changed (GtkAdjustment *adjus
static void gtk_scrolled_window_update_real_placement (GtkScrolledWindow *scrolled_window);
-static void gtk_scrolled_window_size_request_init (GtkSizeRequestIface *iface);
-static void gtk_scrolled_window_get_width (GtkSizeRequest *widget,
+static void gtk_scrolled_window_get_preferred_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
-static void gtk_scrolled_window_get_height (GtkSizeRequest *widget,
+static void gtk_scrolled_window_get_preferred_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
-static void gtk_scrolled_window_get_height_for_width (GtkSizeRequest *layout,
+static void gtk_scrolled_window_get_preferred_height_for_width (GtkWidget *layout,
gint width,
gint *minimum_height,
gint *natural_height);
-static void gtk_scrolled_window_get_width_for_height (GtkSizeRequest *layout,
+static void gtk_scrolled_window_get_preferred_width_for_height (GtkWidget *layout,
gint width,
gint *minimum_height,
gint *natural_height);
static guint signals[LAST_SIGNAL] = {0};
-G_DEFINE_TYPE_WITH_CODE (GtkScrolledWindow, gtk_scrolled_window, GTK_TYPE_BIN,
- G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
- gtk_scrolled_window_size_request_init))
+G_DEFINE_TYPE (GtkScrolledWindow, gtk_scrolled_window, GTK_TYPE_BIN)
static void
@@ -229,6 +225,10 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
widget_class->size_allocate = gtk_scrolled_window_size_allocate;
widget_class->scroll_event = gtk_scrolled_window_scroll_event;
widget_class->focus = gtk_scrolled_window_focus;
+ widget_class->get_preferred_width = gtk_scrolled_window_get_preferred_width;
+ widget_class->get_preferred_height = gtk_scrolled_window_get_preferred_height;
+ widget_class->get_preferred_height_for_width = gtk_scrolled_window_get_preferred_height_for_width;
+ widget_class->get_preferred_width_for_height = gtk_scrolled_window_get_preferred_width_for_height;
container_class->add = gtk_scrolled_window_add;
container_class->remove = gtk_scrolled_window_remove;
@@ -1332,8 +1332,8 @@ gtk_scrolled_window_relative_allocation (GtkWidget *widget,
GtkRequisition vscrollbar_requisition;
gboolean is_rtl;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->vscrollbar),
- &vscrollbar_requisition, NULL);
+ gtk_widget_get_preferred_size (priv->vscrollbar,
+ &vscrollbar_requisition, NULL);
is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
if ((!is_rtl &&
@@ -1350,8 +1350,8 @@ gtk_scrolled_window_relative_allocation (GtkWidget *widget,
{
GtkRequisition hscrollbar_requisition;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->hscrollbar),
- &hscrollbar_requisition, NULL);
+ gtk_widget_get_preferred_size (priv->hscrollbar,
+ &hscrollbar_requisition, NULL);
if (priv->real_window_placement == GTK_CORNER_BOTTOM_LEFT ||
priv->real_window_placement == GTK_CORNER_BOTTOM_RIGHT)
@@ -1454,8 +1454,8 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
{
GtkRequisition hscrollbar_requisition;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->hscrollbar),
- &hscrollbar_requisition, NULL);
+ gtk_widget_get_preferred_size (priv->hscrollbar,
+ &hscrollbar_requisition, NULL);
if (!gtk_widget_get_visible (priv->hscrollbar))
gtk_widget_show (priv->hscrollbar);
@@ -1505,8 +1505,8 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
if (!gtk_widget_get_visible (priv->vscrollbar))
gtk_widget_show (priv->vscrollbar);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->vscrollbar),
- &vscrollbar_requisition, NULL);
+ gtk_widget_get_preferred_size (priv->vscrollbar,
+ &vscrollbar_requisition, NULL);
if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL &&
(priv->real_window_placement == GTK_CORNER_TOP_RIGHT ||
@@ -1800,19 +1800,10 @@ _gtk_scrolled_window_get_scrollbar_spacing (GtkScrolledWindow *scrolled_window)
static void
-gtk_scrolled_window_size_request_init (GtkSizeRequestIface *iface)
-{
- iface->get_width = gtk_scrolled_window_get_width;
- iface->get_height = gtk_scrolled_window_get_height;
- iface->get_height_for_width = gtk_scrolled_window_get_height_for_width;
- iface->get_width_for_height = gtk_scrolled_window_get_width_for_height;
-}
-
-static void
-gtk_scrolled_window_get_size (GtkSizeRequest *widget,
- GtkOrientation orientation,
- gint *minimum_size,
- gint *natural_size)
+gtk_scrolled_window_get_preferred_size (GtkWidget *widget,
+ GtkOrientation orientation,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
GtkScrolledWindowPrivate *priv = scrolled_window->priv;
@@ -1837,9 +1828,9 @@ gtk_scrolled_window_get_size (GtkSizeRequest *widget,
natural_req.width = 0;
natural_req.height = 0;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->hscrollbar),
+ gtk_widget_get_preferred_size ( (priv->hscrollbar),
&hscrollbar_requisition, NULL);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->vscrollbar),
+ gtk_widget_get_preferred_size ( (priv->vscrollbar),
&vscrollbar_requisition, NULL);
child = gtk_bin_get_child (bin);
@@ -1847,9 +1838,9 @@ gtk_scrolled_window_get_size (GtkSizeRequest *widget,
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
- gtk_size_request_get_width (GTK_SIZE_REQUEST (child),
- &min_child_size,
- &nat_child_size);
+ gtk_widget_get_preferred_width (child,
+ &min_child_size,
+ &nat_child_size);
if (priv->hscrollbar_policy == GTK_POLICY_NEVER)
{
@@ -1875,9 +1866,9 @@ gtk_scrolled_window_get_size (GtkSizeRequest *widget,
}
else /* GTK_ORIENTATION_VERTICAL */
{
- gtk_size_request_get_height (GTK_SIZE_REQUEST (child),
- &min_child_size,
- &nat_child_size);
+ gtk_widget_get_preferred_height (child,
+ &min_child_size,
+ &nat_child_size);
if (priv->vscrollbar_policy == GTK_POLICY_NEVER)
{
@@ -1953,39 +1944,39 @@ gtk_scrolled_window_get_size (GtkSizeRequest *widget,
}
static void
-gtk_scrolled_window_get_width (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_scrolled_window_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_scrolled_window_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
+ gtk_scrolled_window_get_preferred_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
}
static void
-gtk_scrolled_window_get_height (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_scrolled_window_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_scrolled_window_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
+ gtk_scrolled_window_get_preferred_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
}
static void
-gtk_scrolled_window_get_height_for_width (GtkSizeRequest *widget,
- gint width,
- gint *minimum_height,
- gint *natural_height)
+gtk_scrolled_window_get_preferred_height_for_width (GtkWidget *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- GTK_SIZE_REQUEST_GET_IFACE (widget)->get_height (widget, minimum_height, natural_height);
+ GTK_WIDGET_GET_CLASS (widget)->get_preferred_height (widget, minimum_height, natural_height);
}
static void
-gtk_scrolled_window_get_width_for_height (GtkSizeRequest *widget,
- gint height,
- gint *minimum_width,
- gint *natural_width)
+gtk_scrolled_window_get_preferred_width_for_height (GtkWidget *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- 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);
}
diff --git a/gtk/gtksizegroup.c b/gtk/gtksizegroup.c
index 9116a18..f22f146 100644
--- a/gtk/gtksizegroup.c
+++ b/gtk/gtksizegroup.c
@@ -25,7 +25,6 @@
#include "gtkprivate.h"
#include "gtksizegroup.h"
#include "gtkbuildable.h"
-#include "gtksizerequest.h"
@@ -717,9 +716,9 @@ compute_dimension (GtkWidget *widget,
else
{
if (mode == GTK_SIZE_GROUP_HORIZONTAL)
- gtk_size_request_get_width (GTK_SIZE_REQUEST (tmp_widget), &min_dimension, &nat_dimension);
+ gtk_widget_get_preferred_width (tmp_widget, &min_dimension, &nat_dimension);
else
- gtk_size_request_get_height (GTK_SIZE_REQUEST (tmp_widget), &min_dimension, &nat_dimension);
+ gtk_widget_get_preferred_height (tmp_widget, &min_dimension, &nat_dimension);
}
if (gtk_widget_get_mapped (tmp_widget) || !priv->ignore_hidden)
@@ -778,7 +777,7 @@ compute_dimension (GtkWidget *widget,
*
* This function is used both to update sizegroup minimum and natural size
* information and widget minimum and natural sizes in multiple passes from
- * the #GtkSizeRequest apis.
+ * the size request apis.
*/
void
_gtk_size_group_bump_requisition (GtkWidget *widget,
diff --git a/gtk/gtksizerequest.c b/gtk/gtksizerequest.c
index cf80491..c11844f 100644
--- a/gtk/gtksizerequest.c
+++ b/gtk/gtksizerequest.c
@@ -25,9 +25,9 @@
/**
* SECTION:gtksizerequest
* @Short_Description: Height-for-width geometry management
- * @Title: GtkSizeRequest
+ * @Title: GtkWidget
*
- * The GtkSizeRequest interface is GTK+'s height-for-width (and width-for-height)
+ * The GtkWidget interface is GTK+'s height-for-width (and width-for-height)
* geometry management system. Height-for-width means that a widget can
* change how much vertical space it needs, depending on the amount
* of horizontal space that it is given (and similar for width-for-height).
@@ -36,14 +36,14 @@
*
* GTK+'s traditional two-pass <link linkend="size-allocation">size-allocation</link>
* algorithm does not allow this flexibility. #GtkWidget provides a default
- * implementation of the #GtkSizeRequest interface for existing widgets,
+ * implementation of the #GtkWidget interface for existing widgets,
* which always requests the same height, regardless of the available width.
*
* <refsect2>
- * <title>Implementing GtkSizeRequest</title>
+ * <title>Implementing GtkWidget </title>
* <para>
* Some important things to keep in mind when implementing
- * the GtkSizeRequest interface and when using it in container
+ * the GtkWidget interface and when using it in container
* implementations.
*
* The geometry management system will query a logical hierarchy in
@@ -54,12 +54,12 @@
* For instance when queried in the normal height-for-width mode:
* First the default minimum and natural width for each widget
* in the interface will computed and collectively returned to
- * the toplevel by way of gtk_size_request_get_width().
+ * the toplevel by way of gtk_widget_get_preferred_width().
* Next, the toplevel will use the minimum width to query for the
* minimum height contextual to that width using
- * gtk_size_request_get_height_for_width(), which will also be a
- * highly recursive operation. This minimum-for-minimum size can be
- * used to set the minimum size constraint on the toplevel.
+ * gtk_widget_get_preferred_height_for_width(), which will also
+ * be a highly recursive operation. This minimum-for-minimum size can
+ * be used to set the minimum size constraint on the toplevel.
*
* When allocating, each container can use the minimum and natural
* sizes reported by their children to allocate natural sizes and
@@ -67,7 +67,7 @@
*
* That means that the request operation at allocation time will
* usually fire again in contexts of different allocated sizes than
- * the ones originally queried for. #GtkSizeRequest caches a
+ * the ones originally queried for. #GtkWidget caches a
* small number of results to avoid re-querying for the same
* allocated size in one allocation cycle.
*
@@ -125,18 +125,6 @@
#include "gtkprivate.h"
#include "gtkintl.h"
-typedef GtkSizeRequestIface GtkSizeRequestInterface;
-G_DEFINE_INTERFACE (GtkSizeRequest,
- gtk_size_request,
- GTK_TYPE_WIDGET);
-
-
-static void
-gtk_size_request_default_init (GtkSizeRequestInterface *iface)
-{
-}
-
-
/* looks for a cached size request for this for_size. If not
* found, returns the oldest entry so it can be overwritten
*
@@ -225,7 +213,7 @@ static GQuark recursion_check_quark = 0;
#endif /* G_DISABLE_CHECKS */
static void
-push_recursion_check (GtkSizeRequest *request,
+push_recursion_check (GtkWidget *request,
GtkSizeGroupMode orientation,
gint for_size)
{
@@ -249,10 +237,10 @@ push_recursion_check (GtkSizeRequest *request,
if (previous_method != NULL)
{
- g_warning ("%s %p: widget tried to gtk_size_request_%s inside "
- " GtkSizeRequest::%s implementation. "
- "Should just invoke GTK_SIZE_REQUEST_GET_IFACE(widget)->%s "
- "directly rather than using gtk_size_request_%s",
+ g_warning ("%s %p: widget tried to gtk_widget_%s inside "
+ " GtkWidget ::%s implementation. "
+ "Should just invoke GTK_WIDGET_GET_CLASS(widget)->%s "
+ "directly rather than using gtk_widget_%s",
G_OBJECT_TYPE_NAME (request), request,
method, previous_method,
method, method);
@@ -263,7 +251,7 @@ push_recursion_check (GtkSizeRequest *request,
}
static void
-pop_recursion_check (GtkSizeRequest *request,
+pop_recursion_check (GtkWidget *request,
GtkSizeGroupMode orientation)
{
#ifndef G_DISABLE_CHECKS
@@ -272,7 +260,7 @@ pop_recursion_check (GtkSizeRequest *request,
}
static void
-compute_size_for_orientation (GtkSizeRequest *request,
+compute_size_for_orientation (GtkWidget *request,
GtkSizeGroupMode orientation,
gint for_size,
gint *minimum_size,
@@ -284,7 +272,7 @@ compute_size_for_orientation (GtkSizeRequest *request,
gboolean found_in_cache = FALSE;
int adjusted_min, adjusted_natural;
- g_return_if_fail (GTK_IS_SIZE_REQUEST (request));
+ g_return_if_fail (GTK_IS_WIDGET (request));
g_return_if_fail (minimum_size != NULL || natural_size != NULL);
widget = GTK_WIDGET (request);
@@ -332,20 +320,20 @@ compute_size_for_orientation (GtkSizeRequest *request,
requisition_size = requisition.width;
if (for_size < 0)
- GTK_SIZE_REQUEST_GET_IFACE (request)->get_width (request, &min_size, &nat_size);
+ GTK_WIDGET_GET_CLASS (request)->get_preferred_width (request, &min_size, &nat_size);
else
- GTK_SIZE_REQUEST_GET_IFACE (request)->get_width_for_height (request, for_size,
- &min_size, &nat_size);
+ GTK_WIDGET_GET_CLASS (request)->get_preferred_width_for_height (request, for_size,
+ &min_size, &nat_size);
}
else
{
requisition_size = requisition.height;
if (for_size < 0)
- GTK_SIZE_REQUEST_GET_IFACE (request)->get_height (request, &min_size, &nat_size);
+ GTK_WIDGET_GET_CLASS (request)->get_preferred_height (request, &min_size, &nat_size);
else
- GTK_SIZE_REQUEST_GET_IFACE (request)->get_height_for_width (request, for_size,
- &min_size, &nat_size);
+ GTK_WIDGET_GET_CLASS (request)->get_preferred_height_for_width (request, for_size,
+ &min_size, &nat_size);
}
pop_recursion_check (request, orientation);
@@ -436,8 +424,8 @@ compute_size_for_orientation (GtkSizeRequest *request,
}
/**
- * gtk_size_request_get_request_mode:
- * @widget: a #GtkSizeRequest instance
+ * gtk_widget_get_preferred:
+ * @widget: a #GtkWidget instance
*
* Gets whether the widget prefers a height-for-width layout
* or a width-for-height layout.
@@ -452,23 +440,23 @@ compute_size_for_orientation (GtkSizeRequest *request,
* Since: 3.0
*/
GtkSizeRequestMode
-gtk_size_request_get_request_mode (GtkSizeRequest *widget)
+gtk_widget_get_request_mode (GtkWidget *widget)
{
- GtkSizeRequestIface *iface;
+ GtkWidgetClass *klass;
- g_return_val_if_fail (GTK_IS_SIZE_REQUEST (widget), GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH);
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH);
- iface = GTK_SIZE_REQUEST_GET_IFACE (widget);
- if (iface->get_request_mode)
- return iface->get_request_mode (widget);
+ klass = GTK_WIDGET_GET_CLASS (widget);
+ if (klass->get_request_mode)
+ return klass->get_request_mode (widget);
/* By default widgets are height-for-width. */
return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
}
/**
- * gtk_size_request_get_width:
- * @widget: a #GtkSizeRequest instance
+ * gtk_widget_get_preferred_width:
+ * @widget: a #GtkWidget instance
* @minimum_width: (out) (allow-none): location to store the minimum width, or %NULL
* @natural_width: (out) (allow-none): location to store the natural width, or %NULL
*
@@ -486,9 +474,9 @@ gtk_size_request_get_request_mode (GtkSizeRequest *widget)
* Since: 3.0
*/
void
-gtk_size_request_get_width (GtkSizeRequest *widget,
- gint *minimum_width,
- gint *natural_width)
+gtk_widget_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width)
{
compute_size_for_orientation (widget, GTK_SIZE_GROUP_HORIZONTAL,
-1, minimum_width, natural_width);
@@ -496,8 +484,8 @@ gtk_size_request_get_width (GtkSizeRequest *widget,
/**
- * gtk_size_request_get_height:
- * @widget: a #GtkSizeRequest instance
+ * gtk_widget_get_preferred_height:
+ * @widget: a #GtkWidget instance
* @minimum_height: (out) (allow-none): location to store the minimum height, or %NULL
* @natural_height: (out) (allow-none): location to store the natural height, or %NULL
*
@@ -514,9 +502,9 @@ gtk_size_request_get_width (GtkSizeRequest *widget,
* Since: 3.0
*/
void
-gtk_size_request_get_height (GtkSizeRequest *widget,
- gint *minimum_height,
- gint *natural_height)
+gtk_widget_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height)
{
compute_size_for_orientation (widget, GTK_SIZE_GROUP_VERTICAL,
-1, minimum_height, natural_height);
@@ -525,8 +513,8 @@ gtk_size_request_get_height (GtkSizeRequest *widget,
/**
- * gtk_size_request_get_width_for_height:
- * @widget: a #GtkSizeRequest instance
+ * gtk_widget_get_preferred_width_for_height:
+ * @widget: a #GtkWidget instance
* @height: the height which is available for allocation
* @minimum_width: (out) (allow-none): location for storing the minimum width, or %NULL
* @natural_width: (out) (allow-none): location for storing the natural width, or %NULL
@@ -543,18 +531,18 @@ gtk_size_request_get_height (GtkSizeRequest *widget,
* Since: 3.0
*/
void
-gtk_size_request_get_width_for_height (GtkSizeRequest *widget,
- gint height,
- gint *minimum_width,
- gint *natural_width)
+gtk_widget_get_preferred_width_for_height (GtkWidget *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width)
{
compute_size_for_orientation (widget, GTK_SIZE_GROUP_HORIZONTAL,
height, minimum_width, natural_width);
}
/**
- * gtk_size_request_get_height_for_width:
- * @widget: a #GtkSizeRequest instance
+ * gtk_widget_get_preferred_height_for_width:
+ * @widget: a #GtkWidget instance
* @width: the width which is available for allocation
* @minimum_height: (out) (allow-none): location for storing the minimum height, or %NULL
* @natural_height: (out) (allow-none): location for storing the natural height, or %NULL
@@ -571,18 +559,18 @@ gtk_size_request_get_width_for_height (GtkSizeRequest *widget,
* Since: 3.0
*/
void
-gtk_size_request_get_height_for_width (GtkSizeRequest *widget,
- gint width,
- gint *minimum_height,
- gint *natural_height)
+gtk_widget_get_preferred_height_for_width (GtkWidget *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height)
{
compute_size_for_orientation (widget, GTK_SIZE_GROUP_VERTICAL,
width, minimum_height, natural_height);
}
/**
- * gtk_size_request_get_size:
- * @widget: a #GtkSizeRequest instance
+ * gtk_widget_get_preferred_size:
+ * @widget: a #GtkWidget instance
* @minimum_size: (out) (allow-none): location for storing the minimum size, or %NULL
* @natural_size: (out) (allow-none): location for storing the natural size, or %NULL
*
@@ -595,49 +583,49 @@ gtk_size_request_get_height_for_width (GtkSizeRequest *widget,
* Since: 3.0
*/
void
-gtk_size_request_get_size (GtkSizeRequest *widget,
- GtkRequisition *minimum_size,
- GtkRequisition *natural_size)
+gtk_widget_get_preferred_size (GtkWidget *widget,
+ GtkRequisition *minimum_size,
+ GtkRequisition *natural_size)
{
gint min_width, nat_width;
gint min_height, nat_height;
- g_return_if_fail (GTK_IS_SIZE_REQUEST (widget));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
- if (gtk_size_request_get_request_mode (widget) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
+ if (gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
{
- gtk_size_request_get_width (widget, &min_width, &nat_width);
+ gtk_widget_get_preferred_width (widget, &min_width, &nat_width);
if (minimum_size)
{
minimum_size->width = min_width;
- gtk_size_request_get_height_for_width (widget, min_width,
- &minimum_size->height, NULL);
+ gtk_widget_get_preferred_height_for_width (widget, min_width,
+ &minimum_size->height, NULL);
}
if (natural_size)
{
natural_size->width = nat_width;
- gtk_size_request_get_height_for_width (widget, nat_width,
- NULL, &natural_size->height);
+ gtk_widget_get_preferred_height_for_width (widget, nat_width,
+ NULL, &natural_size->height);
}
}
else /* GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT */
{
- gtk_size_request_get_height (widget, &min_height, &nat_height);
+ gtk_widget_get_preferred_height (widget, &min_height, &nat_height);
if (minimum_size)
{
minimum_size->height = min_height;
- gtk_size_request_get_width_for_height (widget, min_height,
- &minimum_size->width, NULL);
+ gtk_widget_get_preferred_width_for_height (widget, min_height,
+ &minimum_size->width, NULL);
}
if (natural_size)
{
natural_size->height = nat_height;
- gtk_size_request_get_width_for_height (widget, nat_height,
- NULL, &natural_size->width);
+ gtk_widget_get_preferred_width_for_height (widget, nat_height,
+ NULL, &natural_size->width);
}
}
}
diff --git a/gtk/gtksizerequest.h b/gtk/gtksizerequest.h
index 2724589..22922c2 100644
--- a/gtk/gtksizerequest.h
+++ b/gtk/gtksizerequest.h
@@ -28,14 +28,6 @@
G_BEGIN_DECLS
-#define GTK_TYPE_SIZE_REQUEST (gtk_size_request_get_type ())
-#define GTK_SIZE_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SIZE_REQUEST, GtkSizeRequest))
-#define GTK_SIZE_REQUEST_CLASS(klass) ((GtkSizeRequestIface*)g_type_interface_peek ((klass), GTK_TYPE_SIZE_REQUEST))
-#define GTK_IS_SIZE_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SIZE_REQUEST))
-#define GTK_SIZE_REQUEST_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_SIZE_REQUEST, GtkSizeRequestIface))
-
-typedef struct _GtkSizeRequest GtkSizeRequest;
-typedef struct _GtkSizeRequestIface GtkSizeRequestIface;
typedef struct _GtkRequestedSize GtkRequestedSize;
/**
@@ -56,55 +48,10 @@ struct _GtkRequestedSize
};
-struct _GtkSizeRequestIface
-{
- GTypeInterface g_iface;
-
- /* virtual table */
- GtkSizeRequestMode (* get_request_mode) (GtkSizeRequest *widget);
-
- void (* get_height) (GtkSizeRequest *widget,
- gint *minimum_height,
- gint *natural_height);
- void (* get_width_for_height) (GtkSizeRequest *widget,
- gint height,
- gint *minimum_width,
- gint *natural_width);
- void (* get_width) (GtkSizeRequest *widget,
- gint *minimum_width,
- gint *natural_width);
- void (* get_height_for_width) (GtkSizeRequest *widget,
- gint width,
- gint *minimum_height,
- gint *natural_height);
-};
-
-GType gtk_size_request_get_type (void) G_GNUC_CONST;
-
-GtkSizeRequestMode gtk_size_request_get_request_mode (GtkSizeRequest *widget);
-void gtk_size_request_get_width (GtkSizeRequest *widget,
- gint *minimum_width,
- gint *natural_width);
-void gtk_size_request_get_height_for_width (GtkSizeRequest *widget,
- gint width,
- gint *minimum_height,
- gint *natural_height);
-void gtk_size_request_get_height (GtkSizeRequest *widget,
- gint *minimum_height,
- gint *natural_height);
-void gtk_size_request_get_width_for_height (GtkSizeRequest *widget,
- gint height,
- gint *minimum_width,
- gint *natural_width);
-void gtk_size_request_get_size (GtkSizeRequest *widget,
- GtkRequisition *minimum_size,
- GtkRequisition *natural_size);
-
-
/* General convenience function to aid in allocating natural sizes */
-gint gtk_distribute_natural_allocation (gint extra_space,
- guint n_requested_sizes,
- GtkRequestedSize *sizes);
+gint gtk_distribute_natural_allocation (gint extra_space,
+ guint n_requested_sizes,
+ GtkRequestedSize *sizes);
G_END_DECLS
diff --git a/gtk/gtksocket.c b/gtk/gtksocket.c
index 762cc6e..55719ec 100644
--- a/gtk/gtksocket.c
+++ b/gtk/gtksocket.c
@@ -459,7 +459,7 @@ gtk_socket_size_request (GtkWidget *widget,
if (socket->plug_widget)
{
- gtk_size_request_get_size (GTK_SIZE_REQUEST (socket->plug_widget),
+ gtk_widget_get_preferred_size ( (socket->plug_widget),
requisition, NULL);
}
else
diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c
index 500a8ee..0d29daa 100644
--- a/gtk/gtkspinbutton.c
+++ b/gtk/gtkspinbutton.c
@@ -40,7 +40,6 @@
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtksettings.h"
-#include "gtksizerequest.h"
#include "gtkprivate.h"
#include "gtkintl.h"
@@ -594,7 +593,7 @@ gtk_spin_button_realize (GtkWidget *widget)
arrow_size = spin_button_get_arrow_size (spin_button);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (spin_button), &requisition, NULL);
+ gtk_widget_get_preferred_size (widget, &requisition, NULL);
gtk_widget_get_allocation (widget, &allocation);
gtk_widget_set_events (widget, gtk_widget_get_events (widget) |
@@ -754,7 +753,7 @@ gtk_spin_button_size_allocate (GtkWidget *widget,
arrow_size = spin_button_get_arrow_size (spin);
panel_width = arrow_size + 2 * gtk_widget_get_style (widget)->xthickness;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), &requisition, NULL);
+ gtk_widget_get_preferred_size (widget, &requisition, NULL);
gtk_widget_set_allocation (widget, allocation);
@@ -872,7 +871,7 @@ gtk_spin_button_draw_arrow (GtkSpinButton *spin_button,
widget = GTK_WIDGET (spin_button);
style = gtk_widget_get_style (widget);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), &requisition, NULL);
+ gtk_widget_get_preferred_size (widget, &requisition, NULL);
width = spin_button_get_arrow_size (spin_button) + 2 * style->xthickness;
@@ -979,7 +978,7 @@ gtk_spin_button_enter_notify (GtkWidget *widget,
device = gdk_event_get_device ((GdkEvent *) event);
gdk_window_get_device_position (priv->panel, device, &x, &y, NULL);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), &requisition, NULL);
+ gtk_widget_get_preferred_size (widget, &requisition, NULL);
if (y <= requisition.height / 2)
priv->in_child = GTK_ARROW_UP;
@@ -1160,7 +1159,7 @@ gtk_spin_button_button_press (GtkWidget *widget,
if (GTK_ENTRY (widget)->editable)
gtk_spin_button_update (spin);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), &requisition, NULL);
+ gtk_widget_get_preferred_size (widget, &requisition, NULL);
if (event->y <= requisition.height / 2)
{
@@ -1208,7 +1207,7 @@ gtk_spin_button_button_release (GtkWidget *widget,
{
GtkRequisition requisition;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), &requisition, NULL);
+ gtk_widget_get_preferred_size (widget, &requisition, NULL);
if (event->y >= 0 && event->x >= 0 &&
event->y <= requisition.height &&
@@ -1259,7 +1258,7 @@ gtk_spin_button_motion_notify (GtkWidget *widget,
gdk_event_request_motions (event);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), &requisition, NULL);
+ gtk_widget_get_preferred_size (widget, &requisition, NULL);
if (y <= requisition.height / 2 &&
priv->in_child == GTK_ARROW_DOWN)
diff --git a/gtk/gtkspinner.c b/gtk/gtkspinner.c
index 90b40c9..af96fe9 100644
--- a/gtk/gtkspinner.c
+++ b/gtk/gtkspinner.c
@@ -34,7 +34,6 @@
#include "gtkintl.h"
#include "gtkaccessible.h"
#include "gtkimage.h"
-#include "gtksizerequest.h"
#include "gtkspinner.h"
#include "gtkstyle.h"
@@ -87,13 +86,17 @@ static void gtk_spinner_set_property (GObject *object,
GParamSpec *pspec);
static void gtk_spinner_set_active (GtkSpinner *spinner,
gboolean active);
+static void gtk_spinner_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_spinner_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
+
static AtkObject *gtk_spinner_get_accessible (GtkWidget *widget);
static GType gtk_spinner_accessible_get_type (void);
-static void gtk_spinner_size_request_init (GtkSizeRequestIface *iface);
-G_DEFINE_TYPE_WITH_CODE (GtkSpinner, gtk_spinner, GTK_TYPE_WIDGET,
- G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
- gtk_spinner_size_request_init))
+G_DEFINE_TYPE (GtkSpinner, gtk_spinner, GTK_TYPE_WIDGET)
static void
gtk_spinner_class_init (GtkSpinnerClass *klass)
@@ -113,6 +116,8 @@ gtk_spinner_class_init (GtkSpinnerClass *klass)
widget_class->draw = gtk_spinner_draw;
widget_class->style_set = gtk_spinner_style_set;
widget_class->get_accessible = gtk_spinner_get_accessible;
+ widget_class->get_preferred_width = gtk_spinner_get_preferred_width;
+ widget_class->get_preferred_height = gtk_spinner_get_preferred_height;
/* GtkSpinner:active:
*
@@ -215,9 +220,9 @@ gtk_spinner_init (GtkSpinner *spinner)
}
static void
-gtk_spinner_get_width (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_spinner_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
if (minimum_size)
*minimum_size = SPINNER_SIZE;
@@ -227,9 +232,9 @@ gtk_spinner_get_width (GtkSizeRequest *widget,
}
static void
-gtk_spinner_get_height (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_spinner_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
if (minimum_size)
*minimum_size = SPINNER_SIZE;
@@ -238,14 +243,6 @@ gtk_spinner_get_height (GtkSizeRequest *widget,
*natural_size = SPINNER_SIZE;
}
-static void
-gtk_spinner_size_request_init (GtkSizeRequestIface *iface)
-{
- iface->get_width = gtk_spinner_get_width;
- iface->get_height = gtk_spinner_get_height;
-}
-
-
static gboolean
gtk_spinner_draw (GtkWidget *widget,
cairo_t *cr)
diff --git a/gtk/gtkstatusicon.c b/gtk/gtkstatusicon.c
index 92ae3b9..7e7ab22 100644
--- a/gtk/gtkstatusicon.c
+++ b/gtk/gtkstatusicon.c
@@ -2382,8 +2382,8 @@ gtk_status_icon_position_menu (GtkMenu *menu,
gdk_window_get_origin (window, x, y);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (menu),
- &menu_req, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu),
+ &menu_req, NULL);
gtk_widget_get_allocation (widget, &allocation);
if (_gtk_tray_icon_get_orientation (tray_icon) == GTK_ORIENTATION_VERTICAL)
diff --git a/gtk/gtktable.c b/gtk/gtktable.c
index 9de0ab3..003cff3 100644
--- a/gtk/gtktable.c
+++ b/gtk/gtktable.c
@@ -29,7 +29,6 @@
#include "gtktable.h"
#include "gtkprivate.h"
-#include "gtksizerequest.h"
#include "gtkintl.h"
@@ -1039,7 +1038,7 @@ gtk_table_size_request_init (GtkTable *table)
children = children->next;
if (gtk_widget_get_visible (child->widget))
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child->widget),
+ gtk_widget_get_preferred_size ( (child->widget),
NULL, NULL);
if (child->left_attach == (child->right_attach - 1) && child->xexpand)
@@ -1069,8 +1068,7 @@ gtk_table_size_request_pass1 (GtkTable *table)
{
GtkRequisition child_requisition;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child->widget),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (child->widget, &child_requisition, NULL);
/* Child spans a single column.
*/
@@ -1140,8 +1138,8 @@ gtk_table_size_request_pass3 (GtkTable *table)
{
GtkRequisition child_requisition;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child->widget),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (child->widget,
+ &child_requisition, NULL);
/* Check and see if there is already enough space
* for the child.
@@ -1192,8 +1190,8 @@ gtk_table_size_request_pass3 (GtkTable *table)
{
GtkRequisition child_requisition;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child->widget),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (child->widget,
+ &child_requisition, NULL);
/* Check and see if there is already enough space
* for the child.
@@ -1670,8 +1668,8 @@ gtk_table_size_allocate_pass2 (GtkTable *table)
GtkRequisition child_requisition;
guint border_width;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child->widget),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (child->widget,
+ &child_requisition, NULL);
gtk_widget_get_allocation (GTK_WIDGET (table), &table_allocation);
border_width = gtk_container_get_border_width (GTK_CONTAINER (table));
diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c
index 929810e..c8e0730 100644
--- a/gtk/gtktextlayout.c
+++ b/gtk/gtktextlayout.c
@@ -1614,8 +1614,7 @@ add_child_attrs (GtkTextLayout *layout,
/* Found it */
GtkRequisition req;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
- &req, NULL);
+ gtk_widget_get_preferred_size (child, &req, NULL);
width = req.width;
height = req.height;
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 36d0c79..c6ba991 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -40,7 +40,6 @@
#include "gtkseparatormenuitem.h"
#include "gtksettings.h"
#include "gtkstock.h"
-#include "gtksizerequest.h"
#include "gtktextbufferrichtext.h"
#include "gtktextdisplay.h"
#include "gtktextview.h"
@@ -141,7 +140,7 @@ struct _GtkTextViewPrivate
* FIXME: This could be done in a simpler way by
* consulting the above width/height of the buffer + some
* padding values, however all of this request code needs
- * to be changed to use GtkSizeRequestIface and deserves
+ * to be changed to use GtkWidget Iface and deserves
* more attention.
*/
GtkRequisition cached_size_request;
@@ -3310,11 +3309,9 @@ gtk_text_view_size_request (GtkWidget *widget,
GtkRequisition child_req;
GtkRequisition old_req;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child->widget),
- &old_req, NULL);
+ gtk_widget_get_preferred_size (child->widget, &old_req, NULL);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child->widget),
- &child_req, NULL);
+ gtk_widget_get_preferred_size (child->widget, &child_req, NULL);
/* Invalidate layout lines if required */
if (priv->layout &&
@@ -3327,7 +3324,7 @@ gtk_text_view_size_request (GtkWidget *widget,
{
GtkRequisition child_req;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child->widget),
+ gtk_widget_get_preferred_size ( (child->widget),
&child_req, NULL);
}
@@ -3360,8 +3357,7 @@ gtk_text_view_compute_child_allocation (GtkTextView *text_view,
allocation->x = vc->from_left_of_buffer - text_view->priv->xoffset;
allocation->y = buffer_y - text_view->priv->yoffset;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (vc->widget),
- &req, NULL);
+ gtk_widget_get_preferred_size (vc->widget, &req, NULL);
allocation->width = req.width;
allocation->height = req.height;
}
@@ -3462,8 +3458,7 @@ gtk_text_view_allocate_children (GtkTextView *text_view)
allocation.x = child->x;
allocation.y = child->y;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child->widget),
- &child_req, NULL);
+ gtk_widget_get_preferred_size (child->widget, &child_req, NULL);
allocation.width = child_req.width;
allocation.height = child_req.height;
@@ -8091,7 +8086,7 @@ popup_position_func (GtkMenu *menu,
gtk_text_view_get_visible_rect (text_view, &onscreen_rect);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (text_view->priv->popup_menu),
+ gtk_widget_get_preferred_size ( (text_view->priv->popup_menu),
&req, NULL);
gtk_widget_get_allocation (widget, &allocation);
diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c
index e0692a1..b138e5d 100644
--- a/gtk/gtktoolbar.c
+++ b/gtk/gtktoolbar.c
@@ -53,7 +53,6 @@
#include "gtkseparatormenuitem.h"
#include "gtkseparatortoolitem.h"
#include "gtkstock.h"
-#include "gtksizerequest.h"
#include "gtktoolshell.h"
#include "gtkvbox.h"
#include "gtkprivate.h"
@@ -923,7 +922,7 @@ gtk_toolbar_size_request (GtkWidget *widget,
if (priv->show_arrow)
{
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->arrow_button),
+ gtk_widget_get_preferred_size ( (priv->arrow_button),
&arrow_requisition, NULL);
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
@@ -1453,8 +1452,8 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
border_width += get_internal_padding (toolbar);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->arrow_button),
- &arrow_requisition, NULL);
+ gtk_widget_get_preferred_size (priv->arrow_button,
+ &arrow_requisition, NULL);
shadow_type = get_shadow_type (toolbar);
@@ -2322,8 +2321,8 @@ gtk_toolbar_set_drop_highlight_item (GtkToolbar *toolbar,
g_assert (content);
g_assert (toolbar_content_is_placeholder (content));
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->highlight_tool_item),
- &requisition, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (priv->highlight_tool_item),
+ &requisition, NULL);
toolbar_content_set_expand (content, gtk_tool_item_get_expand (tool_item));
@@ -2587,10 +2586,10 @@ menu_position_func (GtkMenu *menu,
gint monitor_num;
GdkScreen *screen;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->arrow_button),
- &req, NULL);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (menu),
- &menu_req, NULL);
+ gtk_widget_get_preferred_size (priv->arrow_button,
+ &req, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu),
+ &menu_req, NULL);
screen = gtk_widget_get_screen (GTK_WIDGET (menu));
monitor_num = gdk_screen_get_monitor_at_window (screen,
@@ -3322,8 +3321,8 @@ toolbar_content_size_request (ToolbarContent *content,
GtkToolbar *toolbar,
GtkRequisition *requisition)
{
- gtk_size_request_get_size (GTK_SIZE_REQUEST (content->item),
- requisition, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (content->item),
+ requisition, NULL);
if (content->is_placeholder &&
content->disappearing)
{
diff --git a/gtk/gtktoolitem.c b/gtk/gtktoolitem.c
index 2f20218..20da70b 100644
--- a/gtk/gtktoolitem.c
+++ b/gtk/gtktoolitem.c
@@ -502,7 +502,7 @@ gtk_tool_item_size_request (GtkWidget *widget,
child = gtk_bin_get_child (GTK_BIN (widget));
if (child && gtk_widget_get_visible (child))
{
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child),
+ gtk_widget_get_preferred_size ( (child),
requisition, NULL);
}
else
diff --git a/gtk/gtktoolitemgroup.c b/gtk/gtktoolitemgroup.c
index 0b8ad01..aa6558a 100644
--- a/gtk/gtktoolitemgroup.c
+++ b/gtk/gtktoolitemgroup.c
@@ -554,8 +554,8 @@ gtk_tool_item_group_size_request (GtkWidget *widget,
if (priv->children && gtk_tool_item_group_get_label_widget (group))
{
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->header),
- requisition, NULL);
+ gtk_widget_get_preferred_size (priv->header,
+ requisition, NULL);
gtk_widget_show (priv->header);
}
else
@@ -688,8 +688,8 @@ gtk_tool_item_group_real_size_query (GtkWidget *widget,
GtkRequisition req = {0, 0};
guint width;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child->item),
- &req, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (child->item),
+ &req, NULL);
width = udiv (req.width, item_size.width);
col += width;
@@ -747,8 +747,8 @@ gtk_tool_item_group_real_size_query (GtkWidget *widget,
GtkRequisition req = {0, 0};
guint width;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child->item),
- &req, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (child->item),
+ &req, NULL);
width = udiv (req.width, item_size.width);
@@ -803,8 +803,8 @@ gtk_tool_item_group_real_size_query (GtkWidget *widget,
GtkRequisition req = {0, 0};
guint width;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child->item),
- &req, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (child->item),
+ &req, NULL);
width = udiv (req.width, item_size.width);
col += width;
@@ -836,8 +836,8 @@ gtk_tool_item_group_real_size_query (GtkWidget *widget,
{
GtkRequisition child_requisition;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->header),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (priv->header,
+ &child_requisition, NULL);
if (GTK_ORIENTATION_VERTICAL == orientation)
inquery->height += child_requisition.height;
@@ -887,8 +887,8 @@ gtk_tool_item_group_real_size_allocate (GtkWidget *widget,
/* place the header widget */
if (gtk_widget_get_visible (priv->header))
{
- gtk_size_request_get_size (GTK_SIZE_REQUEST (priv->header),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (priv->header,
+ &child_requisition, NULL);
if (GTK_ORIENTATION_VERTICAL == orientation)
{
@@ -972,8 +972,8 @@ gtk_tool_item_group_real_size_allocate (GtkWidget *widget,
if (!child->homogeneous)
{
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child->item),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (child->item),
+ &child_requisition, NULL);
child_requisition.width = MIN (child_requisition.width, item_area.width);
}
@@ -2303,8 +2303,8 @@ _gtk_tool_item_group_item_size_request (GtkToolItemGroup *group,
if (!child->homogeneous && child->expand)
new_row = TRUE;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child->item),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (child->item),
+ &child_requisition, NULL);
if (!homogeneous_only || child->homogeneous)
item_size->width = MAX (item_size->width, child_requisition.width);
@@ -2390,8 +2390,8 @@ _gtk_tool_item_group_get_size_for_limit (GtkToolItemGroup *group,
GtkRequisition requisition;
GtkToolItemGroupPrivate* priv = group->priv;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (group),
- &requisition, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (group),
+ &requisition, NULL);
if (!priv->collapsed || priv->animation_timeout)
{
diff --git a/gtk/gtktoolpalette.c b/gtk/gtktoolpalette.c
index 7871734..397608e 100644
--- a/gtk/gtktoolpalette.c
+++ b/gtk/gtktoolpalette.c
@@ -365,8 +365,8 @@ gtk_tool_palette_size_request (GtkWidget *widget,
if (!group->widget)
continue;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (group->widget),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (group->widget),
+ &child_requisition, NULL);
if (GTK_ORIENTATION_VERTICAL == palette->priv->orientation)
{
diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c
index 77d56f9..faa45a8 100644
--- a/gtk/gtktooltip.c
+++ b/gtk/gtktooltip.c
@@ -938,8 +938,8 @@ gtk_tooltip_position (GtkTooltip *tooltip,
screen = gtk_widget_get_screen (new_tooltip_widget);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (tooltip->current_window),
- &requisition, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (tooltip->current_window),
+ &requisition, NULL);
monitor_num = gdk_screen_get_monitor_at_point (screen,
tooltip->last_x,
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index f1ab6d5..a31771c 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -44,7 +44,6 @@
#include "gtkframe.h"
#include "gtktreemodelsort.h"
#include "gtktooltip.h"
-#include "gtksizerequest.h"
#include "gtkprivate.h"
#define GTK_TREE_VIEW_PRIORITY_VALIDATE (GDK_PRIORITY_REDRAW + 5)
@@ -1972,7 +1971,7 @@ gtk_tree_view_size_request_columns (GtkTreeView *tree_view)
column = list->data;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (column->button),
+ gtk_widget_get_preferred_size ( (column->button),
&requisition, NULL);
column->button_request = requisition.width;
tree_view->priv->header_height = MAX (tree_view->priv->header_height, requisition.height);
@@ -2066,7 +2065,7 @@ gtk_tree_view_size_request (GtkWidget *widget,
tmp_list = tmp_list->next;
if (gtk_widget_get_visible (child->widget))
- gtk_size_request_get_size (GTK_SIZE_REQUEST (child->widget),
+ gtk_widget_get_preferred_size ( (child->widget),
&child_requisition, NULL);
}
}
@@ -5349,7 +5348,7 @@ gtk_tree_view_key_press (GtkWidget *widget,
GtkRequisition button_req;
gint old_width = column->resized_width;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (column->button), &button_req, NULL);
+ gtk_widget_get_preferred_size (column->button, &button_req, NULL);
column->resized_width = MAX (column->resized_width,
column->width);
@@ -6154,8 +6153,8 @@ validate_visible_area (GtkTreeView *tree_view)
* same when we get our next size_allocate. If we don't do this, we'll be
* in an inconsistent state if we call top_row_to_dy. */
- gtk_size_request_get_size (GTK_SIZE_REQUEST (tree_view),
- &requisition, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (tree_view),
+ &requisition, NULL);
tree_view->priv->hadjustment->upper = MAX (tree_view->priv->hadjustment->upper, (gfloat)requisition.width);
tree_view->priv->vadjustment->upper = MAX (tree_view->priv->vadjustment->upper, (gfloat)requisition.height);
gtk_adjustment_changed (tree_view->priv->hadjustment);
@@ -6343,8 +6342,8 @@ do_validate_rows (GtkTreeView *tree_view, gboolean queue_resize)
* same when we get our next size_allocate. If we don't do this, we'll be
* in an inconsistent state when we call top_row_to_dy. */
- gtk_size_request_get_size (GTK_SIZE_REQUEST (tree_view),
- &requisition, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (tree_view),
+ &requisition, NULL);
tree_view->priv->hadjustment->upper = MAX (tree_view->priv->hadjustment->upper, (gfloat)requisition.width);
tree_view->priv->vadjustment->upper = MAX (tree_view->priv->vadjustment->upper, (gfloat)requisition.height);
gtk_adjustment_changed (tree_view->priv->hadjustment);
@@ -6407,8 +6406,8 @@ do_presize_handler (GtkTreeView *tree_view)
{
GtkRequisition requisition;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (tree_view),
- &requisition, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (tree_view),
+ &requisition, NULL);
tree_view->priv->hadjustment->upper = MAX (tree_view->priv->hadjustment->upper, (gfloat)requisition.width);
tree_view->priv->vadjustment->upper = MAX (tree_view->priv->vadjustment->upper, (gfloat)requisition.height);
@@ -10534,7 +10533,7 @@ gtk_tree_view_new_column_width (GtkTreeView *tree_view,
/* Clamp down the value */
if (column->min_width == -1)
{
- gtk_size_request_get_size (GTK_SIZE_REQUEST (column->button), &button_req, NULL);
+ gtk_widget_get_preferred_size (column->button, &button_req, NULL);
width = MAX (button_req.width, width);
}
else
@@ -14210,7 +14209,7 @@ gtk_tree_view_search_position_func (GtkTreeView *tree_view,
gdk_window_get_origin (tree_window, &tree_x, &tree_y);
tree_width = gdk_window_get_width (tree_window);
tree_height = gdk_window_get_height (tree_window);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (search_dialog),
+ gtk_widget_get_preferred_size ( (search_dialog),
&requisition, NULL);
if (tree_x + tree_width > gdk_screen_get_width (screen))
@@ -14828,8 +14827,8 @@ gtk_tree_view_real_start_editing (GtkTreeView *tree_view,
gtk_tree_view_real_set_cursor (tree_view, path, FALSE, TRUE);
cell_area->y += pre_val - (int)tree_view->priv->vadjustment->value;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (cell_editable),
- &requisition, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (cell_editable),
+ &requisition, NULL);
GTK_TREE_VIEW_SET_FLAG (tree_view, GTK_TREE_VIEW_DRAW_KEYFOCUS);
diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c
index 7660e0a..fcf2b8d 100644
--- a/gtk/gtkviewport.c
+++ b/gtk/gtkviewport.c
@@ -26,7 +26,6 @@
#include "config.h"
#include "gtkviewport.h"
-#include "gtksizerequest.h"
#include "gtkintl.h"
#include "gtkmarshalers.h"
#include "gtkprivate.h"
@@ -95,21 +94,18 @@ static void gtk_viewport_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_viewport_adjustment_value_changed (GtkAdjustment *adjustment,
gpointer data);
-static void gtk_viewport_style_set (GtkWidget *widget,
- GtkStyle *previous_style);
+static void gtk_viewport_style_set (GtkWidget *widget,
+ GtkStyle *previous_style);
-static void gtk_viewport_size_request_init (GtkSizeRequestIface *iface);
-static void gtk_viewport_get_width (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_viewport_get_height (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size);
+static void gtk_viewport_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_viewport_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
-G_DEFINE_TYPE_WITH_CODE (GtkViewport, gtk_viewport, GTK_TYPE_BIN,
- G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
- gtk_viewport_size_request_init))
+G_DEFINE_TYPE (GtkViewport, gtk_viewport, GTK_TYPE_BIN)
static void
gtk_viewport_class_init (GtkViewportClass *class)
@@ -134,6 +130,8 @@ gtk_viewport_class_init (GtkViewportClass *class)
widget_class->draw = gtk_viewport_draw;
widget_class->size_allocate = gtk_viewport_size_allocate;
widget_class->style_set = gtk_viewport_style_set;
+ widget_class->get_preferred_width = gtk_viewport_get_preferred_width;
+ widget_class->get_preferred_height = gtk_viewport_get_preferred_height;
container_class->add = gtk_viewport_add;
@@ -445,10 +443,10 @@ viewport_set_hadjustment_values (GtkViewport *viewport,
{
gint minimum_width;
- gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (child),
- view_allocation.height,
- &minimum_width,
- NULL);
+ gtk_widget_get_preferred_width_for_height (child,
+ view_allocation.height,
+ &minimum_width,
+ NULL);
hadjustment->upper = MAX (minimum_width, view_allocation.width);
}
else
@@ -487,10 +485,10 @@ viewport_set_vadjustment_values (GtkViewport *viewport,
{
gint minimum_height;
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child),
- view_allocation.width,
- &minimum_height,
- NULL);
+ gtk_widget_get_preferred_height_for_width (child,
+ view_allocation.width,
+ &minimum_height,
+ NULL);
vadjustment->upper = MAX (minimum_height, view_allocation.height);
}
@@ -941,17 +939,10 @@ gtk_viewport_style_set (GtkWidget *widget,
static void
-gtk_viewport_size_request_init (GtkSizeRequestIface *iface)
-{
- iface->get_width = gtk_viewport_get_width;
- iface->get_height = gtk_viewport_get_height;
-}
-
-static void
-gtk_viewport_get_size (GtkSizeRequest *widget,
- GtkOrientation orientation,
- gint *minimum_size,
- gint *natural_size)
+gtk_viewport_get_preferred_size (GtkWidget *widget,
+ GtkOrientation orientation,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkViewport *viewport = GTK_VIEWPORT (widget);
GtkViewportPrivate *priv = viewport->priv;
@@ -981,9 +972,9 @@ gtk_viewport_get_size (GtkSizeRequest *widget,
if (child && gtk_widget_get_visible (child))
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_size_request_get_width (GTK_SIZE_REQUEST (child), &child_min, &child_nat);
+ gtk_widget_get_preferred_width (child, &child_min, &child_nat);
else
- gtk_size_request_get_height (GTK_SIZE_REQUEST (child), &child_min, &child_nat);
+ gtk_widget_get_preferred_height (child, &child_min, &child_nat);
minimum += child_min;
natural += child_nat;
@@ -997,17 +988,17 @@ gtk_viewport_get_size (GtkSizeRequest *widget,
}
static void
-gtk_viewport_get_width (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_viewport_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_viewport_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
+ gtk_viewport_get_preferred_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
}
static void
-gtk_viewport_get_height (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_viewport_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
- gtk_viewport_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
+ gtk_viewport_get_preferred_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
}
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 937eebb..698fd4d 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -368,6 +368,20 @@ static gint gtk_widget_event_internal (GtkWidget *widget,
GdkEvent *event);
static gboolean gtk_widget_real_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling);
+static void gtk_widget_real_get_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_widget_real_get_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_widget_real_get_height_for_width (GtkWidget *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height);
+static void gtk_widget_real_get_width_for_height (GtkWidget *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width);
static const GtkWidgetAuxInfo* _gtk_widget_get_aux_info_or_defaults (GtkWidget *widget);
static void gtk_widget_aux_info_destroy (GtkWidgetAuxInfo *aux_info);
static AtkObject* gtk_widget_real_get_accessible (GtkWidget *widget);
@@ -408,11 +422,10 @@ static void gtk_widget_buildable_custom_finished (GtkBuildable
static void gtk_widget_buildable_parser_finished (GtkBuildable *buildable,
GtkBuilder *builder);
-static void gtk_widget_size_request_init (GtkSizeRequestIface *iface);
-static void gtk_widget_real_get_width (GtkSizeRequest *widget,
+static void gtk_widget_real_get_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
-static void gtk_widget_real_get_height (GtkSizeRequest *widget,
+static void gtk_widget_real_get_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
@@ -500,13 +513,6 @@ gtk_widget_get_type (void)
NULL /* interface data */
};
- const GInterfaceInfo layout_info =
- {
- (GInterfaceInitFunc) gtk_widget_size_request_init,
- (GInterfaceFinalizeFunc) NULL,
- NULL /* interface data */
- };
-
widget_type = g_type_register_static (GTK_TYPE_OBJECT, "GtkWidget",
&widget_info, G_TYPE_FLAG_ABSTRACT);
@@ -514,8 +520,6 @@ gtk_widget_get_type (void)
&accessibility_info) ;
g_type_add_interface_static (widget_type, GTK_TYPE_BUILDABLE,
&buildable_info) ;
- g_type_add_interface_static (widget_type, GTK_TYPE_SIZE_REQUEST,
- &layout_info) ;
}
return widget_type;
@@ -610,6 +614,10 @@ gtk_widget_class_init (GtkWidgetClass *klass)
klass->unrealize = gtk_widget_real_unrealize;
klass->size_request = gtk_widget_real_size_request;
klass->size_allocate = gtk_widget_real_size_allocate;
+ klass->get_preferred_width = gtk_widget_real_get_width;
+ klass->get_preferred_height = gtk_widget_real_get_height;
+ klass->get_preferred_width_for_height = gtk_widget_real_get_width_for_height;
+ klass->get_preferred_height_for_width = gtk_widget_real_get_height_for_width;
klass->state_changed = NULL;
klass->parent_set = NULL;
klass->hierarchy_changed = NULL;
@@ -4090,7 +4098,7 @@ gtk_widget_queue_resize_no_redraw (GtkWidget *widget)
* Also remember that the size request is not necessarily the size
* a widget will actually be allocated.
*
- * Deprecated: 3.0: Use gtk_size_request_get_size() instead.
+ * Deprecated: 3.0: Use gtk_widget_get_preferred_size() instead.
**/
void
gtk_widget_size_request (GtkWidget *widget,
@@ -4098,7 +4106,7 @@ gtk_widget_size_request (GtkWidget *widget,
{
g_return_if_fail (GTK_IS_WIDGET (widget));
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), requisition, NULL);
+ gtk_widget_get_preferred_size (widget, requisition, NULL);
}
/**
@@ -4126,13 +4134,13 @@ gtk_widget_size_request (GtkWidget *widget,
* gtk_widget_size_request().
*
*
- * Deprecated: 3.0: Use gtk_size_request_get_size() instead.
+ * Deprecated: 3.0: Use gtk_widget_get_preferred_size() instead.
**/
void
gtk_widget_get_child_requisition (GtkWidget *widget,
GtkRequisition *requisition)
{
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), requisition, NULL);
+ gtk_widget_get_preferred_size (widget, requisition, NULL);
}
static gboolean
@@ -4627,7 +4635,7 @@ gtk_widget_real_adjust_size_allocation (GtkWidget *widget,
aux_info = _gtk_widget_get_aux_info_or_defaults (widget);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), &min, &natural);
+ gtk_widget_get_preferred_size (widget, &min, &natural);
get_span_inside_border_horizontal (widget,
aux_info,
@@ -8550,7 +8558,7 @@ gtk_widget_set_size_request (GtkWidget *widget,
* @height indicates that that dimension has not been set explicitly
* and the natural requisition of the widget will be used intead. See
* gtk_widget_set_size_request(). To get the size a widget will
- * actually request, call gtk_size_request_get_size() instead of
+ * actually request, call gtk_size_request_get_preferred_size() instead of
* this function.
**/
void
@@ -11214,13 +11222,10 @@ gtk_widget_buildable_custom_finished (GtkBuildable *buildable,
}
}
-/*
- * GtkSizeRequest implementation
- */
static void
-gtk_widget_real_get_width (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_widget_real_get_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
if (minimum_size)
*minimum_size = 0;
@@ -11230,9 +11235,9 @@ gtk_widget_real_get_width (GtkSizeRequest *widget,
}
static void
-gtk_widget_real_get_height (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_widget_real_get_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
if (minimum_size)
*minimum_size = 0;
@@ -11242,30 +11247,21 @@ gtk_widget_real_get_height (GtkSizeRequest *widget,
}
static void
-gtk_widget_real_get_height_for_width (GtkSizeRequest *layout,
+gtk_widget_real_get_height_for_width (GtkWidget *widget,
gint width,
gint *minimum_height,
gint *natural_height)
{
- GTK_SIZE_REQUEST_GET_IFACE (layout)->get_height(layout, minimum_height, natural_height);
+ GTK_WIDGET_GET_CLASS (widget)->get_preferred_height (widget, minimum_height, natural_height);
}
static void
-gtk_widget_real_get_width_for_height (GtkSizeRequest *layout,
+gtk_widget_real_get_width_for_height (GtkWidget *widget,
gint height,
gint *minimum_width,
gint *natural_width)
{
- GTK_SIZE_REQUEST_GET_IFACE (layout)->get_width(layout, minimum_width, natural_width);
-}
-
-static void
-gtk_widget_size_request_init (GtkSizeRequestIface *iface)
-{
- iface->get_width = gtk_widget_real_get_width;
- iface->get_height = gtk_widget_real_get_height;
- iface->get_width_for_height = gtk_widget_real_get_width_for_height;
- iface->get_height_for_width = gtk_widget_real_get_height_for_width;
+ GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, minimum_width, natural_width);
}
/**
@@ -12112,7 +12108,7 @@ gtk_widget_get_requisition (GtkWidget *widget,
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (requisition != NULL);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), requisition, NULL);
+ gtk_widget_get_preferred_size (widget, requisition, NULL);
}
/**
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 117cd2e..3376466 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -351,6 +351,24 @@ struct _GtkWidgetClass
gboolean (* draw) (GtkWidget *widget,
cairo_t *cr);
+ /* size requests */
+ GtkSizeRequestMode (* get_request_mode) (GtkWidget *widget);
+
+ void (* get_preferred_height) (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height);
+ void (* get_preferred_width_for_height) (GtkWidget *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width);
+ void (* get_preferred_width) (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width);
+ void (* get_preferred_height_for_width) (GtkWidget *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height);
+
/* Mnemonics */
gboolean (* mnemonic_activate) (GtkWidget *widget,
gboolean group_cycling);
@@ -567,6 +585,26 @@ void gtk_widget_size_request (GtkWidget *widget,
#endif
void gtk_widget_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
+
+GtkSizeRequestMode gtk_widget_get_request_mode (GtkWidget *widget);
+void gtk_widget_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width);
+void gtk_widget_get_preferred_height_for_width (GtkWidget *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height);
+void gtk_widget_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height);
+void gtk_widget_get_preferred_width_for_height (GtkWidget *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width);
+void gtk_widget_get_preferred_size (GtkWidget *widget,
+ GtkRequisition *minimum_size,
+ GtkRequisition *natural_size);
+
#ifndef GTK_DISABLE_DEPRECATED
void gtk_widget_get_child_requisition (GtkWidget *widget,
GtkRequisition *requisition);
diff --git a/gtk/gtkwin32embedwidget.c b/gtk/gtkwin32embedwidget.c
index 7daf0ae..1bdd5a9 100644
--- a/gtk/gtkwin32embedwidget.c
+++ b/gtk/gtkwin32embedwidget.c
@@ -188,7 +188,7 @@ gtk_win32_embed_widget_realize (GtkWidget *widget)
GtkRequisition requisition;
GtkAllocation allocation = { 0, 0, 200, 200 };
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget),
+ gtk_widget_get_preferred_size ( (widget),
&requisition, NULL);
if (requisition.width || requisition.height)
{
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 30602c2..29d3427 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -48,7 +48,6 @@
#include "gtkmarshalers.h"
#include "gtkplug.h"
#include "gtkbuildable.h"
-#include "gtksizerequest.h"
#ifdef GDK_WINDOWING_X11
#include "x11/gdkx.h"
@@ -432,19 +431,16 @@ static void gtk_window_buildable_custom_finished (GtkBuildable *buildable,
gpointer user_data);
-static void gtk_window_size_request_init (GtkSizeRequestIface *iface);
-static void gtk_window_get_width (GtkSizeRequest *widget,
+static void gtk_window_get_preferred_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
-static void gtk_window_get_height (GtkSizeRequest *widget,
+static void gtk_window_get_preferred_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
G_DEFINE_TYPE_WITH_CODE (GtkWindow, gtk_window, GTK_TYPE_BIN,
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
- gtk_window_buildable_interface_init)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
- gtk_window_size_request_init))
+ gtk_window_buildable_interface_init))
static void
add_tab_bindings (GtkBindingSet *binding_set,
@@ -553,6 +549,8 @@ gtk_window_class_init (GtkWindowClass *klass)
widget_class->client_event = gtk_window_client_event;
widget_class->focus = gtk_window_focus;
widget_class->draw = gtk_window_draw;
+ widget_class->get_preferred_width = gtk_window_get_preferred_width;
+ widget_class->get_preferred_height = gtk_window_get_preferred_height;
container_class->check_resize = gtk_window_check_resize;
@@ -4658,7 +4656,7 @@ gtk_window_realize (GtkWidget *widget)
GtkRequisition requisition;
GtkAllocation allocation = { 0, 0, 200, 200 };
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget),
+ gtk_widget_get_preferred_size ( (widget),
&requisition, NULL);
if (requisition.width || requisition.height)
{
@@ -5503,18 +5501,10 @@ gtk_window_real_set_focus (GtkWindow *window,
}
-static void
-gtk_window_size_request_init (GtkSizeRequestIface *iface)
-{
- iface->get_width = gtk_window_get_width;
- iface->get_height = gtk_window_get_height;
-}
-
-
static void
-gtk_window_get_width (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_window_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkWindow *window;
GtkWidget *child;
@@ -5530,7 +5520,7 @@ gtk_window_get_width (GtkSizeRequest *widget,
if (child && gtk_widget_get_visible (child))
{
gint child_min, child_nat;
- gtk_size_request_get_width (GTK_SIZE_REQUEST (child), &child_min, &child_nat);
+ gtk_widget_get_preferred_width (child, &child_min, &child_nat);
*minimum_size += child_min;
*natural_size += child_nat;
@@ -5538,9 +5528,9 @@ gtk_window_get_width (GtkSizeRequest *widget,
}
static void
-gtk_window_get_height (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_window_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkWindow *window;
GtkWidget *child;
@@ -5556,7 +5546,7 @@ gtk_window_get_height (GtkSizeRequest *widget,
if (child && gtk_widget_get_visible (child))
{
gint child_min, child_nat;
- gtk_size_request_get_height (GTK_SIZE_REQUEST (child), &child_min, &child_nat);
+ gtk_widget_get_preferred_height (child, &child_min, &child_nat);
*minimum_size += child_min;
*natural_size += child_nat;
@@ -5633,8 +5623,7 @@ gtk_window_compute_configure_request_size (GtkWindow *window,
if (priv->need_default_size)
{
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget),
- &requisition, NULL);
+ gtk_widget_get_preferred_size (widget, &requisition, NULL);
/* Default to requisition */
*width = requisition.width;
@@ -5860,7 +5849,7 @@ gtk_window_compute_configure_request (GtkWindow *window,
screen = gtk_window_check_screen (window);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget),
+ gtk_widget_get_preferred_size ( (widget),
NULL, NULL);
gtk_window_compute_configure_request_size (window, (guint *)&w, (guint *)&h);
@@ -6540,7 +6529,7 @@ gtk_window_constrain_size (GtkWindow *window,
/* Compute the set of geometry hints and flags for a window
* based on the application set geometry, and requisition
- * of the window. gtk_size_request_get_size() must have been
+ * of the window. gtk_size_request_get_preferred_size() must have been
* called first.
*/
static void
@@ -6557,7 +6546,7 @@ gtk_window_compute_hints (GtkWindow *window,
widget = GTK_WIDGET (window);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), &requisition, NULL);
+ gtk_widget_get_preferred_size (widget, &requisition, NULL);
geometry_info = gtk_window_get_geometry_info (GTK_WINDOW (widget), FALSE);
if (geometry_info)
@@ -6587,11 +6576,11 @@ gtk_window_compute_hints (GtkWindow *window,
*
* Finding these answers would be a bit of a mess here. (Bug #68668)
*/
- gtk_size_request_get_size (GTK_SIZE_REQUEST (geometry_info->widget),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (geometry_info->widget,
+ &child_requisition, NULL);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (widget),
- &requisition, NULL);
+ gtk_widget_get_preferred_size (widget,
+ &requisition, NULL);
extra_width = requisition.width - child_requisition.width;
extra_height = requisition.height - child_requisition.height;
}
diff --git a/gtk/gtkwrapbox.c b/gtk/gtkwrapbox.c
index d49cdeb..21cb7f7 100644
--- a/gtk/gtkwrapbox.c
+++ b/gtk/gtkwrapbox.c
@@ -118,28 +118,25 @@ static void gtk_wrap_box_get_child_property (GtkContainer *container,
static GType gtk_wrap_box_child_type (GtkContainer *container);
-/* GtkSizeRequest */
-static void gtk_wrap_box_size_request_init (GtkSizeRequestIface *iface);
-static GtkSizeRequestMode gtk_wrap_box_get_request_mode (GtkSizeRequest *widget);
-static void gtk_wrap_box_get_width (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_wrap_box_get_height (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size);
-static void gtk_wrap_box_get_height_for_width (GtkSizeRequest *box,
- gint width,
- gint *minimum_height,
- gint *natural_height);
-static void gtk_wrap_box_get_width_for_height (GtkSizeRequest *box,
- gint width,
- gint *minimum_height,
- gint *natural_height);
+/* GtkWidget */
+static GtkSizeRequestMode gtk_wrap_box_get_request_mode (GtkWidget *widget);
+static void gtk_wrap_box_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_wrap_box_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void gtk_wrap_box_get_preferred_height_for_width (GtkWidget *box,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height);
+static void gtk_wrap_box_get_preferred_width_for_height (GtkWidget *box,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height);
G_DEFINE_TYPE_WITH_CODE (GtkWrapBox, gtk_wrap_box, GTK_TYPE_CONTAINER,
- G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST,
- gtk_wrap_box_size_request_init)
G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL))
@@ -166,6 +163,11 @@ gtk_wrap_box_class_init (GtkWrapBoxClass *class)
gobject_class->set_property = gtk_wrap_box_set_property;
widget_class->size_allocate = gtk_wrap_box_size_allocate;
+ widget_class->get_request_mode = gtk_wrap_box_get_request_mode;
+ widget_class->get_preferred_width = gtk_wrap_box_get_preferred_width;
+ widget_class->get_preferred_height = gtk_wrap_box_get_preferred_height;
+ widget_class->get_preferred_height_for_width = gtk_wrap_box_get_preferred_height_for_width;
+ widget_class->get_preferred_width_for_height = gtk_wrap_box_get_preferred_width_for_height;
container_class->add = gtk_wrap_box_add;
container_class->remove = gtk_wrap_box_remove;
@@ -492,11 +494,9 @@ get_average_item_size (GtkWrapBox *box,
continue;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_size_request_get_width (GTK_SIZE_REQUEST (child->widget),
- &child_min, &child_nat);
+ gtk_widget_get_preferred_width (child->widget, &child_min, &child_nat);
else
- gtk_size_request_get_height (GTK_SIZE_REQUEST (child->widget),
- &child_min, &child_nat);
+ gtk_widget_get_preferred_height (child->widget, &child_min, &child_nat);
max_min_size = MAX (max_min_size, child_min);
max_nat_size = MAX (max_nat_size, child_nat);
@@ -533,13 +533,13 @@ get_largest_size_for_opposing_orientation (GtkWrapBox *box,
continue;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child->widget),
- item_size,
- &child_min, &child_nat);
+ gtk_widget_get_preferred_height_for_width (child->widget,
+ item_size,
+ &child_min, &child_nat);
else
- gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (child->widget),
- item_size,
- &child_min, &child_nat);
+ gtk_widget_get_preferred_width_for_height (child->widget,
+ item_size,
+ &child_min, &child_nat);
max_min_size = MAX (max_min_size, child_min);
max_nat_size = MAX (max_nat_size, child_nat);
@@ -589,13 +589,13 @@ get_largest_size_for_line_in_opposing_orientation (GtkWrapBox *box,
}
if (orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child->widget),
- this_item_size,
- &child_min, &child_nat);
+ gtk_widget_get_preferred_height_for_width (child->widget,
+ this_item_size,
+ &child_min, &child_nat);
else
- gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (child->widget),
- this_item_size,
- &child_min, &child_nat);
+ gtk_widget_get_preferred_width_for_height (child->widget,
+ this_item_size,
+ &child_min, &child_nat);
max_min_size = MAX (max_min_size, child_min);
max_nat_size = MAX (max_nat_size, child_nat);
@@ -655,11 +655,9 @@ get_largest_size_for_free_line_in_opposing_orientation (GtkWrapBox *box,
continue;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_size_request_get_width (GTK_SIZE_REQUEST (child->widget),
- NULL, &child_size);
+ gtk_widget_get_preferred_width (child->widget, NULL, &child_size);
else
- gtk_size_request_get_height (GTK_SIZE_REQUEST (child->widget),
- NULL, &child_size);
+ gtk_widget_get_preferred_height (child->widget, NULL, &child_size);
if (i > 0)
child_size += spacing;
@@ -688,13 +686,13 @@ get_largest_size_for_free_line_in_opposing_orientation (GtkWrapBox *box,
requested.data = child;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_size_request_get_width (GTK_SIZE_REQUEST (child->widget),
- &requested.minimum_size,
- &requested.natural_size);
+ gtk_widget_get_preferred_width (child->widget,
+ &requested.minimum_size,
+ &requested.natural_size);
else
- gtk_size_request_get_height (GTK_SIZE_REQUEST (child->widget),
- &requested.minimum_size,
- &requested.natural_size);
+ gtk_widget_get_preferred_height (child->widget,
+ &requested.minimum_size,
+ &requested.natural_size);
if (i > 0)
size -= spacing;
@@ -757,13 +755,13 @@ get_largest_size_for_free_line_in_opposing_orientation (GtkWrapBox *box,
}
if (orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child->widget),
- sizes[i].minimum_size,
- &child_min, &child_nat);
+ gtk_widget_get_preferred_height_for_width (child->widget,
+ sizes[i].minimum_size,
+ &child_min, &child_nat);
else
- gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (child->widget),
- sizes[i].minimum_size,
- &child_min, &child_nat);
+ gtk_widget_get_preferred_width_for_height (child->widget,
+ sizes[i].minimum_size,
+ &child_min, &child_nat);
max_min_size = MAX (max_min_size, child_min);
max_nat_size = MAX (max_nat_size, child_nat);
@@ -844,11 +842,11 @@ gather_aligned_item_requests (GtkWrapBox *box,
continue;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_size_request_get_width (GTK_SIZE_REQUEST (child->widget),
- &child_min, &child_nat);
+ gtk_widget_get_preferred_width (child->widget,
+ &child_min, &child_nat);
else
- gtk_size_request_get_height (GTK_SIZE_REQUEST (child->widget),
- &child_min, &child_nat);
+ gtk_widget_get_preferred_height (child->widget,
+ &child_min, &child_nat);
/* Get the index and push it over for the last line when spreading to the end */
position = i % line_length;
@@ -1531,21 +1529,12 @@ gtk_wrap_box_get_child_property (GtkContainer *container,
}
/*****************************************************
- * GtkSizeRequestIface *
+ * size requests *
*****************************************************/
-static void
-gtk_wrap_box_size_request_init (GtkSizeRequestIface *iface)
-{
- iface->get_request_mode = gtk_wrap_box_get_request_mode;
- iface->get_width = gtk_wrap_box_get_width;
- iface->get_height = gtk_wrap_box_get_height;
- iface->get_height_for_width = gtk_wrap_box_get_height_for_width;
- iface->get_width_for_height = gtk_wrap_box_get_width_for_height;
-}
static GtkSizeRequestMode
-gtk_wrap_box_get_request_mode (GtkSizeRequest *widget)
+gtk_wrap_box_get_request_mode (GtkWidget *widget)
{
GtkWrapBox *box = GTK_WRAP_BOX (widget);
GtkWrapBoxPrivate *priv = box->priv;
@@ -1591,11 +1580,11 @@ get_largest_line_length (GtkWrapBox *box,
continue;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_size_request_get_width (GTK_SIZE_REQUEST (child->widget),
- &child_min, &child_nat);
+ gtk_widget_get_preferred_width (child->widget,
+ &child_min, &child_nat);
else /* GTK_ORIENTATION_VERTICAL */
- gtk_size_request_get_height (GTK_SIZE_REQUEST (child->widget),
- &child_min, &child_nat);
+ gtk_widget_get_preferred_height (child->widget,
+ &child_min, &child_nat);
line_min += child_min;
line_nat += child_nat;
@@ -1651,11 +1640,11 @@ get_largest_aligned_line_length (GtkWrapBox *box,
continue;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_size_request_get_width (GTK_SIZE_REQUEST (child->widget),
- &child_min, &child_nat);
+ gtk_widget_get_preferred_width (child->widget,
+ &child_min, &child_nat);
else /* GTK_ORIENTATION_VERTICAL */
- gtk_size_request_get_height (GTK_SIZE_REQUEST (child->widget),
- &child_min, &child_nat);
+ gtk_widget_get_preferred_height (child->widget,
+ &child_min, &child_nat);
aligned_item_sizes[i % line_length].minimum_size =
MAX (aligned_item_sizes[i % line_length].minimum_size, child_min);
@@ -1687,9 +1676,9 @@ get_largest_aligned_line_length (GtkWrapBox *box,
static void
-gtk_wrap_box_get_width (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_wrap_box_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkWrapBox *box = GTK_WRAP_BOX (widget);
GtkWrapBoxPrivate *priv = box->priv;
@@ -1764,8 +1753,9 @@ gtk_wrap_box_get_width (GtkSizeRequest *widget,
/* Return the width for the minimum height */
gint min_height;
- GTK_SIZE_REQUEST_GET_IFACE (widget)->get_height (widget, &min_height, NULL);
- GTK_SIZE_REQUEST_GET_IFACE (widget)->get_width_for_height (widget, min_height, &min_width, &nat_width);
+ GTK_WIDGET_GET_CLASS (widget)->get_preferred_height (widget, &min_height, NULL);
+ GTK_WIDGET_GET_CLASS (widget)->get_preferred_width_for_height (widget, min_height,
+ &min_width, &nat_width);
}
@@ -1777,9 +1767,9 @@ gtk_wrap_box_get_width (GtkSizeRequest *widget,
}
static void
-gtk_wrap_box_get_height (GtkSizeRequest *widget,
- gint *minimum_size,
- gint *natural_size)
+gtk_wrap_box_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
{
GtkWrapBox *box = GTK_WRAP_BOX (widget);
GtkWrapBoxPrivate *priv = box->priv;
@@ -1795,8 +1785,9 @@ gtk_wrap_box_get_height (GtkSizeRequest *widget,
/* Return the height for the minimum width */
gint min_width;
- GTK_SIZE_REQUEST_GET_IFACE (widget)->get_width (widget, &min_width, NULL);
- GTK_SIZE_REQUEST_GET_IFACE (widget)->get_height_for_width (widget, min_width, &min_height, &nat_height);
+ GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, &min_width, NULL);
+ GTK_WIDGET_GET_CLASS (widget)->get_preferred_height_for_width (widget, min_width,
+ &min_height, &nat_height);
}
else /* GTK_ORIENTATION_VERTICAL */
{
@@ -1867,10 +1858,10 @@ gtk_wrap_box_get_height (GtkSizeRequest *widget,
}
static void
-gtk_wrap_box_get_height_for_width (GtkSizeRequest *widget,
- gint width,
- gint *minimum_height,
- gint *natural_height)
+gtk_wrap_box_get_preferred_height_for_width (GtkWidget *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height)
{
GtkWrapBox *box = GTK_WRAP_BOX (widget);
GtkWrapBoxPrivate *priv = box->priv;
@@ -1891,7 +1882,7 @@ gtk_wrap_box_get_height_for_width (GtkSizeRequest *widget,
n_children = get_visible_children (box);
/* Make sure its no smaller than the minimum */
- GTK_SIZE_REQUEST_GET_IFACE (widget)->get_width (widget, &min_width, NULL);
+ GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, &min_width, NULL);
avail_size = MAX (width, min_width);
@@ -2032,7 +2023,7 @@ gtk_wrap_box_get_height_for_width (GtkSizeRequest *widget,
else /* GTK_ORIENTATION_VERTICAL */
{
/* Return the minimum height */
- GTK_SIZE_REQUEST_GET_IFACE (widget)->get_height (widget, &min_height, &nat_height);
+ GTK_WIDGET_GET_CLASS (widget)->get_preferred_height (widget, &min_height, &nat_height);
}
if (minimum_height)
@@ -2043,10 +2034,10 @@ gtk_wrap_box_get_height_for_width (GtkSizeRequest *widget,
}
static void
-gtk_wrap_box_get_width_for_height (GtkSizeRequest *widget,
- gint height,
- gint *minimum_width,
- gint *natural_width)
+gtk_wrap_box_get_preferred_width_for_height (GtkWidget *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width)
{
GtkWrapBox *box = GTK_WRAP_BOX (widget);
GtkWrapBoxPrivate *priv = box->priv;
@@ -2063,7 +2054,7 @@ gtk_wrap_box_get_width_for_height (GtkSizeRequest *widget,
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{
/* Return the minimum width */
- GTK_SIZE_REQUEST_GET_IFACE (widget)->get_width (widget, &min_width, &nat_width);
+ GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, &min_width, &nat_width);
}
else /* GTK_ORIENTATION_VERTICAL */
{
@@ -2072,7 +2063,7 @@ gtk_wrap_box_get_width_for_height (GtkSizeRequest *widget,
n_children = get_visible_children (box);
/* Make sure its no smaller than the minimum */
- GTK_SIZE_REQUEST_GET_IFACE (widget)->get_height (widget, &min_height, NULL);
+ GTK_WIDGET_GET_CLASS (widget)->get_preferred_height (widget, &min_height, NULL);
avail_size = MAX (height, min_height);
diff --git a/modules/input/gtkimcontextxim.c b/modules/input/gtkimcontextxim.c
index 612a8ce..df00bec 100644
--- a/modules/input/gtkimcontextxim.c
+++ b/modules/input/gtkimcontextxim.c
@@ -1695,7 +1695,7 @@ on_status_toplevel_configure (GtkWidget *toplevel,
gdk_window_get_frame_extents (gtk_widget_get_window (toplevel),
&rect);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (status_window->window),
+ gtk_widget_get_preferred_size ( (status_window->window),
&requisition, NULL);
if (rect.y + rect.height + requisition.height < height)
diff --git a/tests/gtkoffscreenbox.c b/tests/gtkoffscreenbox.c
index c8e6250..a9722ef 100644
--- a/tests/gtkoffscreenbox.c
+++ b/tests/gtkoffscreenbox.c
@@ -478,7 +478,7 @@ gtk_offscreen_box_size_request (GtkWidget *widget,
{
GtkRequisition child_requisition;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (offscreen_box->child1),
+ gtk_widget_get_preferred_size ( (offscreen_box->child1),
&child_requisition, NULL);
w = MAX (w, CHILD1_SIZE_SCALE * child_requisition.width);
@@ -489,7 +489,7 @@ gtk_offscreen_box_size_request (GtkWidget *widget,
{
GtkRequisition child_requisition;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (offscreen_box->child2),
+ gtk_widget_get_preferred_size ( (offscreen_box->child2),
&child_requisition, NULL);
w = MAX (w, CHILD2_SIZE_SCALE * child_requisition.width);
@@ -529,8 +529,8 @@ gtk_offscreen_box_size_allocate (GtkWidget *widget,
GtkRequisition child_requisition;
GtkAllocation child_allocation;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (offscreen_box->child1),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (offscreen_box->child1,
+ &child_requisition, NULL);
child_allocation.x = child_requisition.width * (CHILD1_SIZE_SCALE - 1.0) / 2;
child_allocation.y = start_y + child_requisition.height * (CHILD1_SIZE_SCALE - 1.0) / 2;
child_allocation.width = MAX (1, (gint) allocation->width - 2 * border_width);
@@ -554,8 +554,8 @@ gtk_offscreen_box_size_allocate (GtkWidget *widget,
GtkRequisition child_requisition;
GtkAllocation child_allocation;
- gtk_size_request_get_size (GTK_SIZE_REQUEST (offscreen_box->child2),
- &child_requisition, NULL);
+ gtk_widget_get_preferred_size (offscreen_box->child2,
+ &child_requisition, NULL);
child_allocation.x = child_requisition.width * (CHILD2_SIZE_SCALE - 1.0) / 2;
child_allocation.y = start_y + child_requisition.height * (CHILD2_SIZE_SCALE - 1.0) / 2;
child_allocation.width = MAX (1, (gint) allocation->width - 2 * border_width);
diff --git a/tests/testellipsise.c b/tests/testellipsise.c
index e4d2b8c..6124033 100644
--- a/tests/testellipsise.c
+++ b/tests/testellipsise.c
@@ -84,8 +84,7 @@ ebox_draw_cb (GtkWidget *widget,
gtk_widget_translate_coordinates (label, widget, 0, 0, &x, &y);
layout = gtk_widget_create_pango_layout (widget, "");
- gtk_size_request_get_size (GTK_SIZE_REQUEST (label),
- &minimum_size, &natural_size);
+ gtk_widget_get_preferred_size (label, &minimum_size, &natural_size);
pango_layout_set_markup (layout,
"<span color='#c33'>\342\227\217 requisition</span>\n"
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 66efa9e..686cfa9 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -2402,7 +2402,7 @@ create_rotated_text (GtkWidget *widget)
gtk_widget_show_all (gtk_bin_get_child (GTK_BIN (window)));
gtk_widget_set_size_request (drawing_area, DEFAULT_TEXT_RADIUS * 2, DEFAULT_TEXT_RADIUS * 2);
- gtk_size_request_get_size (GTK_SIZE_REQUEST (window),
+ gtk_widget_get_preferred_size ( (window),
&requisition, NULL);
gtk_widget_set_size_request (drawing_area, -1, -1);
gtk_window_resize (GTK_WINDOW (window), requisition.width, requisition.height);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]