diff options
author | Tor Lillqvist <tml@novell.com> | 2005-04-25 00:47:31 +0000 |
---|---|---|
committer | Tor Lillqvist <tml@src.gnome.org> | 2005-04-25 00:47:31 +0000 |
commit | 3b16bb011ea7a96abf0152b94db16ad7945d7648 (patch) | |
tree | 0f6648eb403c72080e1cd86e49d74ed0e4a39904 /gtk/gtkfilesystemwin32.c | |
parent | e0e7056fe210804b9ef335c1e9f92314a6b0ccb3 (diff) | |
download | gtk+-3b16bb011ea7a96abf0152b94db16ad7945d7648.tar.gz |
Get volume name also on Win9x. (#301798, Daniel Atallah)
2005-04-25 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c
(gtk_file_system_win32_volume_get_display_name): Get volume name
also on Win9x. (#301798, Daniel Atallah)
(canonicalize_filename): Add explicit braces to silence compiler
warning.
Diffstat (limited to 'gtk/gtkfilesystemwin32.c')
-rw-r--r-- | gtk/gtkfilesystemwin32.c | 61 |
1 files changed, 44 insertions, 17 deletions
diff --git a/gtk/gtkfilesystemwin32.c b/gtk/gtkfilesystemwin32.c index 2824920e19..8d3ebb6569 100644 --- a/gtk/gtkfilesystemwin32.c +++ b/gtk/gtkfilesystemwin32.c @@ -612,23 +612,48 @@ gtk_file_system_win32_volume_get_display_name (GtkFileSystem *file_system, else if ((filename_is_drive_root (volume->drive) && volume->drive[0] >= 'C') || volume->drive_type != DRIVE_REMOVABLE) { - gunichar2 *wdrive = g_utf8_to_utf16 (volume->drive, -1, NULL, NULL, NULL); - gunichar2 wname[80]; - if (GetVolumeInformationW (wdrive, - wname, G_N_ELEMENTS(wname), - NULL, /* serial number */ - NULL, /* max. component length */ - NULL, /* fs flags */ - NULL, 0) /* fs type like FAT, NTFS */ && - wname[0]) + gchar *name = NULL; + if (G_WIN32_HAVE_WIDECHAR_API ()) { - gchar *name = g_utf16_to_utf8 (wname, -1, NULL, NULL, NULL); + gunichar2 *wdrive = g_utf8_to_utf16 (volume->drive, -1, NULL, NULL, NULL); + gunichar2 wname[80]; + if (GetVolumeInformationW (wdrive, + wname, G_N_ELEMENTS(wname), + NULL, /* serial number */ + NULL, /* max. component length */ + NULL, /* fs flags */ + NULL, 0) /* fs type like FAT, NTFS */ && + wname[0]) + { + name = g_utf16_to_utf8 (wname, -1, NULL, NULL, NULL); + } + g_free (wdrive); + } + else + { + gchar *cpdrive = g_locale_from_utf8 (volume->drive, -1, NULL, NULL, NULL); + gchar cpname[80]; + if (GetVolumeInformationA (cpdrive, + cpname, G_N_ELEMENTS(cpname), + NULL, /* serial number */ + NULL, /* max. component length */ + NULL, /* fs flags */ + NULL, 0) /* fs type like FAT, NTFS */ && + cpname[0]) + { + name = g_locale_to_utf8 (cpname, -1, NULL, NULL, NULL); + } + g_free (cpdrive); + } + if (name != NULL) + { real_display_name = g_strdup_printf (_("%s (%s)"), name, volume->drive); g_free (name); } else - real_display_name = g_strdup (volume->drive); - g_free (wdrive); + { + real_display_name = g_strdup (volume->drive); + } } else real_display_name = g_strdup (volume->drive); @@ -741,7 +766,7 @@ canonicalize_filename (gchar *filename) printf("canonicalize_filename: %s ", filename); #endif - past_root = g_path_skip_root (filename); + past_root = (gchar *) g_path_skip_root (filename); q = p = past_root; @@ -1287,10 +1312,12 @@ gtk_file_system_win32_render_icon (GtkFileSystem *file_system, } if (!icon_set) - if (g_file_test (filename, G_FILE_TEST_IS_EXECUTABLE)) - icon_set = gtk_style_lookup_icon_set (widget->style, GTK_STOCK_EXECUTE); - else - icon_set = gtk_style_lookup_icon_set (widget->style, GTK_STOCK_FILE); + { + if (g_file_test (filename, G_FILE_TEST_IS_EXECUTABLE)) + icon_set = gtk_style_lookup_icon_set (widget->style, GTK_STOCK_EXECUTE); + else + icon_set = gtk_style_lookup_icon_set (widget->style, GTK_STOCK_FILE); + } // FIXME : I'd like to get from pixel_size (=20) back to // icon size, which is an index, but there appears to be no way ? |