1212#import " MMAppController.h"
1313#import " Miscellaneous.h"
1414
15- // On Leopard, we want to use the images provided by the OS for some of the
16- // toolbar images (NSImageNamePreferencesGeneral and friends). We need to jump
17- // through some hoops to do that in a way that MacVim still _compiles_ on Tiger
18- // (life would be easier if we'd require Leopard for building). See
19- // http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html
20- // and http://developer.apple.com/technotes/tn2002/tn2064.html
21- // for how you'd do it with a Leopard build system, and see
22- // http://lists.cairographics.org/archives/cairo-bugs/2007-December/001818.html
23- // for why this doesn't work here.
24- // Using the system images gives us resolution independence and consistency
25- // with other apps.
26-
27- #import < dlfcn.h>
28-
29-
30- NSString * nsImageNamePreferencesGeneral = nil ;
31- NSString * nsImageNamePreferencesAppearance = nil ;
32- NSString * nsImageNamePreferencesAdvanced = nil ;
33-
34-
35- static void loadSymbols ()
36- {
37- // use dlfcn() instead of the deprecated NSModule api.
38- void *ptr;
39- if ((ptr = dlsym (RTLD_DEFAULT, " NSImageNamePreferencesGeneral" )) != NULL )
40- nsImageNamePreferencesGeneral = *(NSString **)ptr;
41- if ((ptr = dlsym (RTLD_DEFAULT, " NSImageNameColorPanel" )) != NULL ) // Closest match for default icon for "appearance"
42- nsImageNamePreferencesAppearance = *(NSString **)ptr;
43- if ((ptr = dlsym (RTLD_DEFAULT, " NSImageNameAdvanced" )) != NULL )
44- nsImageNamePreferencesAdvanced = *(NSString **)ptr;
45- }
46-
47-
4815@implementation MMPreferenceController
4916
5017- (void )windowDidLoad
@@ -66,6 +33,15 @@ - (void)windowDidLoad
6633 }
6734#endif
6835 [super windowDidLoad ];
36+
37+ #if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
38+ if (@available (macos 11.0 , *)) {
39+ // macOS 11 will default to a unified toolbar style unless you use the new
40+ // toolbarStyle to tell it to use a "preference" style, which makes it look nice
41+ // and centered.
42+ [self window ].toolbarStyle = NSWindowToolbarStylePreference;
43+ }
44+ #endif
6945}
7046
7147- (IBAction )showWindow : (id )sender
@@ -76,30 +52,35 @@ - (IBAction)showWindow:(id)sender
7652
7753- (void )setupToolbar
7854{
79- loadSymbols ();
80-
81- if (nsImageNamePreferencesGeneral != NULL ) {
55+ # if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
56+ if (@ available (macos 11.0 , *)) {
57+ // Use SF Symbols for versions of the OS that supports it to be more unified with OS appearance.
8258 [self addView: generalPreferences
8359 label: @" General"
84- image: [NSImage imageNamed: nsImageNamePreferencesGeneral]];
85- } else {
86- [self addView: generalPreferences label: @" General" ];
87- }
60+ image: [NSImage imageWithSystemSymbolName: @" gearshape" accessibilityDescription: nil ]];
8861
89- if (nsImageNamePreferencesAppearance != NULL ) {
9062 [self addView: appearancePreferences
9163 label: @" Appearance"
92- image: [NSImage imageNamed: nsImageNamePreferencesAppearance]];
93- } else {
94- [self addView: appearancePreferences label: @" Appearance" ];
64+ image: [NSImage imageWithSystemSymbolName: @" paintbrush" accessibilityDescription: nil ]];
65+
66+ [self addView: advancedPreferences
67+ label: @" Advanced"
68+ image: [NSImage imageWithSystemSymbolName: @" gearshape.2" accessibilityDescription: nil ]];
9569 }
70+ else
71+ #endif
72+ {
73+ [self addView: generalPreferences
74+ label: @" General"
75+ image: [NSImage imageNamed: NSImageNamePreferencesGeneral ]];
76+
77+ [self addView: appearancePreferences
78+ label: @" Appearance"
79+ image: [NSImage imageNamed: NSImageNameColorPanel ]];
9680
97- if (nsImageNamePreferencesAdvanced != NULL ) {
9881 [self addView: advancedPreferences
9982 label: @" Advanced"
100- image: [NSImage imageNamed: nsImageNamePreferencesAdvanced]];
101- } else {
102- [self addView: advancedPreferences label: @" Advanced" ];
83+ image: [NSImage imageNamed: NSImageNameAdvanced ]];
10384 }
10485}
10586
0 commit comments