[gimp/gtk3-port: 204/215] libgimpwidgets: move all GimpEnumLabel members to a private struct
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 204/215] libgimpwidgets: move all GimpEnumLabel members to a private struct
- Date: Mon, 3 Jan 2011 15:15:32 +0000 (UTC)
commit 937e4e1af1715caaa3c7a29be5f4a6daa0c06c74
Author: Michael Natterer <mitch gimp org>
Date: Mon Jan 3 13:08:25 2011 +0100
libgimpwidgets: move all GimpEnumLabel members to a private struct
libgimpwidgets/gimpenumlabel.c | 34 +++++++++++++++++++++++++++-------
libgimpwidgets/gimpenumlabel.h | 11 +++++++----
2 files changed, 34 insertions(+), 11 deletions(-)
---
diff --git a/libgimpwidgets/gimpenumlabel.c b/libgimpwidgets/gimpenumlabel.c
index e196795..0578349 100644
--- a/libgimpwidgets/gimpenumlabel.c
+++ b/libgimpwidgets/gimpenumlabel.c
@@ -39,6 +39,18 @@
**/
+typedef struct _GimpEnumLabelPrivate GimpEnumLabelPrivate;
+
+struct _GimpEnumLabelPrivate
+{
+ GEnumClass *enum_class;
+};
+
+#define GET_PRIVATE(obj) G_TYPE_INSTANCE_GET_PRIVATE (obj, \
+ GIMP_TYPE_ENUM_LABEL, \
+ GimpEnumLabelPrivate)
+
+
static void gimp_enum_label_finalize (GObject *object);
@@ -53,6 +65,8 @@ gimp_enum_label_class_init (GimpEnumLabelClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gimp_enum_label_finalize;
+
+ g_type_class_add_private (object_class, sizeof (GimpEnumLabelPrivate));
}
static void
@@ -63,10 +77,13 @@ gimp_enum_label_init (GimpEnumLabel *enum_label)
static void
gimp_enum_label_finalize (GObject *object)
{
- GimpEnumLabel *enum_label = GIMP_ENUM_LABEL (object);
+ GimpEnumLabelPrivate *private = GET_PRIVATE (object);
- if (enum_label->enum_class)
- g_type_class_unref (enum_label->enum_class);
+ if (private->enum_class)
+ {
+ g_type_class_unref (private->enum_class);
+ private->enum_class = NULL;
+ }
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -90,7 +107,7 @@ gimp_enum_label_new (GType enum_type,
label = g_object_new (GIMP_TYPE_ENUM_LABEL, NULL);
- label->enum_class = g_type_class_ref (enum_type);
+ GET_PRIVATE (label)->enum_class = g_type_class_ref (enum_type);
gimp_enum_label_set_value (label, value);
@@ -108,16 +125,19 @@ void
gimp_enum_label_set_value (GimpEnumLabel *label,
gint value)
{
- const gchar *desc;
+ GimpEnumLabelPrivate *private;
+ const gchar *desc;
g_return_if_fail (GIMP_IS_ENUM_LABEL (label));
- if (! gimp_enum_get_value (G_TYPE_FROM_CLASS (label->enum_class), value,
+ private = GET_PRIVATE (label);
+
+ if (! gimp_enum_get_value (G_TYPE_FROM_CLASS (private->enum_class), value,
NULL, NULL, &desc, NULL))
{
g_warning ("%s: %d is not valid for enum of type '%s'",
G_STRLOC, value,
- g_type_name (G_TYPE_FROM_CLASS (label->enum_class)));
+ g_type_name (G_TYPE_FROM_CLASS (private->enum_class)));
return;
}
diff --git a/libgimpwidgets/gimpenumlabel.h b/libgimpwidgets/gimpenumlabel.h
index 01b2b34..e66b18e 100644
--- a/libgimpwidgets/gimpenumlabel.h
+++ b/libgimpwidgets/gimpenumlabel.h
@@ -36,15 +36,18 @@ typedef struct _GimpEnumLabelClass GimpEnumLabelClass;
struct _GimpEnumLabel
{
- GtkLabel parent_instance;
-
- /*< private >*/
- GEnumClass *enum_class;
+ GtkLabel parent_instance;
};
struct _GimpEnumLabelClass
{
GtkLabelClass parent_class;
+
+ /* Padding for future expansion */
+ void (* _gimp_reserved1) (void);
+ void (* _gimp_reserved2) (void);
+ void (* _gimp_reserved3) (void);
+ void (* _gimp_reserved4) (void);
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]