[gnome-color-manager] Add two new settings objects 'enable-sane' and 'enable-cups' for in-field debugging



commit 4fb48c9fc03838030c34379d3604d3d6fcca0521
Author: Richard Hughes <richard hughsie com>
Date:   Sat May 29 12:55:03 2010 +0100

    Add two new settings objects 'enable-sane' and 'enable-cups' for in-field debugging

 data/org.gnome.color-manager.gschema.xml |   10 ++++++++++
 src/gcm-client.c                         |   22 ++++++++++++++++++++--
 src/gcm-utils.h                          |    2 ++
 3 files changed, 32 insertions(+), 2 deletions(-)
---
diff --git a/data/org.gnome.color-manager.gschema.xml b/data/org.gnome.color-manager.gschema.xml
index 7e40bdd..9211b3a 100644
--- a/data/org.gnome.color-manager.gschema.xml
+++ b/data/org.gnome.color-manager.gschema.xml
@@ -70,5 +70,15 @@
       <summary>If the data migration has been done</summary>
       <description>This is incremented to the latest config version if the config file has been migrated.</description>
     </key>
+    <key name="enable-sane" type="b">
+      <default>true</default>
+      <summary>If SANE support is enabled</summary>
+      <description>This allows the user to disable scanner support if attached devices fail when probed.</description>
+    </key>
+    <key name="enable-cups" type="b">
+      <default>true</default>
+      <summary>If CUPS support is enabled</summary>
+      <description>This allows the user to disable printer support if attached devices fail when probed.</description>
+    </key>
   </schema>
 </schemalist>
diff --git a/src/gcm-client.c b/src/gcm-client.c
index 7865dd0..92f8be6 100644
--- a/src/gcm-client.c
+++ b/src/gcm-client.c
@@ -422,6 +422,7 @@ gcm_client_uevent_cb (GUdevClient *gudev_client, const gchar *action, GUdevDevic
 	const gchar *value;
 	GcmDevice *device_tmp;
 	guint i;
+	gboolean enable;
 	GcmClientPrivate *priv = client->priv;
 #endif
 
@@ -435,6 +436,11 @@ gcm_client_uevent_cb (GUdevClient *gudev_client, const gchar *action, GUdevDevic
 		value = g_udev_device_get_property (udev_device, "GCM_RESCAN");
 		if (g_strcmp0 (value, "scanner") == 0) {
 
+			/* are we ignoring scanners */
+			enable = g_settings_get_boolean (client->priv->settings, GCM_SETTINGS_ENABLE_SANE);
+			if (!enable)
+				return;
+
 			/* set all scanners as disconnected */
 			for (i=0; i<priv->array->len; i++) {
 				device_tmp = g_ptr_array_index (priv->array, i);
@@ -463,6 +469,12 @@ gcm_client_uevent_cb (GUdevClient *gudev_client, const gchar *action, GUdevDevic
 		/* we need to rescan scanner devices */
 		value = g_udev_device_get_property (udev_device, "GCM_RESCAN");
 		if (g_strcmp0 (value, "scanner") == 0) {
+
+			/* are we ignoring scanners */
+			enable = g_settings_get_boolean (client->priv->settings, GCM_SETTINGS_ENABLE_SANE);
+			if (!enable)
+				return;
+
 			if (priv->refresh_id != 0)
 				g_source_remove (priv->refresh_id);
 			priv->refresh_id = g_timeout_add (GCM_CLIENT_SANE_REMOVED_TIMEOUT,
@@ -1065,6 +1077,8 @@ gcm_client_add_saved (GcmClient *client, GError **error)
 		}
 	}
 out:
+	/* inform the UI */
+	gcm_client_done_loading (client);
 	g_strfreev (groups);
 	g_free (filename);
 	g_key_file_free (keyfile);
@@ -1079,6 +1093,7 @@ gcm_client_coldplug (GcmClient *client, GcmClientColdplug coldplug, GError **err
 {
 	gboolean ret = TRUE;
 	GThread *thread;
+	gboolean enable;
 
 	g_return_val_if_fail (GCM_IS_CLIENT (client), FALSE);
 
@@ -1090,6 +1105,7 @@ gcm_client_coldplug (GcmClient *client, GcmClientColdplug coldplug, GError **err
 
 	/* saved devices */
 	if (!coldplug || coldplug & GCM_CLIENT_COLDPLUG_SAVED) {
+		gcm_client_add_loading (client);
 		ret = gcm_client_add_saved (client, error);
 		if (!ret)
 			goto out;
@@ -1120,7 +1136,8 @@ gcm_client_coldplug (GcmClient *client, GcmClientColdplug coldplug, GError **err
 	}
 
 	/* CUPS */
-	if (!coldplug || coldplug & GCM_CLIENT_COLDPLUG_CUPS) {
+	enable = g_settings_get_boolean (client->priv->settings, GCM_SETTINGS_ENABLE_CUPS);
+	if (enable && (!coldplug || coldplug & GCM_CLIENT_COLDPLUG_CUPS)) {
 		gcm_client_add_loading (client);
 		egg_debug ("adding devices of type CUPS");
 		if (client->priv->use_threads) {
@@ -1136,7 +1153,8 @@ gcm_client_coldplug (GcmClient *client, GcmClientColdplug coldplug, GError **err
 
 #ifdef GCM_USE_SANE
 	/* SANE */
-	if (!coldplug || coldplug & GCM_CLIENT_COLDPLUG_SANE) {
+	enable = g_settings_get_boolean (client->priv->settings, GCM_SETTINGS_ENABLE_SANE);
+	if (enable && (!coldplug || coldplug & GCM_CLIENT_COLDPLUG_SANE)) {
 		gcm_client_add_loading (client);
 		egg_debug ("adding devices of type SANE");
 		if (client->priv->use_threads) {
diff --git a/src/gcm-utils.h b/src/gcm-utils.h
index d5e1ac6..08268c6 100644
--- a/src/gcm-utils.h
+++ b/src/gcm-utils.h
@@ -49,6 +49,8 @@
 #define GCM_SETTINGS_MIGRATE_CONFIG_VERSION		"migrate-config-version"
 #define GCM_SETTINGS_RECALIBRATE_PRINTER_THRESHOLD	"recalibrate-printer-threshold"
 #define GCM_SETTINGS_RECALIBRATE_DISPLAY_THRESHOLD	"recalibrate-display-threshold"
+#define GCM_SETTINGS_ENABLE_SANE			"enable-sane"
+#define GCM_SETTINGS_ENABLE_CUPS			"enable-cups"
 
 #define GCM_CONFIG_VERSION_ORIGINAL			0
 #define GCM_CONFIG_VERSION_SHARED_SPEC			1



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