frame: Remove priv pointer

This commit is contained in:
Timm Bäder 2018-04-15 10:55:21 +02:00
parent be77e0d500
commit bf08537885
2 changed files with 25 additions and 37 deletions

View File

@ -87,14 +87,14 @@
* any other shadow type to remove it. * any other shadow type to remove it.
*/ */
struct _GtkFramePrivate typedef struct
{ {
/* Properties */ /* Properties */
GtkWidget *label_widget; GtkWidget *label_widget;
gint16 shadow_type; gint16 shadow_type;
gfloat label_xalign; gfloat label_xalign;
}; } GtkFramePrivate;
enum { enum {
PROP_0, PROP_0,
@ -229,10 +229,7 @@ gtk_frame_buildable_add_child (GtkBuildable *buildable,
static void static void
gtk_frame_init (GtkFrame *frame) gtk_frame_init (GtkFrame *frame)
{ {
GtkFramePrivate *priv; GtkFramePrivate *priv = gtk_frame_get_instance_private (frame);
frame->priv = gtk_frame_get_instance_private (frame);
priv = frame->priv;
priv->label_widget = NULL; priv->label_widget = NULL;
priv->shadow_type = GTK_SHADOW_ETCHED_IN; priv->shadow_type = GTK_SHADOW_ETCHED_IN;
@ -274,7 +271,7 @@ gtk_frame_get_property (GObject *object,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GtkFrame *frame = GTK_FRAME (object); GtkFrame *frame = GTK_FRAME (object);
GtkFramePrivate *priv = frame->priv; GtkFramePrivate *priv = gtk_frame_get_instance_private (frame);
switch (prop_id) switch (prop_id)
{ {
@ -318,7 +315,7 @@ gtk_frame_remove (GtkContainer *container,
GtkWidget *child) GtkWidget *child)
{ {
GtkFrame *frame = GTK_FRAME (container); GtkFrame *frame = GTK_FRAME (container);
GtkFramePrivate *priv = frame->priv; GtkFramePrivate *priv = gtk_frame_get_instance_private (frame);
if (priv->label_widget == child) if (priv->label_widget == child)
gtk_frame_set_label_widget (frame, NULL); gtk_frame_set_label_widget (frame, NULL);
@ -333,7 +330,7 @@ gtk_frame_forall (GtkContainer *container,
{ {
GtkBin *bin = GTK_BIN (container); GtkBin *bin = GTK_BIN (container);
GtkFrame *frame = GTK_FRAME (container); GtkFrame *frame = GTK_FRAME (container);
GtkFramePrivate *priv = frame->priv; GtkFramePrivate *priv = gtk_frame_get_instance_private (frame);
GtkWidget *child; GtkWidget *child;
child = gtk_bin_get_child (bin); child = gtk_bin_get_child (bin);
@ -388,12 +385,10 @@ gtk_frame_set_label (GtkFrame *frame,
const gchar * const gchar *
gtk_frame_get_label (GtkFrame *frame) gtk_frame_get_label (GtkFrame *frame)
{ {
GtkFramePrivate *priv; GtkFramePrivate *priv = gtk_frame_get_instance_private (frame);
g_return_val_if_fail (GTK_IS_FRAME (frame), NULL); g_return_val_if_fail (GTK_IS_FRAME (frame), NULL);
priv = frame->priv;
if (GTK_IS_LABEL (priv->label_widget)) if (GTK_IS_LABEL (priv->label_widget))
return gtk_label_get_text (GTK_LABEL (priv->label_widget)); return gtk_label_get_text (GTK_LABEL (priv->label_widget));
else else
@ -412,15 +407,13 @@ void
gtk_frame_set_label_widget (GtkFrame *frame, gtk_frame_set_label_widget (GtkFrame *frame,
GtkWidget *label_widget) GtkWidget *label_widget)
{ {
GtkFramePrivate *priv; GtkFramePrivate *priv = gtk_frame_get_instance_private (frame);
gboolean need_resize = FALSE; gboolean need_resize = FALSE;
g_return_if_fail (GTK_IS_FRAME (frame)); g_return_if_fail (GTK_IS_FRAME (frame));
g_return_if_fail (label_widget == NULL || GTK_IS_WIDGET (label_widget)); g_return_if_fail (label_widget == NULL || GTK_IS_WIDGET (label_widget));
g_return_if_fail (label_widget == NULL || gtk_widget_get_parent (label_widget) == NULL); g_return_if_fail (label_widget == NULL || gtk_widget_get_parent (label_widget) == NULL);
priv = frame->priv;
if (priv->label_widget == label_widget) if (priv->label_widget == label_widget)
return; return;
@ -461,9 +454,11 @@ gtk_frame_set_label_widget (GtkFrame *frame,
GtkWidget * GtkWidget *
gtk_frame_get_label_widget (GtkFrame *frame) gtk_frame_get_label_widget (GtkFrame *frame)
{ {
GtkFramePrivate *priv = gtk_frame_get_instance_private (frame);
g_return_val_if_fail (GTK_IS_FRAME (frame), NULL); g_return_val_if_fail (GTK_IS_FRAME (frame), NULL);
return frame->priv->label_widget; return priv->label_widget;
} }
/** /**
@ -480,12 +475,10 @@ void
gtk_frame_set_label_align (GtkFrame *frame, gtk_frame_set_label_align (GtkFrame *frame,
gfloat xalign) gfloat xalign)
{ {
GtkFramePrivate *priv; GtkFramePrivate *priv = gtk_frame_get_instance_private (frame);
g_return_if_fail (GTK_IS_FRAME (frame)); g_return_if_fail (GTK_IS_FRAME (frame));
priv = frame->priv;
xalign = CLAMP (xalign, 0.0, 1.0); xalign = CLAMP (xalign, 0.0, 1.0);
g_object_freeze_notify (G_OBJECT (frame)); g_object_freeze_notify (G_OBJECT (frame));
@ -509,9 +502,11 @@ gtk_frame_set_label_align (GtkFrame *frame,
gfloat gfloat
gtk_frame_get_label_align (GtkFrame *frame) gtk_frame_get_label_align (GtkFrame *frame)
{ {
GtkFramePrivate *priv = gtk_frame_get_instance_private (frame);
g_return_val_if_fail (GTK_IS_FRAME (frame), 0.0); g_return_val_if_fail (GTK_IS_FRAME (frame), 0.0);
return frame->priv->label_xalign; return priv->label_xalign;
} }
/** /**
@ -528,12 +523,10 @@ void
gtk_frame_set_shadow_type (GtkFrame *frame, gtk_frame_set_shadow_type (GtkFrame *frame,
GtkShadowType type) GtkShadowType type)
{ {
GtkFramePrivate *priv; GtkFramePrivate *priv = gtk_frame_get_instance_private (frame);
g_return_if_fail (GTK_IS_FRAME (frame)); g_return_if_fail (GTK_IS_FRAME (frame));
priv = frame->priv;
if ((GtkShadowType) priv->shadow_type != type) if ((GtkShadowType) priv->shadow_type != type)
{ {
priv->shadow_type = type; priv->shadow_type = type;
@ -561,9 +554,11 @@ gtk_frame_set_shadow_type (GtkFrame *frame,
GtkShadowType GtkShadowType
gtk_frame_get_shadow_type (GtkFrame *frame) gtk_frame_get_shadow_type (GtkFrame *frame)
{ {
GtkFramePrivate *priv = gtk_frame_get_instance_private (frame);
g_return_val_if_fail (GTK_IS_FRAME (frame), GTK_SHADOW_ETCHED_IN); g_return_val_if_fail (GTK_IS_FRAME (frame), GTK_SHADOW_ETCHED_IN);
return frame->priv->shadow_type; return priv->shadow_type;
} }
static void static void
@ -572,7 +567,7 @@ gtk_frame_size_allocate (GtkWidget *widget,
int baseline) int baseline)
{ {
GtkFrame *frame = GTK_FRAME (widget); GtkFrame *frame = GTK_FRAME (widget);
GtkFramePrivate *priv = frame->priv; GtkFramePrivate *priv = gtk_frame_get_instance_private (frame);
GtkWidget *child; GtkWidget *child;
GtkAllocation new_allocation; GtkAllocation new_allocation;
@ -623,7 +618,7 @@ static void
gtk_frame_real_compute_child_allocation (GtkFrame *frame, gtk_frame_real_compute_child_allocation (GtkFrame *frame,
GtkAllocation *child_allocation) GtkAllocation *child_allocation)
{ {
GtkFramePrivate *priv = frame->priv; GtkFramePrivate *priv = gtk_frame_get_instance_private (frame);
int frame_width, frame_height; int frame_width, frame_height;
gint height; gint height;
@ -658,13 +653,10 @@ gtk_frame_measure (GtkWidget *widget,
gint *minimum_baseline, gint *minimum_baseline,
gint *natural_baseline) gint *natural_baseline)
{ {
GtkFrame *frame = GTK_FRAME (widget);
GtkFramePrivate *priv = gtk_frame_get_instance_private (frame);
GtkWidget *child; GtkWidget *child;
GtkFrame *frame; int child_min, child_nat;
GtkFramePrivate *priv;
gint child_min, child_nat;
frame = GTK_FRAME (widget);
priv = frame->priv;
child = gtk_bin_get_child (GTK_BIN (widget)); child = gtk_bin_get_child (GTK_BIN (widget));
if (child && gtk_widget_get_visible (child)) if (child && gtk_widget_get_visible (child))

View File

@ -44,15 +44,11 @@ G_BEGIN_DECLS
#define GTK_FRAME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FRAME, GtkFrameClass)) #define GTK_FRAME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FRAME, GtkFrameClass))
typedef struct _GtkFrame GtkFrame; typedef struct _GtkFrame GtkFrame;
typedef struct _GtkFramePrivate GtkFramePrivate;
typedef struct _GtkFrameClass GtkFrameClass; typedef struct _GtkFrameClass GtkFrameClass;
struct _GtkFrame struct _GtkFrame
{ {
GtkBin bin; GtkBin parent_instance;
/*< private >*/
GtkFramePrivate *priv;
}; };
/** /**