diff --git a/app/core/gimpimagefile.c b/app/core/gimpimagefile.c index 13256cde7e..536921f5d8 100644 --- a/app/core/gimpimagefile.c +++ b/app/core/gimpimagefile.c @@ -34,6 +34,7 @@ #include "config/gimpcoreconfig.h" +#include "gegl/gimp-gegl.h" #include "gegl/gimp-gegl-utils.h" #include "gimp.h" @@ -973,9 +974,7 @@ gimp_thumbnail_set_info_from_image (GimpThumbnail *thumbnail, const gchar *mime_type, GimpImage *image) { - GimpEnumDesc *desc; - const Babl *format; - GimpImageType type; + const Babl *format; /* peek the thumbnail to make sure that mtime and filesize are set */ gimp_thumbnail_peek_image (thumbnail); @@ -983,15 +982,11 @@ gimp_thumbnail_set_info_from_image (GimpThumbnail *thumbnail, format = gimp_image_get_layer_format (image, gimp_image_has_alpha (image)); - type = gimp_babl_format_get_image_type (format); - - desc = gimp_enum_get_desc (g_type_class_peek (GIMP_TYPE_IMAGE_TYPE), type); - g_object_set (thumbnail, "image-mimetype", mime_type, "image-width", gimp_image_get_width (image), "image-height", gimp_image_get_height (image), - "image-type", desc->value_desc, + "image-type", gimp_babl_get_description (format), "image-num-layers", gimp_image_get_n_layers (image), NULL); } diff --git a/app/display/gimpdisplayshell-title.c b/app/display/gimpdisplayshell-title.c index 2cc4c28711..b0a86bc070 100644 --- a/app/display/gimpdisplayshell-title.c +++ b/app/display/gimpdisplayshell-title.c @@ -31,6 +31,8 @@ #include "config/gimpdisplayconfig.h" +#include "gegl/gimp-gegl.h" + #include "core/gimpcontainer.h" #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -135,17 +137,6 @@ gimp_display_shell_title_image_type (GimpImage *image) return name; } -static const gchar * -gimp_display_shell_title_drawable_type (GimpDrawable *drawable) -{ - const gchar *name = ""; - - gimp_enum_get_value (GIMP_TYPE_IMAGE_TYPE, - gimp_drawable_type (drawable), NULL, NULL, &name, NULL); - - return name; -} - static gint print (gchar *buf, gint len, gint start, @@ -248,10 +239,11 @@ gimp_display_shell_format_title (GimpDisplayShell *shell, case 'T': /* drawable type */ { GimpDrawable *drawable = gimp_image_get_active_drawable (image); + const Babl *format = gimp_drawable_get_format (drawable); if (drawable) i += print (title, title_len, i, "%s", - gimp_display_shell_title_drawable_type (drawable)); + gimp_babl_get_description (format)); } break; diff --git a/app/gegl/gimp-gegl.c b/app/gegl/gimp-gegl.c index 717553153a..9d7a1e54ae 100644 --- a/app/gegl/gimp-gegl.c +++ b/app/gegl/gimp-gegl.c @@ -79,6 +79,8 @@ #include "gimpoperationreplacemode.h" #include "gimpoperationantierasemode.h" +#include "gimp-intl.h" + static void gimp_gegl_notify_tile_cache_size (GimpBaseConfig *config); @@ -179,6 +181,63 @@ 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 532f17814b..6f07440603 100644 --- a/app/gegl/gimp-gegl.h +++ b/app/gegl/gimp-gegl.h @@ -22,7 +22,9 @@ #define __GIMP_GEGL_H__ -void gimp_gegl_init (Gimp *gimp); +void gimp_gegl_init (Gimp *gimp); + +const gchar * gimp_babl_get_description (const Babl *babl); #endif /* __GIMP_GEGL_H__ */