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



commit a451966d391185881d8d9e8b8e500ecb92159352
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      |   77 ++++++++++++++++++++------------
 libgimpwidgets/gimpcolordisplay.h      |   32 ++++++-------
 libgimpwidgets/gimpcolordisplaystack.c |    2 +-
 3 files changed, 64 insertions(+), 47 deletions(-)
---
diff --git a/libgimpwidgets/gimpcolordisplay.c b/libgimpwidgets/gimpcolordisplay.c
index 69f5796..e1d5e51 100644
--- a/libgimpwidgets/gimpcolordisplay.c
+++ b/libgimpwidgets/gimpcolordisplay.c
@@ -62,13 +62,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);
@@ -106,8 +112,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,
@@ -147,12 +151,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
@@ -167,7 +175,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)
     {
@@ -196,12 +204,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:
@@ -226,22 +235,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:
@@ -254,7 +261,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);
 
@@ -272,7 +279,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);
 
@@ -318,12 +325,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);
         }
@@ -349,10 +354,14 @@ gimp_color_display_convert_buffer (GimpColorDisplay *display,
                                    GeglBuffer       *buffer,
                                    GeglRectangle    *area)
 {
+  GimpColorDisplayPrivate *private;
+
   g_return_if_fail (GIMP_IS_COLOR_DISPLAY (display));
   g_return_if_fail (GEGL_IS_BUFFER (buffer));
 
-  if (display->enabled &&
+  private = GET_PRIVATE (display);
+
+  if (private->enabled &&
       GIMP_COLOR_DISPLAY_GET_CLASS (display)->convert_buffer)
     {
       GIMP_COLOR_DISPLAY_GET_CLASS (display)->convert_buffer (display, buffer,
@@ -375,12 +384,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);
@@ -410,11 +423,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);
@@ -507,9 +524,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,
@@ -522,7 +543,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;
 }
 
 /**
@@ -538,7 +559,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;
 }
 
 /**
@@ -554,5 +575,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 34fd4f0..33cefc8 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,21 @@ struct _GimpColorDisplayClass
 
   const gchar  *name;
   const gchar  *help_id;
+  const gchar  *icon_name;
 
   /*  virtual functions  */
 
   /*  implementing the GimpColorDisplay::clone method is deprecated       */
   GimpColorDisplay * (* clone)           (GimpColorDisplay *display);
 
+  void               (* convert_buffer)  (GimpColorDisplay *display,
+                                          GeglBuffer       *buffer,
+                                          GeglRectangle    *area);
+
+  /*  implementing the GimpColorDisplay::convert_surface method is deprecated  */
+  void               (* convert_surface) (GimpColorDisplay *display,
+                                          cairo_surface_t  *surface);
+
   /*  implementing the GimpColorDisplay::convert method is deprecated     */
   void               (* convert)         (GimpColorDisplay *display,
                                           guchar           *buf,
@@ -83,22 +90,11 @@ struct _GimpColorDisplayClass
   /*  signals  */
   void               (* changed)         (GimpColorDisplay *display);
 
-#ifdef GIMP_DISABLE_DEPRECATED
-  gpointer     deprecated_stock_id;
-#else
-  const gchar *stock_id;
-#endif
-
-  /*  implementing the GimpColorDisplay::convert_surface method is deprecated  */
-  void               (* convert_surface) (GimpColorDisplay *display,
-                                          cairo_surface_t  *surface);
-
-  void               (* convert_buffer)  (GimpColorDisplay *display,
-                                          GeglBuffer       *buffer,
-                                          GeglRectangle    *area);
-
-  /*  icon name  */
-  const gchar *icon_name;
+  /* 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 f15ce10..9bf0464 100644
--- a/libgimpwidgets/gimpcolordisplaystack.c
+++ b/libgimpwidgets/gimpcolordisplaystack.c
@@ -387,7 +387,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]