[gnome-color-manager/colord: 6/6] Only search for per-user ICC profiles, colord does the system ones now



commit 183af0002378eaead148f882a8ec1b586e1b7819
Author: Richard Hughes <richard hughsie com>
Date:   Sat Jan 15 15:17:00 2011 +0000

    Only search for per-user ICC profiles, colord does the system ones now

 data/org.gnome.color-manager.gschema.xml |    5 -
 libcolor-glib/gcm-profile-store.c        |  194 +++--------------------------
 libcolor-glib/gcm-profile-store.h        |   11 +--
 src/cc-color-panel.c                     |    8 +-
 src/gcm-import.c                         |    2 +-
 src/gcm-picker.c                         |    2 +-
 src/gcm-session.c                        |    9 +--
 src/gcm-utils.h                          |    1 -
 src/gcm-viewer.c                         |    9 +--
 9 files changed, 26 insertions(+), 215 deletions(-)
---
diff --git a/data/org.gnome.color-manager.gschema.xml b/data/org.gnome.color-manager.gschema.xml
index 34bcee7..097c967 100644
--- a/data/org.gnome.color-manager.gschema.xml
+++ b/data/org.gnome.color-manager.gschema.xml
@@ -35,11 +35,6 @@
       <summary>Whether the display should be globally corrected or left to applications</summary>
       <description>If set to TRUE then the video LUT is set with the display profile</description>
     </key>
-    <key name="use-profiles-from-volumes" type="b">
-      <default>true</default>
-      <summary>Whether ICC profiles should be loaded from external disks</summary>
-      <description>If set to TRUE then external disks are searched for device ICC profiles at startup, for instance looking in the OSX library folder or Windows XP system folders. This may increase startup time if disks need to be spun up to be searched.</description>
-    </key>
     <key name="set-icc-profile-atom" type="b">
       <default>true</default>
       <summary>Set the _ICC_PROFILE hint for applications</summary>
diff --git a/libcolor-glib/gcm-profile-store.c b/libcolor-glib/gcm-profile-store.c
index dbdc76f..8e24a19 100644
--- a/libcolor-glib/gcm-profile-store.c
+++ b/libcolor-glib/gcm-profile-store.c
@@ -48,7 +48,6 @@ struct _GcmProfileStorePrivate
 	GPtrArray			*profile_array;
 	GPtrArray			*monitor_array;
 	GPtrArray			*directory_array;
