[gnome-color-manager: 7/18] trivial: add a convenience function to set the CIE diagram from a profile instance
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager: 7/18] trivial: add a convenience function to set the CIE diagram from a profile instance
- Date: Fri, 8 Oct 2010 16:08:45 +0000 (UTC)
commit 7bb7c0a008952c6ba226643923d76a8bc72e4aaf
Author: Richard Hughes <richard hughsie com>
Date: Fri Oct 8 12:32:27 2010 +0100
trivial: add a convenience function to set the CIE diagram from a profile instance
src/gcm-cie-widget.c | 41 +++++++++++++++++++++++++++++++++++++++++
src/gcm-cie-widget.h | 3 +++
src/gcm-import.c | 25 ++-----------------------
src/gcm-viewer.c | 38 +++-----------------------------------
4 files changed, 49 insertions(+), 58 deletions(-)
---
diff --git a/src/gcm-cie-widget.c b/src/gcm-cie-widget.c
index 85a1cab..e370209 100644
--- a/src/gcm-cie-widget.c
+++ b/src/gcm-cie-widget.c
@@ -513,6 +513,47 @@ gcm_cie_widget_class_init (GcmCieWidgetClass *class)
}
/**
+ * gcm_cie_widget_set_from_profile:
+ **/
+void
+gcm_cie_widget_set_from_profile (GtkWidget *widget, GcmProfile *profile)
+{
+ GcmCieWidget *cie = GCM_CIE_WIDGET (widget);
+ GcmColorXYZ *white;
+ GcmColorXYZ *red;
+ GcmColorXYZ *green;
+ GcmColorXYZ *blue;
+
+ /* get the new details from the profile */
+ g_object_get (profile,
+ "white", &white,
+ "red", &red,
+ "green", &green,
+ "blue", &blue,
+ NULL);
+
+ /* copy into this widget */
+ gcm_color_convert_XYZ_to_Yxy (white, cie->priv->white);
+ gcm_color_convert_XYZ_to_Yxy (red, cie->priv->red);
+ gcm_color_convert_XYZ_to_Yxy (green, cie->priv->green);
+ gcm_color_convert_XYZ_to_Yxy (blue, cie->priv->blue);
+
+ /* hide if we have no data */
+ if (cie->priv->white->x > 0.001) {
+ gtk_widget_hide (widget);
+ gtk_widget_show (widget);
+ } else {
+ gtk_widget_hide (widget);
+ }
+
+ /* free */
+ gcm_color_free_XYZ (white);
+ gcm_color_free_XYZ (red);
+ gcm_color_free_XYZ (green);
+ gcm_color_free_XYZ (blue);
+}
+
+/**
* gcm_cie_widget_init:
**/
static void
diff --git a/src/gcm-cie-widget.h b/src/gcm-cie-widget.h
index a488503..e931b44 100644
--- a/src/gcm-cie-widget.h
+++ b/src/gcm-cie-widget.h
@@ -23,6 +23,7 @@
#define __GCM_CIE_WIDGET_H__
#include <gtk/gtk.h>
+#include <gcm-profile.h>
G_BEGIN_DECLS
@@ -50,6 +51,8 @@ struct GcmCieWidgetClass
GType gcm_cie_widget_get_type (void);
GtkWidget *gcm_cie_widget_new (void);
+void gcm_cie_widget_set_from_profile (GtkWidget *widget,
+ GcmProfile *profile);
G_END_DECLS
diff --git a/src/gcm-import.c b/src/gcm-import.c
index 7a6edf5..b756edf 100644
--- a/src/gcm-import.c
+++ b/src/gcm-import.c
@@ -75,10 +75,6 @@ main (int argc, char **argv)
GtkWidget *dialog;
GtkResponseType response;
GtkWidget *cie_widget = NULL;
- GcmColorXYZ *white = NULL;
- GcmColorXYZ *red = NULL;
- GcmColorXYZ *green = NULL;
- GcmColorXYZ *blue = NULL;
const GOptionEntry options[] = {
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &files,
@@ -132,24 +128,15 @@ main (int argc, char **argv)
description = gcm_profile_get_description (profile);
copyright = gcm_profile_get_copyright (profile);
colorspace = gcm_profile_get_colorspace (profile);
- g_object_get (profile,
- "white", &white,
- "red", &red,
- "green", &green,
- "blue", &blue,
- NULL);
/* use CIE widget */
cie_widget = gcm_cie_widget_new ();
- gtk_widget_set_size_request (cie_widget, 200, 200);
g_object_set (cie_widget,
"use-grid", FALSE,
"use-whitepoint", FALSE,
- "white", white,
- "red", red,
- "green", green,
- "blue", blue,
NULL);
+ gtk_widget_set_size_request (cie_widget, 200, 200);
+ gcm_cie_widget_set_from_profile (cie_widget, profile);
/* check file does't already exist as a file */
destination = gcm_utils_get_profile_destination (file);
@@ -237,14 +224,6 @@ main (int argc, char **argv)
out:
if (file != NULL)
g_object_unref (file);
- if (white != NULL)
- g_object_unref (white);
- if (red != NULL)
- g_object_unref (red);
- if (green != NULL)
- g_object_unref (green);
- if (blue != NULL)
- g_object_unref (blue);
if (string != NULL)
g_string_free (string, TRUE);
if (profile != NULL)
diff --git a/src/gcm-viewer.c b/src/gcm-viewer.c
index ce18b67..6c5d9db 100644
--- a/src/gcm-viewer.c
+++ b/src/gcm-viewer.c
@@ -630,14 +630,6 @@ gcm_viewer_profiles_treeview_clicked_cb (GtkTreeSelection *selection, GcmViewerP
GcmProfile *profile;
GcmClut *clut_trc = NULL;
GcmClut *clut_vcgt = NULL;
- GcmColorXYZ *white;
- GcmColorXYZ *red;
- GcmColorXYZ *green;
- GcmColorXYZ *blue;
- GcmColorYxy white_Yxy;
- GcmColorYxy red_Yxy;
- GcmColorYxy green_Yxy;
- GcmColorYxy blue_Yxy;
const gchar *profile_copyright;
const gchar *profile_manufacturer;
const gchar *profile_model ;
@@ -687,30 +679,10 @@ gcm_viewer_profiles_treeview_clicked_cb (GtkTreeSelection *selection, GcmViewerP
gcm_image_set_abstract_profile (GCM_IMAGE(viewer->preview_widget_output), NULL);
}
- /* get the new details from the profile */
- g_object_get (profile,
- "white", &white,
- "red", &red,
- "green", &green,
- "blue", &blue,
- NULL);
-
- /* check we have enough data for the CIE widget */
- gcm_color_convert_XYZ_to_Yxy (white, &white_Yxy);
- gcm_color_convert_XYZ_to_Yxy (red, &red_Yxy);
- gcm_color_convert_XYZ_to_Yxy (green, &green_Yxy);
- gcm_color_convert_XYZ_to_Yxy (blue, &blue_Yxy);
+ /* setup cie widget */
+ gcm_cie_widget_set_from_profile (viewer->cie_widget, profile);
widget = GTK_WIDGET (gtk_builder_get_object (viewer->builder, "vbox_cie_axis"));
- if (white_Yxy.x > 0.001) {
- g_object_set (viewer->cie_widget,
- "white", &white_Yxy,
- "red", &red_Yxy,
- "green", &green_Yxy,
- "blue", &blue_Yxy,
- NULL);
- } else {
- gtk_widget_hide (widget);
- }
+ gtk_widget_set_visible (widget, gtk_widget_get_visible (viewer->cie_widget));
/* get curve data */
clut_trc = gcm_profile_generate_curve (profile, 256);
@@ -869,10 +841,6 @@ gcm_viewer_profiles_treeview_clicked_cb (GtkTreeSelection *selection, GcmViewerP
g_object_unref (clut_trc);
if (clut_vcgt != NULL)
g_object_unref (clut_vcgt);
- gcm_color_free_XYZ (white);
- gcm_color_free_XYZ (red);
- gcm_color_free_XYZ (green);
- gcm_color_free_XYZ (blue);
g_free (size_text);
g_free (basename);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]