[Bf-blender-cvs] [92d606ba268] master: UI: show better volume names and icons in file browser on macOS

Yevgeny Makarov noreply at git.blender.org
Tue Jan 28 11:13:54 CET 2020


Commit: 92d606ba268f5172228a19d5614298e7cf387714
Author: Yevgeny Makarov
Date:   Tue Jan 28 11:10:35 2020 +0100
Branches: master
https://developer.blender.org/rB92d606ba268f5172228a19d5614298e7cf387714

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

===================================================================

M	source/blender/editors/space_file/fsmenu.c

===================================================================

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);



More information about the Bf-blender-cvs mailing list