-	GVolumeMonitor			*volume_monitor;
 };
 
 enum {
@@ -385,107 +384,6 @@ out:
 }
 
 /**
- * gcm_profile_store_add_profiles_from_mounted_volume:
- **/
-static gboolean
-gcm_profile_store_add_profiles_from_mounted_volume (GcmProfileStore *profile_store, GMount *mount)
-{
-	GFile *root;
-	gchar *path;
-	gchar *path_root;
-	const gchar *type;
-	GFileInfo *info;
-	GError *error = NULL;
-	gboolean ret;
-	gboolean success = FALSE;
-
-	/* get the mount root */
-	root = g_mount_get_root (mount);
-	path_root = g_file_get_path (root);
-	if (path_root == NULL)
-		goto out;
-
-	/* get the filesystem type */
-	info = g_file_query_filesystem_info (root, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE, NULL, &error);
-	if (info == NULL) {
-		g_warning ("failed to get filesystem type: %s", error->message);
-		g_error_free (error);
-		goto out;
-	}
-	type = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE);
-	g_debug ("filesystem mounted on %s has type %s", path_root, type);
-
-	/* only scan hfs volumes for OSX */
-	if (g_strcmp0 (type, "hfs") == 0) {
-		path = g_build_filename (path_root, "Library", "ColorSync", "Profiles", "Displays", NULL);
-		ret = gcm_profile_store_search_path (profile_store, path);
-		if (ret)
-			success = TRUE;
-		g_free (path);
-
-		/* no more matching */
-		goto out;
-	}
-
-	/* and fat32 and ntfs for windows */
-	if (g_strcmp0 (type, "ntfs") == 0 || g_strcmp0 (type, "msdos") == 0) {
-
-		/* Windows XP */
-		path = g_build_filename (path_root, "Windows", "system32", "spool", "drivers", "color", NULL);
-		ret = gcm_profile_store_search_path (profile_store, path);
-		if (ret)
-			success = TRUE;
-		g_free (path);
-
-		/* Windows 2000 */
-		path = g_build_filename (path_root, "Winnt", "system32", "spool", "drivers", "color", NULL);
-		ret = gcm_profile_store_search_path (profile_store, path);
-		if (ret)
-			success = TRUE;
-		g_free (path);
-
-		/* Windows 98 and ME */
-		path = g_build_filename (path_root, "Windows", "System", "Color", NULL);
-		ret = gcm_profile_store_search_path (profile_store, path);
-		if (ret)
-			success = TRUE;
-		g_free (path);
-
-		/* no more matching */
-		goto out;
-	}
-out:
-	g_free (path_root);
-	g_object_unref (root);
-	return success;
-}
-
-/**
- * gcm_profile_store_add_profiles_from_mounted_volumes:
- **/
-static gboolean
-gcm_profile_store_add_profiles_from_mounted_volumes (GcmProfileStore *profile_store)
-{
-	gboolean ret;
-	gboolean success = FALSE;
-	GList *mounts, *l;
-	GMount *mount;
-	GcmProfileStorePrivate *priv = profile_store->priv;
-
-	/* get all current mounts */
-	mounts = g_volume_monitor_get_mounts (priv->volume_monitor);
-	for (l = mounts; l != NULL; l = l->next) {
-		mount = l->data;
-		ret = gcm_profile_store_add_profiles_from_mounted_volume (profile_store, mount);
-		if (ret)
-			success = TRUE;
-		g_object_unref (mount);
-	}
-	g_list_free (mounts);
-	return success;
-}
-
-/**
  * gcm_profile_store_mkdir_with_parents:
  **/
 static gboolean
@@ -511,7 +409,6 @@ out:
 /**
  * gcm_profile_store_search:
  * @profile_store: a valid %GcmProfileStore instance
- * @flags: the #GcmProfileSearchFlags locations to search
  *
  * Searches specified locations for ICC profiles.
  *
@@ -520,86 +417,43 @@ out:
  * Since: 2.91.1
  **/
 gboolean
