[gimp/gtk3-port: 160/227] libgimpwidgets: move all GimpColorDisplay members to a private struct



commit 352960230f03c80f6ec7b419d060499f3395ac99
Author: Michael Natterer <mitch gimp org>
Date:   Fri Dec 31 19:03:47 2010 +0100

    libgimpwidgets: move all GimpColorDisplay members to a private struct

 libgimpwidgets/gimpcolordisplay.c      | 71 +++++++++++++++++++++-------------
 libgimpwidgets/gimpcolordisplay.h      | 13 +++----
 libgimpwidgets/gimpcolordisplaystack.c |  2 +-
 3 files changed, 51 insertions(+), 35 deletions(-)
---
diff --git a/libgimpwidgets/gimpcolordisplay.c b/libgimpwidgets/gimpcolordisplay.c
index 37e8dc0..9e56099 100644
--- a/libgimpwidgets/gimpcolordisplay.c
+++ b/libgimpwidgets/gimpcolordisplay.c
@@ -64,13 +64,19 @@ enum
 };
 
 
-typedef struct
+typedef struct _GimpColorDisplayPrivate GimpColorDisplayPrivate;
+
+struct _GimpColorDisplayPrivate
 {
+  gboolean          enabled;
   GimpColorConfig  *config;
   GimpColorManaged *managed;
-} GimpColorDisplayPrivate;
+};
+
+#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
+                                                       GIMP_TYPE_COLOR_DISPLAY, \
+                                                       GimpColorDisplayPrivate))
 
-#define GIMP_COLOR_DISPLAY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GIMP_TYPE_COLOR_DISPLAY, 
GimpColorDisplayPrivate))
 
 
 static void       gimp_color_display_constructed (GObject       *object);
@@ -108,8 +114,6 @@ gimp_color_display_class_init (GimpColorDisplayClass *klass)
   object_class->set_property = gimp_color_display_set_property;
   object_class->get_property = gimp_color_display_get_property;
 
