David Zeuthen 3d17b0
From 3f3f21fe6e2bdac8fd6acf048da6fb228adde092 Mon Sep 17 00:00:00 2001
David Zeuthen 3d17b0
From: David Zeuthen <davidz@redhat.com>
David Zeuthen 3d17b0
Date: Fri, 01 May 2009 19:59:54 +0000
David Zeuthen 3d17b0
Subject: Use new gnome-disk-utility API to figure out when media was inserted
David Zeuthen 3d17b0
David Zeuthen 3d17b0
This fixes a problem with Nautilus automounting newly created volumes
David Zeuthen 3d17b0
appearing as a result of formatting/partitioning.
David Zeuthen 3d17b0
---
David Zeuthen 3d17b0
diff --git a/monitor/gdu/ggdudrive.c b/monitor/gdu/ggdudrive.c
David Zeuthen 3d17b0
index 29e108d..c2c8b76 100644
David Zeuthen 3d17b0
--- a/monitor/gdu/ggdudrive.c
David Zeuthen 3d17b0
+++ b/monitor/gdu/ggdudrive.c
David Zeuthen 3d17b0
@@ -51,7 +51,6 @@ struct _GGduDrive {
David Zeuthen 3d17b0
   gboolean can_eject;
David Zeuthen 3d17b0
   gboolean can_poll_for_media;
David Zeuthen 3d17b0
   gboolean is_media_check_automatic;
David Zeuthen 3d17b0
-  time_t time_of_last_media_insertion;
David Zeuthen 3d17b0
 };
David Zeuthen 3d17b0
 
David Zeuthen 3d17b0
 static void g_gdu_drive_drive_iface_init (GDriveIface *iface);
David Zeuthen 3d17b0
@@ -178,9 +177,6 @@ update_drive (GGduDrive *drive)
David Zeuthen 3d17b0
   if (device != NULL)
David Zeuthen 3d17b0
     g_object_unref (device);
David Zeuthen 3d17b0
 
David Zeuthen 3d17b0
-  if (drive->has_media != old_has_media)
David Zeuthen 3d17b0
-    drive->time_of_last_media_insertion = time (NULL);
David Zeuthen 3d17b0
-
David Zeuthen 3d17b0
   /* compute whether something changed */
David Zeuthen 3d17b0
   changed = !((old_is_media_removable == drive->is_media_removable) &&
David Zeuthen 3d17b0
               (old_has_media == drive->has_media) &&
David Zeuthen 3d17b0
@@ -233,8 +229,6 @@ g_gdu_drive_new (GVolumeMonitor       *volume_monitor,
David Zeuthen 3d17b0
 
David Zeuthen 3d17b0
   drive->presentable = g_object_ref (presentable);
David Zeuthen 3d17b0
 
David Zeuthen 3d17b0
-  drive->time_of_last_media_insertion = time (NULL);
David Zeuthen 3d17b0
-
David Zeuthen 3d17b0
   g_signal_connect (drive->presentable, "changed", G_CALLBACK (presentable_changed), drive);
David Zeuthen 3d17b0
   g_signal_connect (drive->presentable, "job-changed", G_CALLBACK (presentable_job_changed), drive);
David Zeuthen 3d17b0
 
David Zeuthen 3d17b0
@@ -685,7 +679,16 @@ g_gdu_drive_has_presentable (GGduDrive       *drive,
David Zeuthen 3d17b0
 time_t
David Zeuthen 3d17b0
 g_gdu_drive_get_time_of_last_media_insertion (GGduDrive *drive)
David Zeuthen 3d17b0
 {
David Zeuthen 3d17b0
-  return drive->time_of_last_media_insertion;
David Zeuthen 3d17b0
+  GduDevice *device;
David Zeuthen 3d17b0
+  time_t ret;
David Zeuthen 3d17b0
+
David Zeuthen 3d17b0
+  ret = 0;
David Zeuthen 3d17b0
+  device = gdu_presentable_get_device (drive->presentable);
David Zeuthen 3d17b0
+  if (device != NULL) {
David Zeuthen 3d17b0
+    ret = gdu_device_get_media_detection_time (device);
David Zeuthen 3d17b0
+    g_object_unref (device);
David Zeuthen 3d17b0
+  }
David Zeuthen 3d17b0
+  return ret;
David Zeuthen 3d17b0
 }
David Zeuthen 3d17b0
 
David Zeuthen 3d17b0
 GduPresentable *
David Zeuthen 3d17b0
--
David Zeuthen 3d17b0
cgit v0.8.2