-gcm_profile_store_search (GcmProfileStore *profile_store, GcmProfileSearchFlags flags)
+gcm_profile_store_search (GcmProfileStore *profile_store)
 {
 	gchar *path;
 	gboolean ret;
 	gboolean success = FALSE;
 	GError *error;
 
-	/* get OSX and Linux system-wide profiles */
-	if (flags == GCM_PROFILE_STORE_SEARCH_ALL ||
-	    flags & GCM_PROFILE_STORE_SEARCH_SYSTEM) {
-		ret = gcm_profile_store_search_path (profile_store, "/usr/share/color/icc");
-		if (ret)
-			success = TRUE;
-		ret = gcm_profile_store_search_path (profile_store, "/usr/local/share/color/icc");
-		if (ret)
-			success = TRUE;
-		ret = gcm_profile_store_search_path (profile_store, "/Library/ColorSync/Profiles/Displays");
-		if (ret)
-			success = TRUE;
-	}
-
-	/* get OSX and Windows system-wide profiles when using Linux */
-	if (flags == GCM_PROFILE_STORE_SEARCH_ALL ||
-	    flags & GCM_PROFILE_STORE_SEARCH_VOLUMES) {
-		ret = gcm_profile_store_add_profiles_from_mounted_volumes (profile_store);
-		if (ret)
-			success = TRUE;
-	}
-
 	/* get Linux per-user profiles */
-	if (flags == GCM_PROFILE_STORE_SEARCH_ALL ||
-	    flags & GCM_PROFILE_STORE_SEARCH_USER) {
-		path = g_build_filename (g_get_user_data_dir (), "icc", NULL);
-		ret = gcm_profile_store_mkdir_with_parents (path, &error);
-		if (!ret) {
-			g_warning ("failed to create directory on startup: %s", error->message);
-			g_error_free (error);
-		} else {
-			ret = gcm_profile_store_search_path (profile_store, path);
-			if (ret)
-				success = TRUE;
-		}
-		g_free (path);
-
-		/* get per-user profiles from obsolete location */
-		path = g_build_filename (g_get_home_dir (), ".color", "icc", NULL);
-		ret = gcm_profile_store_search_path (profile_store, path);
-		if (ret)
-			success = TRUE;
-		g_free (path);
-
-		/* get OSX per-user profiles */
-		path = g_build_filename (g_get_home_dir (), "Library", "ColorSync", "Profiles", NULL);
+	path = g_build_filename (g_get_user_data_dir (), "icc", NULL);
+	ret = gcm_profile_store_mkdir_with_parents (path, &error);
+	if (!ret) {
+		g_warning ("failed to create directory on startup: %s", error->message);
+		g_error_free (error);
+	} else {
 		ret = gcm_profile_store_search_path (profile_store, path);
 		if (ret)
 			success = TRUE;
-		g_free (path);
 	}
+	g_free (path);
 
-	/* get machine specific profiles */
-	if (flags == GCM_PROFILE_STORE_SEARCH_ALL ||
-	    flags & GCM_PROFILE_STORE_SEARCH_MACHINE) {
-		ret = gcm_profile_store_search_path (profile_store, "/var/lib/color/icc");
-		if (ret)
-			success = TRUE;
-	}
+	/* get per-user profiles from obsolete location */
+	path = g_build_filename (g_get_home_dir (), ".color", "icc", NULL);
+	ret = gcm_profile_store_search_path (profile_store, path);
+	if (ret)
+		success = TRUE;
+	g_free (path);
 
+	/* get OSX per-user profiles */
+	path = g_build_filename (g_get_home_dir (), "Library", "ColorSync", "Profiles", NULL);
+	ret = gcm_profile_store_search_path (profile_store, path);
+	if (ret)
+		success = TRUE;
+	g_free (path);
 	return success;
 }
 
 /**
- * gcm_profile_store_volume_monitor_mount_added_cb:
- **/
-static void
-gcm_profile_store_volume_monitor_mount_added_cb (GVolumeMonitor *volume_monitor, GMount *mount, GcmProfileStore *profile_store)
-{
-	gcm_profile_store_add_profiles_from_mounted_volume (profile_store, mount);
-}
-
-/**
  * gcm_profile_store_class_init:
  **/
 static void
@@ -655,13 +509,6 @@ gcm_profile_store_init (GcmProfileStore *profile_store)
 	profile_store->priv->profile_array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
 	profile_store->priv->monitor_array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
 	profile_store->priv->directory_array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_free);
