[gnome-color-manager] Only scan ICC locations with hfs partition types for OSX and msdos/NTFS types for Windows
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] Only scan ICC locations with hfs partition types for OSX and msdos/NTFS types for Windows
- Date: Tue, 19 Jan 2010 10:50:47 +0000 (UTC)
commit e6122f0cc35af82e48d9ff672f0e98001856efdb
Author: Richard Hughes <richard hughsie com>
Date: Tue Jan 19 10:50:15 2010 +0000
Only scan ICC locations with hfs partition types for OSX and msdos/NTFS types for Windows
src/gcm-profile-store.c | 123 +++++++++++++++++++++++++++++++++-------------
1 files changed, 88 insertions(+), 35 deletions(-)
---
diff --git a/src/gcm-profile-store.c b/src/gcm-profile-store.c
index bfff9af..01beeea 100644
--- a/src/gcm-profile-store.c
+++ b/src/gcm-profile-store.c
@@ -54,6 +54,7 @@ struct _GcmProfileStorePrivate
GPtrArray *profile_array;
GPtrArray *monitor_array;
GPtrArray *directory_array;
+ GVolumeMonitor *volume_monitor;
};
enum {
@@ -304,50 +305,85 @@ out:
}
/**
- * gcm_profile_store_add_profiles_from_mounted_volumes:
+ * gcm_profile_store_add_profiles_from_mounted_volume:
**/
static void
-gcm_profile_store_add_profiles_from_mounted_volumes (GcmProfileStore *profile_store)
+gcm_profile_store_add_profiles_from_mounted_volume (GcmProfileStore *profile_store, GMount *mount)
{
- GVolumeMonitor *volume_monitor;
- GMount *mount;
GFile *root;
- GList *mounts, *l;
gchar *path;
gchar *path_root;
+ const gchar *type;
+ GFileInfo *info;
+ GError *error = NULL;
+
+ /* 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) {
+ egg_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);
+ egg_warning ("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);
+ gcm_profile_store_add_profiles_for_path (profile_store, path);
+ 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);
+ gcm_profile_store_add_profiles_for_path (profile_store, path);
+ g_free (path);
+
+ /* Windows 2000 */
+ path = g_build_filename (path_root, "Winnt", "system32", "spool", "drivers", "color", NULL);
+ gcm_profile_store_add_profiles_for_path (profile_store, path);
+ g_free (path);
+
+ /* Windows 98 and ME */
+ path = g_build_filename (path_root, "Windows", "System", "Color", NULL);
+ gcm_profile_store_add_profiles_for_path (profile_store, path);
+ g_free (path);
+
+ /* no more matching */
+ goto out;
+ }
+out:
+ g_free (path_root);
+ g_object_unref (root);
+}
- volume_monitor = g_volume_monitor_get ();
- mounts = g_volume_monitor_get_mounts (volume_monitor);
+/**
+ * gcm_profile_store_add_profiles_from_mounted_volumes:
+ **/
+static void
+gcm_profile_store_add_profiles_from_mounted_volumes (GcmProfileStore *profile_store)
+{
+ 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;
- root = g_mount_get_root (mount);
- path_root = g_file_get_path (root);
-
- /* FIXME: only scan hsfplus volumes for osx, and fat32 and ntfs for windows */
- if (path_root != NULL) {
-
- /* OSX */
- path = g_build_filename (path_root, "Library", "ColorSync", "Profiles", "Displays", NULL);
- gcm_profile_store_add_profiles_for_path (profile_store, path);
- g_free (path);
-
- /* Windows XP */
- path = g_build_filename (path_root, "Windows", "system32", "spool", "drivers", "color", NULL);
- gcm_profile_store_add_profiles_for_path (profile_store, path);
- g_free (path);
-
- /* Windows 2000 */
- path = g_build_filename (path_root, "Winnt", "system32", "spool", "drivers", "color", NULL);
- gcm_profile_store_add_profiles_for_path (profile_store, path);
- g_free (path);
-
- /* Windows 98 and ME */
- path = g_build_filename (path_root, "Windows", "System", "Color", NULL);
- gcm_profile_store_add_profiles_for_path (profile_store, path);
- g_free (path);
- }
- g_free (path_root);
- g_object_unref (root);
+ gcm_profile_store_add_profiles_from_mounted_volume (profile_store, mount);
g_object_unref (mount);
}
g_list_free (mounts);
@@ -381,6 +417,15 @@ gcm_profile_store_add_profiles (GcmProfileStore *profile_store)
}
/**
+ * 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
@@ -431,6 +476,13 @@ gcm_profile_store_init (GcmProfileStore *profile_store)
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);
+
/* get profiles */
gcm_profile_store_add_profiles (profile_store);
}
@@ -447,6 +499,7 @@ 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]