summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2015-10-14 21:42:16 +0200
committerCarlos Soriano <csoriano@gnome.org>2015-10-15 19:16:56 +0200
commit0cd4e7ec43a07ae8dc77231bef25ee792ddda529 (patch)
tree696463b51bbb24a147f5bc98676027c8288ac5ef
parent11ee4b40af850c3c271b6c5fce64cdd0a9066594 (diff)
downloadgtk+-0cd4e7ec43a07ae8dc77231bef25ee792ddda529.tar.gz
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
-rw-r--r--gtk/gtkplacessidebar.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index d8a21908ad..42179c3333 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;