summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2013-04-22 17:37:05 -0400
committerBenjamin Otte <otte@redhat.com>2013-04-22 18:29:01 -0400
commit3450388ff03794ef4c4e7c24e91bfb40798dbec5 (patch)
tree5e1ac6eb992437e320d57f466e481e831b9d1b53
parent009aadf378150c32aed9347bbffffda2ca0af6f2 (diff)
downloadgtk+-3450388ff03794ef4c4e7c24e91bfb40798dbec5.tar.gz
sizerequest: Split out a common function
-rw-r--r--gtk/gtkmenubar.c22
-rw-r--r--gtk/gtknotebook.c29
-rw-r--r--gtk/gtkpaned.c24
-rw-r--r--gtk/gtksizerequest.c23
-rw-r--r--gtk/gtkwidgetprivate.h5
5 files changed, 38 insertions, 65 deletions
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 {
@@ -309,25 +310,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,
gint size,
@@ -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
@@ -2215,25 +2215,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"
/**
@@ -870,25 +871,6 @@ gtk_paned_finalize (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_paned_get_preferred_size (GtkWidget *widget,
GtkOrientation orientation,
gint size,
@@ -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,