mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
gio: Add g_drive_is_removable() support
Nautilus wants to show entries in the sidebar only for removable devices. It uses currently sort of conditions to determine which devices should be shown. Those condition fails in some cases unfortunatelly. Lets provide g_drive_is_removable() which uses udisks Removable property to determine which devices should be shown. It should return true for all drives with removable media, or flash media, or drives on usb and firewire buses. https://bugzilla.gnome.org/show_bug.cgi?id=765900
This commit is contained in:
parent
098f19bced
commit
7b3f6da307
@ -1225,6 +1225,7 @@ g_drive_poll_for_media
|
|||||||
g_drive_poll_for_media_finish
|
g_drive_poll_for_media_finish
|
||||||
g_drive_has_media
|
g_drive_has_media
|
||||||
g_drive_is_media_check_automatic
|
g_drive_is_media_check_automatic
|
||||||
|
g_drive_is_removable
|
||||||
g_drive_is_media_removable
|
g_drive_is_media_removable
|
||||||
g_drive_eject
|
g_drive_eject
|
||||||
g_drive_eject_finish
|
g_drive_eject_finish
|
||||||
|
25
gio/gdrive.c
25
gio/gdrive.c
@ -266,6 +266,31 @@ g_drive_is_media_check_automatic (GDrive *drive)
|
|||||||
return (* iface->is_media_check_automatic) (drive);
|
return (* iface->is_media_check_automatic) (drive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_drive_is_removable:
|
||||||
|
* @drive: a #GDrive.
|
||||||
|
*
|
||||||
|
* Checks if the #GDrive and/or its media is considered removable by the user.
|
||||||
|
* See g_drive_is_media_removable().
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if @drive and/or its media is considered removable, %FALSE otherwise.
|
||||||
|
*
|
||||||
|
* Since: 2.50
|
||||||
|
**/
|
||||||
|
gboolean
|
||||||
|
g_drive_is_removable (GDrive *drive)
|
||||||
|
{
|
||||||
|
GDriveIface *iface;
|
||||||
|
|
||||||
|
g_return_val_if_fail (G_IS_DRIVE (drive), FALSE);
|
||||||
|
|
||||||
|
iface = G_DRIVE_GET_IFACE (drive);
|
||||||
|
if (iface->is_removable != NULL)
|
||||||
|
return iface->is_removable (drive);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* g_drive_is_media_removable:
|
* g_drive_is_media_removable:
|
||||||
* @drive: a #GDrive.
|
* @drive: a #GDrive.
|
||||||
|
@ -45,6 +45,7 @@ G_BEGIN_DECLS
|
|||||||
* @get_icon: Returns a #GIcon for the given #GDrive.
|
* @get_icon: Returns a #GIcon for the given #GDrive.
|
||||||
* @has_volumes: Returns %TRUE if the #GDrive has mountable volumes.
|
* @has_volumes: Returns %TRUE if the #GDrive has mountable volumes.
|
||||||
* @get_volumes: Returns a list #GList of #GVolume for the #GDrive.
|
* @get_volumes: Returns a list #GList of #GVolume for the #GDrive.
|
||||||
|
* @is_removable: Returns %TRUE if the #GDrive and/or its media is considered removable by the user. Since 2.50.
|
||||||
* @is_media_removable: Returns %TRUE if the #GDrive supports removal and insertion of media.
|
* @is_media_removable: Returns %TRUE if the #GDrive supports removal and insertion of media.
|
||||||
* @has_media: Returns %TRUE if the #GDrive has media inserted.
|
* @has_media: Returns %TRUE if the #GDrive has media inserted.
|
||||||
* @is_media_check_automatic: Returns %TRUE if the #GDrive is capabable of automatically detecting media changes.
|
* @is_media_check_automatic: Returns %TRUE if the #GDrive is capabable of automatically detecting media changes.
|
||||||
@ -90,6 +91,7 @@ struct _GDriveIface
|
|||||||
GIcon * (* get_icon) (GDrive *drive);
|
GIcon * (* get_icon) (GDrive *drive);
|
||||||
gboolean (* has_volumes) (GDrive *drive);
|
gboolean (* has_volumes) (GDrive *drive);
|
||||||
GList * (* get_volumes) (GDrive *drive);
|
GList * (* get_volumes) (GDrive *drive);
|
||||||
|
gboolean (* is_removable) (GDrive *drive);
|
||||||
gboolean (* is_media_removable) (GDrive *drive);
|
gboolean (* is_media_removable) (GDrive *drive);
|
||||||
gboolean (* has_media) (GDrive *drive);
|
gboolean (* has_media) (GDrive *drive);
|
||||||
gboolean (* is_media_check_automatic) (GDrive *drive);
|
gboolean (* is_media_check_automatic) (GDrive *drive);
|
||||||
@ -170,6 +172,8 @@ GLIB_AVAILABLE_IN_ALL
|
|||||||
gboolean g_drive_has_volumes (GDrive *drive);
|
gboolean g_drive_has_volumes (GDrive *drive);
|
||||||
GLIB_AVAILABLE_IN_ALL
|
GLIB_AVAILABLE_IN_ALL
|
||||||
GList * g_drive_get_volumes (GDrive *drive);
|
GList * g_drive_get_volumes (GDrive *drive);
|
||||||
|
GLIB_AVAILABLE_IN_2_50
|
||||||
|
gboolean g_drive_is_removable (GDrive *drive);
|
||||||
GLIB_AVAILABLE_IN_ALL
|
GLIB_AVAILABLE_IN_ALL
|
||||||
gboolean g_drive_is_media_removable (GDrive *drive);
|
gboolean g_drive_is_media_removable (GDrive *drive);
|
||||||
GLIB_AVAILABLE_IN_ALL
|
GLIB_AVAILABLE_IN_ALL
|
||||||
|
Loading…
Reference in New Issue
Block a user