Remove gtk_widget_get_preferred_*

They are unnecessary now that we have gtk_widget_measure.
This commit is contained in:
Timm Bäder 2017-05-02 21:50:50 +02:00
parent 1a7a089e2c
commit 3d21128dbb
4 changed files with 18 additions and 177 deletions

View File

@ -4661,11 +4661,6 @@ gtk_requisition_free
<SUBSECTION Width-for-Height>
GtkSizeRequestMode
GtkRequestedSize
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_preferred_height_and_baseline_for_width
gtk_widget_get_request_mode
gtk_widget_get_preferred_size
gtk_distribute_natural_allocation

View File

@ -445,149 +445,6 @@ gtk_widget_get_request_mode (GtkWidget *widget)
return cache->request_mode;
}
/**
* 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
*
* Retrieves a widgets initial minimum and natural width.
*
* This call is specific to height-for-width requests.
*
* The returned request will be modified by the
* GtkWidgetClass::adjust_size_request virtual method and by any
* #GtkSizeGroups that have been applied. That is, the returned request
* is the one that should be used for layout, not necessarily the one
* returned by the widget itself.
*
* Since: 3.0
*/
void
gtk_widget_get_preferred_width (GtkWidget *widget,
gint *minimum_width,
gint *natural_width)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (minimum_width != NULL || natural_width != NULL);
gtk_widget_measure (widget,
GTK_ORIENTATION_HORIZONTAL,
-1,
minimum_width,
natural_width,
NULL, NULL);
}
/**
* 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
*
* Retrieves a widgets initial minimum and natural height.
*
* This call is specific to width-for-height requests.
*
* The returned request will be modified by the
* GtkWidgetClass::adjust_size_request virtual method and by any
* #GtkSizeGroups that have been applied. That is, the returned request
* is the one that should be used for layout, not necessarily the one
* returned by the widget itself.
*
* Since: 3.0
*/
void
gtk_widget_get_preferred_height (GtkWidget *widget,
gint *minimum_height,
gint *natural_height)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (minimum_height != NULL || natural_height != NULL);
gtk_widget_measure (widget,
GTK_ORIENTATION_VERTICAL,
-1,
minimum_height,
natural_height,
NULL, NULL);
}
/**
* 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
*
* Retrieves a widgets minimum and natural width if it would be given
* the specified @height.
*
* The returned request will be modified by the
* GtkWidgetClass::adjust_size_request virtual method and by any
* #GtkSizeGroups that have been applied. That is, the returned request
* is the one that should be used for layout, not necessarily the one
* returned by the widget itself.
*
* Since: 3.0
*/
void
gtk_widget_get_preferred_width_for_height (GtkWidget *widget,
gint height,
gint *minimum_width,
gint *natural_width)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (minimum_width != NULL || natural_width != NULL);
g_return_if_fail (height >= 0);
gtk_widget_measure (widget,
GTK_ORIENTATION_HORIZONTAL,
height,
minimum_width,
natural_width,
NULL, NULL);
}
/**
* 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
*
* Retrieves a widgets minimum and natural height if it would be given
* the specified @width.
*
* The returned request will be modified by the
* GtkWidgetClass::adjust_size_request virtual method and by any
* #GtkSizeGroups that have been applied. That is, the returned request
* is the one that should be used for layout, not necessarily the one
* returned by the widget itself.
*
* Since: 3.0
*/
void
gtk_widget_get_preferred_height_for_width (GtkWidget *widget,
gint width,
gint *minimum_height,
gint *natural_height)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (minimum_height != NULL || natural_height != NULL);
g_return_if_fail (width >= 0);
gtk_widget_measure (widget,
GTK_ORIENTATION_VERTICAL,
width,
minimum_height,
natural_height,
NULL, NULL);
}
/*
* _gtk_widget_get_preferred_size_and_baseline:
* @widget: a #GtkWidget instance
@ -622,7 +479,8 @@ _gtk_widget_get_preferred_size_and_baseline (GtkWidget *widget,
if (gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
{
gtk_widget_get_preferred_width (widget, &min_width, &nat_width);
gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL, -1,
&min_width, &nat_width, NULL, NULL);
if (minimum_size)
{
@ -648,15 +506,15 @@ _gtk_widget_get_preferred_size_and_baseline (GtkWidget *widget,
if (minimum_size)
{
minimum_size->height = min_height;
gtk_widget_get_preferred_width_for_height (widget, min_height,
&minimum_size->width, NULL);
gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL, min_height,
&minimum_size->width, NULL, NULL, NULL);
}
if (natural_size)
{
natural_size->height = nat_height;
gtk_widget_get_preferred_width_for_height (widget, nat_height,
NULL, &natural_size->width);
gtk_widget_measure (widget, GTK_ORIENTATION_HORIZONTAL, nat_height,
NULL, &natural_size->width, NULL, NULL);
}
}
}

View File

@ -551,24 +551,6 @@ void gtk_widget_size_allocate_with_baseline (GtkWidget *widget,
GDK_AVAILABLE_IN_ALL
GtkSizeRequestMode gtk_widget_get_request_mode (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_widget_get_preferred_width (GtkWidget *widget,
gint *minimum_width,
gint *natural_width);
GDK_AVAILABLE_IN_ALL
void gtk_widget_get_preferred_height_for_width (GtkWidget *widget,
gint width,
gint *minimum_height,
gint *natural_height);
GDK_AVAILABLE_IN_ALL
void gtk_widget_get_preferred_height (GtkWidget *widget,
gint *minimum_height,
gint *natural_height);
GDK_AVAILABLE_IN_ALL
void gtk_widget_get_preferred_width_for_height (GtkWidget *widget,
gint height,
gint *minimum_width,
gint *natural_width);
GDK_AVAILABLE_IN_3_90
void gtk_widget_measure (GtkWidget *widget,
GtkOrientation orientation,

View File

@ -33,7 +33,8 @@ test_size (GtkOrientation orientation,
{
gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW (scrolledwindow), MIN_SIZE);
gtk_widget_get_preferred_width (scrolledwindow, &size, NULL);
gtk_widget_measure (scrolledwindow, GTK_ORIENTATION_HORIZONTAL, -1,
&size, NULL, NULL, NULL);
g_assert_cmpint (size, ==, MIN_SIZE);
}
@ -47,8 +48,10 @@ test_size (GtkOrientation orientation,
* Here, the content is purposely bigger than the scrolled window,
* so it should grow up to max-content-width.
*/
gtk_widget_get_preferred_width (scrolledwindow, NULL, &size);
gtk_widget_get_preferred_width (box, &child_size, NULL);
gtk_widget_measure (scrolledwindow, GTK_ORIENTATION_HORIZONTAL, -1,
NULL, &size, NULL, NULL);
gtk_widget_measure (box, GTK_ORIENTATION_HORIZONTAL, -1,
&child_size, NULL, NULL, NULL);
g_assert_cmpint (child_size, ==, BOX_SIZE);
g_assert_cmpint (size, ==, MAX_SIZE);
@ -61,7 +64,8 @@ test_size (GtkOrientation orientation,
{
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (scrolledwindow), MIN_SIZE);
gtk_widget_get_preferred_height (scrolledwindow, &size, NULL);
gtk_widget_measure (scrolledwindow, GTK_ORIENTATION_HORIZONTAL, -1,
&size, NULL, NULL, NULL);
g_assert_cmpint (size, ==, MIN_SIZE);
}
@ -75,8 +79,10 @@ test_size (GtkOrientation orientation,
* Here, the content is purposely bigger than the scrolled window,
* so it should grow up to max-content-height.
*/
gtk_widget_get_preferred_height (scrolledwindow, NULL, &size);
gtk_widget_get_preferred_height (box, &child_size, NULL);
gtk_widget_measure (scrolledwindow, GTK_ORIENTATION_VERTICAL, -1,
NULL, &size, NULL, NULL);
gtk_widget_measure (box, GTK_ORIENTATION_VERTICAL, -1,
&child_size, NULL, NULL, NULL);
g_assert_cmpint (child_size, ==, BOX_SIZE);
g_assert_cmpint (size, ==, MAX_SIZE);