[gimp/goat-invasion: 523/526] app: add gimp-babl.[ch] and move Babl specific code there
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 523/526] app: add gimp-babl.[ch] and move Babl specific code there
- Date: Sun, 22 Apr 2012 13:43:14 +0000 (UTC)
commit adabc4df86a8250d44abd675ec7556da8478a3a5
Author: Michael Natterer <mitch gimp org>
Date: Sat Apr 21 23:46:41 2012 +0200
app: add gimp-babl.[ch] and move Babl specific code there
app/core/gimpimagefile.c | 2 +-
app/display/gimpdisplayshell-title.c | 2 +-
app/gegl/Makefile.am | 2 +
app/gegl/gimp-babl.c | 124 ++++++++++++++++++++++++++++++++++
app/gegl/gimp-babl.h | 30 ++++++++
app/gegl/gimp-gegl.c | 93 +-------------------------
app/gegl/gimp-gegl.h | 4 +-
7 files changed, 161 insertions(+), 96 deletions(-)
---
diff --git a/app/core/gimpimagefile.c b/app/core/gimpimagefile.c
index bb60713..aceb2ec 100644
--- a/app/core/gimpimagefile.c
+++ b/app/core/gimpimagefile.c
@@ -34,7 +34,7 @@
#include "config/gimpcoreconfig.h"
-#include "gegl/gimp-gegl.h"
+#include "gegl/gimp-babl.h"
#include "gegl/gimp-gegl-utils.h"
#include "gimp.h"
diff --git a/app/display/gimpdisplayshell-title.c b/app/display/gimpdisplayshell-title.c
index b0a86bc..9ece777 100644
--- a/app/display/gimpdisplayshell-title.c
+++ b/app/display/gimpdisplayshell-title.c
@@ -31,7 +31,7 @@
#include "config/gimpdisplayconfig.h"
-#include "gegl/gimp-gegl.h"
+#include "gegl/gimp-babl.h"
#include "core/gimpcontainer.h"
#include "core/gimpdrawable.h"
diff --git a/app/gegl/Makefile.am b/app/gegl/Makefile.am
index 6e9d2ef..bac873d 100644
--- a/app/gegl/Makefile.am
+++ b/app/gegl/Makefile.am
@@ -18,6 +18,8 @@ noinst_LIBRARIES = libappgegl.a
libappgegl_a_sources = \
gimp-gegl-enums.h \
gimp-gegl-types.h \
+ gimp-babl.c \
+ gimp-babl.h \
gimp-gegl.c \
gimp-gegl.h \
gimp-gegl-config-proxy.c \
diff --git a/app/gegl/gimp-babl.c b/app/gegl/gimp-babl.c
new file mode 100644
index 0000000..0d62bd3
--- /dev/null
+++ b/app/gegl/gimp-babl.c
@@ -0,0 +1,124 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimp-babl.c
+ * Copyright (C) 2012 Michael Natterer <mitch gimp org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <gegl.h>
+
+#include "gimp-gegl-types.h"
+
+#include "gimp-babl.h"
+
+#include "gimp-intl.h"
+
+
+void
+gimp_babl_init (void)
+{
+ babl_format_new ("name", "R' u8",
+ babl_model ("R'G'B'A"),
+ babl_type ("u8"),
+ babl_component ("R'"),
+ NULL);
+ babl_format_new ("name", "G' u8",
+ babl_model ("R'G'B'A"),
+ babl_type ("u8"),
+ babl_component ("G'"),
+ NULL);
+ babl_format_new ("name", "B' u8",
+ babl_model ("R'G'B'A"),
+ babl_type ("u8"),
+ babl_component ("B'"),
+ NULL);
+ babl_format_new ("name", "A u8",
+ babl_model ("R'G'B'A"),
+ babl_type ("u8"),
+ babl_component ("A"),
+ NULL);
+
+ babl_format_new ("name", "A float",
+ babl_model ("R'G'B'A"),
+ babl_type ("float"),
+ babl_component ("A"),
+ NULL);
+
+ babl_format_new ("name", "A double",
+ babl_model ("R'G'B'A"),
+ babl_type ("double"),
+ babl_component ("A"),
+ NULL);
+}
+
+static const struct
+{
+ const gchar *name;
+ const gchar *description;
+}
+babl_descriptions[] =
+{
+ { "R'G'B' u8", N_("RGB") },
+ { "R'G'B'A u8", N_("RGB-alpha") },
+ { "Y' u8", N_("Grayscale") },
+ { "Y'A u8", N_("Grayscale-alpha") },
+ { "R' u8", N_("Red component") },
+ { "G' u8", N_("Green component") },
+ { "B' u8", N_("Blue component") },
+ { "A u8", N_("Alpha component") }
+};
+
+static GHashTable *babl_description_hash = NULL;
+
+const gchar *
+gimp_babl_get_description (const Babl *babl)
+{
+ const gchar *description;
+
+ g_return_val_if_fail (babl != NULL, NULL);
+
+ if (G_UNLIKELY (! babl_description_hash))
+ {
+ gint i;
+
+ babl_description_hash = g_hash_table_new (g_str_hash,
+ g_str_equal);
+
+ for (i = 0; i < G_N_ELEMENTS (babl_descriptions); i++)
+ g_hash_table_insert (babl_description_hash,
+ (gpointer) babl_descriptions[i].name,
+ gettext (babl_descriptions[i].description));
+ }
+
+ if (babl_format_is_palette (babl))
+ {
+ if (babl_format_has_alpha (babl))
+ return _("Indexed-alpha");
+ else
+ return _("Indexed");
+ }
+
+ description = g_hash_table_lookup (babl_description_hash,
+ babl_get_name (babl));
+
+ if (description)
+ return description;
+
+ return g_strconcat ("ERROR: unknown Babl format ",
+ babl_get_name (babl), NULL);
+}
diff --git a/app/gegl/gimp-babl.h b/app/gegl/gimp-babl.h
new file mode 100644
index 0000000..06dd3ec
--- /dev/null
+++ b/app/gegl/gimp-babl.h
@@ -0,0 +1,30 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimp-babl.h
+ * Copyright (C) 2012 Michael Natterer <mitch gimp org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_BABL_H__
+#define __GIMP_BABL_H__
+
+
+void gimp_babl_init (void);
+
+const gchar * gimp_babl_get_description (const Babl *babl);
+
+
+#endif /* __GIMP_BABL_H__ */
diff --git a/app/gegl/gimp-gegl.c b/app/gegl/gimp-gegl.c
index af0b471..8f905d1 100644
--- a/app/gegl/gimp-gegl.c
+++ b/app/gegl/gimp-gegl.c
@@ -30,6 +30,7 @@
#include "core/gimp.h"
+#include "gimp-babl.h"
#include "gimp-gegl.h"
#include "gimpoperationborder.h"
@@ -80,8 +81,6 @@
#include "gimpoperationreplacemode.h"
#include "gimpoperationantierasemode.h"
-#include "gimp-intl.h"
-
static void gimp_gegl_notify_tile_cache_size (GimpBaseConfig *config);
@@ -113,38 +112,7 @@ gimp_gegl_init (Gimp *gimp)
G_CALLBACK (gimp_gegl_notify_tile_cache_size),
NULL);
- babl_format_new ("name", "R' u8",
- babl_model ("R'G'B'A"),
- babl_type ("u8"),
- babl_component ("R'"),
- NULL);
- babl_format_new ("name", "G' u8",
- babl_model ("R'G'B'A"),
- babl_type ("u8"),
- babl_component ("G'"),
- NULL);
- babl_format_new ("name", "B' u8",
- babl_model ("R'G'B'A"),
- babl_type ("u8"),
- babl_component ("B'"),
- NULL);
- babl_format_new ("name", "A u8",
- babl_model ("R'G'B'A"),
- babl_type ("u8"),
- babl_component ("A"),
- NULL);
-
- babl_format_new ("name", "A float",
- babl_model ("R'G'B'A"),
- babl_type ("float"),
- babl_component ("A"),
- NULL);
-
- babl_format_new ("name", "A double",
- babl_model ("R'G'B'A"),
- babl_type ("double"),
- babl_component ("A"),
- NULL);
+ gimp_babl_init ();
g_type_class_ref (GIMP_TYPE_OPERATION_BORDER);
g_type_class_ref (GIMP_TYPE_OPERATION_CAGE_COEF_CALC);
@@ -195,63 +163,6 @@ gimp_gegl_init (Gimp *gimp)
g_type_class_ref (GIMP_TYPE_OPERATION_ANTI_ERASE_MODE);
}
-static const struct
-{
- const gchar *name;
- const gchar *description;
-}
-babl_descriptions[] =
-{
- { "R'G'B' u8", N_("RGB") },
- { "R'G'B'A u8", N_("RGB-alpha") },
- { "Y' u8", N_("Grayscale") },
- { "Y'A u8", N_("Grayscale-alpha") },
- { "R' u8", N_("Red component") },
- { "G' u8", N_("Green component") },
- { "B' u8", N_("Blue component") },
- { "A u8", N_("Alpha component") }
-};
-
-static GHashTable *babl_description_hash = NULL;
-
-const gchar *
-gimp_babl_get_description (const Babl *babl)
-{
- const gchar *description;
-
- g_return_val_if_fail (babl != NULL, NULL);
-
- if (G_UNLIKELY (! babl_description_hash))
- {
- gint i;
-
- babl_description_hash = g_hash_table_new (g_str_hash,
- g_str_equal);
-
- for (i = 0; i < G_N_ELEMENTS (babl_descriptions); i++)
- g_hash_table_insert (babl_description_hash,
- (gpointer) babl_descriptions[i].name,
- gettext (babl_descriptions[i].description));
- }
-
- if (babl_format_is_palette (babl))
- {
- if (babl_format_has_alpha (babl))
- return _("Indexed-alpha");
- else
- return _("Indexed");
- }
-
- description = g_hash_table_lookup (babl_description_hash,
- babl_get_name (babl));
-
- if (description)
- return description;
-
- return g_strconcat ("ERROR: unknown Babl format ",
- babl_get_name (babl), NULL);
-}
-
static void
gimp_gegl_notify_tile_cache_size (GimpBaseConfig *config)
{
diff --git a/app/gegl/gimp-gegl.h b/app/gegl/gimp-gegl.h
index 6f07440..532f178 100644
--- a/app/gegl/gimp-gegl.h
+++ b/app/gegl/gimp-gegl.h
@@ -22,9 +22,7 @@
#define __GIMP_GEGL_H__
-void gimp_gegl_init (Gimp *gimp);
-
-const gchar * gimp_babl_get_description (const Babl *babl);
+void gimp_gegl_init (Gimp *gimp);
#endif /* __GIMP_GEGL_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]