diff options
Diffstat (limited to 'meta/packages/gtk+/gtk+-2.13.3/filesystem-volumes.patch')
| -rw-r--r-- | meta/packages/gtk+/gtk+-2.13.3/filesystem-volumes.patch | 198 |
1 files changed, 198 insertions, 0 deletions
diff --git a/meta/packages/gtk+/gtk+-2.13.3/filesystem-volumes.patch b/meta/packages/gtk+/gtk+-2.13.3/filesystem-volumes.patch new file mode 100644 index 0000000000..826fd6bee0 --- /dev/null +++ b/meta/packages/gtk+/gtk+-2.13.3/filesystem-volumes.patch | |||
| @@ -0,0 +1,198 @@ | |||
| 1 | Index: gtk+-2.12.3/gtk/gtkfilesystemunix.c | ||
| 2 | =================================================================== | ||
| 3 | --- gtk+-2.12.3.orig/gtk/gtkfilesystemunix.c 2007-12-04 16:52:08.000000000 +0000 | ||
| 4 | +++ gtk+-2.12.3/gtk/gtkfilesystemunix.c 2008-01-02 13:15:02.000000000 +0000 | ||
| 5 | @@ -38,6 +38,7 @@ | ||
| 6 | #include <errno.h> | ||
| 7 | #include <string.h> | ||
| 8 | #include <sys/stat.h> | ||
| 9 | +#include <sys/statvfs.h> | ||
| 10 | #include <sys/types.h> | ||
| 11 | #include <pwd.h> | ||
| 12 | #ifdef HAVE_UNISTD_H | ||
| 13 | @@ -474,7 +475,55 @@ | ||
| 14 | static GSList * | ||
| 15 | gtk_file_system_unix_list_volumes (GtkFileSystem *file_system) | ||
| 16 | { | ||
| 17 | - return g_slist_append (NULL, get_root_volume ()); | ||
| 18 | + struct statvfs stv; | ||
| 19 | + struct stat st; | ||
| 20 | + GSList * l = g_slist_append (NULL, get_root_volume ()); | ||
| 21 | + | ||
| 22 | + if (!statvfs ("/.", &stv)) | ||
| 23 | + { | ||
| 24 | + fsblkcnt_t root_blocks = stv.f_blocks; | ||
| 25 | + fsfilcnt_t root_files = stv.f_files; | ||
| 26 | + | ||
| 27 | + GDir * dir; | ||
| 28 | + if ((dir = g_dir_open ("/media", 0, NULL)) != NULL) | ||
| 29 | + { | ||
| 30 | + const gchar * name; | ||
| 31 | + while ((name = g_dir_read_name (dir)) != NULL) | ||
| 32 | + { | ||
| 33 | + gchar * abs_name; | ||
| 34 | + | ||
| 35 | + /* Skip ram disks */ | ||
| 36 | + if (!strcmp (name, "ram")) | ||
| 37 | + continue; | ||
| 38 | + | ||
| 39 | + abs_name = g_strconcat ("/media/", name, NULL); | ||
| 40 | + | ||
| 41 | + if (!stat (abs_name, &st) && S_ISDIR (st.st_mode)) | ||
| 42 | + { | ||
| 43 | + gchar * dot = g_strconcat (abs_name, "/.", NULL); | ||
| 44 | + if (!statvfs (dot, &stv) && | ||
| 45 | + (stv.f_blocks != root_blocks || | ||
| 46 | + stv.f_files != root_files)) | ||
| 47 | + { | ||
| 48 | + GtkFilePath * path = | ||
| 49 | + gtk_file_system_filename_to_path (file_system, | ||
| 50 | + abs_name); | ||
| 51 | + | ||
| 52 | + if (path) | ||
| 53 | + l = g_slist_append (l, path); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + g_free (dot); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + g_free (abs_name); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + g_dir_close (dir); | ||
| 63 | + } | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + return l; | ||
| 67 | } | ||
| 68 | |||
| 69 | static GtkFileSystemVolume * | ||
| 70 | @@ -488,13 +537,18 @@ | ||
| 71 | remove_trailing_slash (const char *filename) | ||
| 72 | { | ||
| 73 | int len; | ||
| 74 | - | ||
| 75 | + | ||
| 76 | len = strlen (filename); | ||
| 77 | |||
| 78 | - if (len > 1 && filename[len - 1] == '/') | ||
| 79 | - return g_strndup (filename, len - 1); | ||
| 80 | - else | ||
| 81 | - return g_memdup (filename, len + 1); | ||
| 82 | + if (len > 1) | ||
| 83 | + { | ||
| 84 | + gchar *c = g_utf8_prev_char (filename + len); | ||
| 85 | + | ||
| 86 | + if (c && *c == '/') | ||
| 87 | + return g_strndup (filename, len - 1); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + return g_memdup (filename, len + 1); | ||
| 91 | } | ||
| 92 | |||
| 93 | /* Delay callback dispatching | ||
| 94 | @@ -1128,7 +1182,7 @@ | ||
| 95 | gtk_file_system_unix_volume_get_base_path (GtkFileSystem *file_system, | ||
| 96 | GtkFileSystemVolume *volume) | ||
| 97 | { | ||
| 98 | - return gtk_file_path_new_dup ("/"); | ||
| 99 | + return gtk_file_path_copy ((GtkFilePath*)volume); | ||
| 100 | } | ||
| 101 | |||
| 102 | static gboolean | ||
| 103 | @@ -1162,7 +1216,32 @@ | ||
| 104 | gtk_file_system_unix_volume_get_display_name (GtkFileSystem *file_system, | ||
| 105 | GtkFileSystemVolume *volume) | ||
| 106 | { | ||
| 107 | - return g_strdup (_("File System")); /* Same as Nautilus */ | ||
| 108 | + gchar * slash; | ||
| 109 | + gchar * path; | ||
| 110 | + gchar * c; | ||
| 111 | + | ||
| 112 | + g_return_val_if_fail (file_system && volume, NULL); | ||
| 113 | + | ||
| 114 | + path = gtk_file_system_path_to_filename (file_system, (GtkFilePath*) volume); | ||
| 115 | + | ||
| 116 | + g_return_val_if_fail (path && *path, NULL); | ||
| 117 | + | ||
| 118 | + if (path[0] == '/' && !path[1]) | ||
| 119 | + return g_strdup (_("Filesystem")); /* Same as Nautilus */ | ||
| 120 | + | ||
| 121 | + /* Now the media volumes */ | ||
| 122 | + /* strip trailing / if any */ | ||
| 123 | + c = g_utf8_prev_char (path + strlen(path)); | ||
| 124 | + | ||
| 125 | + if (*c == '/') | ||
| 126 | + *c = 0; | ||
| 127 | + | ||
| 128 | + slash = g_utf8_strrchr (path, -1, '/'); | ||
| 129 | + | ||
| 130 | + if (!slash) | ||
| 131 | + return g_strdup (path); | ||
| 132 | + | ||
| 133 | + return g_strdup (slash + 1); | ||
| 134 | } | ||
| 135 | |||
| 136 | static IconType | ||
| 137 | @@ -1250,10 +1329,57 @@ | ||
| 138 | GtkFileSystemVolume *volume, | ||
| 139 | GError **error) | ||
| 140 | { | ||
| 141 | - /* FIXME: maybe we just always want to return GTK_STOCK_HARDDISK here? | ||
| 142 | - * or the new tango icon name? | ||
| 143 | - */ | ||
| 144 | - return g_strdup ("gnome-dev-harddisk"); | ||
| 145 | + gchar * c; | ||
| 146 | + gchar * slash; | ||
| 147 | + gchar * path = NULL; | ||
| 148 | + GtkFilePath * fpath; | ||
| 149 | + const gchar * id = NULL; | ||
| 150 | + | ||
| 151 | + g_return_val_if_fail (file_system && volume, NULL); | ||
| 152 | + | ||
| 153 | + fpath = gtk_file_system_volume_get_base_path (file_system, volume); | ||
| 154 | + | ||
| 155 | + if (!fpath) | ||
| 156 | + goto out; | ||
| 157 | + | ||
| 158 | + path = gtk_file_system_path_to_filename (file_system, fpath); | ||
| 159 | + gtk_file_path_free (fpath); | ||
| 160 | + | ||
| 161 | + if (!path || !*path || (*path == '/' && !path[1])) | ||
| 162 | + goto out; | ||
| 163 | + | ||
| 164 | + /* Now the media volumes */ | ||
| 165 | + /* strip trailing / if any */ | ||
| 166 | + c = g_utf8_prev_char (path + strlen(path)); | ||
| 167 | + | ||
| 168 | + if (*c == '/') | ||
| 169 | + *c = 0; | ||
| 170 | + | ||
| 171 | + slash = g_utf8_strrchr (path, -1, '/'); | ||
| 172 | + | ||
| 173 | + if (slash) | ||
| 174 | + { | ||
| 175 | + slash++; | ||
| 176 | + | ||
| 177 | + if (!strcmp (slash, "card")) | ||
| 178 | + id = "gnome-dev-media-sdmmc"; | ||
| 179 | + else if (!strcmp (slash, "cf")) | ||
| 180 | + id = "gnome-dev-media-cf"; | ||
| 181 | + else if (!strncmp (slash, "mmc", 3)) | ||
| 182 | + id = "gnome-dev-media-sdmmc"; | ||
| 183 | + else if (!strcmp (slash, "usbhdd")) | ||
| 184 | + id = "gnome-dev-removable-usb"; | ||
| 185 | + else | ||
| 186 | + id = "gnome-dev-removable"; | ||
| 187 | + } | ||
| 188 | + | ||
| 189 | + out: | ||
| 190 | + g_free (path); | ||
| 191 | + | ||
| 192 | + if (!id) | ||
| 193 | + id = "gnome-fs-blockdev"; | ||
| 194 | + | ||
| 195 | + return g_strdup (id); | ||
| 196 | } | ||
| 197 | |||
| 198 | static char * | ||