-
-	/* watch for volumes to be connected */
-	profile_store->priv->volume_monitor = g_volume_monitor_get ();
-	g_signal_connect (profile_store->priv->volume_monitor,
-			  "mount-added",
-			  G_CALLBACK(gcm_profile_store_volume_monitor_mount_added_cb),
-			  profile_store);
 }
 
 /**
@@ -676,7 +523,6 @@ gcm_profile_store_finalize (GObject *object)
 	g_ptr_array_unref (priv->profile_array);
 	g_ptr_array_unref (priv->monitor_array);
 	g_ptr_array_unref (priv->directory_array);
-	g_object_unref (priv->volume_monitor);
 
 	G_OBJECT_CLASS (gcm_profile_store_parent_class)->finalize (object);
 }
diff --git a/libcolor-glib/gcm-profile-store.h b/libcolor-glib/gcm-profile-store.h
index 618bce0..961d5a2 100644
--- a/libcolor-glib/gcm-profile-store.h
+++ b/libcolor-glib/gcm-profile-store.h
@@ -63,14 +63,6 @@ struct _GcmProfileStoreClass
 	void (*_gcm_reserved5) (void);
 };
 
-typedef enum {
-	GCM_PROFILE_STORE_SEARCH_ALL		= 0,
-	GCM_PROFILE_STORE_SEARCH_SYSTEM		= 1,
-	GCM_PROFILE_STORE_SEARCH_VOLUMES	= 2,
-	GCM_PROFILE_STORE_SEARCH_USER		= 4,
-	GCM_PROFILE_STORE_SEARCH_MACHINE	= 8
-} GcmProfileSearchFlags;
-
 GType		 gcm_profile_store_get_type		(void);
 GcmProfileStore	*gcm_profile_store_new			(void);
 
@@ -79,8 +71,7 @@ GcmProfile	*gcm_profile_store_get_by_filename	(GcmProfileStore	*profile_store,
 GcmProfile	*gcm_profile_store_get_by_checksum	(GcmProfileStore	*profile_store,
 							 const gchar		*checksum);
 GPtrArray	*gcm_profile_store_get_array		(GcmProfileStore	*profile_store);
-gboolean	 gcm_profile_store_search		(GcmProfileStore	*profile_store,
-							 GcmProfileSearchFlags	 flags);
+gboolean	 gcm_profile_store_search		(GcmProfileStore	*profile_store);
 gboolean	 gcm_profile_store_search_path		(GcmProfileStore	*profile_store,
 							 const gchar		*path);
 
diff --git a/src/cc-color-panel.c b/src/cc-color-panel.c
index 17e172c..bf4921c 100644
--- a/src/cc-color-panel.c
+++ b/src/cc-color-panel.c
@@ -2164,15 +2164,9 @@ cc_color_panel_startup_idle_cb (CcColorPanel *panel)
 	gchar *colorspace_gray;
 	gint intent_display = -1;
 	gint intent_softproof = -1;
-	GcmProfileSearchFlags search_flags = GCM_PROFILE_STORE_SEARCH_ALL;
-
-	/* volume checking is optional */
-	ret = g_settings_get_boolean (panel->priv->settings, GCM_SETTINGS_USE_PROFILES_FROM_VOLUMES);
-	if (!ret)
-		search_flags &= ~GCM_PROFILE_STORE_SEARCH_VOLUMES;
 
 	/* search the disk for profiles */
-	gcm_profile_store_search (panel->priv->profile_store, search_flags);
+	gcm_profile_store_search (panel->priv->profile_store);
 	g_signal_connect (panel->priv->profile_store, "changed", G_CALLBACK(cc_color_panel_profile_store_changed_cb), panel);
 
 	/* setup RGB combobox */
diff --git a/src/gcm-import.c b/src/gcm-import.c
index 5c3cfe9..8037f28 100644
--- a/src/gcm-import.c
+++ b/src/gcm-import.c
@@ -152,7 +152,7 @@ main (int argc, char **argv)
 
 	/* check file does't already exist as system-wide */
 	profile_store = gcm_profile_store_new ();
