diff options
author | Yevgeny Makarov <jenkm> | 2020-01-28 13:10:35 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2020-01-28 13:13:12 +0300 |
commit | 92d606ba268f5172228a19d5614298e7cf387714 (patch) | |
tree | c8892f3617d7973dd74bc97bc3723d8e136b1c12 | |
parent | bb65f49005ed17806bce2b048d37903cc1342d27 (diff) |
UI: show better volume names and icons in file browser on macOS
Now it shows "Macintosh HD" instead of "/", and a different icon for
removable and network drives.
Differential Revision: https://developer.blender.org/D6683
-rw-r--r-- | source/blender/editors/space_file/fsmenu.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index fc03453a5cc..da105da77ab 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -578,11 +578,41 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) CFURLGetFileSystemRepresentation(cfURL, false, (UInt8 *)defPath, FILE_MAX); + /* Get name of the volume. */ + char name[FILE_MAXFILE] = ""; + CFStringRef nameString = NULL; + CFURLCopyResourcePropertyForKey(cfURL, kCFURLVolumeLocalizedNameKey, &nameString, NULL); + if (nameString != NULL) { + CFStringGetCString(nameString, name, sizeof(name), kCFStringEncodingUTF8); + CFRelease(nameString); + } + + /* Set icon for regular, removable or network drive. */ + int icon = ICON_DISK_DRIVE; + CFBooleanRef localKey = NULL; + CFURLCopyResourcePropertyForKey(cfURL, kCFURLVolumeIsLocalKey, &localKey, NULL); + if (localKey != NULL) { + if (!CFBooleanGetValue(localKey)) { + icon = ICON_NETWORK_DRIVE; + } + else { + CFBooleanRef ejectableKey = NULL; + CFURLCopyResourcePropertyForKey(cfURL, kCFURLVolumeIsEjectableKey, &ejectableKey, NULL); + if (ejectableKey != NULL) { + if (CFBooleanGetValue(ejectableKey)) { + icon = ICON_EXTERNAL_DRIVE; + } + CFRelease(ejectableKey); + } + } + CFRelease(localKey); + } + /* Add end slash for consistency with other platforms */ BLI_add_slash(defPath); fsmenu_insert_entry( - fsmenu, FS_CATEGORY_SYSTEM, defPath, NULL, ICON_DISK_DRIVE, FS_INSERT_SORTED); + fsmenu, FS_CATEGORY_SYSTEM, defPath, name[0] ? name : NULL, icon, FS_INSERT_SORTED); } CFRelease(volEnum); |