summaryrefslogtreecommitdiff
path: root/monitor/proxy
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2016-04-29 16:59:41 +0200
committerOndrej Holy <oholy@redhat.com>2016-05-20 10:39:34 +0200
commitb7986553f898976bade0f4dc2f042c30ec550255 (patch)
treedee3da7d27d23d740dd36faa3d00c2b737cc265d /monitor/proxy
parent265c237408ec7a9ca0c02396b1e9d1bab265fb42 (diff)
downloadgvfs-b7986553f898976bade0f4dc2f042c30ec550255.tar.gz
monitor: 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. Add support for this property also in gvfs-mount tool. Bump GLib version accordingly. https://bugzilla.gnome.org/show_bug.cgi?id=765457
Diffstat (limited to 'monitor/proxy')
-rw-r--r--monitor/proxy/gproxydrive.c25
-rw-r--r--monitor/proxy/gvfsproxyvolumemonitordaemon.c4
2 files changed, 28 insertions, 1 deletions
diff --git a/monitor/proxy/gproxydrive.c b/monitor/proxy/gproxydrive.c
index a8ac61d3..8cb5e6a4 100644
--- a/monitor/proxy/gproxydrive.c
+++ b/monitor/proxy/gproxydrive.c
@@ -53,6 +53,7 @@ struct _GProxyDrive {
gboolean can_poll_for_media;
gboolean is_media_check_automatic;
gboolean has_media;
+ gboolean is_removable;
gboolean is_media_removable;
gboolean can_start;
gboolean can_start_degraded;
@@ -141,6 +142,7 @@ g_proxy_drive_new (GProxyVolumeMonitor *volume_monitor)
* dict:string->string identifiers
* string sort_key
* a{sv} expansion
+ * boolean is-removable
*/
#define DRIVE_STRUCT_TYPE "(&s&s&s&sbbbbbbbbuasa{ss}&sa{sv})"
@@ -168,6 +170,8 @@ g_proxy_drive_update (GProxyDrive *drive,
GVariantIter *iter_volume_ids;
GVariantIter *iter_identifiers;
GVariantIter *iter_expansion;
+ GVariant *value;
+ const gchar *key;
sort_key = NULL;
@@ -238,7 +242,12 @@ g_proxy_drive_update (GProxyDrive *drive,
drive->volume_ids = g_strdupv ((char **) volume_ids->pdata);
drive->sort_key = g_strdup (sort_key);
- /* TODO: decode expansion, once used */
+ drive->is_removable = FALSE;
+ while (g_variant_iter_loop (iter_expansion, "{sv}", &key, &value))
+ {
+ if (g_str_equal (key, "is-removable"))
+ drive->is_removable = g_variant_get_boolean (value);
+ }
out:
g_variant_iter_free (iter_volume_ids);
@@ -335,6 +344,19 @@ g_proxy_drive_has_volumes (GDrive *drive)
}
static gboolean
+g_proxy_drive_is_removable (GDrive *drive)
+{
+ GProxyDrive *proxy_drive = G_PROXY_DRIVE (drive);
+ gboolean res;
+
+ G_LOCK (proxy_drive);
+ res = proxy_drive->is_removable;
+ G_UNLOCK (proxy_drive);
+
+ return res;
+}
+
+static gboolean
g_proxy_drive_is_media_removable (GDrive *drive)
{
GProxyDrive *proxy_drive = G_PROXY_DRIVE (drive);
@@ -1152,6 +1174,7 @@ g_proxy_drive_drive_iface_init (GDriveIface *iface)
iface->get_symbolic_icon = g_proxy_drive_get_symbolic_icon;
iface->has_volumes = g_proxy_drive_has_volumes;
iface->get_volumes = g_proxy_drive_get_volumes;
+ iface->is_removable = g_proxy_drive_is_removable;
iface->is_media_removable = g_proxy_drive_is_media_removable;
iface->has_media = g_proxy_drive_has_media;
iface->is_media_check_automatic = g_proxy_drive_is_media_check_automatic;
diff --git a/monitor/proxy/gvfsproxyvolumemonitordaemon.c b/monitor/proxy/gvfsproxyvolumemonitordaemon.c
index 768d307a..9a2e8da6 100644
--- a/monitor/proxy/gvfsproxyvolumemonitordaemon.c
+++ b/monitor/proxy/gvfsproxyvolumemonitordaemon.c
@@ -531,6 +531,7 @@ static void monitor_try_create (void);
* dict:string->string identifiers
* string sort_key
* a{sv} expansion
+ * boolean is-removable
*/
#define DRIVE_STRUCT_TYPE "(ssssbbbbbbbbuasa{ss}sa{sv})"
@@ -546,6 +547,7 @@ drive_to_dbus (GDrive *drive)
gboolean can_eject;
gboolean can_poll_for_media;
gboolean has_media;
+ gboolean is_removable;
gboolean is_media_removable;
gboolean is_media_check_automatic;
gboolean can_start;
@@ -577,6 +579,7 @@ drive_to_dbus (GDrive *drive)
can_eject = g_drive_can_eject (drive);
can_poll_for_media = g_drive_can_poll_for_media (drive);
has_media = g_drive_has_media (drive);
+ is_removable = g_drive_is_removable (drive);
is_media_removable = g_drive_is_media_removable (drive);
is_media_check_automatic = g_drive_is_media_check_automatic (drive);
can_start = g_drive_can_start (drive);
@@ -616,6 +619,7 @@ drive_to_dbus (GDrive *drive)
}
expansion_builder = g_variant_builder_new (G_VARIANT_TYPE_VARDICT);
+ g_variant_builder_add (expansion_builder, "{sv}", "is-removable", g_variant_new_boolean (is_removable));
/* left for future expansion without ABI breaks */
for (n = 0; identifiers != NULL && identifiers[n] != NULL; n++)