-	gcm_profile_store_search (profile_store, GCM_PROFILE_STORE_SEARCH_SYSTEM);
+	gcm_profile_store_search (profile_store);
 	profile_tmp = gcm_profile_store_get_by_checksum (profile_store, gcm_profile_get_checksum (profile));
 	if (profile_tmp != NULL) {
 		/* TRANSLATORS: color profile already been installed */
diff --git a/src/gcm-picker.c b/src/gcm-picker.c
index 7d4abcd..c539fac 100644
--- a/src/gcm-picker.c
+++ b/src/gcm-picker.c
@@ -622,7 +622,7 @@ gcm_picker_startup_cb (GApplication *application, gpointer user_data)
 
 	/* maintain a list of profiles */
 	profile_store = gcm_profile_store_new ();
-	gcm_profile_store_search (profile_store, GCM_PROFILE_STORE_SEARCH_ALL);
+	gcm_profile_store_search (profile_store);
 
 	/* default to AdobeRGB */
 	profile_filename = "/usr/share/color/icc/Argyll/ClayRGB1998.icm";
diff --git a/src/gcm-session.c b/src/gcm-session.c
index d3b32ea..6dda727 100644
--- a/src/gcm-session.c
+++ b/src/gcm-session.c
@@ -699,7 +699,6 @@ main (int argc, char *argv[])
 	guint poll_id = 0;
 	GFile *file = NULL;
 	gchar *introspection_data = NULL;
-	GcmProfileSearchFlags search_flags = GCM_PROFILE_STORE_SEARCH_ALL;
 
 	const GOptionEntry options[] = {
 		{ "no-timed-exit", '\0', 0, G_OPTION_ARG_NONE, &no_timed_exit,
@@ -744,13 +743,7 @@ main (int argc, char *argv[])
 
 	/* have access to all profiles */
 	profile_store = gcm_profile_store_new ();
-
-	/* volume checking is optional */
-	ret = g_settings_get_boolean (settings, GCM_SETTINGS_USE_PROFILES_FROM_VOLUMES);
-	if (!ret)
-		search_flags &= ~GCM_PROFILE_STORE_SEARCH_VOLUMES;
-
-	gcm_profile_store_search (profile_store, search_flags);
+	gcm_profile_store_search (profile_store);
 	timer = g_timer_new ();
 
 	/* get all connected devices */
diff --git a/src/gcm-utils.h b/src/gcm-utils.h
index f52391a..672f2d0 100644
--- a/src/gcm-utils.h
+++ b/src/gcm-utils.h
@@ -43,7 +43,6 @@
 #define GCM_SETTINGS_COLORSPACE_RGB			"colorspace-rgb"
 #define GCM_SETTINGS_COLORSPACE_CMYK			"colorspace-cmyk"
 #define GCM_SETTINGS_COLORSPACE_GRAY			"colorspace-gray"
-#define GCM_SETTINGS_USE_PROFILES_FROM_VOLUMES		"use-profiles-from-volumes"
 #define GCM_SETTINGS_CALIBRATION_LENGTH			"calibration-length"
 #define GCM_SETTINGS_SHOW_FINE_TUNING			"show-fine-tuning"
 #define GCM_SETTINGS_SHOW_NOTIFICATIONS			"show-notifications"
diff --git a/src/gcm-viewer.c b/src/gcm-viewer.c
index a1b97ce..487f334 100644
--- a/src/gcm-viewer.c
+++ b/src/gcm-viewer.c
@@ -894,19 +894,12 @@ gcm_viewer_profile_store_changed_cb (GcmProfileStore *profile_store, GcmViewerPr
 static gboolean
 gcm_viewer_startup_phase1_idle_cb (GcmViewerPrivate *viewer)
 {
-	gboolean ret;
 	GtkWidget *widget;
 	GtkTreeSelection *selection;
 	GtkTreePath *path;
-	GcmProfileSearchFlags search_flags = GCM_PROFILE_STORE_SEARCH_ALL;
-
-	/* volume checking is optional */
-	ret = g_settings_get_boolean (viewer->settings, GCM_SETTINGS_USE_PROFILES_FROM_VOLUMES);
-	if (!ret)
-		search_flags &= ~GCM_PROFILE_STORE_SEARCH_VOLUMES;
 
 	/* search the disk for profiles */
-	gcm_profile_store_search (viewer->profile_store, search_flags);
+	gcm_profile_store_search (viewer->profile_store);
 	g_signal_connect (viewer->profile_store, "changed",
 			  G_CALLBACK(gcm_viewer_profile_store_changed_cb), viewer);
 	g_signal_connect (viewer->profile_store, "added",



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