[gnome-color-manager] trivial: add some more getters and setters in various objects



commit cebd3a901f29619a8f0ad75a77ebb647743b0cfd
Author: Richard Hughes <richard hughsie com>
Date:   Thu Mar 25 21:44:27 2010 +0000

    trivial: add some more getters and setters in various objects

 src/gcm-calibrate.c |    9 +++++++++
 src/gcm-calibrate.h |    1 +
 src/gcm-client.c    |   16 ++++++++++++++++
 src/gcm-client.h    |    1 +
 src/gcm-clut.c      |    9 +++++++++
 src/gcm-clut.h      |    1 +
 src/gcm-dump-edid.c |   34 +++++++++++++---------------------
 src/gcm-prefs.c     |   43 ++++++++++---------------------------------
 src/gcm-profile.c   |   44 +++++++++++++++-----------------------------
 9 files changed, 75 insertions(+), 83 deletions(-)
---
diff --git a/src/gcm-calibrate.c b/src/gcm-calibrate.c
index 33198c4..1c638cc 100644
--- a/src/gcm-calibrate.c
+++ b/src/gcm-calibrate.c
@@ -195,6 +195,15 @@ gcm_calibrate_get_time (void)
 }
 
 /**
+ * gcm_calibrate_get_filename_result:
+ **/
+const gchar *
+gcm_calibrate_get_filename_result (GcmCalibrate *calibrate)
+{
+	return calibrate->priv->filename_result;
+}
+
+/**
  * gcm_calibrate_set_basename:
  **/
 static void
diff --git a/src/gcm-calibrate.h b/src/gcm-calibrate.h
index 1721d63..db2719d 100644
--- a/src/gcm-calibrate.h
+++ b/src/gcm-calibrate.h
@@ -133,6 +133,7 @@ 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);
 
 G_END_DECLS
 
diff --git a/src/gcm-client.c b/src/gcm-client.c
index 57e32a9..6285030 100644
--- a/src/gcm-client.c
+++ b/src/gcm-client.c
@@ -148,6 +148,22 @@ gcm_client_get_devices (GcmClient *client)
 }
 
 /**
+ * gcm_client_get_loading:
+ *
+ * @client: a valid %GcmClient instance
+ *
+ * Gets the loading status.
+ *
+ * Return value: %TRUE if the object is still loading devices
+ **/
+gboolean
+gcm_client_get_loading (GcmClient *client)
+{
+	g_return_val_if_fail (GCM_IS_CLIENT (client), FALSE);
+	return client->priv->loading;
+}
+
+/**
  * gcm_client_get_device_by_id:
  *
  * @client: a valid %GcmClient instance
diff --git a/src/gcm-client.h b/src/gcm-client.h
index 2087cbd..4b8c7dc 100644
--- a/src/gcm-client.h
+++ b/src/gcm-client.h
@@ -80,6 +80,7 @@ gboolean	 gcm_client_add_saved				(GcmClient		*client,
 GPtrArray	*gcm_client_get_devices				(GcmClient		*client);
 void		 gcm_client_set_use_threads			(GcmClient		*client,
 								 gboolean		 use_threads);
+gboolean	 gcm_client_get_loading				(GcmClient		*client);
 
 G_END_DECLS
 
diff --git a/src/gcm-clut.c b/src/gcm-clut.c
index 9e3ded5..bc3c0d4 100644
--- a/src/gcm-clut.c
+++ b/src/gcm-clut.c
@@ -148,6 +148,15 @@ gcm_clut_get_adjusted_value (guint value, gfloat min, gfloat max, gfloat custom_
 }
 
 /**
+ * gcm_clut_get_size:
+ **/
+guint
+gcm_clut_get_size (GcmClut *clut)
+{
+	return clut->priv->size;
+}
+
+/**
  * gcm_clut_get_array:
  **/
 GPtrArray *
diff --git a/src/gcm-clut.h b/src/gcm-clut.h
index a093fcd..00461c4 100644
--- a/src/gcm-clut.h
+++ b/src/gcm-clut.h
@@ -67,6 +67,7 @@ gboolean	 gcm_clut_set_source_array		(GcmClut		*clut,
 							 GPtrArray		*array);
 gboolean	 gcm_clut_reset				(GcmClut		*clut);
 void		 gcm_clut_print				(GcmClut		*clut);
+guint		 gcm_clut_get_size			(GcmClut		*clut);
 
 G_END_DECLS
 
