[gnome-color-manager/colord: 62/72] Add media whitepoint and color temperature data to gcm-picker
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager/colord: 62/72] Add media whitepoint and color temperature data to gcm-picker
- Date: Tue, 8 Mar 2011 11:28:33 +0000 (UTC)
commit 7990795f4bbb37ec58b3afabefe879f8efbcb082
Author: Richard Hughes <richard hughsie com>
Date: Mon Feb 14 10:46:24 2011 +0000
Add media whitepoint and color temperature data to gcm-picker
data/gcm-picker.ui | 259 +++++++++++++++++++++++++++++++++++++++-------------
src/gcm-picker.c | 84 ++++++++++++-----
2 files changed, 256 insertions(+), 87 deletions(-)
---
diff --git a/data/gcm-picker.ui b/data/gcm-picker.ui
index 66bc3f7..4746575 100644
--- a/data/gcm-picker.ui
+++ b/data/gcm-picker.ui
@@ -1,30 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="2.16"/>
- <!-- interface-naming-policy project-wide -->
<object class="GtkDialog" id="dialog_picker">
+ <property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="title" translatable="yes" comments="Window title, where the user can pick spot colors using a measuring device">Color Picker</property>
<property name="icon_name">gnome-color-manager</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
- <object class="GtkVBox" id="dialog-vbox1">
+ <object class="GtkBox" id="dialog-vbox1">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
<property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="button_help">
+ <property name="label">gtk-help</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ <property name="secondary">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_close">
+ <property name="label">gtk-close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="border_width">12</property>
<property name="spacing">12</property>
<child>
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkImage" id="image_preview">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
@@ -34,6 +79,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="image_position">top</property>
</object>
@@ -57,18 +103,22 @@
<child>
<object class="GtkVBox" id="vbox2">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="border_width">9</property>
<property name="spacing">6</property>
<child>
<object class="GtkHBox" id="hbox_xyz">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="spacing">12</property>
<child>
<object class="GtkHBox" id="hbox_xyz_align">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label_xyz_title">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="label" translatable="yes" comments="the color representation">XYZ:</property>
</object>
<packing>
@@ -87,6 +137,7 @@
<child>
<object class="GtkLabel" id="label_xyz">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="selectable">True</property>
</object>
<packing>
@@ -105,13 +156,16 @@
<child>
<object class="GtkHBox" id="hbox_lab">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="spacing">12</property>
<child>
<object class="GtkHBox" id="hbox_lab_align">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label_lab_title">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="label" translatable="yes" comments="Lab is the color representation and D50 is the white point">Lab (D50):</property>
</object>
<packing>
@@ -130,6 +184,7 @@
<child>
<object class="GtkLabel" id="label_lab">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="selectable">True</property>
</object>
<packing>
@@ -146,16 +201,19 @@
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox2">
+ <object class="GtkHBox" id="hbox_whitepoint">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="spacing">12</property>
<child>
- <object class="GtkHBox" id="hbox_colorspace_align">
+ <object class="GtkHBox" id="hbox_whitepoint_align">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
- <object class="GtkLabel" id="label_colorspace">
+ <object class="GtkLabel" id="label_whitepoint_title">
<property name="visible">True</property>
- <property name="label" translatable="yes" comments="This is the title to a combobox that switches the RGB conversion between different colorspaces such as Adobe RGB and sRGB">Colorspace:</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" comments="This refers to the amount of ambient light on the sensor">Media whitepoint:</property>
</object>
<packing>
<property name="expand">False</property>
@@ -171,10 +229,14 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="combobox_colorspace">
+ <object class="GtkLabel" id="label_whitepoint">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="selectable">True</property>
</object>
<packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
@@ -186,16 +248,19 @@
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox_rgb">
+ <object class="GtkHBox" id="hbox_temperature">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="spacing">12</property>
<child>
- <object class="GtkHBox" id="hbox_rgb_align">
+ <object class="GtkHBox" id="hbox_temperature_align">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
- <object class="GtkLabel" id="label_rgb_title">
+ <object class="GtkLabel" id="label_temperature_title">
<property name="visible">True</property>
- <property name="label" translatable="yes" comments="These are the values of the chosen color in Red, Green, Blue encoding">RGB:</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" comments="This refers to the amount of ambient light on the sensor">Color Temperature:</property>
</object>
<packing>
<property name="expand">False</property>
@@ -211,8 +276,9 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label_rgb">
+ <object class="GtkLabel" id="label_temperature">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="selectable">True</property>
</object>
<packing>
@@ -229,16 +295,19 @@
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox_error">
+ <object class="GtkHBox" id="hbox_ambient">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="spacing">12</property>
<child>
- <object class="GtkHBox" id="hbox_error_align">
+ <object class="GtkHBox" id="hbox_ambient_align">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
- <object class="GtkLabel" id="label_error_title">
+ <object class="GtkLabel" id="label_ambient_title">
<property name="visible">True</property>
- <property name="label" translatable="yes" comments="This shows the error in the conversion to RGB.">Error:</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" comments="This refers to the amount of ambient light on the sensor">Ambient:</property>
</object>
<packing>
<property name="expand">False</property>
@@ -254,8 +323,9 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label_error">
+ <object class="GtkLabel" id="label_ambient">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="selectable">True</property>
</object>
<packing>
@@ -272,16 +342,19 @@
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox_ambient">
+ <object class="GtkHBox" id="hbox2">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="spacing">12</property>
<child>
- <object class="GtkHBox" id="hbox_ambient_align">
+ <object class="GtkHBox" id="hbox_colorspace_align">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
- <object class="GtkLabel" id="label_ambient_title">
+ <object class="GtkLabel" id="label_colorspace">
<property name="visible">True</property>
- <property name="label" translatable="yes" comments="This refers to the amount of ambient light on the sensor">Ambient:</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" comments="This is the title to a combobox that switches the RGB conversion between different colorspaces such as Adobe RGB and sRGB">Colorspace:</property>
</object>
<packing>
<property name="expand">False</property>
@@ -297,8 +370,55 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label_ambient">
+ <object class="GtkComboBox" id="combobox_colorspace">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox_rgb">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkHBox" id="hbox_rgb_align">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="label_rgb_title">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" comments="These are the values of the chosen color in Red, Green, Blue encoding">RGB:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_rgb">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="selectable">True</property>
</object>
<packing>
@@ -311,7 +431,54 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">5</property>
+ <property name="position">6</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox_error">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkHBox" id="hbox_error_align">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="label_error_title">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" comments="This shows the error in the conversion to RGB.">Error:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_error">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="selectable">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">7</property>
</packing>
</child>
</object>
@@ -319,6 +486,7 @@
<child type="label">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="label" translatable="yes" comments="Expander title, the results from the color picker">Results</property>
<attributes>
<attribute name="weight" value="bold"/>
@@ -328,52 +496,15 @@
</object>
<packing>
<property name="expand">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- <child internal-child="action_area">
- <object class="GtkHButtonBox" id="dialog-action_area1">
- <property name="visible">True</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="button_help">
- <property name="label">gtk-help</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- <property name="secondary">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="button_close">
- <property name="label">gtk-close</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
+ <property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
@@ -391,6 +522,8 @@
<widget name="hbox_rgb_align"/>
<widget name="hbox_error_align"/>
<widget name="hbox_ambient_align"/>
+ <widget name="hbox_temperature_align"/>
+ <widget name="hbox_whitepoint_align"/>
</widgets>
</object>
</interface>
diff --git a/src/gcm-picker.c b/src/gcm-picker.c
index 584f31e..f8e8476 100644
--- a/src/gcm-picker.c
+++ b/src/gcm-picker.c
@@ -90,24 +90,29 @@ gcm_picker_set_pixbuf_color (GdkPixbuf *pixbuf, gchar red, gchar green, gchar bl
static void
gcm_picker_refresh_results (void)
{
- GtkImage *image;
- GtkLabel *label;
- GdkPixbuf *pixbuf = NULL;
- GcmColorRGBint color_rgb;
- GcmColorLab color_lab;
- GcmColorXYZ color_xyz;
- GcmColorXYZ color_error;
- gchar *text_xyz = NULL;
- gchar *text_lab = NULL;
- gchar *text_rgb = NULL;
- gchar *text_error = NULL;
- gchar *text_ambient = NULL;
- cmsHPROFILE profile_xyz;
- cmsHPROFILE profile_rgb;
+ cmsCIExyY xyY;
cmsHPROFILE profile_lab;
- cmsHTRANSFORM transform_rgb;
- cmsHTRANSFORM transform_lab;
+ cmsHPROFILE profile_rgb;
+ cmsHPROFILE profile_xyz;
cmsHTRANSFORM transform_error;
+ cmsHTRANSFORM transform_lab;
+ cmsHTRANSFORM transform_rgb;
+ gboolean ret;
+ gchar *text_ambient = NULL;
+ gchar *text_error = NULL;
+ gchar *text_lab = NULL;
+ gchar *text_rgb = NULL;
+ gchar *text_temperature = NULL;
+ gchar *text_whitepoint = NULL;
+ gchar *text_xyz = NULL;
+ GcmColorLab color_lab;
+ GcmColorRGBint color_rgb;
+ GcmColorXYZ color_error;
+ GcmColorXYZ color_xyz;
+ GdkPixbuf *pixbuf = NULL;
+ gdouble temperature = 0.0f;
+ GtkImage *image;
+ GtkLabel *label;
/* copy as we're modifying the value */
gcm_color_copy_XYZ (&last_sample, &color_xyz);
@@ -126,9 +131,15 @@ gcm_picker_refresh_results (void)
profile_lab = cmsCreateLab4Profile (cmsD50_xyY ());
/* create transforms */
- transform_rgb = cmsCreateTransform (profile_xyz, TYPE_XYZ_DBL, profile_rgb, TYPE_RGB_8, INTENT_PERCEPTUAL, 0);
- transform_lab = cmsCreateTransform (profile_xyz, TYPE_XYZ_DBL, profile_lab, TYPE_Lab_DBL, INTENT_PERCEPTUAL, 0);
- transform_error = cmsCreateTransform (profile_rgb, TYPE_RGB_8, profile_xyz, TYPE_XYZ_DBL, INTENT_PERCEPTUAL, 0);
+ transform_rgb = cmsCreateTransform (profile_xyz, TYPE_XYZ_DBL,
+ profile_rgb, TYPE_RGB_8,
+ INTENT_PERCEPTUAL, 0);
+ transform_lab = cmsCreateTransform (profile_xyz, TYPE_XYZ_DBL,
+ profile_lab, TYPE_Lab_DBL,
+ INTENT_PERCEPTUAL, 0);
+ transform_error = cmsCreateTransform (profile_rgb, TYPE_RGB_8,
+ profile_xyz, TYPE_XYZ_DBL,
+ INTENT_PERCEPTUAL, 0);
cmsDoTransform (transform_rgb, &color_xyz, &color_rgb, 1);
cmsDoTransform (transform_lab, &color_xyz, &color_lab, 1);
@@ -144,14 +155,37 @@ gcm_picker_refresh_results (void)
/* set XYZ */
label = GTK_LABEL (gtk_builder_get_object (builder, "label_xyz"));
- text_xyz = g_strdup_printf ("%.3f, %.3f, %.3f", last_sample.X, last_sample.Y, last_sample.Z);
+ text_xyz = g_strdup_printf ("%.3f, %.3f, %.3f",
+ last_sample.X,
+ last_sample.Y,
+ last_sample.Z);
gtk_label_set_label (label, text_xyz);
/* set LAB */
label = GTK_LABEL (gtk_builder_get_object (builder, "label_lab"));
- text_lab = g_strdup_printf ("%.3f, %.3f, %.3f", color_lab.L, color_lab.a, color_lab.b);
+ text_lab = g_strdup_printf ("%.3f, %.3f, %.3f",
+ color_lab.L,
+ color_lab.a,
+ color_lab.b);
gtk_label_set_label (label, text_lab);
+ /* set whitepoint */
+ cmsXYZ2xyY (&xyY, (cmsCIEXYZ *)&last_sample);
+ label = GTK_LABEL (gtk_builder_get_object (builder, "label_whitepoint"));
+ text_whitepoint = g_strdup_printf ("%.3f,%.3f [%.3f]",
+ xyY.x, xyY.y, xyY.Y);
+ gtk_label_set_label (label, text_whitepoint);
+
+ /* set temperature */
+ ret = cmsTempFromWhitePoint (&temperature, &xyY);
+ if (ret) {
+ /* round to nearest 10K */
+ temperature = (((guint) temperature) / 10) * 10;
+ }
+ label = GTK_LABEL (gtk_builder_get_object (builder, "label_temperature"));
+ text_temperature = g_strdup_printf ("%.0fK", temperature);
+ gtk_label_set_label (label, text_temperature);
+
/* set RGB */
label = GTK_LABEL (gtk_builder_get_object (builder, "label_rgb"));
text_rgb = g_strdup_printf ("%i, %i, %i (#%02X%02X%02X)",
@@ -182,11 +216,13 @@ gcm_picker_refresh_results (void)
image = GTK_IMAGE (gtk_builder_get_object (builder, "image_preview"));
gtk_image_set_from_pixbuf (image, pixbuf);
- g_free (text_xyz);
+ g_free (text_ambient);
+ g_free (text_error);
g_free (text_lab);
g_free (text_rgb);
- g_free (text_error);
- g_free (text_ambient);
+ g_free (text_temperature);
+ g_free (text_whitepoint);
+ g_free (text_xyz);
if (pixbuf != NULL)
g_object_unref (pixbuf);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]