[gnome-color-manager/gnome-2-30] Do not connect to sane in gcm-apply, we only need XRandR devices. Fixes rh#585723
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager/gnome-2-30] Do not connect to sane in gcm-apply, we only need XRandR devices. Fixes rh#585723
- Date: Tue, 4 May 2010 08:09:46 +0000 (UTC)
commit abe59349ac324764d45c9c934edc6c4a4c649e24
Author: Richard Hughes <richard hughsie com>
Date: Thu Apr 29 15:56:52 2010 +0100
Do not connect to sane in gcm-apply, we only need XRandR devices. Fixes rh#585723
src/gcm-apply.c | 2 +-
src/gcm-client.c | 99 ++++++++++++++++++++++++++++++++++++-----------------
src/gcm-client.h | 10 +++++
src/gcm-dbus.c | 2 +-
src/gcm-prefs.c | 2 +-
5 files changed, 80 insertions(+), 35 deletions(-)
---
diff --git a/src/gcm-apply.c b/src/gcm-apply.c
index 5935421..dbf757d 100644
--- a/src/gcm-apply.c
+++ b/src/gcm-apply.c
@@ -63,7 +63,7 @@ main (int argc, char **argv)
/* get devices */
client = gcm_client_new ();
- ret = gcm_client_add_connected (client, &error);
+ ret = gcm_client_add_connected (client, GCM_CLIENT_COLDPLUG_XRANDR, &error);
if (!ret) {
egg_warning ("failed to get devices: %s", error->message);
g_error_free (error);
diff --git a/src/gcm-client.c b/src/gcm-client.c
index de515b5..867710c 100644
--- a/src/gcm-client.c
+++ b/src/gcm-client.c
@@ -132,6 +132,22 @@ gcm_client_done_loading (GcmClient *client)
}
/**
+ * gcm_client_add_loading:
+ **/
+static void
+gcm_client_add_loading (GcmClient *client)
+{
+ static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
+
+ /* decrement refcount, with a lock */
+ g_static_mutex_lock (&mutex);
+ client->priv->loading_refcount++;
+ if (client->priv->loading_refcount > 0)
+ gcm_client_set_loading (client, TRUE);
+ g_static_mutex_unlock (&mutex);
+}
+
+/**
* gcm_client_get_devices:
*
* @client: a valid %GcmClient instance
@@ -646,6 +662,10 @@ gcm_client_add_connected_devices_xrandr (GcmClient *client, GError **error)
return FALSE;
for (i=0; outputs[i] != NULL; i++)
gcm_client_xrandr_add (client, outputs[i]);
+
+ /* inform the UI */
+ gcm_client_done_loading (client);
+
return TRUE;
}
@@ -966,53 +986,68 @@ out:
* gcm_client_add_connected:
**/
gboolean
-gcm_client_add_connected (GcmClient *client, GError **error)
+gcm_client_add_connected (GcmClient *client, GcmClientColdplug coldplug, GError **error)
{
gboolean ret;
GThread *thread;
g_return_val_if_fail (GCM_IS_CLIENT (client), FALSE);
- /* XRandR */
- ret = gcm_client_add_connected_devices_xrandr (client, error);
- if (!ret)
- goto out;
-
- /* inform UI if we are loading devices still */
- client->priv->loading_refcount = 3;
- gcm_client_set_loading (client, TRUE);
+ /* reset */
+ client->priv->loading_refcount = 0;
- /* UDEV */
- if (client->priv->use_threads) {
- thread = g_thread_create ((GThreadFunc) gcm_client_add_connected_devices_udev_thrd, client, FALSE, error);
- if (thread == NULL)
- goto out;
- } else {
- ret = gcm_client_add_connected_devices_udev (client, error);
+ /* XRandR */
+ if (!coldplug || coldplug & GCM_CLIENT_COLDPLUG_XRANDR) {
+ gcm_client_add_loading (client);
+ egg_debug ("adding devices of type XRandR");
+ ret = gcm_client_add_connected_devices_xrandr (client, error);
if (!ret)
goto out;
}
+ /* UDEV */
+ if (!coldplug || coldplug & GCM_CLIENT_COLDPLUG_UDEV) {
+ gcm_client_add_loading (client);
+ egg_debug ("adding devices of type UDEV");
+ if (client->priv->use_threads) {
+ thread = g_thread_create ((GThreadFunc) gcm_client_add_connected_devices_udev_thrd, client, FALSE, error);
+ if (thread == NULL)
+ goto out;
+ } else {
+ ret = gcm_client_add_connected_devices_udev (client, error);
+ if (!ret)
+ goto out;
+ }
+ }
+
/* CUPS */
- if (client->priv->use_threads) {
- thread = g_thread_create ((GThreadFunc) gcm_client_add_connected_devices_cups_thrd, client, FALSE, error);
- if (thread == NULL)
- goto out;
- } else {
- ret = gcm_client_add_connected_devices_cups (client, error);
- if (!ret)
- goto out;
+ if (!coldplug || coldplug & GCM_CLIENT_COLDPLUG_CUPS) {
+ gcm_client_add_loading (client);
+ egg_debug ("adding devices of type CUPS");
+ if (client->priv->use_threads) {
+ thread = g_thread_create ((GThreadFunc) gcm_client_add_connected_devices_cups_thrd, client, FALSE, error);
+ if (thread == NULL)
+ goto out;
+ } else {
+ ret = gcm_client_add_connected_devices_cups (client, error);
+ if (!ret)
+ goto out;
+ }
}
/* SANE */
- if (client->priv->use_threads) {
- thread = g_thread_create ((GThreadFunc) gcm_client_add_connected_devices_sane_thrd, client, FALSE, error);
- if (thread == NULL)
- goto out;
- } else {
- ret = gcm_client_add_connected_devices_sane (client, error);
- if (!ret)
- goto out;
+ if (!coldplug || coldplug & GCM_CLIENT_COLDPLUG_SANE) {
+ gcm_client_add_loading (client);
+ egg_debug ("adding devices of type SANE");
+ if (client->priv->use_threads) {
+ thread = g_thread_create ((GThreadFunc) gcm_client_add_connected_devices_sane_thrd, client, FALSE, error);
+ if (thread == NULL)
+ goto out;
+ } else {
+ ret = gcm_client_add_connected_devices_sane (client, error);
+ if (!ret)
+ goto out;
+ }
}
out:
return ret;
diff --git a/src/gcm-client.h b/src/gcm-client.h
index a9e7186..083cb5d 100644
--- a/src/gcm-client.h
+++ b/src/gcm-client.h
@@ -60,6 +60,15 @@ struct _GcmClientClass
void (*_gcm_reserved5) (void);
};
+typedef enum {
+ GCM_CLIENT_COLDPLUG_ALL = 0x00,
+ GCM_CLIENT_COLDPLUG_XRANDR = 0x01,
+ GCM_CLIENT_COLDPLUG_CUPS = 0x02,
+ GCM_CLIENT_COLDPLUG_SANE = 0x04,
+ GCM_CLIENT_COLDPLUG_UDEV = 0x08,
+ GCM_CLIENT_COLDPLUG_LAST,
+} GcmClientColdplug;
+
GType gcm_client_get_type (void);
GcmClient *gcm_client_new (void);
@@ -74,6 +83,7 @@ gboolean gcm_client_delete_device (GcmClient *client,
GcmDevice *device,
GError **error);
gboolean gcm_client_add_connected (GcmClient *client,
+ GcmClientColdplug coldplug,
GError **error);
gboolean gcm_client_add_saved (GcmClient *client,
GError **error);
diff --git a/src/gcm-dbus.c b/src/gcm-dbus.c
index 85d961c..7ba4223 100644
--- a/src/gcm-dbus.c
+++ b/src/gcm-dbus.c
@@ -565,7 +565,7 @@ gcm_dbus_init (GcmDbus *dbus)
dbus->priv->colorspace_cmyk = gconf_client_get_string (dbus->priv->gconf_client, GCM_SETTINGS_COLORSPACE_CMYK, NULL);
/* get all devices */
- ret = gcm_client_add_connected (dbus->priv->client, &error);
+ ret = gcm_client_add_connected (dbus->priv->client, GCM_CLIENT_COLDPLUG_ALL, &error);
if (!ret) {
egg_warning ("failed to coldplug: %s", error->message);
g_error_free (error);
diff --git a/src/gcm-prefs.c b/src/gcm-prefs.c
index 4330195..83e164e 100644
--- a/src/gcm-prefs.c
+++ b/src/gcm-prefs.c
@@ -2423,7 +2423,7 @@ gcm_prefs_startup_phase1_idle_cb (gpointer user_data)
G_CALLBACK (gcm_prefs_renderer_combo_changed_cb), (gpointer) "softproof");
/* coldplug plugged in devices */
- ret = gcm_client_add_connected (gcm_client, &error);
+ ret = gcm_client_add_connected (gcm_client, GCM_CLIENT_COLDPLUG_ALL, &error);
if (!ret) {
egg_warning ("failed to add connected devices: %s", error->message);
g_error_free (error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]