[gimp] app: pass a status_callback to gimp_babl_init_fishes()



commit 17ac37ef8e168e8716e9e80096bfa8302d4f650e
Author: Michael Natterer <mitch gimp org>
Date:   Fri Nov 11 13:09:12 2016 +0100

    app: pass a status_callback to gimp_babl_init_fishes()
    
    and make it report progress. Also call it at the end of initialization.

 app/core/gimp.c      |    8 +++---
 app/gegl/gimp-babl.c |   58 +++++++++++++++++++++++++++++++++----------------
 app/gegl/gimp-babl.h |    4 +-
 3 files changed, 45 insertions(+), 25 deletions(-)
---
diff --git a/app/core/gimp.c b/app/core/gimp.c
index d34d572..eb0bbb0 100644
--- a/app/core/gimp.c
+++ b/app/core/gimp.c
@@ -602,10 +602,6 @@ gimp_real_initialize (Gimp               *gimp,
 
   gimp_plug_in_manager_initialize (gimp->plug_in_manager, status_callback);
 
-  /*  initialize babl fishes  */
-  status_callback (NULL, "Babl Fishes", 0.9);
-  gimp_babl_init_fishes ();
-
   status_callback (NULL, "", 1.0);
 }
 
@@ -619,6 +615,10 @@ gimp_real_restore (Gimp               *gimp,
   gimp_plug_in_manager_restore (gimp->plug_in_manager,
                                 gimp_get_user_context (gimp), status_callback);
 
+  /*  initialize babl fishes  */
+  status_callback (_("Initialization"), "Babl Fishes", 0.0);
+  gimp_babl_init_fishes (status_callback);
+
   gimp->restored = TRUE;
 }
 
diff --git a/app/gegl/gimp-babl.c b/app/gegl/gimp-babl.c
index 64e5add..e432551 100644
--- a/app/gegl/gimp-babl.c
+++ b/app/gegl/gimp-babl.c
@@ -254,29 +254,49 @@ gimp_babl_init (void)
 }
 
 void
-gimp_babl_init_fishes (void)
+gimp_babl_init_fishes (GimpInitStatusFunc status_callback)
 {
   /* create a bunch of fishes - to decrease the initial lazy
    * intialization cost for some interactions
    */
-  babl_fish (babl_format ("Y' u8"),          babl_format ("RaGaBaA float"));
-  babl_fish (babl_format ("Y u8"),           babl_format ("RaGaBaA float"));
-  babl_fish (babl_format ("R'G'B'A u8"),     babl_format ("RaGaBaA float"));
-  babl_fish (babl_format ("R'G'B'A float"),  babl_format ("R'G'B'A u8"));
-  babl_fish (babl_format ("R'G'B'A float"),  babl_format ("R'G'B' u8"));
-  babl_fish (babl_format ("R'G'B'A u8"),     babl_format ("RGBA float"));
-  babl_fish (babl_format ("RGBA float"),     babl_format ("R'G'B'A u8"));
-  babl_fish (babl_format ("RGBA float"),     babl_format ("R'G'B'A u8"));
-  babl_fish (babl_format ("RGBA float"),     babl_format ("R'G'B'A float"));
-  babl_fish (babl_format ("Y' u8"),          babl_format ("R'G'B' u8"));
-  babl_fish (babl_format ("Y u8"),           babl_format ("Y float"));
-  babl_fish (babl_format ("R'G'B' u8"),      babl_format ("cairo-RGB24"));
-  babl_fish (babl_format ("R'G'B' u8"),      babl_format ("R'G'B'A float"));
-  babl_fish (babl_format ("R'G'B' u8"),      babl_format ("R'G'B'A u8"));
-  babl_fish (babl_format ("R'G'B'A u8"),     babl_format ("R'G'B'A float"));
-  babl_fish (babl_format ("R'G'B'A u8"),     babl_format ("cairo-ARGB32"));
-  babl_fish (babl_format ("R'G'B'A double"), babl_format ("RGBA float"));
-  babl_fish (babl_format ("R'G'B'A float"),  babl_format ("RGBA double"));
+  static const struct
+  {
+    const gchar *from_format;
+    const gchar *to_format;
+  }
+  fishes[] =
+  {
+    { "Y' u8",          "RaGaBaA float" },
+    { "Y u8",           "RaGaBaA float" },
+    { "R'G'B'A u8",     "RaGaBaA float" },
+    { "R'G'B'A float",  "R'G'B'A u8"    },
+    { "R'G'B'A float",  "R'G'B' u8"     },
+    { "R'G'B'A u8",     "RGBA float"    },
+    { "RGBA float",     "R'G'B'A u8"    },
+    { "RGBA float",     "R'G'B'A u8"    },
+    { "RGBA float",     "R'G'B'A float" },
+    { "Y' u8",          "R'G'B' u8"     },
+    { "Y u8",           "Y float"       },
+    { "R'G'B' u8",      "cairo-RGB24"   },
+    { "R'G'B' u8",      "R'G'B'A float" },
+    { "R'G'B' u8",      "R'G'B'A u8"    },
+    { "R'G'B'A u8",     "R'G'B'A float" },
+    { "R'G'B'A u8",     "cairo-ARGB32"  },
+    { "R'G'B'A double", "RGBA float"    },
+    { "R'G'B'A float",  "RGBA double"   }
+  };
+
+  gint i;
+
+  for (i = 0; i < G_N_ELEMENTS (fishes); i++)
+    {
+      status_callback (NULL, NULL,
+                       (gdouble) (i + 1) /
+                       (gdouble) G_N_ELEMENTS (fishes) / 2.0);
+
+      babl_fish (babl_format (fishes[i].from_format),
+                 babl_format (fishes[i].to_format));
+    }
 }
 
 static const struct
diff --git a/app/gegl/gimp-babl.h b/app/gegl/gimp-babl.h
index bab9298..7a9e1c3 100644
--- a/app/gegl/gimp-babl.h
+++ b/app/gegl/gimp-babl.h
@@ -22,8 +22,8 @@
 #define __GIMP_BABL_H__
 
 
-void                gimp_babl_init                      (void);
-void                gimp_babl_init_fishes               (void);
+void                gimp_babl_init             (void);
+void                gimp_babl_init_fishes      (GimpInitStatusFunc status_callback);
 
 const gchar       * gimp_babl_format_get_description    (const Babl *format);
 GimpColorProfile  * gimp_babl_format_get_color_profile  (const Babl *format);


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