summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2016-04-29 17:14:57 +0200
committerOndrej Holy <oholy@redhat.com>2016-05-20 10:31:22 +0200
commit7b3f6da30718c443d64169813b4ae1b3a28ba934 (patch)
tree79b680272a5b3bc0d77d1b48053ee6843e59c24f
parent098f19bcedc2235f4ee0999b772f9713a1544beb (diff)
downloadglib-7b3f6da30718c443d64169813b4ae1b3a28ba934.tar.gz
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
-rw-r--r--docs/reference/gio/gio-sections.txt1
-rw-r--r--gio/gdrive.c25
-rw-r--r--gio/gdrive.h4
3 files changed, 30 insertions, 0 deletions
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
index d5620da5b..756b390c5 100644
--- a/docs/reference/gio/gio-sections.txt
+++ b/docs/reference/gio/gio-sections.txt
@@ -1225,6 +1225,7 @@ g_drive_poll_for_media
g_drive_poll_for_media_finish
g_drive_has_media
g_drive_is_media_check_automatic
+g_drive_is_removable
g_drive_is_media_removable
g_drive_eject
g_drive_eject_finish
diff --git a/gio/gdrive.c b/gio/gdrive.c
index 5d7928656..ab19ab832 100644
--- a/gio/gdrive.c
+++ b/gio/gdrive.c
@@ -267,6 +267,31 @@ g_drive_is_media_check_automatic (GDrive *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:
* @drive: a #GDrive.
*
diff --git a/gio/gdrive.h b/gio/gdrive.h
index 451e417f9..371f5047d 100644
--- a/gio/gdrive.h
+++ b/gio/gdrive.h
@@ -45,6 +45,7 @@ G_BEGIN_DECLS
* @get_icon: Returns a #GIcon for the given #GDrive.
* @has_volumes: Returns %TRUE if the #GDrive has mountable volumes.
* @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.
* @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.
@@ -90,6 +91,7 @@ struct _GDriveIface
GIcon * (* get_icon) (GDrive *drive);
gboolean (* has_volumes) (GDrive *drive);
GList * (* get_volumes) (GDrive *drive);
+ gboolean (* is_removable) (GDrive *drive);
gboolean (* is_media_removable) (GDrive *drive);
gboolean (* has_media) (GDrive *drive);
gboolean (* is_media_check_automatic) (GDrive *drive);
@@ -170,6 +172,8 @@ GLIB_AVAILABLE_IN_ALL
gboolean g_drive_has_volumes (GDrive *drive);
GLIB_AVAILABLE_IN_ALL
GList * g_drive_get_volumes (GDrive *drive);
+GLIB_AVAILABLE_IN_2_50
+gboolean g_drive_is_removable (GDrive *drive);
GLIB_AVAILABLE_IN_ALL
gboolean g_drive_is_media_removable (GDrive *drive);
GLIB_AVAILABLE_IN_ALL