-  g_type_class_add_private (object_class, sizeof (GimpColorDisplayPrivate));
-
   g_object_class_install_property (object_class, PROP_ENABLED,
                                    g_param_spec_boolean ("enabled", NULL, NULL,
                                                          TRUE,
@@ -148,12 +152,16 @@ gimp_color_display_class_init (GimpColorDisplayClass *klass)
   klass->configure       = NULL;
   klass->configure_reset = NULL;
   klass->changed         = NULL;
+
+  g_type_class_add_private (object_class, sizeof (GimpColorDisplayPrivate));
 }
 
 static void
 gimp_color_display_init (GimpColorDisplay *display)
 {
-  display->enabled = FALSE;
+  GimpColorDisplayPrivate *private = GET_PRIVATE (display);
+
+  private->enabled = FALSE;
 }
 
 static void
@@ -168,7 +176,7 @@ gimp_color_display_constructed (GObject *object)
 static void
 gimp_color_display_dispose (GObject *object)
 {
-  GimpColorDisplayPrivate *private = GIMP_COLOR_DISPLAY_GET_PRIVATE (object);
+  GimpColorDisplayPrivate *private = GET_PRIVATE (object);
 
   if (private->config)
     {
@@ -197,12 +205,13 @@ gimp_color_display_set_property (GObject      *object,
                                  const GValue *value,
                                  GParamSpec   *pspec)
 {
-  GimpColorDisplay *display = GIMP_COLOR_DISPLAY (object);
+  GimpColorDisplay        *display = GIMP_COLOR_DISPLAY (object);
+  GimpColorDisplayPrivate *private = GET_PRIVATE (object);
 
   switch (property_id)
     {
     case PROP_ENABLED:
-      display->enabled = g_value_get_boolean (value);
+      private->enabled = g_value_get_boolean (value);
       break;
 
     case PROP_COLOR_CONFIG:
@@ -227,22 +236,20 @@ gimp_color_display_get_property (GObject    *object,
                                  GValue     *value,
                                  GParamSpec *pspec)
 {
-  GimpColorDisplay *display = GIMP_COLOR_DISPLAY (object);
+  GimpColorDisplayPrivate *private = GET_PRIVATE (object);
 
   switch (property_id)
     {
     case PROP_ENABLED:
-      g_value_set_boolean (value, display->enabled);
+      g_value_set_boolean (value, private->enabled);
       break;
 
     case PROP_COLOR_CONFIG:
-      g_value_set_object (value,
-                          GIMP_COLOR_DISPLAY_GET_PRIVATE (display)->config);
+      g_value_set_object (value, private->config);
       break;
 
     case PROP_COLOR_MANAGED:
-      g_value_set_object (value,
-                          GIMP_COLOR_DISPLAY_GET_PRIVATE (display)->managed);
+      g_value_set_object (value, private->managed);
       break;
 
     default:
@@ -255,7 +262,7 @@ static void
 gimp_color_display_set_color_config (GimpColorDisplay *display,
                                      GimpColorConfig  *config)
 {
-  GimpColorDisplayPrivate *private = GIMP_COLOR_DISPLAY_GET_PRIVATE (display);
+  GimpColorDisplayPrivate *private = GET_PRIVATE (display);
 
   g_return_if_fail (private->config == NULL);
 
@@ -273,7 +280,7 @@ static void
 gimp_color_display_set_color_managed (GimpColorDisplay *display,
                                       GimpColorManaged *managed)
 {
-  GimpColorDisplayPrivate *private = GIMP_COLOR_DISPLAY_GET_PRIVATE (display);
+  GimpColorDisplayPrivate *private = GET_PRIVATE (display);
 
   g_return_if_fail (private->managed == NULL);
 
@@ -319,12 +326,10 @@ gimp_color_display_clone (GimpColorDisplay *display)
 
       if (clone)
         {
-          GimpColorDisplayPrivate *private;
-
-          private = GIMP_COLOR_DISPLAY_GET_PRIVATE (display);
+          GimpColorDisplayPrivate *private = GET_PRIVATE (display);
 
           g_object_set (clone,
-                        "enabled",       display->enabled,
+                        "enabled",       private->enabled,
                         "color-managed", private->managed,
                         NULL);
         }
@@ -348,12 +353,16 @@ void
 gimp_color_display_convert_surface (GimpColorDisplay *display,
                                     cairo_surface_t  *surface)
 {
+  GimpColorDisplayPrivate *private;
+
   g_return_if_fail (GIMP_IS_COLOR_DISPLAY (display));
   g_return_if_fail (surface != NULL);
   g_return_if_fail (cairo_surface_get_type (surface) ==
                     CAIRO_SURFACE_TYPE_IMAGE);
 
-  if (display->enabled &&
+  private = GET_PRIVATE (display);
+
+  if (private->enabled &&
       GIMP_COLOR_DISPLAY_GET_CLASS (display)->convert_surface)
     {
       cairo_surface_flush (surface);
@@ -383,11 +392,15 @@ gimp_color_display_convert (GimpColorDisplay *display,
                             gint               bpp,
                             gint               bpl)
 {
+  GimpColorDisplayPrivate *private;
+
   g_return_if_fail (GIMP_IS_COLOR_DISPLAY (display));
 
+  private = GET_PRIVATE (display);
+
   /*  implementing the convert method is deprecated
    */
-  if (display->enabled && GIMP_COLOR_DISPLAY_GET_CLASS (display)->convert)
+  if (private->enabled && GIMP_COLOR_DISPLAY_GET_CLASS (display)->convert)
     GIMP_COLOR_DISPLAY_GET_CLASS (display)->convert (display, buf,
                                                      width, height,
                                                      bpp, bpl);
@@ -480,9 +493,13 @@ void
 gimp_color_display_set_enabled (GimpColorDisplay *display,
                                 gboolean          enabled)
 {
+  GimpColorDisplayPrivate *private;
+
   g_return_if_fail (GIMP_IS_COLOR_DISPLAY (display));
 
-  if (enabled != display->enabled)
+  private = GET_PRIVATE (display);
+
+  if (enabled != private->enabled)
     {
       g_object_set (display,
                     "enabled", enabled,
@@ -495,7 +512,7 @@ gimp_color_display_get_enabled (GimpColorDisplay *display)
 {
   g_return_val_if_fail (GIMP_IS_COLOR_DISPLAY (display), FALSE);
 
-  return display->enabled;
+  return GET_PRIVATE (display)->enabled;
 }
 
 /**
@@ -511,7 +528,7 @@ gimp_color_display_get_config (GimpColorDisplay *display)
 {
   g_return_val_if_fail (GIMP_IS_COLOR_DISPLAY (display), NULL);
 
-  return GIMP_COLOR_DISPLAY_GET_PRIVATE (display)->config;
+  return GET_PRIVATE (display)->config;
 }
 
 /**
@@ -527,5 +544,5 @@ gimp_color_display_get_managed (GimpColorDisplay *display)
 {
   g_return_val_if_fail (GIMP_IS_COLOR_DISPLAY (display), NULL);
 
-  return GIMP_COLOR_DISPLAY_GET_PRIVATE (display)->managed;
+  return GET_PRIVATE (display)->managed;
 }
diff --git a/libgimpwidgets/gimpcolordisplay.h b/libgimpwidgets/gimpcolordisplay.h
index 3d45311..74fb3d5 100644
--- a/libgimpwidgets/gimpcolordisplay.h
+++ b/libgimpwidgets/gimpcolordisplay.h
@@ -44,8 +44,6 @@ typedef struct _GimpColorDisplayClass GimpColorDisplayClass;
 struct _GimpColorDisplay
 {
   GObject  parent_instance;
-
-  gboolean enabled;
 };
 
 struct _GimpColorDisplayClass
@@ -54,12 +52,16 @@ struct _GimpColorDisplayClass
 
   const gchar  *name;
   const gchar  *help_id;
+  const gchar  *stock_id;
 
   /*  virtual functions  */
 
   /*  implementing the GimpColorDisplay::clone method is deprecated       */
   GimpColorDisplay * (* clone)           (GimpColorDisplay *display);
 
+  void               (* convert_surface) (GimpColorDisplay *display,
+                                          cairo_surface_t  *surface);
+
   /*  implementing the GimpColorDisplay::convert method is deprecated     */
   void               (* convert)         (GimpColorDisplay *display,
                                           guchar           *buf,
@@ -83,12 +85,9 @@ struct _GimpColorDisplayClass
   /*  signals  */
   void               (* changed)         (GimpColorDisplay *display);
 
-  const gchar  *stock_id;
-
-  void               (* convert_surface) (GimpColorDisplay *display,
-                                          cairo_surface_t  *surface);
-
   /* Padding for future expansion */
+  void (* _gimp_reserved1) (void);
+  void (* _gimp_reserved2) (void);
   void (* _gimp_reserved3) (void);
   void (* _gimp_reserved4) (void);
 };
diff --git a/libgimpwidgets/gimpcolordisplaystack.c b/libgimpwidgets/gimpcolordisplaystack.c
index 5a0401d..0a91714 100644
--- a/libgimpwidgets/gimpcolordisplaystack.c
+++ b/libgimpwidgets/gimpcolordisplaystack.c
@@ -355,7 +355,7 @@ static void
 gimp_color_display_stack_display_changed (GimpColorDisplay      *display,
                                           GimpColorDisplayStack *stack)
 {
-  if (display->enabled)
+  if (gimp_color_display_get_enabled (display))
     gimp_color_display_stack_changed (stack);
 }
 


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