[gvfs] Better handling of PC floppy drives



commit c6405c6653c27b247f1fbb59c01b95938fb6b2d8
Author: David Zeuthen <davidz redhat com>
Date:   Tue Jun 16 19:49:38 2009 -0400

    Better handling of PC floppy drives
    
    PC Floppy Drives are handled in a special way since we don't poll for
    media (it would make a lot of noise). Specifically we never probe for
    the filesystem type. So if encountering a PC Floppy Drive, just always
    show all volumes from it. Since we already have working support for
    g_drive_poll_for_media() in Nautilus, things Just Work(tm)
    
    http://people.freedesktop.org/~david/dkd-gnome-floppy-welcome-to-the-1980s.png
    
    E.g. you can use the "Rescan" menu option to force media detection.
    
    Welcome to the 1980s.

 monitor/gdu/ggdudrive.c         |    5 ++++-
 monitor/gdu/ggduvolume.c        |    5 ++++-
 monitor/gdu/ggduvolumemonitor.c |   28 +++++++++++++++++++++++++++-
 monitor/gdu/ggduvolumemonitor.h |    2 ++
 4 files changed, 37 insertions(+), 3 deletions(-)
---
diff --git a/monitor/gdu/ggdudrive.c b/monitor/gdu/ggdudrive.c
index 6195f97..d332e14 100644
--- a/monitor/gdu/ggdudrive.c
+++ b/monitor/gdu/ggdudrive.c
@@ -148,7 +148,10 @@ update_drive (GGduDrive *drive)
   drive->icon = gdu_presentable_get_icon (drive->presentable);
 
   g_free (drive->name);
-  drive->name = gdu_presentable_get_name (drive->presentable);
+  if (_is_pc_floppy_drive (device))
+    drive->name = g_strdup (_("Floppy Drive"));
+  else
+    drive->name = gdu_presentable_get_name (drive->presentable);
 
   /* the GduDevice for an activatable drive (such as RAID) is NULL if the drive is not activated */
   if (device == NULL)
diff --git a/monitor/gdu/ggduvolume.c b/monitor/gdu/ggduvolume.c
index 8f75247..73ad0fc 100644
--- a/monitor/gdu/ggduvolume.c
+++ b/monitor/gdu/ggduvolume.c
@@ -304,7 +304,10 @@ update_volume (GGduVolume *volume)
       volume->icon = gdu_presentable_get_icon (GDU_PRESENTABLE (volume->gdu_volume));
 
       g_free (volume->name);
-      volume->name = gdu_presentable_get_name (GDU_PRESENTABLE (volume->gdu_volume));
+      if (_is_pc_floppy_drive (device))
+        volume->name = g_strdup (_("Floppy Disk"));
+      else
+        volume->name = gdu_presentable_get_name (GDU_PRESENTABLE (volume->gdu_volume));
 
       /* special case the name and icon for audio discs */
       activation_uri = volume->activation_root != NULL ? g_file_get_uri (volume->activation_root) : NULL;
diff --git a/monitor/gdu/ggduvolumemonitor.c b/monitor/gdu/ggduvolumemonitor.c
index 5c80f64..6da7393 100644
--- a/monitor/gdu/ggduvolumemonitor.c
+++ b/monitor/gdu/ggduvolumemonitor.c
@@ -744,6 +744,32 @@ should_mount_be_ignored (GduPool *pool, GduDevice *d)
   return ret;
 }
 
+gboolean
+_is_pc_floppy_drive (GduDevice *device)
+{
+  gboolean ret;
+  gchar **drive_media_compat;
+  const gchar *drive_connection_interface;
+
+  ret = FALSE;
+
+  if (device != NULL)
+    {
+      drive_media_compat = gdu_device_drive_get_media_compatibility (device);
+      drive_connection_interface = gdu_device_drive_get_connection_interface (device);
+
+      if (g_strcmp0 (drive_connection_interface, "platform") == 0 &&
+          (drive_media_compat != NULL &&
+           g_strv_length (drive_media_compat) > 0 &&
+           g_strcmp0 (drive_media_compat[0], "floppy") == 0))
+        {
+          ret = TRUE;
+        }
+    }
+
+  return ret;
+}
+
 static gboolean
 should_volume_be_ignored (GduPool *pool, GduVolume *volume, GList *fstab_mount_points)
 {
@@ -763,7 +789,7 @@ should_volume_be_ignored (GduPool *pool, GduVolume *volume, GList *fstab_mount_p
   usage = gdu_device_id_get_usage (device);
   type = gdu_device_id_get_type (device);
 
-  if (g_strcmp0 (usage, "filesystem") == 0)
+  if (_is_pc_floppy_drive (device) || g_strcmp0 (usage, "filesystem") == 0)
     {
       GUnixMountPoint *mount_point;
 
diff --git a/monitor/gdu/ggduvolumemonitor.h b/monitor/gdu/ggduvolumemonitor.h
index ec559c4..b91ceb9 100644
--- a/monitor/gdu/ggduvolumemonitor.h
+++ b/monitor/gdu/ggduvolumemonitor.h
@@ -55,6 +55,8 @@ GType g_gdu_volume_monitor_get_type (void) G_GNUC_CONST;
 
 GVolumeMonitor *g_gdu_volume_monitor_new                          (void);
 
+gboolean _is_pc_floppy_drive (GduDevice *device);
+
 G_END_DECLS
 
 #endif /* __G_GDU_VOLUME_MONITOR_H__ */



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