12
12
#import " MMAppController.h"
13
13
#import " Miscellaneous.h"
14
14
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
-
48
15
@implementation MMPreferenceController
49
16
50
17
- (void )windowDidLoad
@@ -66,6 +33,15 @@ - (void)windowDidLoad
66
33
}
67
34
#endif
68
35
[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
69
45
}
70
46
71
47
- (IBAction )showWindow : (id )sender
@@ -76,30 +52,35 @@ - (IBAction)showWindow:(id)sender
76
52
77
53
- (void )setupToolbar
78
54
{
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.
82
58
[self addView: generalPreferences
83
59
label: @" General"
84
- image: [NSImage imageNamed: nsImageNamePreferencesGeneral]];
85
- } else {
86
- [self addView: generalPreferences label: @" General" ];
87
- }
60
+ image: [NSImage imageWithSystemSymbolName: @" gearshape" accessibilityDescription: nil ]];
88
61
89
- if (nsImageNamePreferencesAppearance != NULL ) {
90
62
[self addView: appearancePreferences
91
63
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 ]];
95
69
}
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 ]];
96
80
97
- if (nsImageNamePreferencesAdvanced != NULL ) {
98
81
[self addView: advancedPreferences
99
82
label: @" Advanced"
100
- image: [NSImage imageNamed: nsImageNamePreferencesAdvanced]];
101
- } else {
102
- [self addView: advancedPreferences label: @" Advanced" ];
83
+ image: [NSImage imageNamed: NSImageNameAdvanced ]];
103
84
}
104
85
}
105
86
0 commit comments