[gtk+] gtkplacessidebar: improve heuristics for external drives



commit 0cd4e7ec43a07ae8dc77231bef25ee792ddda529
Author: Carlos Soriano <csoriano gnome org>
Date:   Wed Oct 14 21:42:16 2015 +0200

    gtkplacessidebar: improve heuristics for external drives
    
    Since the change to use GtkPlacesView we don't want to show
    internal storage on the sidebar.
    
    In our case we were checking for drive_can_eject and
    drive_is_media_removable.
    
    However for some external hard drives it's reported that they
    are not ejectable nor the have removable media. So the only
    attribute that they have different from internal drives is that
    they can be stopped.
    So check for if the drive can be stopped to decide if it is
    external or internal.
    
    On the way realized we don't need to check for the mounts associated
    with the volume to know if the volume can be ejected or not. So remove
    that code.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=756589

 gtk/gtkplacessidebar.c |   27 ++++++++++-----------------
 1 files changed, 10 insertions(+), 17 deletions(-)
---
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index d8a2190..42179c3 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -823,36 +823,29 @@ out:
 }
 
 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);
-      is_removable |= g_drive_is_media_removable (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;
 }
 
 static void
@@ -991,7 +984,7 @@ update_places (GtkPlacesSidebar *sidebar)
                 }
               g_free (identifier);
 
-              if (sidebar->show_other_locations && !is_removable_volume (volume))
+              if (sidebar->show_other_locations && !is_external_volume (volume))
                 {
                   g_object_unref (volume);
                   continue;
@@ -1095,7 +1088,7 @@ update_places (GtkPlacesSidebar *sidebar)
         }
       g_free (identifier);
 
-      if (sidebar->show_other_locations && !is_removable_volume (volume))
+      if (sidebar->show_other_locations && !is_external_volume (volume))
         {
           g_object_unref (volume);
           continue;


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