[gthumb] show the color profile description in the property view
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] show the color profile description in the property view
- Date: Wed, 28 Jun 2017 09:51:42 +0000 (UTC)
commit 1a614b05b6f3ca9110714bde39aac40d8ef38643
Author: Paolo Bacchilega <paobac src gnome org>
Date: Tue Jun 27 17:00:20 2017 +0200
show the color profile description in the property view
extensions/image_viewer/gth-image-viewer-page.c | 25 ++++++++++++-
gthumb/gth-icc-profile.c | 43 +++++++++++++++++++++-
gthumb/gth-icc-profile.h | 1 +
gthumb/gth-main-default-metadata.c | 1 +
4 files changed, 66 insertions(+), 4 deletions(-)
---
diff --git a/extensions/image_viewer/gth-image-viewer-page.c b/extensions/image_viewer/gth-image-viewer-page.c
index 4afe487..fa67c96 100644
--- a/extensions/image_viewer/gth-image-viewer-page.c
+++ b/extensions/image_viewer/gth-image-viewer-page.c
@@ -97,6 +97,7 @@ struct _GthImageViewerPagePrivate {
guint file_popup_merge_id;
GthImageHistory *history;
GthFileData *file_data;
+ GFileInfo *updated_info;
gboolean active;
gboolean image_changed;
gboolean loading_image;
@@ -127,6 +128,7 @@ gth_image_viewer_page_file_loaded (GthImageViewerPage *self,
gth_viewer_page_file_loaded (GTH_VIEWER_PAGE (self),
self->priv->file_data,
+ self->priv->updated_info,
success);
}
@@ -1319,13 +1321,29 @@ preloader_load_ready_cb (GObject *source_object,
gth_image_viewer_get_original_size (GTH_IMAGE_VIEWER (self->priv->viewer),
&original_width,
&original_height);
- g_file_info_set_attribute_int32 (self->priv->file_data->info,
+ g_file_info_set_attribute_int32 (self->priv->updated_info,
"frame::width",
original_width);
- g_file_info_set_attribute_int32 (self->priv->file_data->info,
+ g_file_info_set_attribute_int32 (self->priv->updated_info,
"frame::height",
original_height);
+ {
+ GthICCProfile *profile;
+
+ profile = gth_image_get_icc_profile (image);
+ if (profile != NULL) {
+ char *desc = gth_icc_profile_get_description (profile);
+
+ if (desc != NULL) {
+ g_file_info_set_attribute_string (self->priv->updated_info,
+ "Loaded::Image::ColorProfile",
+ desc);
+ g_free (desc);
+ }
+ }
+ }
+
gth_image_viewer_page_file_loaded (self, TRUE);
update_image_quality_if_required (self);
@@ -1350,6 +1368,8 @@ _gth_image_viewer_page_load (GthImageViewerPage *self,
if (self->priv->file_data != file_data) {
_g_object_unref (self->priv->file_data);
self->priv->file_data = gth_file_data_dup (file_data);
+ _g_object_unref (self->priv->updated_info);
+ self->priv->updated_info = g_file_info_new ();
}
self->priv->image_changed = FALSE;
self->priv->loading_image = TRUE;
@@ -1918,6 +1938,7 @@ gth_image_viewer_page_init (GthImageViewerPage *self)
self->priv->file_popup_merge_id = 0;
self->priv->history = gth_image_history_new ();
self->priv->file_data = NULL;
+ self->priv->updated_info = NULL;
self->priv->active = FALSE;
self->priv->image_changed = FALSE;
self->priv->loading_image = FALSE;
diff --git a/gthumb/gth-icc-profile.c b/gthumb/gth-icc-profile.c
index 13323e2..5c63d85 100644
--- a/gthumb/gth-icc-profile.c
+++ b/gthumb/gth-icc-profile.c
@@ -26,6 +26,7 @@
#include <lcms2.h>
#endif /* HAVE_LCMS2 */
#include "gth-icc-profile.h"
+#include "glib-utils.h"
struct _GthICCProfilePrivate {
@@ -158,6 +159,8 @@ gth_icc_profile_new (const char *id,
{
GthICCProfile *icc_profile;
+ g_return_val_if_fail (profile != NULL, NULL);
+
icc_profile = g_object_new (GTH_TYPE_ICC_PROFILE, NULL);
if (! gth_icc_profile_id_is_unknown (id))
icc_profile->priv->id = g_strdup (id);
@@ -197,11 +200,47 @@ gth_icc_profile_new_srgb (void)
const char *
gth_icc_profile_get_id (GthICCProfile *self)
{
- g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (GTH_IS_ICC_PROFILE (self), NULL);
return self->priv->id;
}
+char *
+gth_icc_profile_get_description (GthICCProfile *self)
+{
+#ifdef HAVE_LCMS2
+
+ GString *color_profile;
+ cmsHPROFILE hProfile;
+ const int buffer_size = 128;
+ wchar_t buffer[buffer_size];
+ cmsUInt32Number size;
+ char *result;
+
+ color_profile = g_string_new ("");
+ hProfile = (cmsHPROFILE) gth_icc_profile_get_profile (self);
+ size = cmsGetProfileInfo (hProfile, cmsInfoDescription, "en", "US", (wchar_t *) buffer, buffer_size);
+ if (size > 0) {
+ for (int i = 0; (i < size) && (buffer[i] != 0); i++)
+ g_string_append_c (color_profile, buffer[i]);
+ }
+
+ result = NULL;
+ if (color_profile->len > 0)
+ result = _g_utf8_try_from_any (color_profile->str);
+
+ g_string_free (color_profile, TRUE);
+
+ return result;
+
+#else
+
+ return NULL;
+
+#endif
+}
+
+
gboolean
gth_icc_profile_id_is_unknown (const char *id)
{
@@ -221,7 +260,7 @@ gboolean
gth_icc_profile_equal (GthICCProfile *a,
GthICCProfile *b)
{
- g_return_val_if_fail ((a == NULL) || (b == NULL), NULL);
+ g_return_val_if_fail ((a == NULL) || (b == NULL), FALSE);
if (gth_icc_profile_id_is_unknown (a->priv->id) || gth_icc_profile_id_is_unknown (b->priv->id))
return FALSE;
diff --git a/gthumb/gth-icc-profile.h b/gthumb/gth-icc-profile.h
index 430ff09..bb78a19 100644
--- a/gthumb/gth-icc-profile.h
+++ b/gthumb/gth-icc-profile.h
@@ -81,6 +81,7 @@ GthICCProfile * gth_icc_profile_new (const char *id,
GthCMSProfile profile);
GthICCProfile * gth_icc_profile_new_srgb (void);
const char * gth_icc_profile_get_id (GthICCProfile *icc_profile);
+char * gth_icc_profile_get_description (GthICCProfile *icc_profile);
gboolean gth_icc_profile_id_is_unknown (const char *id);
GthCMSProfile gth_icc_profile_get_profile (GthICCProfile *icc_profile);
gboolean gth_icc_profile_equal (GthICCProfile *a,
diff --git a/gthumb/gth-main-default-metadata.c b/gthumb/gth-main-default-metadata.c
index c647ad0..8407ed5 100644
--- a/gthumb/gth-main-default-metadata.c
+++ b/gthumb/gth-main-default-metadata.c
@@ -54,6 +54,7 @@ GthMetadataInfo file_metadata_info[] = {
{ "Embedded::Photo::FocalLength", N_("Focal Length"), "general", 16, NULL,
GTH_METADATA_ALLOW_EVERYWHERE },
{ "Embedded::Photo::Flash", N_("Flash"), "general", 17, NULL, GTH_METADATA_ALLOW_EVERYWHERE },
{ "Embedded::Photo::CameraModel", N_("Camera Model"), "general", 18, NULL,
GTH_METADATA_ALLOW_EVERYWHERE },
+ { "Loaded::Image::ColorProfile", N_("Color Profile"), "general", 19, NULL,
GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "general::datetime", N_("General Date & Time"), "general", 20, NULL, GTH_METADATA_ALLOW_EVERYWHERE
},
{ "general::title", N_("Title"), "general", 21, NULL, GTH_METADATA_ALLOW_EVERYWHERE },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]