[gnome-color-manager] trivial: make GcmDeviceXrandr implement the apply() virtual function



commit bb8da4f41624c6d1d165be3a1a8c1b9b904c0bbb
Author: Richard Hughes <richard hughsie com>
Date:   Tue Feb 9 20:01:57 2010 +0000

    trivial: make GcmDeviceXrandr implement the apply() virtual function

 src/gcm-apply.c         |    2 +-
 src/gcm-device-xrandr.c |   24 +++++++++++++-----------
 src/gcm-device-xrandr.h |    2 --
 src/gcm-prefs.c         |   10 +++++-----
 4 files changed, 19 insertions(+), 19 deletions(-)
---
diff --git a/src/gcm-apply.c b/src/gcm-apply.c
index b83ef99..94863ee 100644
--- a/src/gcm-apply.c
+++ b/src/gcm-apply.c
@@ -85,7 +85,7 @@ main (int argc, char **argv)
 
 		/* set gamma for device */
 		egg_debug ("setting %s gamma", gcm_device_get_id (device));
-		ret = gcm_device_xrandr_set_gamma (GCM_DEVICE_XRANDR (device), &error);
+		ret = gcm_device_apply (device, &error);
 		if (!ret) {
 			retval = 1;
 			egg_warning ("failed to set gamma: %s", error->message);
diff --git a/src/gcm-device-xrandr.c b/src/gcm-device-xrandr.c
index 218ed72..4c40ba7 100644
--- a/src/gcm-device-xrandr.c
+++ b/src/gcm-device-xrandr.c
@@ -339,10 +339,10 @@ out:
 }
 
 /**
- * gcm_device_xrandr_set_gamma_fallback:
+ * gcm_device_xrandr_apply_fallback:
  **/
 static gboolean
-gcm_device_xrandr_set_gamma_fallback (XRRCrtcGamma *crtc_gamma, guint size)
+gcm_device_xrandr_apply_fallback (XRRCrtcGamma *crtc_gamma, guint size)
 {
 	Bool rc;
 
@@ -356,12 +356,12 @@ gcm_device_xrandr_set_gamma_fallback (XRRCrtcGamma *crtc_gamma, guint size)
 }
 
 /**
- * gcm_device_xrandr_set_gamma_for_crtc:
+ * gcm_device_xrandr_apply_for_crtc:
  *
  * Return value: %TRUE for success;
  **/
 static gboolean
