Package: gnome-vfs / 1:2.24.4-6

23_improve_volume_labels.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
Index: gnome-vfs-2.24.2/libgnomevfs/gnome-vfs-hal-mounts.c
===================================================================
--- gnome-vfs-2.24.2.orig/libgnomevfs/gnome-vfs-hal-mounts.c	2010-02-06 11:55:50.133278538 +0100
+++ gnome-vfs-2.24.2/libgnomevfs/gnome-vfs-hal-mounts.c	2010-02-06 11:55:50.437281509 +0100
@@ -328,6 +328,7 @@
 	LibHalDriveType drive_type;
 	char *name;
 	char *vm_name;
+	char *size_str = NULL;
 	gboolean may_prepend_external;
 
 
@@ -341,7 +342,7 @@
 	    !libhal_drive_uses_removable_media (hal_drive) && 
 	    hal_volume != NULL) {
 		const char *label;
-		const char *size_str;
+		const char *mountpoint;
 
 		/* use label if available */
 		label = libhal_volume_get_label (hal_volume);
@@ -350,9 +351,23 @@
 			goto out;
 		}
 
-		/* Otherwise, just use volume size */
-
 		size_str = gnome_vfs_format_file_size_for_display (libhal_volume_get_size (hal_volume));
+
+		/* use mount point if available */
+		mountpoint = libhal_volume_get_mount_point (hal_volume);
+		if (mountpoint != NULL && strlen (mountpoint) > 0) {
+			/* chop off /media prefix */
+			if (!strncmp (mountpoint, "/media/", 7) && strlen (mountpoint) > 7)
+				mountpoint += 7;
+			if (size_str != NULL) {
+				name = g_strdup_printf ("%s (%s)", mountpoint, size_str);
+			} else {
+				name = g_strdup (mountpoint);
+			}
+			goto out;
+		}
+
+		/* Otherwise, just use volume size */
 		if (size_str != NULL) {
 			name = g_strdup_printf (_("%s Volume"), size_str);
 		}
@@ -463,6 +478,7 @@
 	}
 
 out:
+	g_free (size_str);
 	/* lame fallback */
 	if (name == NULL)
 		name = g_strdup (_("Drive"));
@@ -485,7 +501,8 @@
 	LibHalDriveType drive_type;
 	const char *volume_label;
 	char *name;
-	char *size_str;
+	char *size_str = NULL;
+	const char *mountpoint;
 
 	name = NULL;
 
@@ -573,20 +590,36 @@
 		goto out;
 	}
 
-	/* Fallback: size of media */
-
 	size_str = gnome_vfs_format_file_size_for_display (libhal_volume_get_size (hal_volume));
+
+	/* mount point, when it's not removable */
+	if (!libhal_drive_uses_removable_media (hal_drive)) {
+		mountpoint = libhal_volume_get_mount_point (hal_volume);
+		if (mountpoint != NULL && strlen (mountpoint) > 0) {
+			/* chop off /media prefix */
+			if (!strncmp (mountpoint, "/media/", 7) && strlen (mountpoint) > 7)
+				mountpoint += 7;
+			if (size_str != NULL) {
+				name = g_strdup_printf ("%s (%s)", mountpoint, size_str);
+			} else {
+				name = g_strdup (mountpoint);
+			}
+		    goto out;
+		}
+	}
+
+	/* Fallback: size of media */
 	if (size_str != NULL) {
 		if (libhal_drive_uses_removable_media (hal_drive)) {
 			name = g_strdup_printf (_("%s Removable Volume"), size_str);
 		} else {
 			name = g_strdup_printf (_("%s Volume"), size_str);
 		}
-		g_free (size_str);
 	}
 
 
 out:
+	g_free (size_str);
 	/* lame fallback */
 	if (name == NULL)
 		name = g_strdup (_("Volume"));