diff options
Diffstat (limited to 'meta/packages/gtk+/gtk+-2.6.10/filesystem-volumes.patch')
-rw-r--r-- | meta/packages/gtk+/gtk+-2.6.10/filesystem-volumes.patch | 182 |
1 files changed, 182 insertions, 0 deletions
diff --git a/meta/packages/gtk+/gtk+-2.6.10/filesystem-volumes.patch b/meta/packages/gtk+/gtk+-2.6.10/filesystem-volumes.patch new file mode 100644 index 0000000000..4386d83ee9 --- /dev/null +++ b/meta/packages/gtk+/gtk+-2.6.10/filesystem-volumes.patch | |||
@@ -0,0 +1,182 @@ | |||
1 | --- gtk+-2.6.8/gtk/gtkfilesystemunix.c.orig 2007-02-08 12:01:19.000000000 +0000 | ||
2 | +++ gtk+-2.6.8/gtk/gtkfilesystemunix.c 2007-02-08 12:01:19.000000000 +0000 | ||
3 | @@ -33,6 +33,7 @@ | ||
4 | #include <errno.h> | ||
5 | #include <string.h> | ||
6 | #include <sys/stat.h> | ||
7 | +#include <sys/statvfs.h> | ||
8 | #include <sys/types.h> | ||
9 | #include <pwd.h> | ||
10 | #ifdef HAVE_UNISTD_H | ||
11 | @@ -358,7 +359,49 @@ | ||
12 | static GSList * | ||
13 | gtk_file_system_unix_list_volumes (GtkFileSystem *file_system) | ||
14 | { | ||
15 | - return g_slist_append (NULL, get_root_volume ()); | ||
16 | + struct statvfs stv; | ||
17 | + struct stat st; | ||
18 | + GSList * l = g_slist_append (NULL, get_root_volume ()); | ||
19 | + | ||
20 | + if (!statvfs ("/.", &stv)) | ||
21 | + { | ||
22 | + fsblkcnt_t root_blocks = stv.f_blocks; | ||
23 | + fsfilcnt_t root_files = stv.f_files; | ||
24 | + | ||
25 | + GDir * dir; | ||
26 | + if ((dir = g_dir_open ("/media", 0, NULL)) != NULL) | ||
27 | + { | ||
28 | + const gchar * name; | ||
29 | + while ((name = g_dir_read_name (dir)) != NULL) | ||
30 | + { | ||
31 | + gchar * abs_name = g_strconcat ("/media/", name, NULL); | ||
32 | + | ||
33 | + if (!stat (abs_name, &st) && S_ISDIR (st.st_mode)) | ||
34 | + { | ||
35 | + gchar * dot = g_strconcat (abs_name, "/.", NULL); | ||
36 | + if (!statvfs (dot, &stv) && | ||
37 | + (stv.f_blocks != root_blocks || | ||
38 | + stv.f_files != root_files)) | ||
39 | + { | ||
40 | + GtkFilePath * path = | ||
41 | + gtk_file_system_filename_to_path (file_system, | ||
42 | + abs_name); | ||
43 | + | ||
44 | + if (path) | ||
45 | + l = g_slist_append (l, path); | ||
46 | + } | ||
47 | + | ||
48 | + g_free (dot); | ||
49 | + } | ||
50 | + | ||
51 | + g_free (abs_name); | ||
52 | + } | ||
53 | + | ||
54 | + g_dir_close (dir); | ||
55 | + } | ||
56 | + } | ||
57 | + | ||
58 | + return l; | ||
59 | } | ||
60 | |||
61 | static GtkFileSystemVolume * | ||
62 | @@ -375,10 +418,15 @@ | ||
63 | |||
64 | len = strlen (filename); | ||
65 | |||
66 | - if (len > 1 && filename[len - 1] == '/') | ||
67 | - return g_strndup (filename, len - 1); | ||
68 | - else | ||
69 | - return g_memdup (filename, len + 1); | ||
70 | + if (len > 1) | ||
71 | + { | ||
72 | + gchar *c = g_utf8_prev_char (filename + len); | ||
73 | + | ||
74 | + if (c && *c == '/') | ||
75 | + return g_strndup (filename, len - 1); | ||
76 | + } | ||
77 | + | ||
78 | + return g_memdup (filename, len + 1); | ||
79 | } | ||
80 | |||
81 | static GtkFileFolder * | ||
82 | @@ -590,7 +638,7 @@ | ||
83 | gtk_file_system_unix_volume_get_base_path (GtkFileSystem *file_system, | ||
84 | GtkFileSystemVolume *volume) | ||
85 | { | ||
86 | - return gtk_file_path_new_dup ("/"); | ||
87 | + return gtk_file_path_copy ((GtkFilePath*)volume); | ||
88 | } | ||
89 | |||
90 | static gboolean | ||
91 | @@ -616,7 +664,32 @@ | ||
92 | gtk_file_system_unix_volume_get_display_name (GtkFileSystem *file_system, | ||
93 | GtkFileSystemVolume *volume) | ||
94 | { | ||
95 | - return g_strdup (_("Filesystem")); /* Same as Nautilus */ | ||
96 | + gchar * slash; | ||
97 | + gchar * path; | ||
98 | + gchar * c; | ||
99 | + | ||
100 | + g_return_val_if_fail (file_system && volume, NULL); | ||
101 | + | ||
102 | + path = gtk_file_system_path_to_filename (file_system, (GtkFilePath*) volume); | ||
103 | + | ||
104 | + g_return_val_if_fail (path && *path, NULL); | ||
105 | + | ||
106 | + if (path[0] == '/' && !path[1]) | ||
107 | + return g_strdup (_("Filesystem")); /* Same as Nautilus */ | ||
108 | + | ||
109 | + /* Now the media volumes */ | ||
110 | + /* strip trailing / if any */ | ||
111 | + c = g_utf8_prev_char (path + strlen(path)); | ||
112 | + | ||
113 | + if (*c == '/') | ||
114 | + *c = 0; | ||
115 | + | ||
116 | + slash = g_utf8_strrchr (path, -1, '/'); | ||
117 | + | ||
118 | + if (!slash) | ||
119 | + return g_strdup (path); | ||
120 | + | ||
121 | + return g_strdup (slash + 1); | ||
122 | } | ||
123 | |||
124 | static IconType | ||
125 | @@ -787,11 +860,54 @@ | ||
126 | GError **error) | ||
127 | { | ||
128 | GdkPixbuf *pixbuf; | ||
129 | + gchar * slash; | ||
130 | + gchar * path; | ||
131 | + gchar * c; | ||
132 | + const gchar * id = NULL; | ||
133 | + | ||
134 | + g_return_val_if_fail (file_system && volume, NULL); | ||
135 | + | ||
136 | + path = gtk_file_system_path_to_filename (file_system, (GtkFilePath*) volume); | ||
137 | |||
138 | - pixbuf = get_cached_icon (widget, "gnome-fs-blockdev", pixel_size); | ||
139 | - if (pixbuf) | ||
140 | - return pixbuf; | ||
141 | + g_return_val_if_fail (path && *path, NULL); | ||
142 | + | ||
143 | + if (path[0] == '/' && !path[1]) | ||
144 | + id = "gnome-fs-blockdev"; | ||
145 | + else | ||
146 | + { | ||
147 | + /* Now the media volumes */ | ||
148 | + /* strip trailing / if any */ | ||
149 | + c = g_utf8_prev_char (path + strlen(path)); | ||
150 | + | ||
151 | + if (*c == '/') | ||
152 | + *c = 0; | ||
153 | + | ||
154 | + slash = g_utf8_strrchr (path, -1, '/'); | ||
155 | |||
156 | + if (slash) | ||
157 | + { | ||
158 | + slash++; | ||
159 | + | ||
160 | + if (!strcmp (slash, "card")) | ||
161 | + id = "gnome-dev-media-sdmmc"; | ||
162 | + else if (!strcmp (slash, "cf")) | ||
163 | + id = "gnome-dev-media-cf"; | ||
164 | + else if (!strncmp (slash, "mmc", 3)) | ||
165 | + id = "gnome-dev-media-sdmmc"; | ||
166 | + else if (!strcmp (slash, "usbhdd")) | ||
167 | + id = "gnome-dev-removable-usb"; | ||
168 | + else | ||
169 | + id = "gnome-dev-removable"; | ||
170 | + } | ||
171 | + } | ||
172 | + | ||
173 | + if (id) | ||
174 | + { | ||
175 | + pixbuf = get_cached_icon (widget, id, pixel_size); | ||
176 | + if (pixbuf) | ||
177 | + return pixbuf; | ||
178 | + } | ||
179 | + | ||
180 | pixbuf = get_fallback_icon (widget, ICON_BLOCK_DEVICE, error); | ||
181 | g_assert (pixbuf != NULL); | ||
182 | |||