[gvfs/wip/udisks2] udisks2: support fstab comments to set name and icon
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs/wip/udisks2] udisks2: support fstab comments to set name and icon
- Date: Fri, 30 Sep 2011 04:00:48 +0000 (UTC)
commit 9c2a9b4da43edf22d24fb7b9f349cba9a83bdc5c
Author: David Zeuthen <davidz redhat com>
Date: Thu Sep 29 23:58:20 2011 -0400
udisks2: support fstab comments to set name and icon
For example, for this /etc/fstab entry
nfs-server:/path/to/dir /media/somewhere nfs4 defaults,users,comment=gvfs.name=Foo\040Bar,comment=gvfs.icon_name=gnome-help 0 0
the name "Foo Bar" and the icon gnome-help is used.
This depends on the glib2 patch from this bug
https://bugzilla.gnome.org/show_bug.cgi?id=660536
Signed-off-by: David Zeuthen <davidz redhat com>
monitor/udisks2/gvfsudisks2volume.c | 43 +++++++++++++++++++++++++++++++++-
1 files changed, 41 insertions(+), 2 deletions(-)
---
diff --git a/monitor/udisks2/gvfsudisks2volume.c b/monitor/udisks2/gvfsudisks2volume.c
index 23394f0..8e9b456 100644
--- a/monitor/udisks2/gvfsudisks2volume.c
+++ b/monitor/udisks2/gvfsudisks2volume.c
@@ -143,6 +143,32 @@ emit_changed (GVfsUDisks2Volume *volume)
g_signal_emit_by_name (volume->monitor, "volume-changed", volume);
}
+static gchar *
+lookup_mount_option_value (GUnixMountPoint *mount_point,
+ const gchar *key)
+{
+ const gchar *options;
+ gchar *ret = NULL;
+
+ options = g_unix_mount_point_get_options (mount_point);
+ if (options != NULL)
+ {
+ const gchar *start;
+ guint n;
+
+ start = strstr (options, key);
+ if (start != NULL)
+ {
+ start += strlen (key);
+ for (n = 0; start[n] != ',' && start[n] != '\0'; n++)
+ ;
+ if (n > 01)
+ ret = g_strndup (start, n);
+ }
+ }
+ return ret;
+}
+
static gboolean
update_volume (GVfsUDisks2Volume *volume)
{
@@ -245,8 +271,21 @@ update_volume (GVfsUDisks2Volume *volume)
}
else
{
- volume->name = g_unix_mount_point_guess_name (volume->mount_point);
- volume->icon = gvfs_udisks2_utils_icon_from_fs_type (g_unix_mount_point_get_fs_type (volume->mount_point));
+ gchar *icon_name;
+
+ volume->name = lookup_mount_option_value (volume->mount_point, "comment=gvfs.name=");
+ if (volume->name == NULL)
+ volume->name = g_unix_mount_point_guess_name (volume->mount_point);
+
+ icon_name = lookup_mount_option_value (volume->mount_point, "comment=gvfs.icon_name=");
+ if (icon_name != NULL)
+ {
+ volume->icon = g_themed_icon_new_with_default_fallbacks (icon_name);
+ g_free (icon_name);
+ }
+
+ if (volume->icon == NULL)
+ volume->icon = gvfs_udisks2_utils_icon_from_fs_type (g_unix_mount_point_get_fs_type (volume->mount_point));
}
/* ---------------------------------------------------------------------------------------------------- */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]