diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c index d337d712ae..62615cc711 100644 --- a/gtk/gtkmenubar.c +++ b/gtk/gtkmenubar.c @@ -50,6 +50,7 @@ #include "gtkintl.h" #include "gtkprivate.h" #include "gtktypebuiltins.h" +#include "gtkwidgetprivate.h" /* Properties */ enum { @@ -308,25 +309,6 @@ gtk_menu_bar_get_property (GObject *object, } } -static void -get_preferred_size_for_size (GtkWidget *widget, - GtkOrientation orientation, - gint size, - gint *minimum, - gint *natural) -{ - if (orientation == GTK_ORIENTATION_HORIZONTAL) - if (size < 0) - gtk_widget_get_preferred_width (widget, minimum, natural); - else - gtk_widget_get_preferred_width_for_height (widget, size, minimum, natural); - else - if (size < 0) - gtk_widget_get_preferred_height (widget, minimum, natural); - else - gtk_widget_get_preferred_height_for_width (widget, size, minimum, natural); -} - static void gtk_menu_bar_size_request (GtkWidget *widget, GtkOrientation orientation, @@ -374,7 +356,7 @@ gtk_menu_bar_size_request (GtkWidget *widget, if (gtk_widget_get_visible (child)) { - get_preferred_size_for_size (child, orientation, size, &child_minimum, &child_natural); + _gtk_widget_get_preferred_size_for_size (child, orientation, size, &child_minimum, &child_natural); if (use_toggle_size) { diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 5f0ce009a8..2ac7936af3 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -2214,25 +2214,6 @@ gtk_notebook_get_preferred_tabs_size (GtkNotebook *notebook, } } -static void -get_preferred_size_for_size (GtkWidget *widget, - GtkOrientation orientation, - gint size, - gint *minimum, - gint *natural) -{ - if (orientation == GTK_ORIENTATION_HORIZONTAL) - if (size < 0) - gtk_widget_get_preferred_width (widget, minimum, natural); - else - gtk_widget_get_preferred_width_for_height (widget, size, minimum, natural); - else - if (size < 0) - gtk_widget_get_preferred_height (widget, minimum, natural); - else - gtk_widget_get_preferred_height_for_width (widget, size, minimum, natural); -} - static void get_padding_and_border (GtkNotebook *notebook, GtkBorder *border) @@ -2282,11 +2263,11 @@ gtk_notebook_size_request (GtkWidget *widget, if (gtk_widget_get_visible (page->child)) { vis_pages++; - get_preferred_size_for_size (page->child, - orientation, - size, - &child_minimum, - &child_natural); + _gtk_widget_get_preferred_size_for_size (page->child, + orientation, + size, + &child_minimum, + &child_natural); *minimum = MAX (*minimum, child_minimum); *natural = MAX (*natural, child_natural); diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c index 7c5ec381f3..4d16e4fe02 100644 --- a/gtk/gtkpaned.c +++ b/gtk/gtkpaned.c @@ -35,6 +35,7 @@ #include "gtkorientableprivate.h" #include "gtkprivate.h" #include "gtkintl.h" +#include "gtkwidgetprivate.h" #include "a11y/gtkpanedaccessible.h" /** @@ -869,25 +870,6 @@ gtk_paned_finalize (GObject *object) G_OBJECT_CLASS (gtk_paned_parent_class)->finalize (object); } -static void -get_preferred_size_for_size (GtkWidget *widget, - GtkOrientation orientation, - gint size, - gint *minimum, - gint *natural) -{ - if (orientation == GTK_ORIENTATION_HORIZONTAL) - if (size < 0) - gtk_widget_get_preferred_width (widget, minimum, natural); - else - gtk_widget_get_preferred_width_for_height (widget, size, minimum, natural); - else - if (size < 0) - gtk_widget_get_preferred_height (widget, minimum, natural); - else - gtk_widget_get_preferred_height_for_width (widget, size, minimum, natural); -} - static void gtk_paned_get_preferred_size (GtkWidget *widget, GtkOrientation orientation, @@ -903,7 +885,7 @@ gtk_paned_get_preferred_size (GtkWidget *widget, if (priv->child1 && gtk_widget_get_visible (priv->child1)) { - get_preferred_size_for_size (priv->child1, orientation, size, &child_min, &child_nat); + _gtk_widget_get_preferred_size_for_size (priv->child1, orientation, size, &child_min, &child_nat); if (priv->child1_shrink && priv->orientation == orientation) *minimum = 0; else @@ -913,7 +895,7 @@ gtk_paned_get_preferred_size (GtkWidget *widget, if (priv->child2 && gtk_widget_get_visible (priv->child2)) { - get_preferred_size_for_size (priv->child2, orientation, size, &child_min, &child_nat); + _gtk_widget_get_preferred_size_for_size (priv->child2, orientation, size, &child_min, &child_nat); if (priv->orientation == orientation) { diff --git a/gtk/gtksizerequest.c b/gtk/gtksizerequest.c index 54a63f1338..36d24f2f0c 100644 --- a/gtk/gtksizerequest.c +++ b/gtk/gtksizerequest.c @@ -657,3 +657,26 @@ gtk_distribute_natural_allocation (gint extra_space, return extra_space; } + +void +_gtk_widget_get_preferred_size_for_size (GtkWidget *widget, + GtkOrientation orientation, + gint size, + gint *minimum, + gint *natural) +{ + g_return_if_fail (GTK_IS_WIDGET (widget)); + g_return_if_fail (size >= -1); + + if (orientation == GTK_ORIENTATION_HORIZONTAL) + if (size < 0) + gtk_widget_get_preferred_width (widget, minimum, natural); + else + gtk_widget_get_preferred_width_for_height (widget, size, minimum, natural); + else + if (size < 0) + gtk_widget_get_preferred_height (widget, minimum, natural); + else + gtk_widget_get_preferred_height_for_width (widget, size, minimum, natural); +} + diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h index 4542580e41..84cad6429f 100644 --- a/gtk/gtkwidgetprivate.h +++ b/gtk/gtkwidgetprivate.h @@ -70,6 +70,11 @@ void _gtk_widget_compute_size_for_orientation (GtkWidget *widget, gint for_size, gint *minimum_size, gint *natural_size); +void _gtk_widget_get_preferred_size_for_size (GtkWidget *widget, + GtkOrientation orientation, + gint size, + gint *minimum, + gint *natural); gboolean _gtk_widget_get_translation_to_window (GtkWidget *widget, GdkWindow *window,