[gnome-color-manager] Do not try to calculate the error in gcm-picker if the values are invalid



commit 94ea343a36ba47baf762a8c7e1e01632e718c668
Author: Richard Hughes <richard hughsie com>
Date:   Tue Apr 5 13:27:19 2011 +0100

    Do not try to calculate the error in gcm-picker if the values are invalid

 contrib/gnome-color-manager.spec.in |    1 +
 src/gcm-picker.c                    |   17 ++++++++++++-----
 2 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/contrib/gnome-color-manager.spec.in b/contrib/gnome-color-manager.spec.in
index 45fb27f..48358c5 100644
--- a/contrib/gnome-color-manager.spec.in
+++ b/contrib/gnome-color-manager.spec.in
@@ -83,6 +83,7 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &> /dev/null || :
 %defattr(-,root,root,-)
 %doc AUTHORS COPYING NEWS README
 %{_bindir}/gcm-*
+%{_libexecdir}/gcm-helper-exiv
 %dir %{_datadir}/gnome-color-manager
 %{_datadir}/gnome-color-manager/gcm-*.ui
 %dir %{_datadir}/gnome-color-manager/targets
diff --git a/src/gcm-picker.c b/src/gcm-picker.c
index 7ba6c4c..a79daf4 100644
--- a/src/gcm-picker.c
+++ b/src/gcm-picker.c
@@ -193,11 +193,18 @@ gcm_picker_refresh_results (void)
 
 	/* set error */
 	label = GTK_LABEL (gtk_builder_get_object (builder, "label_error"));
-	text_error = g_strdup_printf ("%.1f%%, %.1f%%, %.1f%%",
-				      ABS ((color_error.X - color_xyz.X) / color_xyz.X * 100),
-				      ABS ((color_error.Y - color_xyz.Y) / color_xyz.Y * 100),
-				      ABS ((color_error.Z - color_xyz.Z) / color_xyz.Z * 100));
-	gtk_label_set_label (label, text_error);
+	if (color_xyz.X > 0.01f &&
+	    color_xyz.Y > 0.01f &&
+	    color_xyz.Z > 0.01f) {
+		text_error = g_strdup_printf ("%.1f%%, %.1f%%, %.1f%%",
+					      ABS ((color_error.X - color_xyz.X) / color_xyz.X * 100),
+					      ABS ((color_error.Y - color_xyz.Y) / color_xyz.Y * 100),
+					      ABS ((color_error.Z - color_xyz.Z) / color_xyz.Z * 100));
+		gtk_label_set_label (label, text_error);
+	} else {
+		/* TRANSLATORS: this is when the error is invalid */
+		gtk_label_set_label (label, _("Unknown"));
+	}
 
 	/* set ambient */
 	label = GTK_LABEL (gtk_builder_get_object (builder, "label_ambient"));



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