[gtk+] gtkplacesview: improve heuristics for external drives



commit 1dbcce785e0a0705ece237fe4c1ba8b99203639d
Author: Carlos Soriano <csoriano gnome org>
Date:   Wed Oct 14 21:48:06 2015 +0200

    gtkplacesview: improve heuristics for external drives
    
    Following the sidebar on commit b0989b190df, improve the way
    we check when a drive is external or not.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=756589

 gtk/gtkplacesview.c |   22 +++++++++-------------
 1 files changed, 9 insertions(+), 13 deletions(-)
---
diff --git a/gtk/gtkplacesview.c b/gtk/gtkplacesview.c
index 1335b4d..957eeb8 100644
--- a/gtk/gtkplacesview.c
+++ b/gtk/gtkplacesview.c
@@ -457,33 +457,29 @@ gtk_places_view_set_property (GObject      *object,
 }
 
 static gboolean
-is_removable_volume (GVolume *volume)
+is_external_volume (GVolume *volume)
 {
-  gboolean is_removable;
+  gboolean is_external;
   GDrive *drive;
-  GMount *mount;
   gchar *id;
 
   drive = g_volume_get_drive (volume);
-  mount = g_volume_get_mount (volume);
   id = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_CLASS);
 
-  is_removable = g_volume_can_eject (volume);
+  is_external = g_volume_can_eject (volume);
 
   /* NULL volume identifier only happens on removable devices */
-  is_removable |= !id;
+  is_external |= !id;
 
   if (drive)
-    is_removable |= g_drive_can_eject (drive);
-
-  if (mount)
-    is_removable |= (g_mount_can_eject (mount) && !g_mount_can_unmount (mount));
+    is_external |= g_drive_can_eject (drive) ||
+                   g_drive_is_media_removable (drive) ||
+                   g_drive_can_stop (drive);
 
   g_clear_object (&drive);
-  g_clear_object (&mount);
   g_free (id);
 
-  return is_removable;
+  return is_external;
 }
 
 typedef struct
@@ -693,7 +689,7 @@ add_volume (GtkPlacesView *view,
   gchar *name;
   gchar *path;
 
-  if (is_removable_volume (volume))
+  if (is_external_volume (volume))
     return;
 
   identifier = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_CLASS);


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