[gimp] app: some updates in the new colormap palette proxy code



commit d899328a1cd7d21d9357a2899d1bfbc174704119
Author: Michael Natterer <mitch gimp org>
Date:   Thu Oct 28 02:12:52 2010 +0200

    app: some updates in the new colormap palette proxy code
    
    - update the palette when single colormap entries change
    - set the palette to 16 columns
    - add an accessor for the palette

 app/core/gimpimage-colormap.c |   20 ++++++++++++++++-
 app/core/gimpimage-colormap.h |   44 +++++++++++++++++++++-------------------
 2 files changed, 41 insertions(+), 23 deletions(-)
---
diff --git a/app/core/gimpimage-colormap.c b/app/core/gimpimage-colormap.c
index ee66d0d..d8fec85 100644
--- a/app/core/gimpimage-colormap.c
+++ b/app/core/gimpimage-colormap.c
@@ -70,6 +70,8 @@ gimp_image_colormap_init (GimpImage *image)
   private->colormap = g_new0 (guchar, GIMP_IMAGE_COLORMAP_SIZE);
   private->palette  = GIMP_PALETTE (gimp_palette_new (NULL, palette_name));
 
+  gimp_palette_set_columns  (private->palette, 16);
+
   gimp_data_make_internal (GIMP_DATA (private->palette), palette_id);
 
   palettes = gimp_data_factory_get_container (image->gimp->palette_factory);
@@ -117,6 +119,14 @@ gimp_image_colormap_free (GimpImage *image)
   private->palette = NULL;
 }
 
+GimpPalette *
+gimp_image_get_colormap_palette (GimpImage *image)
+{
+  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+
+  return GIMP_IMAGE_GET_PRIVATE (image)->palette;
+}
+
 const guchar *
 gimp_image_get_colormap (const GimpImage *image)
 {
@@ -170,8 +180,6 @@ gimp_image_set_colormap (GimpImage    *image,
 
   private->n_colors = n_colors;
 
-  gimp_image_colormap_changed (image, -1);
-
   if (private->palette)
     {
       GimpPaletteEntry *entry;
@@ -187,6 +195,8 @@ gimp_image_set_colormap (GimpImage    *image,
 
       gimp_data_thaw (GIMP_DATA (private->palette));
     }
+
+  gimp_image_colormap_changed (image, -1);
 }
 
 void
@@ -236,6 +246,9 @@ gimp_image_set_colormap_entry (GimpImage     *image,
                       &private->colormap[color_index * 3 + 1],
                       &private->colormap[color_index * 3 + 2]);
 
+  if (private->palette)
+    gimp_image_colormap_set_palette_entry (image, color_index);
+
   gimp_image_colormap_changed (image, color_index);
 }
 
@@ -261,6 +274,9 @@ gimp_image_add_colormap_entry (GimpImage     *image,
                       &private->colormap[private->n_colors * 3 + 1],
                       &private->colormap[private->n_colors * 3 + 2]);
 
+  if (private->palette)
+    gimp_image_colormap_set_palette_entry (image, private->n_colors - 1);
+
   private->n_colors++;
 
   gimp_image_colormap_changed (image, -1);
diff --git a/app/core/gimpimage-colormap.h b/app/core/gimpimage-colormap.h
index 03fb048..54be91e 100644
--- a/app/core/gimpimage-colormap.h
+++ b/app/core/gimpimage-colormap.h
@@ -22,27 +22,29 @@
 #define GIMP_IMAGE_COLORMAP_SIZE 768
 
 
-void           gimp_image_colormap_init      (GimpImage       *image);
-void           gimp_image_colormap_dispose   (GimpImage       *image);
-void           gimp_image_colormap_free      (GimpImage       *image);
-
-const guchar * gimp_image_get_colormap       (const GimpImage *image);
-gint           gimp_image_get_colormap_size  (const GimpImage *image);
-void           gimp_image_set_colormap       (GimpImage       *image,
-                                              const guchar    *colormap,
-                                              gint             n_colors,
-                                              gboolean         push_undo);
-
-void           gimp_image_get_colormap_entry (GimpImage       *image,
-                                              gint             color_index,
-                                              GimpRGB         *color);
-void           gimp_image_set_colormap_entry (GimpImage       *image,
-                                              gint             color_index,
-                                              const GimpRGB   *color,
-                                              gboolean         push_undo);
-
-void           gimp_image_add_colormap_entry (GimpImage       *image,
-                                              const GimpRGB   *color);
+void           gimp_image_colormap_init        (GimpImage       *image);
+void           gimp_image_colormap_dispose     (GimpImage       *image);
+void           gimp_image_colormap_free        (GimpImage       *image);
+
+GimpPalette  * gimp_image_get_colormap_palette (GimpImage       *image);
+
+const guchar * gimp_image_get_colormap         (const GimpImage *image);
+gint           gimp_image_get_colormap_size    (const GimpImage *image);
+void           gimp_image_set_colormap         (GimpImage       *image,
+                                                const guchar    *colormap,
+                                                gint             n_colors,
+                                                gboolean         push_undo);
+
+void           gimp_image_get_colormap_entry   (GimpImage       *image,
+                                                gint             color_index,
+                                                GimpRGB         *color);
+void           gimp_image_set_colormap_entry   (GimpImage       *image,
+                                                gint             color_index,
+                                                const GimpRGB   *color,
+                                                gboolean         push_undo);
+
+void           gimp_image_add_colormap_entry   (GimpImage       *image,
+                                                const GimpRGB   *color);
 
 
 #endif /* __GIMP_IMAGE_COLORMAP_H__ */



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