[gnome-color-manager] trivial: Move the generation of profile names from GcmCalibrateArgyll to GcmCalibrate



commit 425d1905b7f70bbac84fcaf3a9e4b7cd56e88c6d
Author: Richard Hughes <richard hughsie com>
Date:   Thu Oct 14 13:09:57 2010 +0100

    trivial: Move the generation of profile names from GcmCalibrateArgyll to GcmCalibrate

 src/gcm-calibrate-argyll.c |   77 +++++++++++++--------------------------
 src/gcm-calibrate.c        |   87 +++++++++++++++++++++++++++++++-------------
 src/gcm-calibrate.h        |   10 +++--
 src/gcm-self-test.c        |   11 ++++--
 4 files changed, 100 insertions(+), 85 deletions(-)
---
diff --git a/src/gcm-calibrate-argyll.c b/src/gcm-calibrate-argyll.c
index d9bb03c..74b03dd 100644
--- a/src/gcm-calibrate-argyll.c
+++ b/src/gcm-calibrate-argyll.c
@@ -820,15 +820,12 @@ gcm_calibrate_argyll_display_generate_profile (GcmCalibrateArgyll *calibrate_arg
 	gboolean ret = TRUE;
 	GcmCalibrateArgyllPrivate *priv = calibrate_argyll->priv;
 	gchar **argv = NULL;
-	GDate *date = NULL;
 	gchar *copyright = NULL;
-	gchar *description_new = NULL;
+	gchar *description = NULL;
+	gchar *manufacturer = NULL;
+	gchar *model = NULL;
 	gchar *command = NULL;
 	gchar *basename = NULL;
-	const gchar *description = NULL;
-	const gchar *manufacturer = NULL;
-	const gchar *model = NULL;
-	gchar *device = NULL;
 	GPtrArray *array = NULL;
 	const gchar *title;
 	const gchar *message;
@@ -836,13 +833,13 @@ gcm_calibrate_argyll_display_generate_profile (GcmCalibrateArgyll *calibrate_arg
 	/* get shared data */
 	g_object_get (calibrate_argyll,
 		      "basename", &basename,
-		      "device", &device,
 		      NULL);
 
-	/* get, returning fallbacks if nothing was set */
-	model = gcm_calibrate_get_model_fallback (GCM_CALIBRATE (calibrate_argyll));
-	manufacturer = gcm_calibrate_get_manufacturer_fallback (GCM_CALIBRATE (calibrate_argyll));
-	description = gcm_calibrate_get_description_fallback (GCM_CALIBRATE (calibrate_argyll));
+	/* get profile text data */
+	copyright = gcm_calibrate_get_profile_copyright (GCM_CALIBRATE (calibrate_argyll));
+	description = gcm_calibrate_get_profile_description (GCM_CALIBRATE (calibrate_argyll));
+	model = gcm_calibrate_get_profile_model (GCM_CALIBRATE (calibrate_argyll));
+	manufacturer = gcm_calibrate_get_profile_manufacturer (GCM_CALIBRATE (calibrate_argyll));
 
 	/* get correct name of the command */
 	command = gcm_calibrate_argyll_get_tool_filename ("colprof", error);
@@ -851,16 +848,6 @@ gcm_calibrate_argyll_display_generate_profile (GcmCalibrateArgyll *calibrate_arg
 		goto out;
 	}
 
-	/* create date and set it to now */
-	date = g_date_new ();
-	g_date_set_time_t (date, time (NULL));
-
-        /* get description */
-	description_new = g_strdup_printf ("%s, %s (%04i-%02i-%02i)", device, description, date->year, date->month, date->day);
-
-	/* TRANSLATORS: this is the copyright string, where it might be "Copyright (c) 2009 Edward Scissorhands" - YOU NEED TO STICK TO ASCII */
-	copyright = g_strdup_printf ("%s %04i %s", _("Copyright (c)"), date->year, g_get_real_name ());
-
 	/* TRANSLATORS: title, a profile is a ICC file */
 	title = _("Generating the profile");
 	/* TRANSLATORS: dialog message */
@@ -881,7 +868,7 @@ gcm_calibrate_argyll_display_generate_profile (GcmCalibrateArgyll *calibrate_arg
 	g_ptr_array_add (array, g_strdup ("-v"));
 	g_ptr_array_add (array, g_strdup_printf ("-A%s", manufacturer));
 	g_ptr_array_add (array, g_strdup_printf ("-M%s", model));
-	g_ptr_array_add (array, g_strdup_printf ("-D%s", description_new));
+	g_ptr_array_add (array, g_strdup_printf ("-D%s", description));
 	g_ptr_array_add (array, g_strdup_printf ("-C%s", copyright));
 	g_ptr_array_add (array, g_strdup (gcm_calibrate_argyll_get_quality_arg (calibrate_argyll)));
 	g_ptr_array_add (array, g_strdup ("-as"));
@@ -922,13 +909,12 @@ gcm_calibrate_argyll_display_generate_profile (GcmCalibrateArgyll *calibrate_arg
 out:
 	if (array != NULL)
 		g_ptr_array_unref (array);
-	if (date != NULL)
-		g_date_free (date);
 	g_free (basename);
 	g_free (command);
-	g_free (description_new);
-	g_free (device);
 	g_free (copyright);
+	g_free (description);
+	g_free (manufacturer);
+	g_free (model);
 	g_strfreev (argv);
 	return ret;
 }
@@ -1160,16 +1146,13 @@ gcm_calibrate_argyll_device_generate_profile (GcmCalibrateArgyll *calibrate_argy
 	gboolean ret = TRUE;
 	GcmCalibrateArgyllPrivate *priv = calibrate_argyll->priv;
 	gchar **argv = NULL;
-	GDate *date = NULL;
-	gchar *description_tmp = NULL;
-	const gchar *description;
-	gchar *copyright = NULL;
 	GPtrArray *array = NULL;
 	gchar *command = NULL;
 	gchar *basename = NULL;
-	const gchar *manufacturer;
-	const gchar *model;
-	const gchar *device;
+	gchar *copyright = NULL;
+	gchar *description = NULL;
+	gchar *manufacturer = NULL;
+	gchar *model = NULL;
 	const gchar *title;
 	const gchar *message;
 	GcmCalibrateReferenceKind reference_kind;
@@ -1180,11 +1163,11 @@ gcm_calibrate_argyll_device_generate_profile (GcmCalibrateArgyll *calibrate_argy
 		      "reference-kind", &reference_kind,
 		      NULL);
 
-	/* get, returning fallbacks if nothing was set */
-	model = gcm_calibrate_get_model_fallback (GCM_CALIBRATE (calibrate_argyll));
-	manufacturer = gcm_calibrate_get_manufacturer_fallback (GCM_CALIBRATE (calibrate_argyll));
-	description = gcm_calibrate_get_description_fallback (GCM_CALIBRATE (calibrate_argyll));
-	device = gcm_calibrate_get_device_fallback (GCM_CALIBRATE (calibrate_argyll));
+	/* get profile text data */
+	copyright = gcm_calibrate_get_profile_copyright (GCM_CALIBRATE (calibrate_argyll));
+	description = gcm_calibrate_get_profile_description (GCM_CALIBRATE (calibrate_argyll));
+	model = gcm_calibrate_get_profile_model (GCM_CALIBRATE (calibrate_argyll));
+	manufacturer = gcm_calibrate_get_profile_manufacturer (GCM_CALIBRATE (calibrate_argyll));
 
 	/* get correct name of the command */
 	command = gcm_calibrate_argyll_get_tool_filename ("colprof", error);
@@ -1193,16 +1176,6 @@ gcm_calibrate_argyll_device_generate_profile (GcmCalibrateArgyll *calibrate_argy
 		goto out;
 	}
 
-	/* create date and set it to now */
-	date = g_date_new ();
-	g_date_set_time_t (date, time (NULL));
-
-        /* create a long description */
-	description_tmp = g_strdup_printf ("%s, %s (%04i-%02i-%02i)", device, description, date->year, date->month, date->day);
-
-	/* TRANSLATORS: this is the copyright string, where it might be "Copyright (c) 2009 Edward Scissorhands" */
-	copyright = g_strdup_printf ("%s %04i %s", _("Copyright (c)"), date->year, g_get_real_name ());
-
 	/* TRANSLATORS: title, a profile is a ICC file */
 	title = _("Generating the profile");
 	/* TRANSLATORS: dialog message */
@@ -1223,7 +1196,7 @@ gcm_calibrate_argyll_device_generate_profile (GcmCalibrateArgyll *calibrate_argy
 	g_ptr_array_add (array, g_strdup ("-v"));
 	g_ptr_array_add (array, g_strdup_printf ("-A%s", manufacturer));
 	g_ptr_array_add (array, g_strdup_printf ("-M%s", model));
-	g_ptr_array_add (array, g_strdup_printf ("-D%s", description_tmp));
+	g_ptr_array_add (array, g_strdup_printf ("-D%s", description));
 	g_ptr_array_add (array, g_strdup_printf ("-C%s", copyright));
 	g_ptr_array_add (array, g_strdup (gcm_calibrate_argyll_get_quality_arg (calibrate_argyll)));
 
@@ -1269,10 +1242,10 @@ gcm_calibrate_argyll_device_generate_profile (GcmCalibrateArgyll *calibrate_argy
 out:
 	if (array != NULL)
 		g_ptr_array_unref (array);
-	if (date != NULL)
-		g_date_free (date);
-	g_free (description_tmp);
 	g_free (copyright);
+	g_free (description);
+	g_free (manufacturer);
+	g_free (model);
 	g_free (basename);
 	g_free (command);
 	g_strfreev (argv);
diff --git a/src/gcm-calibrate.c b/src/gcm-calibrate.c
index ace5e9b..bc3688a 100644
--- a/src/gcm-calibrate.c
+++ b/src/gcm-calibrate.c
@@ -127,59 +127,85 @@ out:
 }
 
 /**
- * gcm_calibrate_get_model_fallback:
+ * gcm_calibrate_get_device_fallback:
  **/
-const gchar *
-gcm_calibrate_get_model_fallback (GcmCalibrate *calibrate)
+gchar *
+gcm_calibrate_get_profile_copyright (GcmCalibrate *calibrate)
 {
-	GcmCalibratePrivate *priv = calibrate->priv;
-	if (priv->model != NULL)
-		return priv->model;
+	gchar *text;
+	GDate *date = NULL;
 
-	/* TRANSLATORS: this is saved in the profile */
-	return _("Unknown model");
+	/* create date and set it to now */
+	date = g_date_new ();
+	g_date_set_time_t (date, time (NULL));
+
+	/* TRANSLATORS: this is the copyright string, where it might be "Copyright (c) 2009 Edward Scissorhands" - YOU NEED TO USE ASCII ONLY */
+	text = g_strdup_printf ("%s %04i %s", _("Copyright (c)"), date->year, g_get_real_name ());
+
+	g_date_free (date);
+	return text;
 }
 
 /**
- * gcm_calibrate_get_description_fallback:
+ * gcm_calibrate_get_device_fallback:
  **/
-const gchar *
-gcm_calibrate_get_description_fallback (GcmCalibrate *calibrate)
+gchar *
+gcm_calibrate_get_profile_description (GcmCalibrate *calibrate)
 {
+	gchar *text;
+	GDate *date = NULL;
+	const gchar *description;
 	GcmCalibratePrivate *priv = calibrate->priv;
-	if (priv->description != NULL)
-		return priv->description;
 
-	/* TRANSLATORS: this is saved in the profile */
-	return _("Unknown description");
+	/* create date and set it to now */
+	date = g_date_new ();
+	g_date_set_time_t (date, time (NULL));
+
+	/* we've got something set */
+	if (priv->description != NULL) {
+		description = priv->description;
+	} else {
+		/* TRANSLATORS: this is saved in the profile */
+		description = _("Unknown description");
+	}
+
+	/* get description */
+	text = g_strdup_printf ("%s, %s (%04i-%02i-%02i)", priv->device, description, date->year, date->month, date->day);
+
+	g_date_free (date);
+	return text;
 }
 
 /**
- * gcm_calibrate_get_manufacturer_fallback:
+ * gcm_calibrate_get_device_fallback:
  **/
-const gchar *
-gcm_calibrate_get_manufacturer_fallback (GcmCalibrate *calibrate)
+gchar *
+gcm_calibrate_get_profile_model (GcmCalibrate *calibrate)
 {
 	GcmCalibratePrivate *priv = calibrate->priv;
-	if (priv->manufacturer != NULL)
-		return priv->manufacturer;
+
+	/* we've got something set */
+	if (priv->model != NULL)
+		return g_strdup (priv->model);
 
 	/* TRANSLATORS: this is saved in the profile */
-	return _("Unknown manufacturer");
+	return g_strdup (_("Unknown model"));
 }
 
 /**
  * gcm_calibrate_get_device_fallback:
  **/
-const gchar *
-gcm_calibrate_get_device_fallback (GcmCalibrate *calibrate)
+gchar *
+gcm_calibrate_get_profile_manufacturer (GcmCalibrate *calibrate)
 {
 	GcmCalibratePrivate *priv = calibrate->priv;
-	if (priv->device != NULL)
-		return priv->device;
+
+	/* we've got something set */
+	if (priv->manufacturer != NULL)
+		return g_strdup (priv->manufacturer);
 
 	/* TRANSLATORS: this is saved in the profile */
-	return _("Unknown device");
+	return g_strdup (_("Unknown manufacturer"));
 }
 
 /**
@@ -219,6 +245,15 @@ gcm_calibrate_get_working_path (GcmCalibrate *calibrate)
 }
 
 /**
+ * gcm_calibrate_get_basename:
+ **/
+const gchar *
+gcm_calibrate_get_basename (GcmCalibrate *calibrate)
+{
+	return calibrate->priv->basename;
+}
+
+/**
  * gcm_calibrate_set_basename:
  **/
 static void
diff --git a/src/gcm-calibrate.h b/src/gcm-calibrate.h
index e222356..00f7a16 100644
--- a/src/gcm-calibrate.h
+++ b/src/gcm-calibrate.h
@@ -135,12 +135,14 @@ gboolean	 gcm_calibrate_set_from_device		(GcmCalibrate	*calibrate,
 gboolean	 gcm_calibrate_set_from_exif		(GcmCalibrate	*calibrate,
 							 const gchar	*filename,
 							 GError		**error);
-const gchar	*gcm_calibrate_get_model_fallback	(GcmCalibrate	*calibrate);
-const gchar	*gcm_calibrate_get_description_fallback	(GcmCalibrate	*calibrate);
-const gchar	*gcm_calibrate_get_manufacturer_fallback (GcmCalibrate	*calibrate);
-const gchar	*gcm_calibrate_get_device_fallback	(GcmCalibrate	*calibrate);
 const gchar	*gcm_calibrate_get_filename_result	(GcmCalibrate	*calibrate);
 const gchar	*gcm_calibrate_get_working_path		(GcmCalibrate	*calibrate);
+const gchar	*gcm_calibrate_get_basename		(GcmCalibrate	*calibrate);
+
+gchar		*gcm_calibrate_get_profile_copyright	(GcmCalibrate	*calibrate);
+gchar		*gcm_calibrate_get_profile_description	(GcmCalibrate	*calibrate);
+gchar		*gcm_calibrate_get_profile_model	(GcmCalibrate	*calibrate);
+gchar		*gcm_calibrate_get_profile_manufacturer	(GcmCalibrate	*calibrate);
 
 G_END_DECLS
 
diff --git a/src/gcm-self-test.c b/src/gcm-self-test.c
index 3691489..12204a0 100644
--- a/src/gcm-self-test.c
+++ b/src/gcm-self-test.c
@@ -129,6 +129,8 @@ gcm_test_calibrate_func (void)
 	GcmCalibrate *calibrate;
 	gboolean ret;
 	GError *error = NULL;
+	gchar *model;
+	gchar *manufacturer;
 
 	calibrate = gcm_calibrate_new ();
 	g_assert (calibrate != NULL);
@@ -137,9 +139,12 @@ gcm_test_calibrate_func (void)
 	ret = gcm_calibrate_set_from_exif (GCM_CALIBRATE(calibrate), TESTDATADIR "/test.tif", &error);
 	g_assert_no_error (error);
 	g_assert (ret);
-	g_assert_cmpstr (gcm_calibrate_get_model_fallback (calibrate), ==, "NIKON D60");
-	g_assert_cmpstr (gcm_calibrate_get_manufacturer_fallback (calibrate), ==, "NIKON CORPORATION");
-
+	model = gcm_calibrate_get_profile_model (calibrate);
+	manufacturer = gcm_calibrate_get_profile_manufacturer (calibrate);
+	g_assert_cmpstr (model, ==, "NIKON D60");
+	g_assert_cmpstr (manufacturer, ==, "NIKON CORPORATION");
+	g_free (model);
+	g_free (manufacturer);
 	g_object_unref (calibrate);
 }
 



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