diff --git a/src/gcm-dump-edid.c b/src/gcm-dump-edid.c
index 4f95f02..7639d47 100644
--- a/src/gcm-dump-edid.c
+++ b/src/gcm-dump-edid.c
@@ -38,11 +38,11 @@
 static gboolean
 gcm_dump_edid_filename (const gchar *filename)
 {
-	gchar *monitor_name = NULL;
-	gchar *vendor_name = NULL;
-	gchar *serial_number = NULL;
-	gchar *ascii_string = NULL;
-	gchar *pnp_id = NULL;
+	const gchar *monitor_name;
+	const gchar *vendor_name;
+	const gchar *serial_number;
+	const gchar *ascii_string;
+	const gchar *pnp_id;
 	gchar *data = NULL;
 	guint width;
 	guint height;
@@ -68,42 +68,39 @@ gcm_dump_edid_filename (const gchar *filename)
 		goto out;
 	}
 
-	g_object_get (edid,
-		      "monitor-name", &monitor_name,
-		      "vendor-name", &vendor_name,
-		      "serial-number", &serial_number,
-		      "ascii-string", &ascii_string,
-		      "pnp-id", &pnp_id,
-		      "width", &width,
-		      "height", &height,
-		      "gamma", &gamma,
-		      NULL);
-
 	/* print data */
+	monitor_name = gcm_edid_get_monitor_name (edid);
 	if (monitor_name != NULL) {
 		/* TRANSLATORS: this is debugging output for the supplied EDID file */
 		g_print ("  %s: %s\n", _("Monitor name"), monitor_name);
 	}
+	vendor_name = gcm_edid_get_vendor_name (edid);
 	if (vendor_name != NULL) {
 		/* TRANSLATORS: this is debugging output for the supplied EDID file */
 		g_print ("  %s: %s\n", _("Vendor name"), vendor_name);
 	}
+	serial_number = gcm_edid_get_serial_number (edid);
 	if (serial_number != NULL) {
 		/* TRANSLATORS: this is debugging output for the supplied EDID file */
 		g_print ("  %s: %s\n", _("Serial number"), serial_number);
 	}
+	ascii_string = gcm_edid_get_ascii_string (edid);
 	if (ascii_string != NULL) {
 		/* TRANSLATORS: this is debugging output for the supplied EDID file */
 		g_print ("  %s: %s\n", _("Text string"), ascii_string);
 	}
+	pnp_id = gcm_edid_get_pnp_id (edid);
 	if (pnp_id != NULL) {
 		/* TRANSLATORS: this is debugging output for the supplied EDID file */
 		g_print ("  %s: %s\n", _("PNP identifier"), pnp_id);
 	}
+	width = gcm_edid_get_width (edid);
+	height = gcm_edid_get_height (edid);
 	if (width != 0) {
 		/* TRANSLATORS: this is debugging output for the supplied EDID file */
 		g_print ("  %s: %ix%i\n", _("Size"), width, height);
 	}
+	gamma = gcm_edid_get_gamma (edid);
 	if (gamma > 0.0f) {
 		/* TRANSLATORS: this is debugging output for the supplied EDID file */
 		g_print ("  %s: %f\n", _("Gamma"), gamma);
@@ -111,11 +108,6 @@ gcm_dump_edid_filename (const gchar *filename)
 out:
 	if (edid != NULL)
 		g_object_unref (edid);
-	g_free (monitor_name);
-	g_free (vendor_name);
-	g_free (serial_number);
-	g_free (ascii_string);
-	g_free (pnp_id);
 	g_free (data);
 	return ret;
 }
diff --git a/src/gcm-prefs.c b/src/gcm-prefs.c
index a21aef8..1b91863 100644
--- a/src/gcm-prefs.c
+++ b/src/gcm-prefs.c
@@ -725,7 +725,7 @@ gcm_prefs_calibrate_cb (GtkWidget *widget, gpointer data)
 	GcmDeviceKind kind;
 	gboolean ret;
 	GError *error = NULL;
-	gchar *filename = NULL;
+	const gchar *filename;
 	guint i;
 	const gchar *name;
 	GcmProfile *profile;
@@ -764,12 +764,8 @@ gcm_prefs_calibrate_cb (GtkWidget *widget, gpointer data)
 	if (!ret)
 		goto out;
 
-	/* finish */
-	g_object_get (calibrate,
-		      "filename-result", &filename,
-		      NULL);
-
 	/* failed to get profile */
