summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2011-05-04 11:56:48 +0100
committerRichard Hughes <richard@hughsie.com>2011-05-04 11:56:48 +0100
commitc3c6e2b64e5655e11b983c704aaab79722e5207b (patch)
tree309e7669f4fbc6e01c060dfdc307f4e3075aa2d1 /src
parentd3826dcb77dece2af0f648243bda3af8e04883cf (diff)
downloadcolord-c3c6e2b64e5655e11b983c704aaab79722e5207b.tar.gz
Only enable the volume mount tracking when cd_profile_store_search() is called with CD_PROFILE_STORE_SEARCH_VOLUMES
Diffstat (limited to 'src')
-rw-r--r--src/cd-profile-store.c59
1 files changed, 44 insertions, 15 deletions
diff --git a/src/cd-profile-store.c b/src/cd-profile-store.c
index 9c22b06..397138e 100644
--- a/src/cd-profile-store.c
+++ b/src/cd-profile-store.c
@@ -41,6 +41,7 @@ struct _CdProfileStorePrivate
GPtrArray *monitor_array;
GPtrArray *directory_array;
GVolumeMonitor *volume_monitor;
+ guint mount_added_id;
};
enum {
@@ -472,6 +473,45 @@ cd_profile_store_add_profiles_from_mounted_volumes (CdProfileStore *profile_stor
}
/**
+ * cd_profile_store_volume_monitor_mount_added_cb:
+ **/
+static void
+cd_profile_store_volume_monitor_mount_added_cb (GVolumeMonitor *volume_monitor,
+ GMount *mount,
+ CdProfileStore *profile_store)
+{
+ cd_profile_store_add_profiles_from_mounted_volume (profile_store, mount);
+}
+
+/**
+ * cd_profile_mount_tracking_enable:
+ **/
+static void
+cd_profile_mount_tracking_enable (CdProfileStore *profile_store)
+{
+ if (profile_store->priv->mount_added_id != 0)
+ return;
+ profile_store->priv->mount_added_id =
+ g_signal_connect (profile_store->priv->volume_monitor,
+ "mount-added",
+ G_CALLBACK(cd_profile_store_volume_monitor_mount_added_cb),
+ profile_store);
+}
+
+/**
+ * cd_profile_mount_tracking_disable:
+ **/
+static void
+cd_profile_mount_tracking_disable (CdProfileStore *profile_store)
+{
+ if (profile_store->priv->mount_added_id == 0)
+ return;
+ g_signal_handler_disconnect (profile_store->priv->volume_monitor,
+ profile_store->priv->mount_added_id);
+ profile_store->priv->mount_added_id = 0;
+}
+
+/**
* cd_profile_store_search:
**/
gboolean
@@ -502,6 +542,9 @@ cd_profile_store_search (CdProfileStore *profile_store,
ret = cd_profile_store_add_profiles_from_mounted_volumes (profile_store);
if (ret)
success = TRUE;
+ cd_profile_mount_tracking_enable (profile_store);
+ } else {
+ cd_profile_mount_tracking_disable (profile_store);
}
/* get machine specific profiles */
@@ -516,17 +559,6 @@ cd_profile_store_search (CdProfileStore *profile_store,
}
/**
- * cd_profile_store_volume_monitor_mount_added_cb:
- **/
-static void
-cd_profile_store_volume_monitor_mount_added_cb (GVolumeMonitor *volume_monitor,
- GMount *mount,
- CdProfileStore *profile_store)
-{
- cd_profile_store_add_profiles_from_mounted_volume (profile_store, mount);
-}
-
-/**
* cd_profile_store_class_init:
**/
static void
@@ -563,10 +595,6 @@ cd_profile_store_init (CdProfileStore *profile_store)
/* 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(cd_profile_store_volume_monitor_mount_added_cb),
- profile_store);
}
/**
@@ -578,6 +606,7 @@ cd_profile_store_finalize (GObject *object)
CdProfileStore *profile_store = CD_PROFILE_STORE (object);
CdProfileStorePrivate *priv = profile_store->priv;
+ cd_profile_mount_tracking_disable (profile_store);
g_ptr_array_unref (priv->profile_array);
g_ptr_array_unref (priv->monitor_array);
g_ptr_array_unref (priv->directory_array);