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



commit d183fcf7173594bbabcdd3b85950ee4db897d2cc
Author: Michael Natterer <mitch gimp org>
Date:   Fri Dec 31 19:11:27 2010 +0100

    libgimpwidgets: move all GimpColorDisplayStack members to a private struct

 app/widgets/gimpcolordisplayeditor.c   |   10 ++-
 libgimpwidgets/gimpcolordisplaystack.c |  101 ++++++++++++++++++++++++--------
 libgimpwidgets/gimpcolordisplaystack.h |   40 ++++++------
 3 files changed, 104 insertions(+), 47 deletions(-)
---
diff --git a/app/widgets/gimpcolordisplayeditor.c b/app/widgets/gimpcolordisplayeditor.c
index 9e842ea..1284525 100644
--- a/app/widgets/gimpcolordisplayeditor.c
+++ b/app/widgets/gimpcolordisplayeditor.c
@@ -408,7 +408,9 @@ gimp_color_display_editor_new (GimpColorDisplayStack *stack,
 
   g_free (display_types);
 
-  for (list = stack->filters; list; list = g_list_next (list))
+  for (list = gimp_color_display_stack_get_filters (stack);
+       list;
+       list = g_list_next (list))
     {
       GimpColorDisplay *display = list->data;
       GtkTreeIter       iter;
@@ -701,6 +703,7 @@ gimp_color_display_editor_reordered (GimpColorDisplayStack  *stack,
 
       if (display == display2)
         {
+          GList       *filters = gimp_color_display_stack_get_filters (stack);
           GtkTreePath *path;
           gint         old_position;
 
@@ -711,7 +714,7 @@ gimp_color_display_editor_reordered (GimpColorDisplayStack  *stack,
           if (position == old_position)
             return;
 
-          if (position == -1 || position == g_list_length (stack->filters) - 1)
+          if (position == -1 || position == g_list_length (filters) - 1)
             {
               gtk_list_store_move_before (editor->dest, &iter, NULL);
             }
@@ -812,11 +815,12 @@ gimp_color_display_editor_update_buttons (GimpColorDisplayEditor *editor)
 
   if (gtk_tree_selection_get_selected (editor->dest_sel, &model, &iter))
     {
+      GList       *filters = gimp_color_display_stack_get_filters (editor->stack);
       GtkTreePath *path    = gtk_tree_model_get_path (model, &iter);
       gint        *indices = gtk_tree_path_get_indices (path);
 
       up_sensitive   = indices[0] > 0;
-      down_sensitive = indices[0] < (g_list_length (editor->stack->filters) - 1);
+      down_sensitive = indices[0] < (g_list_length (filters) - 1);
 
       gtk_tree_path_free (path);
     }
diff --git a/libgimpwidgets/gimpcolordisplaystack.c b/libgimpwidgets/gimpcolordisplaystack.c
index 0a91714..bdfef53 100644
--- a/libgimpwidgets/gimpcolordisplaystack.c
+++ b/libgimpwidgets/gimpcolordisplaystack.c
@@ -54,6 +54,18 @@ enum
 };
 
 
+typedef struct _GimpColorDisplayStackPrivate GimpColorDisplayStackPrivate;
+
+struct _GimpColorDisplayStackPrivate
+{
+  GList *filters;
+};
+
+#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
+                                                       GIMP_TYPE_COLOR_DISPLAY_STACK, \
+                                                       GimpColorDisplayStackPrivate))
+
+
 static void   gimp_color_display_stack_dispose         (GObject               *object);
 
 static void   gimp_color_display_stack_display_changed (GimpColorDisplay      *display,
@@ -124,24 +136,29 @@ gimp_color_display_stack_class_init (GimpColorDisplayStackClass *klass)
   klass->added          = NULL;
   klass->removed        = NULL;
   klass->reordered      = NULL;
+
+  g_type_class_add_private (object_class, sizeof (GimpColorDisplayStackPrivate));
 }
 
 static void
 gimp_color_display_stack_init (GimpColorDisplayStack *stack)
 {
-  stack->filters = NULL;
+  GimpColorDisplayStackPrivate *private = GET_PRIVATE (stack);
+
+  private->filters = NULL;
 }
 
 static void
 gimp_color_display_stack_dispose (GObject *object)
 {
-  GimpColorDisplayStack *stack = GIMP_COLOR_DISPLAY_STACK (object);
+  GimpColorDisplayStack        *stack   = GIMP_COLOR_DISPLAY_STACK (object);
+  GimpColorDisplayStackPrivate *private = GET_PRIVATE (object);
 
-  if (stack->filters)
+  if (private->filters)
     {
       GList *list;
 
-      for (list = stack->filters; list; list = g_list_next (list))
+      for (list = private->filters; list; list = g_list_next (list))
         {
           GimpColorDisplay *display = list->data;
 
@@ -149,13 +166,16 @@ gimp_color_display_stack_dispose (GObject *object)
           g_object_unref (display);
         }
 
-      g_list_free (stack->filters);
-      stack->filters = NULL;
+      g_list_free (private->filters);
+      private->filters = NULL;
     }
 
   G_OBJECT_CLASS (parent_class)->dispose (object);
 }
 
+
+/*  public functions  */
+
 GimpColorDisplayStack *
 gimp_color_display_stack_new (void)
 {
@@ -165,14 +185,17 @@ gimp_color_display_stack_new (void)
 GimpColorDisplayStack *
 gimp_color_display_stack_clone (GimpColorDisplayStack *stack)
 {
-  GimpColorDisplayStack *clone;
-  GList                 *list;
+  GimpColorDisplayStackPrivate *private;
+  GimpColorDisplayStack        *clone;
+  GList                        *list;
 
   g_return_val_if_fail (GIMP_IS_COLOR_DISPLAY_STACK (stack), NULL);
 
+  private = GET_PRIVATE (stack);
+
   clone = g_object_new (GIMP_TYPE_COLOR_DISPLAY_STACK, NULL);
 
-  for (list = stack->filters; list; list = g_list_next (list))
+  for (list = private->filters; list; list = g_list_next (list))
     {
       GimpColorDisplay *display;
 
@@ -193,15 +216,28 @@ gimp_color_display_stack_changed (GimpColorDisplayStack *stack)
   g_signal_emit (stack, stack_signals[CHANGED], 0);
 }
 
+GList *
+gimp_color_display_stack_get_filters (GimpColorDisplayStack *stack)
+{
+  g_return_val_if_fail (GIMP_IS_COLOR_DISPLAY_STACK (stack), NULL);
+
+  return GET_PRIVATE (stack)->filters;
+}
+
 void
 gimp_color_display_stack_add (GimpColorDisplayStack *stack,
                               GimpColorDisplay      *display)
 {
+  GimpColorDisplayStackPrivate *private;
+
   g_return_if_fail (GIMP_IS_COLOR_DISPLAY_STACK (stack));
   g_return_if_fail (GIMP_IS_COLOR_DISPLAY (display));
-  g_return_if_fail (g_list_find (stack->filters, display) == NULL);
 
-  stack->filters = g_list_append (stack->filters, g_object_ref (display));
+  private = GET_PRIVATE (stack);
+
+  g_return_if_fail (g_list_find (private->filters, display) == NULL);
+
+  private->filters = g_list_append (private->filters, g_object_ref (display));
 
   g_signal_connect (display, "changed",
                     G_CALLBACK (gimp_color_display_stack_display_changed),
@@ -211,7 +247,7 @@ gimp_color_display_stack_add (GimpColorDisplayStack *stack,
                     G_OBJECT (stack));
 
   g_signal_emit (stack, stack_signals[ADDED], 0,
-                 display, g_list_length (stack->filters) - 1);
+                 display, g_list_length (private->filters) - 1);
 
   gimp_color_display_stack_changed (stack);
 }
@@ -220,13 +256,18 @@ void
 gimp_color_display_stack_remove (GimpColorDisplayStack *stack,
                                  GimpColorDisplay      *display)
 {
+  GimpColorDisplayStackPrivate *private;
+
   g_return_if_fail (GIMP_IS_COLOR_DISPLAY_STACK (stack));
   g_return_if_fail (GIMP_IS_COLOR_DISPLAY (display));
-  g_return_if_fail (g_list_find (stack->filters, display) != NULL);
+
+  private = GET_PRIVATE (stack);
+
+  g_return_if_fail (g_list_find (private->filters, display) != NULL);
 
   gimp_color_display_stack_disconnect (stack, display);
 
-  stack->filters = g_list_remove (stack->filters, display);
+  private->filters = g_list_remove (private->filters, display);
 
   g_signal_emit (stack, stack_signals[REMOVED], 0, display);
 
@@ -239,12 +280,15 @@ void
 gimp_color_display_stack_reorder_up (GimpColorDisplayStack *stack,
                                      GimpColorDisplay      *display)
 {
-  GList *list;
+  GimpColorDisplayStackPrivate *private;
+  GList                        *list;
 
   g_return_if_fail (GIMP_IS_COLOR_DISPLAY_STACK (stack));
   g_return_if_fail (GIMP_IS_COLOR_DISPLAY (display));
 
-  list = g_list_find (stack->filters, display);
+  private = GET_PRIVATE (stack);
+
+  list = g_list_find (private->filters, display);
 
   g_return_if_fail (list != NULL);
 
@@ -254,7 +298,7 @@ gimp_color_display_stack_reorder_up (GimpColorDisplayStack *stack,
       list->prev->data = display;
 
       g_signal_emit (stack, stack_signals[REORDERED], 0,
-                     display, g_list_position (stack->filters, list->prev));
+                     display, g_list_position (private->filters, list->prev));
 
       gimp_color_display_stack_changed (stack);
     }
@@ -264,12 +308,15 @@ void
 gimp_color_display_stack_reorder_down (GimpColorDisplayStack *stack,
                                        GimpColorDisplay      *display)
 {
-  GList *list;
+  GimpColorDisplayStackPrivate *private;
+  GList                        *list;
 
   g_return_if_fail (GIMP_IS_COLOR_DISPLAY_STACK (stack));
   g_return_if_fail (GIMP_IS_COLOR_DISPLAY (display));
 
-  list = g_list_find (stack->filters, display);
+  private = GET_PRIVATE (stack);
+
+  list = g_list_find (private->filters, display);
 
   g_return_if_fail (list != NULL);
 
@@ -279,7 +326,7 @@ gimp_color_display_stack_reorder_down (GimpColorDisplayStack *stack,
       list->next->data = display;
 
       g_signal_emit (stack, stack_signals[REORDERED], 0,
-                     display, g_list_position (stack->filters, list->next));
+                     display, g_list_position (private->filters, list->next));
 
       gimp_color_display_stack_changed (stack);
     }
@@ -298,14 +345,17 @@ void
 gimp_color_display_stack_convert_surface (GimpColorDisplayStack *stack,
                                           cairo_surface_t       *surface)
 {
-  GList *list;
+  GimpColorDisplayStackPrivate *private;
+  GList                        *list;
 
   g_return_if_fail (GIMP_IS_COLOR_DISPLAY_STACK (stack));
   g_return_if_fail (surface != NULL);
   g_return_if_fail (cairo_surface_get_type (surface) ==
                     CAIRO_SURFACE_TYPE_IMAGE);
 
-  for (list = stack->filters; list; list = g_list_next (list))
+  private = GET_PRIVATE (stack);
+
+  for (list = private->filters; list; list = g_list_next (list))
     {
       GimpColorDisplay *display = list->data;
 
@@ -334,11 +384,14 @@ gimp_color_display_stack_convert (GimpColorDisplayStack *stack,
                                   gint                   bpp,
                                   gint                   bpl)
 {
-  GList *list;
+  GimpColorDisplayStackPrivate *private;
+  GList                        *list;
 
   g_return_if_fail (GIMP_IS_COLOR_DISPLAY_STACK (stack));
 
-  for (list = stack->filters; list; list = g_list_next (list))
+  private = GET_PRIVATE (stack);
+
+  for (list = private->filters; list; list = g_list_next (list))
     {
       GimpColorDisplay *display = list->data;
 
diff --git a/libgimpwidgets/gimpcolordisplaystack.h b/libgimpwidgets/gimpcolordisplaystack.h
index d3e0304..d6140b2 100644
--- a/libgimpwidgets/gimpcolordisplaystack.h
+++ b/libgimpwidgets/gimpcolordisplaystack.h
@@ -44,8 +44,6 @@ typedef struct _GimpColorDisplayStackClass GimpColorDisplayStackClass;
 struct _GimpColorDisplayStack
 {
   GObject  parent_instance;
-
-  GList   *filters;
 };
 
 struct _GimpColorDisplayStackClass
@@ -75,25 +73,27 @@ GType                   gimp_color_display_stack_get_type (void) G_GNUC_CONST;
 GimpColorDisplayStack * gimp_color_display_stack_new      (void);
 GimpColorDisplayStack * gimp_color_display_stack_clone    (GimpColorDisplayStack *stack);
 
-void   gimp_color_display_stack_changed         (GimpColorDisplayStack *stack);
-
-void   gimp_color_display_stack_add             (GimpColorDisplayStack *stack,
-                                                 GimpColorDisplay      *display);
-void   gimp_color_display_stack_remove          (GimpColorDisplayStack *stack,
-                                                 GimpColorDisplay      *display);
-void   gimp_color_display_stack_reorder_up      (GimpColorDisplayStack *stack,
-                                                 GimpColorDisplay      *display);
-void   gimp_color_display_stack_reorder_down    (GimpColorDisplayStack *stack,
-                                                 GimpColorDisplay      *display);
-void   gimp_color_display_stack_convert_surface (GimpColorDisplayStack *stack,
-                                                 cairo_surface_t       *surface);
+void    gimp_color_display_stack_changed         (GimpColorDisplayStack *stack);
+
+GList * gimp_color_display_stack_get_filters     (GimpColorDisplayStack *stack);
+
+void    gimp_color_display_stack_add             (GimpColorDisplayStack *stack,
+                                                  GimpColorDisplay      *display);
+void    gimp_color_display_stack_remove          (GimpColorDisplayStack *stack,
+                                                  GimpColorDisplay      *display);
+void    gimp_color_display_stack_reorder_up      (GimpColorDisplayStack *stack,
+                                                  GimpColorDisplay      *display);
+void    gimp_color_display_stack_reorder_down    (GimpColorDisplayStack *stack,
+                                                  GimpColorDisplay      *display);
+void    gimp_color_display_stack_convert_surface (GimpColorDisplayStack *stack,
+                                                  cairo_surface_t       *surface);
 GIMP_DEPRECATED_FOR(gimp_color_display_stack_convert_surface)
-void   gimp_color_display_stack_convert         (GimpColorDisplayStack *stack,
-                                                 guchar                *buf,
-                                                 gint                   width,
-                                                 gint                   height,
-                                                 gint                   bpp,
-                                                 gint                   bpl);
+void    gimp_color_display_stack_convert         (GimpColorDisplayStack *stack,
+                                                  guchar                *buf,
+                                                  gint                   width,
+                                                  gint                   height,
+                                                  gint                   bpp,
+                                                  gint                   bpl);
 
 G_END_DECLS
 


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