[gnome-color-manager] Do not rely on usb.ids, but instead encode the colorimeter type in the udev rules
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] Do not rely on usb.ids, but instead encode the colorimeter type in the udev rules
- Date: Thu, 25 Mar 2010 22:23:09 +0000 (UTC)
commit 11eda404e4b7c3e438540a03fa167d4f93f092cb
Author: Richard Hughes <richard hughsie com>
Date: Thu Mar 25 22:22:57 2010 +0000
Do not rely on usb.ids, but instead encode the colorimeter type in the udev rules
rules/95-gcm-colorimeters.rules | 35 ++++++++--------
src/gcm-colorimeter.c | 86 ++++++++++++++++++++++++++-------------
src/gcm-colorimeter.h | 16 ++++---
3 files changed, 84 insertions(+), 53 deletions(-)
---
diff --git a/rules/95-gcm-colorimeters.rules b/rules/95-gcm-colorimeters.rules
index e0ac363..39e1f85 100644
--- a/rules/95-gcm-colorimeters.rules
+++ b/rules/95-gcm-colorimeters.rules
@@ -11,11 +11,12 @@
# Colorimeter devices used for profiling
#
# These are properties defining the behavior:
-# GCM_COLORIMETER (Can measure color)
-# GCM_TYPE_DISPLAY (Can profile a display device)
-# GCM_TYPE_PROJECTOR (Can profile a projector device)
-# GCM_TYPE_PRINTER (Can profile a printer device)
-# GCM_TYPE_SPOT (Can be used for spot measurements)
+# GCM_COLORIMETER Can measure color
+# GCM_KIND The kind of sensor
+# GCM_TYPE_DISPLAY Can profile a display device
+# GCM_TYPE_PROJECTOR Can profile a projector device
+# GCM_TYPE_PRINTER Can profile a printer device
+# GCM_TYPE_SPOT Can be used for spot measurements
#
# Skip all this to speed things up if it'a not a usb add.
@@ -23,40 +24,40 @@ ACTION!="add", GOTO="gcm_rules_end"
SUBSYSTEM!="usb", GOTO="gcm_rules_end"
# DTP20
-ATTRS{idVendor}=="0765", ATTRS{idProduct}=="d020", ENV{GCM_COLORIMETER}="1", ENV{GCM_TYPE_PRINTER}="1", ENV{GCM_TYPE_SPOT}="1"
+ATTRS{idVendor}=="0765", ATTRS{idProduct}=="d020", ENV{GCM_COLORIMETER}="1", ENV{GCM_KIND}="dtp20", ENV{GCM_TYPE_PRINTER}="1", ENV{GCM_TYPE_SPOT}="1"
# DTP92Q (not tested)
-ATTRS{idVendor}=="0765", ATTRS{idProduct}=="d092", ENV{GCM_COLORIMETER}="1", ENV{GCM_TYPE_DISPLAY}="1"
+ATTRS{idVendor}=="0765", ATTRS{idProduct}=="d092", ENV{GCM_COLORIMETER}="1", ENV{GCM_KIND}="unknown", ENV{GCM_TYPE_DISPLAY}="1"
# DTP94
-ATTRS{idVendor}=="0765", ATTRS{idProduct}=="d094", ENV{GCM_COLORIMETER}="1", ENV{GCM_TYPE_DISPLAY}="1"
+ATTRS{idVendor}=="0765", ATTRS{idProduct}=="d094", ENV{GCM_COLORIMETER}="1", ENV{GCM_KIND}="unknown", ENV{GCM_TYPE_DISPLAY}="1"
# MonacoOPTIX (Same as i1 Display 1)
-ATTRS{idVendor}=="0670", ATTRS{idProduct}=="0001", ENV{GCM_COLORIMETER}="1", ENV{GCM_TYPE_DISPLAY}="1"
+ATTRS{idVendor}=="0670", ATTRS{idProduct}=="0001", ENV{GCM_COLORIMETER}="1", ENV{GCM_KIND}="i1-pro", ENV{GCM_TYPE_DISPLAY}="1"
# i1Display
-ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2003", ENV{GCM_COLORIMETER}="1", ENV{GCM_TYPE_DISPLAY}="1"
+ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2003", ENV{GCM_COLORIMETER}="1", ENV{GCM_KIND}="i1-pro", ENV{GCM_TYPE_DISPLAY}="1"
# i1Monitor
-ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2001", ENV{GCM_COLORIMETER}="1", ENV{GCM_TYPE_DISPLAY}="1"
+ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2001", ENV{GCM_COLORIMETER}="1", ENV{GCM_KIND}="i1-pro", ENV{GCM_TYPE_DISPLAY}="1"
# i1Pro
-ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2000", ENV{GCM_COLORIMETER}="1", ENV{GCM_TYPE_DISPLAY}="1", ENV{GCM_TYPE_PROJECTOR}="1", ENV{GCM_TYPE_PRINTER}="1"
+ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2000", ENV{GCM_COLORIMETER}="1", ENV{GCM_KIND}="i1-pro", ENV{GCM_TYPE_DISPLAY}="1", ENV{GCM_TYPE_PROJECTOR}="1", ENV{GCM_TYPE_PRINTER}="1"
# ColorMunki
-ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2007", ENV{GCM_COLORIMETER}="1", ENV{GCM_TYPE_DISPLAY}="1", ENV{GCM_TYPE_PROJECTOR}="1", ENV{GCM_TYPE_PRINTER}="1", ENV{GCM_TYPE_SPOT}="1"
+ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2007", ENV{GCM_COLORIMETER}="1", ENV{GCM_KIND}="color-munki", ENV{GCM_TYPE_DISPLAY}="1", ENV{GCM_TYPE_PROJECTOR}="1", ENV{GCM_TYPE_PRINTER}="1", ENV{GCM_TYPE_SPOT}="1"
# Colorimtre HCFR
-ATTRS{idVendor}=="04db", ATTRS{idProduct}=="005b", ENV{GCM_COLORIMETER}="1", ENV{GCM_TYPE_PROJECTOR}="1"
+ATTRS{idVendor}=="04db", ATTRS{idProduct}=="005b", ENV{GCM_COLORIMETER}="1", ENV{GCM_KIND}="unknown", ENV{GCM_TYPE_PROJECTOR}="1"
# Spyder 2
-ATTRS{idVendor}=="085c", ATTRS{idProduct}=="0200", ENV{GCM_COLORIMETER}="1", ENV{GCM_TYPE_DISPLAY}="1"
+ATTRS{idVendor}=="085c", ATTRS{idProduct}=="0200", ENV{GCM_COLORIMETER}="1", ENV{GCM_KIND}="spyder", ENV{GCM_TYPE_DISPLAY}="1"
# Spyder 3
-ATTRS{idVendor}=="085c", ATTRS{idProduct}=="0300", ENV{GCM_COLORIMETER}="1", ENV{GCM_TYPE_DISPLAY}="1"
+ATTRS{idVendor}=="085c", ATTRS{idProduct}=="0300", ENV{GCM_COLORIMETER}="1", ENV{GCM_KIND}="spyder", ENV{GCM_TYPE_DISPLAY}="1"
# Huey
-ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2005", ENV{GCM_COLORIMETER}="1", ENV{GCM_TYPE_DISPLAY}="1"
+ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2005", ENV{GCM_COLORIMETER}="1", ENV{GCM_KIND}="huey", ENV{GCM_TYPE_DISPLAY}="1"
# color calibration device
ENV{GCM_COLORIMETER}=="*?", ENV{ID_MODEL}=="", IMPORT{program}="usb_id --export %p"
diff --git a/src/gcm-colorimeter.c b/src/gcm-colorimeter.c
index 919227b..e86e34d 100644
--- a/src/gcm-colorimeter.c
+++ b/src/gcm-colorimeter.c
@@ -276,6 +276,59 @@ gcm_colorimeter_class_init (GcmColorimeterClass *klass)
g_type_class_add_private (klass, sizeof (GcmColorimeterPrivate));
}
+/**
+ * gcm_colorimeter_kind_to_string:
+ **/
+const gchar *
+gcm_colorimeter_kind_to_string (GcmColorimeterKind colorimeter_kind)
+{
+ if (colorimeter_kind == GCM_COLORIMETER_KIND_HUEY)
+ return "huey";
+ if (colorimeter_kind == GCM_COLORIMETER_KIND_COLOR_MUNKI)
+ return "color-munki";
+ if (colorimeter_kind == GCM_COLORIMETER_KIND_SPYDER)
+ return "spyder";
+ if (colorimeter_kind == GCM_COLORIMETER_KIND_DTP20)
+ return "dtp20";
+ if (colorimeter_kind == GCM_COLORIMETER_KIND_DTP22)
+ return "dtp22";
+ if (colorimeter_kind == GCM_COLORIMETER_KIND_DTP41)
+ return "dtp41";
+ if (colorimeter_kind == GCM_COLORIMETER_KIND_DTP51)
+ return "dtp51";
+ if (colorimeter_kind == GCM_COLORIMETER_KIND_SPECTRO_SCAN)
+ return "spectro-scan";
+ if (colorimeter_kind == GCM_COLORIMETER_KIND_I1_PRO)
+ return "i1-pro";
+ return "unknown";
+}
+
+/**
+ * gcm_colorimeter_kind_from_string:
+ **/
+GcmColorimeterKind
+gcm_colorimeter_kind_from_string (const gchar *colorimeter_kind)
+{
+ if (g_strcmp0 (colorimeter_kind, "huey") == 0)
+ return GCM_COLORIMETER_KIND_HUEY;
+ if (g_strcmp0 (colorimeter_kind, "color-munki") == 0)
+ return GCM_COLORIMETER_KIND_COLOR_MUNKI;
+ if (g_strcmp0 (colorimeter_kind, "spyder") == 0)
+ return GCM_COLORIMETER_KIND_SPYDER;
+ if (g_strcmp0 (colorimeter_kind, "dtp20") == 0)
+ return GCM_COLORIMETER_KIND_DTP20;
+ if (g_strcmp0 (colorimeter_kind, "dtp22") == 0)
+ return GCM_COLORIMETER_KIND_DTP22;
+ if (g_strcmp0 (colorimeter_kind, "dtp41") == 0)
+ return GCM_COLORIMETER_KIND_DTP41;
+ if (g_strcmp0 (colorimeter_kind, "dtp51") == 0)
+ return GCM_COLORIMETER_KIND_DTP51;
+ if (g_strcmp0 (colorimeter_kind, "spectro-scan") == 0)
+ return GCM_COLORIMETER_KIND_SPECTRO_SCAN;
+ if (g_strcmp0 (colorimeter_kind, "i1-pro") == 0)
+ return GCM_COLORIMETER_KIND_I1_PRO;
+ return GCM_COLORIMETER_KIND_UNKNOWN;
+}
/**
* gcm_colorimeter_device_add:
@@ -285,6 +338,7 @@ gcm_colorimeter_device_add (GcmColorimeter *colorimeter, GUdevDevice *device)
{
gboolean ret;
GtkWidget *dialog;
+ const gchar *kind_str;
GcmColorimeterPrivate *priv = colorimeter->priv;
/* interesting device? */
@@ -318,13 +372,9 @@ gcm_colorimeter_device_add (GcmColorimeter *colorimeter, GUdevDevice *device)
priv->supports_printer = g_udev_device_get_property_as_boolean (device, "GCM_TYPE_PRINTER");
/* try to get type */
- if (priv->model != NULL && g_ascii_strcasecmp (priv->model, "Huey") == 0) {
- priv->colorimeter_kind = GCM_COLORIMETER_KIND_HUEY;
- } else if (priv->model != NULL && g_ascii_strcasecmp (priv->model, "ColorMunki") == 0) {
- priv->colorimeter_kind = GCM_COLORIMETER_KIND_COLOR_MUNKI;
- } else if (priv->model != NULL && g_ascii_strcasecmp (priv->model, "Monitor Spyder") == 0) {
- priv->colorimeter_kind = GCM_COLORIMETER_KIND_SPYDER;
- } else if (priv->model != NULL) {
+ kind_str = g_udev_device_get_property (device, "GCM_KIND");
+ priv->colorimeter_kind = gcm_colorimeter_kind_from_string (kind_str);
+ if (priv->colorimeter_kind == GCM_COLORIMETER_KIND_UNKNOWN) {
egg_warning ("Failed to recognize color device: %s", priv->model);
/* show dialog, in order to help the project */
@@ -346,28 +396,6 @@ gcm_colorimeter_device_add (GcmColorimeter *colorimeter, GUdevDevice *device)
priv->shown_warning = TRUE;
}
priv->colorimeter_kind = GCM_COLORIMETER_KIND_UNKNOWN;
- } else {
- egg_warning ("Failed to recognize color device");
-
- /* show dialog, in order to help the project */
- if (!priv->shown_warning) {
- dialog = gtk_message_dialog_new (NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_INFO,
- GTK_BUTTONS_OK,
- /* TRANSLATORS: this is when the device is not recognized */
- _("Measuring instrument not registered"));
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- "The attached measuring devicer device has not been registered in usb.ids. "
- "It should work okay, but if you want to help the project, "
- "please visit %s and supply the required information.",
- "http://live.gnome.org/GnomeColorManager/Help");
- gtk_window_set_icon_name (GTK_WINDOW (dialog), GCM_STOCK_ICON);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- priv->shown_warning = TRUE;
- }
- priv->colorimeter_kind = GCM_COLORIMETER_KIND_UNKNOWN;
}
/* signal the addition */
diff --git a/src/gcm-colorimeter.h b/src/gcm-colorimeter.h
index 2480901..412e40d 100644
--- a/src/gcm-colorimeter.h
+++ b/src/gcm-colorimeter.h
@@ -72,13 +72,15 @@ GType gcm_colorimeter_get_type (void);
GcmColorimeter *gcm_colorimeter_new (void);
/* accessors */
-const gchar *gcm_colorimeter_get_model (GcmColorimeter *colorimeter);
-const gchar *gcm_colorimeter_get_vendor (GcmColorimeter *colorimeter);
-gboolean gcm_colorimeter_get_present (GcmColorimeter *colorimeter);
-GcmColorimeterKind gcm_colorimeter_get_kind (GcmColorimeter *colorimeter);
-gboolean gcm_colorimeter_supports_display (GcmColorimeter *colorimeter);
-gboolean gcm_colorimeter_supports_projector (GcmColorimeter *colorimeter);
-gboolean gcm_colorimeter_supports_printer (GcmColorimeter *colorimeter);
+const gchar *gcm_colorimeter_get_model (GcmColorimeter *colorimeter);
+const gchar *gcm_colorimeter_get_vendor (GcmColorimeter *colorimeter);
+gboolean gcm_colorimeter_get_present (GcmColorimeter *colorimeter);
+GcmColorimeterKind gcm_colorimeter_get_kind (GcmColorimeter *colorimeter);
+gboolean gcm_colorimeter_supports_display (GcmColorimeter *colorimeter);
+gboolean gcm_colorimeter_supports_projector (GcmColorimeter *colorimeter);
+gboolean gcm_colorimeter_supports_printer (GcmColorimeter *colorimeter);
+const gchar *gcm_colorimeter_kind_to_string (GcmColorimeterKind colorimeter_kind);
+GcmColorimeterKind gcm_colorimeter_kind_from_string (const gchar *colorimeter_kind);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]