[glib] gio: Add g_drive_is_removable() support



commit 7b3f6da30718c443d64169813b4ae1b3a28ba934
Author: Ondrej Holy <oholy redhat com>
Date:   Fri Apr 29 17:14:57 2016 +0200

    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

 docs/reference/gio/gio-sections.txt |    1 +
 gio/gdrive.c                        |   25 +++++++++++++++++++++++++
 gio/gdrive.h                        |    4 ++++
 3 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
index d5620da..756b390 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 5d79286..ab19ab8 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 451e417..371f504 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


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