mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-09-22 23:04:07 +00:00
gtkbin: Move public members to private structure
This commit is contained in:
parent
63d3b197c2
commit
80df961edb
75
gtk/gtkbin.c
75
gtk/gtkbin.c
@ -43,6 +43,11 @@
|
||||
#include "gtkintl.h"
|
||||
|
||||
|
||||
struct _GtkBinPriv
|
||||
{
|
||||
GtkWidget *child;
|
||||
};
|
||||
|
||||
static void gtk_bin_add (GtkContainer *container,
|
||||
GtkWidget *widget);
|
||||
static void gtk_bin_remove (GtkContainer *container,
|
||||
@ -82,21 +87,32 @@ gtk_bin_class_init (GtkBinClass *class)
|
||||
container_class->remove = gtk_bin_remove;
|
||||
container_class->forall = gtk_bin_forall;
|
||||
container_class->child_type = gtk_bin_child_type;
|
||||
|
||||
g_type_class_add_private (class, sizeof (GtkBinPriv));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_bin_init (GtkBin *bin)
|
||||
{
|
||||
GtkBinPriv *priv;
|
||||
|
||||
bin->priv = G_TYPE_INSTANCE_GET_PRIVATE (bin,
|
||||
GTK_TYPE_BIN,
|
||||
GtkBinPriv);
|
||||
priv = bin->priv;
|
||||
|
||||
gtk_widget_set_has_window (GTK_WIDGET (bin), FALSE);
|
||||
|
||||
bin->child = NULL;
|
||||
priv->child = NULL;
|
||||
}
|
||||
|
||||
|
||||
static GType
|
||||
gtk_bin_child_type (GtkContainer *container)
|
||||
{
|
||||
if (!GTK_BIN (container)->child)
|
||||
GtkBinPriv *priv = GTK_BIN (container)->priv;
|
||||
|
||||
if (!priv->child)
|
||||
return GTK_TYPE_WIDGET;
|
||||
else
|
||||
return G_TYPE_NONE;
|
||||
@ -107,8 +123,9 @@ gtk_bin_add (GtkContainer *container,
|
||||
GtkWidget *child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN (container);
|
||||
GtkBinPriv *priv = bin->priv;
|
||||
|
||||
if (bin->child != NULL)
|
||||
if (priv->child != NULL)
|
||||
{
|
||||
g_warning ("Attempting to add a widget with type %s to a %s, "
|
||||
"but as a GtkBin subclass a %s can only contain one widget at a time; "
|
||||
@ -116,12 +133,12 @@ gtk_bin_add (GtkContainer *container,
|
||||
g_type_name (G_OBJECT_TYPE (child)),
|
||||
g_type_name (G_OBJECT_TYPE (bin)),
|
||||
g_type_name (G_OBJECT_TYPE (bin)),
|
||||
g_type_name (G_OBJECT_TYPE (bin->child)));
|
||||
g_type_name (G_OBJECT_TYPE (priv->child)));
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_widget_set_parent (child, GTK_WIDGET (bin));
|
||||
bin->child = child;
|
||||
priv->child = child;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -129,14 +146,15 @@ gtk_bin_remove (GtkContainer *container,
|
||||
GtkWidget *child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN (container);
|
||||
GtkBinPriv *priv = bin->priv;
|
||||
gboolean widget_was_visible;
|
||||
|
||||
g_return_if_fail (bin->child == child);
|
||||
g_return_if_fail (priv->child == child);
|
||||
|
||||
widget_was_visible = gtk_widget_get_visible (child);
|
||||
|
||||
gtk_widget_unparent (child);
|
||||
bin->child = NULL;
|
||||
priv->child = NULL;
|
||||
|
||||
/* queue resize regardless of gtk_widget_get_visible (container),
|
||||
* since that's what is needed by toplevels, which derive from GtkBin.
|
||||
@ -152,9 +170,10 @@ gtk_bin_forall (GtkContainer *container,
|
||||
gpointer callback_data)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN (container);
|
||||
GtkBinPriv *priv = bin->priv;
|
||||
|
||||
if (bin->child)
|
||||
(* callback) (bin->child, callback_data);
|
||||
if (priv->child)
|
||||
(* callback) (priv->child, callback_data);
|
||||
}
|
||||
|
||||
|
||||
@ -181,9 +200,10 @@ static GtkSizeRequestMode
|
||||
gtk_bin_get_request_mode (GtkSizeRequest *widget)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN (widget);
|
||||
GtkBinPriv *priv = bin->priv;
|
||||
|
||||
if (bin->child)
|
||||
return gtk_size_request_get_request_mode (GTK_SIZE_REQUEST (bin->child));
|
||||
if (priv->child)
|
||||
return gtk_size_request_get_request_mode (GTK_SIZE_REQUEST (priv->child));
|
||||
|
||||
return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
|
||||
}
|
||||
@ -193,13 +213,14 @@ get_child_padding_delta (GtkBin *bin,
|
||||
gint *delta_h,
|
||||
gint *delta_v)
|
||||
{
|
||||
GtkBinPriv *priv = bin->priv;
|
||||
gint hmin, vmin, child_hmin, child_vmin;
|
||||
|
||||
gtk_size_request_get_width (GTK_SIZE_REQUEST (bin), &hmin, NULL);
|
||||
gtk_size_request_get_height (GTK_SIZE_REQUEST (bin), &vmin, NULL);
|
||||
|
||||
gtk_size_request_get_width (GTK_SIZE_REQUEST (bin->child), &child_hmin, NULL);
|
||||
gtk_size_request_get_height (GTK_SIZE_REQUEST (bin->child), &child_vmin, NULL);
|
||||
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);
|
||||
|
||||
*delta_h = hmin - child_hmin;
|
||||
*delta_v = vmin - child_vmin;
|
||||
@ -212,16 +233,17 @@ gtk_bin_get_width_for_height (GtkSizeRequest *widget,
|
||||
gint *natural_width)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN (widget);
|
||||
GtkBinPriv *priv = bin->priv;
|
||||
gint hdelta, vdelta, child_min, child_nat;
|
||||
|
||||
if (bin->child)
|
||||
if (priv->child)
|
||||
{
|
||||
get_child_padding_delta (bin, &hdelta, &vdelta);
|
||||
|
||||
gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (bin->child),
|
||||
height - vdelta,
|
||||
&child_min, &child_nat);
|
||||
|
||||
|
||||
gtk_size_request_get_width_for_height (GTK_SIZE_REQUEST (priv->child),
|
||||
height - vdelta,
|
||||
&child_min, &child_nat);
|
||||
|
||||
if (minimum_width)
|
||||
*minimum_width = child_min + hdelta;
|
||||
|
||||
@ -239,16 +261,17 @@ gtk_bin_get_height_for_width (GtkSizeRequest *widget,
|
||||
gint *natural_height)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN (widget);
|
||||
GtkBinPriv *priv = bin->priv;
|
||||
gint hdelta, vdelta, child_min, child_nat;
|
||||
|
||||
if (bin->child)
|
||||
if (priv->child)
|
||||
{
|
||||
get_child_padding_delta (bin, &hdelta, &vdelta);
|
||||
|
||||
gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (bin->child),
|
||||
width - hdelta,
|
||||
&child_min, &child_nat);
|
||||
|
||||
|
||||
gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (priv->child),
|
||||
width - hdelta,
|
||||
&child_min, &child_nat);
|
||||
|
||||
if (minimum_height)
|
||||
*minimum_height = child_min + vdelta;
|
||||
|
||||
@ -275,7 +298,7 @@ gtk_bin_get_child (GtkBin *bin)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_BIN (bin), NULL);
|
||||
|
||||
return bin->child;
|
||||
return bin->priv->child;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -46,13 +46,15 @@ G_BEGIN_DECLS
|
||||
|
||||
|
||||
typedef struct _GtkBin GtkBin;
|
||||
typedef struct _GtkBinPriv GtkBinPriv;
|
||||
typedef struct _GtkBinClass GtkBinClass;
|
||||
|
||||
struct _GtkBin
|
||||
{
|
||||
GtkContainer container;
|
||||
|
||||
GtkWidget *GSEAL (child);
|
||||
/*< private >*/
|
||||
GtkBinPriv *priv;
|
||||
};
|
||||
|
||||
struct _GtkBinClass
|
||||
|
Loading…
Reference in New Issue
Block a user