[gnome-color-manager] Add gcm-dump-sensor for comparing different sensors
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] Add gcm-dump-sensor for comparing different sensors
- Date: Thu, 22 Jul 2010 11:44:00 +0000 (UTC)
commit aee6abce911a9c4fcfd816de494e15860f845129
Author: Richard Hughes <richard hughsie com>
Date: Thu Jul 22 12:42:21 2010 +0100
Add gcm-dump-sensor for comparing different sensors
libcolor-glib/gcm-sensor-huey.c | 2 +-
libcolor-glib/gcm-sensor.c | 8 +--
libcolor-glib/gcm-sensor.h | 2 +-
src/gcm-picker.c | 4 +-
tools/.gitignore | 1 +
tools/Makefile.am | 41 ++++------------
tools/gcm-dump-sensor.c | 97 +++++++++++++++++++++++++++++++++++++++
7 files changed, 116 insertions(+), 39 deletions(-)
---
diff --git a/libcolor-glib/gcm-sensor-huey.c b/libcolor-glib/gcm-sensor-huey.c
index 94ae131..ba5fbde 100644
--- a/libcolor-glib/gcm-sensor-huey.c
+++ b/libcolor-glib/gcm-sensor-huey.c
@@ -821,7 +821,7 @@ gcm_sensor_huey_dump (GcmSensor *sensor, GString *data, GError **error)
/* dump the unlock string */
g_string_append_printf (data, "huey dump version: %i\n", 1);
- g_string_printf (data, "unlock string: %s\n", priv->unlock_string);
+ g_string_append_printf (data, "unlock string: %s\n", priv->unlock_string);
/* read all the register space */
for (i=0; i<0xff; i++) {
diff --git a/libcolor-glib/gcm-sensor.c b/libcolor-glib/gcm-sensor.c
index 0324671..c32c887 100644
--- a/libcolor-glib/gcm-sensor.c
+++ b/libcolor-glib/gcm-sensor.c
@@ -220,7 +220,7 @@ gcm_sensor_get_output_type (GcmSensor *sensor)
}
/**
- * gcm_sensor_get_is_native:
+ * gcm_sensor_is_native:
* @sensor: a valid #GcmSensor instance
*
* Sensor support can be built in, for instance the HUEY, or rely on
@@ -230,7 +230,7 @@ gcm_sensor_get_output_type (GcmSensor *sensor)
* Return value: %TRUE for internal, native, support.
**/
gboolean
-gcm_sensor_get_is_native (GcmSensor *sensor)
+gcm_sensor_is_native (GcmSensor *sensor)
{
return sensor->priv->native;
}
@@ -403,16 +403,14 @@ gcm_sensor_dump (GcmSensor *sensor, GString *data, GError **error)
}
/* write common sensor details */
- g_string_append (data, "AUTOMATICALLY GENERATED -- DO NOT EDIT\n");
+ g_string_append (data, "// AUTOMATICALLY GENERATED -- DO NOT EDIT\n");
g_string_append_printf (data, "generic dump version: %i\n", 1);
g_string_append_printf (data, "kind: %s\n", gcm_sensor_kind_to_string (priv->kind));
g_string_append_printf (data, "vendor: %s\n", priv->vendor);
g_string_append_printf (data, "model: %s\n", priv->model);
g_string_append_printf (data, "device: %s\n", priv->device);
- g_string_append (data, "\n");
/* dump sensor */
- g_string_append (data, "device specific data:\n");
if (klass->dump == NULL) {
ret = FALSE;
g_set_error_literal (error,
diff --git a/libcolor-glib/gcm-sensor.h b/libcolor-glib/gcm-sensor.h
index f5f3e12..4f84344 100644
--- a/libcolor-glib/gcm-sensor.h
+++ b/libcolor-glib/gcm-sensor.h
@@ -155,7 +155,7 @@ gboolean gcm_sensor_supports_display (GcmSensor *sensor);
gboolean gcm_sensor_supports_projector (GcmSensor *sensor);
gboolean gcm_sensor_supports_printer (GcmSensor *sensor);
gboolean gcm_sensor_supports_spot (GcmSensor *sensor);
-gboolean gcm_sensor_get_is_native (GcmSensor *sensor);
+gboolean gcm_sensor_is_native (GcmSensor *sensor);
const gchar *gcm_sensor_kind_to_string (GcmSensorKind sensor_kind);
GcmSensorKind gcm_sensor_kind_from_string (const gchar *sensor_kind);
diff --git a/src/gcm-picker.c b/src/gcm-picker.c
index f918fe1..f0377e7 100644
--- a/src/gcm-picker.c
+++ b/src/gcm-picker.c
@@ -220,7 +220,7 @@ gcm_picker_measure_cb (GtkWidget *widget, gpointer data)
widget = GTK_WIDGET (gtk_builder_get_object (builder, "image_preview"));
gtk_image_set_from_file (GTK_IMAGE (widget), DATADIR "/icons/hicolor/64x64/apps/gnome-color-manager.png");
- if (gcm_sensor_get_is_native (sensor)) {
+ if (gcm_sensor_is_native (sensor)) {
/* set mode */
gcm_sensor_set_output_type (sensor, GCM_SENSOR_OUTPUT_TYPE_LCD);
@@ -325,7 +325,7 @@ gcm_picker_sensor_client_setup_ui (GcmSensorClient *sensor_client)
}
#ifndef HAVE_VTE
- if (!gcm_sensor_get_is_native (sensor)) {
+ if (!gcm_sensor_is_native (sensor)) {
/* TRANSLATORS: this is displayed if VTE support is not enabled */
gtk_label_set_label (GTK_LABEL (info_bar_hardware_label), _("This application was compiled without VTE support."));
goto out;
diff --git a/tools/.gitignore b/tools/.gitignore
index ad966e6..d40c51d 100644
--- a/tools/.gitignore
+++ b/tools/.gitignore
@@ -7,6 +7,7 @@
.deps
gcm-dump-edid
gcm-dump-profile
+gcm-dump-sensor
gcm-fix-profile
gcm-glsl-demo
gcm-ddc-util
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 4f5b592..ac3b186 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -2,14 +2,6 @@ INCLUDES = \
$(GLIB_CFLAGS) \
$(X11_CFLAGS) \
$(GTK_CFLAGS) \
- $(GNOMEDESKTOP_CFLAGS) \
- $(VTE_CFLAGS) \
- $(XORG_CFLAGS) \
- $(CUPS_CFLAGS) \
- $(SANE_CFLAGS) \
- $(TIFF_CFLAGS) \
- $(EXIF_CFLAGS) \
- $(EXIV_CFLAGS) \
$(NOTIFY_CFLAGS) \
$(CANBERRA_CFLAGS) \
$(CONTROL_CENTER_CFLAGS) \
@@ -32,6 +24,7 @@ INCLUDES = \
noinst_PROGRAMS = \
gcm-dump-profile \
+ gcm-dump-sensor \
gcm-fix-profile \
gcm-ddc-util \
gcm-sensor-example
@@ -41,14 +34,6 @@ gcm_dump_edid_SOURCES = \
gcm-dump-edid.c
gcm_dump_edid_LDADD = \
- $(GLIB_LIBS) \
- $(X11_LIBS) \
- $(GNOMEDESKTOP_LIBS) \
- $(GUDEV_LIBS) \
- $(XORG_LIBS) \
- $(GTK_LIBS) \
- $(SANE_LIBS) \
- $(CUPS_LIBS) \
$(COLOR_GLIB_LIBS) \
-lm
@@ -60,29 +45,27 @@ gcm_dump_profile_SOURCES = \
gcm-dump-profile.c
gcm_dump_profile_LDADD = \
- $(GLIB_LIBS) \
- $(X11_LIBS) \
- $(GNOMEDESKTOP_LIBS) \
- $(GUDEV_LIBS) \
- $(XORG_LIBS) \
- $(GTK_LIBS) \
- $(SANE_LIBS) \
- $(CUPS_LIBS) \
$(COLOR_GLIB_LIBS) \
-lm
gcm_dump_profile_CFLAGS = \
$(WARNINGFLAGS_C)
+gcm_dump_sensor_SOURCES = \
+ gcm-dump-sensor.c
+
+gcm_dump_sensor_LDADD = \
+ $(COLOR_GLIB_LIBS) \
+ -lm
+
+gcm_dump_sensor_CFLAGS = \
+ $(WARNINGFLAGS_C)
+
gcm_fix_profile_SOURCES = \
gcm-fix-profile.c
gcm_fix_profile_LDADD = \
$(GLIB_LIBS) \
- $(X11_LIBS) \
- $(GTK_LIBS) \
- $(SANE_LIBS) \
- $(CUPS_LIBS) \
$(LCMS_LIBS) \
-lm
@@ -96,7 +79,6 @@ gcm_ddc_util_SOURCES = \
gcm-ddc-util.c
gcm_ddc_util_LDADD = \
- $(GLIB_LIBS) \
$(COLOR_GLIB_LIBS)
gcm_ddc_util_CFLAGS = \
@@ -110,7 +92,6 @@ gcm_sensor_example_SOURCES = \
gcm-sensor-example.c
gcm_sensor_example_LDADD = \
- $(GLIB_LIBS) \
$(COLOR_GLIB_LIBS)
gcm_sensor_example_CFLAGS = \
diff --git a/tools/gcm-dump-sensor.c b/tools/gcm-dump-sensor.c
new file mode 100644
index 0000000..e5b28e3
--- /dev/null
+++ b/tools/gcm-dump-sensor.c
@@ -0,0 +1,97 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2010 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+#include <locale.h>
+
+#include "gcm-sensor-client.h"
+
+/**
+ * main:
+ **/
+int
+main (int argc, char **argv)
+{
+ guint retval = 0;
+ gboolean ret;
+ GError *error = NULL;
+ GString *data = NULL;
+ GOptionContext *context;
+ GcmSensorClient *sensor_client;
+ GcmSensor *sensor;
+
+ setlocale (LC_ALL, "");
+
+ g_type_init ();
+
+ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
+ context = g_option_context_new ("ICC profile dump program");
+ g_option_context_parse (context, &argc, &argv, NULL);
+ g_option_context_free (context);
+
+ /* find sensors */
+ sensor_client = gcm_sensor_client_new ();
+
+ /* get the default sensor */
+ sensor = gcm_sensor_client_get_sensor (sensor_client);
+ if (sensor == NULL) {
+ g_print ("FAILED: Failed to find a supported sensor\n");
+ goto out;
+ }
+
+ /* check is native */
+ if (!gcm_sensor_is_native (sensor)) {
+ g_print ("FAILED: Failed to find a native sensor\n");
+ goto out;
+ }
+
+ /* dump details */
+ g_print ("Dumping sensor details... ");
+ data = g_string_new ("");
+ ret = gcm_sensor_dump (sensor, data, &error);
+ if (!ret) {
+ g_print ("FAILED: Failed to dump sensor: %s\n", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ /* write to file */
+ ret = g_file_set_contents ("./sensor-dump.txt", data->str, data->len, &error);
+ if (!ret) {
+ g_print ("FAILED: Failed to write file: %s\n", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ /* success */
+ g_print ("SUCCESS!!\n");
+out:
+ if (data != NULL)
+ g_string_free (data, TRUE);
+ g_object_unref (sensor_client);
+ return retval;
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]