forked from AuroraMiddleware/gtk
sizerequest: Split out a common function
This commit is contained in:
parent
009aadf378
commit
3450388ff0
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user