-gcm_device_xrandr_set_gamma_for_crtc (GcmDeviceXrandr *device_xrandr, GnomeRRCrtc *crtc, GcmClut *clut, GError **error)
+gcm_device_xrandr_apply_for_crtc (GcmDeviceXrandr *device_xrandr, GnomeRRCrtc *crtc, GcmClut *clut, GError **error)
 {
 	guint id;
 	gboolean ret = TRUE;
@@ -403,7 +403,7 @@ gcm_device_xrandr_set_gamma_for_crtc (GcmDeviceXrandr *device_xrandr, GnomeRRCrt
 	gdk_flush ();
 	if (gdk_error_trap_pop ()) {
 		/* some drivers support Xrandr 1.2, not 1.3 */
-		ret = gcm_device_xrandr_set_gamma_fallback (crtc_gamma, array->len);
+		ret = gcm_device_xrandr_apply_fallback (crtc_gamma, array->len);
 		if (!ret) {
 			g_set_error (error, 1, 0, "failed to set crtc gamma %p (%i) on %i", crtc_gamma, array->len, id);
 			goto out;
@@ -418,12 +418,12 @@ out:
 }
 
 /**
- * gcm_device_xrandr_set_gamma:
+ * gcm_device_xrandr_apply:
  *
  * Return value: %TRUE for success;
  **/
-gboolean
-gcm_device_xrandr_set_gamma (GcmDeviceXrandr *device_xrandr, GError **error)
+static gboolean
+gcm_device_xrandr_apply (GcmDevice *device, GError **error)
 {
 	gboolean ret = FALSE;
 	GcmClut *clut = NULL;
@@ -444,10 +444,9 @@ gcm_device_xrandr_set_gamma (GcmDeviceXrandr *device_xrandr, GError **error)
 	gboolean use_atom;
 	gboolean leftmost_screen = FALSE;
 	GcmDeviceTypeEnum type;
+	GcmDeviceXrandr *device_xrandr = GCM_DEVICE_XRANDR (device);
 	GcmDeviceXrandrPrivate *priv = device_xrandr->priv;
 
-	g_return_val_if_fail (device_xrandr != NULL, FALSE);
-
 	/* get details about the device */
 	g_object_get (device_xrandr,
 		      "id", &id,
@@ -530,7 +529,7 @@ gcm_device_xrandr_set_gamma (GcmDeviceXrandr *device_xrandr, GError **error)
 	}
 
 	/* actually set the gamma */
-	ret = gcm_device_xrandr_set_gamma_for_crtc (device_xrandr, crtc, clut, error);
+	ret = gcm_device_xrandr_apply_for_crtc (device_xrandr, crtc, clut, error);
 	if (!ret)
 		goto out;
 
@@ -625,10 +624,13 @@ gcm_device_xrandr_class_init (GcmDeviceXrandrClass *klass)
 {
 	GParamSpec *pspec;
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	GcmDeviceClass *device_class = GCM_DEVICE_CLASS (klass);
+
 	object_class->finalize = gcm_device_xrandr_finalize;
 	object_class->get_property = gcm_device_xrandr_get_property;
 	object_class->set_property = gcm_device_xrandr_set_property;
 
+	device_class->apply = gcm_device_xrandr_apply;
 
 	/**
 	 * GcmDeviceXrandr:native-device:
diff --git a/src/gcm-device-xrandr.h b/src/gcm-device-xrandr.h
index d56c4f9..4ecb76a 100644
--- a/src/gcm-device-xrandr.h
+++ b/src/gcm-device-xrandr.h
@@ -53,8 +53,6 @@ GcmDevice	*gcm_device_xrandr_new			(void);
 gboolean	 gcm_device_xrandr_set_from_output	(GcmDevice		*device,
 							 GnomeRROutput		*output,
 							 GError			**error);
-gboolean	 gcm_device_xrandr_set_gamma		(GcmDeviceXrandr	*device_xrandr,
-							 GError			**error);
 
 G_END_DECLS
 
diff --git a/src/gcm-prefs.c b/src/gcm-prefs.c
index 8f7d0ea..66b330d 100644
--- a/src/gcm-prefs.c
+++ b/src/gcm-prefs.c
@@ -385,7 +385,7 @@ gcm_prefs_calibrate_display (GcmCalibrate *calibrate)
 out:
 	/* need to set the gamma back to the default after calibration */
 	error = NULL;
-	ret_tmp = gcm_device_xrandr_set_gamma (GCM_DEVICE_XRANDR (current_device), &error);
+	ret_tmp = gcm_device_apply (current_device, &error);
 	if (!ret_tmp) {
 		egg_warning ("failed to set output gamma: %s", error->message);
 		g_error_free (error);
@@ -2131,7 +2131,7 @@ gcm_prefs_add_device_xrandr (GcmDevice *device)
 	/* italic for non-connected devices */
 	if (connected) {
 		/* set the gamma on the device */
-		ret = gcm_device_xrandr_set_gamma (GCM_DEVICE_XRANDR (device), &error);
+		ret = gcm_device_apply (device, &error);
 		if (!ret) {
 			egg_warning ("failed to set output gamma: %s", error->message);
 			g_error_free (error);
@@ -2269,7 +2269,7 @@ gcm_prefs_profile_combo_changed_cb (GtkWidget *widget, gpointer data)
 
 		/* set the gamma for display types */
 		if (type == GCM_DEVICE_TYPE_ENUM_DISPLAY) {
-			ret = gcm_device_xrandr_set_gamma (GCM_DEVICE_XRANDR (current_device), &error);
+			ret = gcm_device_apply (current_device, &error);
 			if (!ret) {
 				egg_warning ("failed to set output gamma: %s", error->message);
 				g_error_free (error);
@@ -2322,7 +2322,7 @@ gcm_prefs_slider_changed_cb (GtkRange *range, gpointer *user_data)
 	}
 
 	/* actually set the new profile */
-	ret = gcm_device_xrandr_set_gamma (GCM_DEVICE_XRANDR (current_device), &error);
+	ret = gcm_device_apply (current_device, &error);
 	if (!ret) {
 		egg_warning ("failed to set output gamma: %s", error->message);
 		g_error_free (error);
@@ -2815,7 +2815,7 @@ gcm_prefs_reset_devices_idle_cb (gpointer user_data)
 			continue;
 
 		/* set gamma for device */
-		ret = gcm_device_xrandr_set_gamma (GCM_DEVICE_XRANDR (device), &error);
+		ret = gcm_device_apply (device, &error);
 		if (!ret) {
 			egg_warning ("failed to set gamma: %s", error->message);
 			g_error_free (error);



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