[gimp/gtk3-port: 210/215] libgimpwidgets: move all GimpColorProfileStore members to a private struct



commit ea199e51285f204617d8d60db35c4b146136fead
Author: Michael Natterer <mitch gimp org>
Date:   Mon Jan 3 14:31:51 2011 +0100

    libgimpwidgets: move all GimpColorProfileStore members to a private struct

 libgimpwidgets/gimpcolorprofilestore.c |   57 +++++++++++++++++++------------
 libgimpwidgets/gimpcolorprofilestore.h |    4 +--
 2 files changed, 36 insertions(+), 25 deletions(-)
---
diff --git a/libgimpwidgets/gimpcolorprofilestore.c b/libgimpwidgets/gimpcolorprofilestore.c
index 0e0c043..a663615 100644
--- a/libgimpwidgets/gimpcolorprofilestore.c
+++ b/libgimpwidgets/gimpcolorprofilestore.c
@@ -54,6 +54,18 @@ enum
 };
 
 
+typedef struct _GimpColorProfileStorePrivate GimpColorProfileStorePrivate;
+
+struct _GimpColorProfileStorePrivate
+{
+  gchar *history;
+};
+
+#define GET_PRIVATE(obj) G_TYPE_INSTANCE_GET_PRIVATE (obj, \
+                                                      GIMP_TYPE_COLOR_PROFILE_STORE, \
+                                                      GimpColorProfileStorePrivate)
+
+
 static GObject * gimp_color_profile_store_constructor    (GType                  type,
                                                           guint                  n_params,
                                                           GObjectConstructParam *params);
@@ -114,6 +126,8 @@ gimp_color_profile_store_class_init (GimpColorProfileStoreClass *klass)
                                                         NULL,
                                                         G_PARAM_CONSTRUCT_ONLY |
                                                         GIMP_PARAM_READWRITE));
+
+  g_type_class_add_private (object_class, sizeof (GimpColorProfileStorePrivate));
 }
 
 static void
@@ -136,13 +150,15 @@ gimp_color_profile_store_constructor  (GType                  type,
                                        guint                  n_params,
                                        GObjectConstructParam *params)
 {
-  GObject               *object;
-  GimpColorProfileStore *store;
-  GtkTreeIter            iter;
+  GObject                      *object;
+  GimpColorProfileStore        *store;
+  GimpColorProfileStorePrivate *private;
+  GtkTreeIter                   iter;
 
   object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
 
-  store = GIMP_COLOR_PROFILE_STORE (object);
+  store   = GIMP_COLOR_PROFILE_STORE (object);
+  private = GET_PRIVATE (store);
 
   gtk_list_store_append (GTK_LIST_STORE (store), &iter);
   gtk_list_store_set (GTK_LIST_STORE (store), &iter,
@@ -152,10 +168,8 @@ gimp_color_profile_store_constructor  (GType                  type,
                       _("Select color profile from disk..."),
                       -1);
 
-  if (store->history)
-    {
-      gimp_color_profile_store_load (store, store->history, NULL);
-    }
+  if (private->history)
+    gimp_color_profile_store_load (store, private->history, NULL);
 
   return object;
 }
@@ -163,12 +177,11 @@ gimp_color_profile_store_constructor  (GType                  type,
 static void
 gimp_color_profile_store_dispose (GObject *object)
 {
-  GimpColorProfileStore *store = GIMP_COLOR_PROFILE_STORE (object);
+  GimpColorProfileStore        *store   = GIMP_COLOR_PROFILE_STORE (object);
+  GimpColorProfileStorePrivate *private = GET_PRIVATE (store);
 
-  if (store->history)
-    {
-      gimp_color_profile_store_save (store, store->history, NULL);
-    }
+  if (private->history)
+    gimp_color_profile_store_save (store, private->history, NULL);
 
   G_OBJECT_CLASS (parent_class)->dispose (object);
 }
@@ -176,12 +189,12 @@ gimp_color_profile_store_dispose (GObject *object)
 static void
 gimp_color_profile_store_finalize (GObject *object)
 {
-  GimpColorProfileStore *store = GIMP_COLOR_PROFILE_STORE (object);
+  GimpColorProfileStorePrivate *private = GET_PRIVATE (object);
 
-  if (store->history)
+  if (private->history)
     {
-      g_free (store->history);
-      store->history = NULL;
+      g_free (private->history);
+      private->history = NULL;
     }
 
   G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -193,13 +206,13 @@ gimp_color_profile_store_set_property (GObject      *object,
                                        const GValue *value,
                                        GParamSpec   *pspec)
 {
-  GimpColorProfileStore *store = GIMP_COLOR_PROFILE_STORE (object);
+  GimpColorProfileStorePrivate *private = GET_PRIVATE (object);
 
   switch (property_id)
     {
     case PROP_HISTORY:
-      g_return_if_fail (store->history == NULL);
-      store->history = g_value_dup_string (value);
+      g_return_if_fail (private->history == NULL);
+      private->history = g_value_dup_string (value);
       break;
 
     default:
@@ -214,12 +227,12 @@ gimp_color_profile_store_get_property (GObject    *object,
                                        GValue     *value,
                                        GParamSpec *pspec)
 {
-  GimpColorProfileStore *store = GIMP_COLOR_PROFILE_STORE (object);
+  GimpColorProfileStorePrivate *private = GET_PRIVATE (object);
 
   switch (property_id)
     {
     case PROP_HISTORY:
-      g_value_set_string (value, store->history);
+      g_value_set_string (value, private->history);
       break;
 
     default:
diff --git a/libgimpwidgets/gimpcolorprofilestore.h b/libgimpwidgets/gimpcolorprofilestore.h
index c15e6f4..f52b303 100644
--- a/libgimpwidgets/gimpcolorprofilestore.h
+++ b/libgimpwidgets/gimpcolorprofilestore.h
@@ -37,9 +37,7 @@ typedef struct _GimpColorProfileStoreClass  GimpColorProfileStoreClass;
 
 struct _GimpColorProfileStore
 {
-  GtkListStore       parent_instance;
-
-  gchar             *history;
+  GtkListStore  parent_instance;
 };
 
 struct _GimpColorProfileStoreClass



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]