[gtk+/refactor: 39/106] gtkbin: Move public members to private structure
- From: Javier Jardón <jjardon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/refactor: 39/106] gtkbin: Move public members to private structure
- Date: Tue, 13 Jul 2010 17:45:17 +0000 (UTC)
commit 80df961edb1557bae3a545e6b18871d7c4c6f566
Author: Javier Jardón <jjardon gnome org>
Date: Mon May 24 21:51:49 2010 +0200
gtkbin: Move public members to private structure
gtk/gtkbin.c | 75 +++++++++++++++++++++++++++++++++++++--------------------
gtk/gtkbin.h | 4 ++-
2 files changed, 52 insertions(+), 27 deletions(-)
---
diff --git a/gtk/gtkbin.c b/gtk/gtkbin.c
index 95d814e..388ad7a 100644
--- a/gtk/gtkbin.c
+++ b/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
diff --git a/gtk/gtkbin.h b/gtk/gtkbin.h
index 9a3a460..80b6846 100644
--- a/gtk/gtkbin.h
+++ b/gtk/gtkbin.h
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]