+	filename = gcm_calibrate_get_filename_result (calibrate);
 	if (filename == NULL) {
 		egg_warning ("failed to get filename from calibration");
 		goto out;
@@ -804,9 +800,7 @@ gcm_prefs_calibrate_cb (GtkWidget *widget, gpointer data)
 		egg_debug ("adding: %s", destination);
 
 		/* set this default */
-		g_object_set (current_device,
-			      "profile-filename", destination,
-			      NULL);
+		gcm_device_set_profile_filename (current_device, destination);
 		ret = gcm_device_save (current_device, &error);
 		if (!ret) {
 			egg_warning ("failed to save default: %s", error->message);
@@ -826,7 +820,6 @@ gcm_prefs_calibrate_cb (GtkWidget *widget, gpointer data)
 			 /* TRANSLATORS: this is the sound description */
 			 CA_PROP_EVENT_DESCRIPTION, _("Profiling completed"), NULL);
 out:
-	g_free (filename);
 	g_free (destination);
 	if (profile_array != NULL)
 		g_ptr_array_unref (profile_array);
@@ -1536,14 +1529,8 @@ gcm_prefs_profiles_treeview_clicked_cb (GtkTreeSelection *selection, gpointer us
 	/* get curve data */
 	clut = gcm_profile_generate_curve (profile, 256);
 
-	/* get size */
-	if (clut != NULL) {
-		g_object_get (clut,
-			      "size", &size,
-			      NULL);
-	}
-
 	/* only show if there is useful information */
+	size = gcm_clut_get_size (clut);
 	if (size > 0) {
 		g_object_set (trc_widget,
 			      "clut", clut,
@@ -1896,11 +1883,9 @@ gcm_prefs_profile_combo_changed_cb (GtkWidget *widget, gpointer data)
 
 	/* set new profile */
 	if (changed) {
-		g_object_set (current_device,
-			      "profile-filename", filename,
-			      NULL);
 
 		/* save new profile */
+		gcm_device_set_profile_filename (current_device, filename);
 		ret = gcm_device_save (current_device, &error);
 		if (!ret) {
 			egg_warning ("failed to save config: %s", error->message);
@@ -1950,11 +1935,9 @@ gcm_prefs_slider_changed_cb (GtkRange *range, gpointer *user_data)
 	widget = GTK_WIDGET (gtk_builder_get_object (builder, "hscale_contrast"));
 	contrast = gtk_range_get_value (GTK_RANGE (widget));
 
-	g_object_set (current_device,
-		      "gamma", localgamma,
-		      "brightness", brightness * 100.0f,
-		      "contrast", contrast * 100.0f,
-		      NULL);
+	gcm_device_set_gamma (current_device, localgamma);
+	gcm_device_set_brightness (current_device, brightness * 100.0f);
+	gcm_device_set_contrast (current_device, contrast * 100.0f);
 
 	/* save new profile */
 	ret = gcm_device_save (current_device, &error);
@@ -2170,12 +2153,8 @@ gcm_prefs_removed_cb (GcmClient *gcm_client_, GcmDevice *gcm_device, gpointer us
 	/* remove from the UI */
 	gcm_prefs_remove_device (gcm_device);
 
-	/* get device properties */
-	g_object_get (gcm_device,
-		      "connected", &connected,
-		      NULL);
-
 	/* ensure this device is re-added if it's been saved */
+	connected = gcm_device_get_connected (gcm_device);
 	if (connected)
 		gcm_client_add_saved (gcm_client, NULL);
 
@@ -2600,10 +2579,8 @@ gcm_prefs_client_notify_loading_cb (GcmClient *client, GParamSpec *pspec, gpoint
 {
 	gboolean loading;
 
-	/* get the new state */
-	g_object_get (client, "loading", &loading, NULL);
-
 	/*if loading show the bar */
+	loading = gcm_client_get_loading (client);
 	if (loading) {
 		gtk_widget_show (info_bar_loading);
 		return;
diff --git a/src/gcm-profile.c b/src/gcm-profile.c
index 6f605ce..8ca7dd3 100644
--- a/src/gcm-profile.c
+++ b/src/gcm-profile.c
@@ -868,16 +868,14 @@ typedef struct {
 void
 gcm_profile_test_parse_file (EggTest *test, const guint8 *datafile, GcmProfileTestData *test_data)
 {
-	gchar *filename;
-	gchar *filename_tmp;
-	gchar *copyright;
-	gchar *manufacturer;
-	gchar *model;
-	gchar *datetime;
-	gchar *description;
-	gchar *ascii_string;
-	gchar *pnp_id;
-	gchar *data;
+	gchar *filename = NULL;
+	const gchar *copyright;
+	const gchar *manufacturer;
+	const gchar *model;
+	const gchar *datetime;
+	const gchar *description;
+	const gchar *ascii_string;
+	const gchar *pnp_id;
 	guint width;
 	guint kind;
 	guint colorspace;
@@ -909,20 +907,9 @@ gcm_profile_test_parse_file (EggTest *test, const guint8 *datafile, GcmProfileTe
 		egg_test_failed (test, "failed to parse: %s", error->message);
 	g_object_unref (file);
 
-	/* get some properties */
-	g_object_get (profile_lcms1,
-		      "copyright", &copyright,
-		      "manufacturer", &manufacturer,
-		      "model", &model,
-		      "datetime", &datetime,
-		      "description", &description,
-		      "filename", &filename_tmp,
-		      "kind", &kind,
-		      "colorspace", &colorspace,
-		      NULL);
-
 	/************************************************************/
 	egg_test_title (test, "check copyright for %s", datafile);
+	copyright = gcm_profile_get_copyright (profile_lcms1);
 	if (g_strcmp0 (copyright, test_data->copyright) == 0)
 		egg_test_success (test, NULL);
 	else
@@ -930,6 +917,7 @@ gcm_profile_test_parse_file (EggTest *test, const guint8 *datafile, GcmProfileTe
 
 	/************************************************************/
 	egg_test_title (test, "check manufacturer for %s", datafile);
+	manufacturer = gcm_profile_get_manufacturer (profile_lcms1);
 	if (g_strcmp0 (manufacturer, test_data->manufacturer) == 0)
 		egg_test_success (test, NULL);
 	else
@@ -937,6 +925,7 @@ gcm_profile_test_parse_file (EggTest *test, const guint8 *datafile, GcmProfileTe
 
 	/************************************************************/
 	egg_test_title (test, "check model for %s", datafile);
+	model = gcm_profile_get_model (profile_lcms1);
 	if (g_strcmp0 (model, test_data->model) == 0)
 		egg_test_success (test, NULL);
 	else
@@ -944,6 +933,7 @@ gcm_profile_test_parse_file (EggTest *test, const guint8 *datafile, GcmProfileTe
 
 	/************************************************************/
 	egg_test_title (test, "check datetime for %s", datafile);
+	datetime = gcm_profile_get_datetime (profile_lcms1);
 	if (g_strcmp0 (datetime, test_data->datetime) == 0)
 		egg_test_success (test, NULL);
 	else
@@ -951,6 +941,7 @@ gcm_profile_test_parse_file (EggTest *test, const guint8 *datafile, GcmProfileTe
 
 	/************************************************************/
 	egg_test_title (test, "check description for %s", datafile);
+	description = gcm_profile_get_description (profile_lcms1);
 	if (g_strcmp0 (description, test_data->description) == 0)
 		egg_test_success (test, NULL);
 	else
@@ -958,6 +949,7 @@ gcm_profile_test_parse_file (EggTest *test, const guint8 *datafile, GcmProfileTe
 
 	/************************************************************/
 	egg_test_title (test, "check kind for %s", datafile);
+	kind = gcm_profile_get_kind (profile_lcms1);
 	if (kind == test_data->kind)
 		egg_test_success (test, NULL);
 	else
@@ -965,6 +957,7 @@ gcm_profile_test_parse_file (EggTest *test, const guint8 *datafile, GcmProfileTe
 
 	/************************************************************/
 	egg_test_title (test, "check colorspace for %s", datafile);
+	colorspace = gcm_profile_get_colorspace (profile_lcms1);
 	if (colorspace == test_data->colorspace)
 		egg_test_success (test, NULL);
 	else
@@ -983,14 +976,7 @@ gcm_profile_test_parse_file (EggTest *test, const guint8 *datafile, GcmProfileTe
 
 	g_object_unref (xyz);
 	g_object_unref (profile_lcms1);
-	g_free (copyright);
-	g_free (manufacturer);
-	g_free (model);
-	g_free (datetime);
-	g_free (description);
-	g_free (data);
 	g_free (filename);
-	g_free (filename_tmp);
 }
 
 void



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