@@ -132,11 +132,13 @@ - (id)initWithBackend:(id)backend pid:(int)processIdentifier
132
132
[[MMWindowController alloc ] initWithVimController: self ];
133
133
backendProxy = [backend retain ];
134
134
popupMenuItems = [[NSMutableArray alloc ] init ];
135
- #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_12
136
135
toolbarItemDict = [[NSMutableDictionary alloc ] init ];
137
- touchbarItemDict = [[NSMutableDictionary alloc ] init ];
138
- touchbarItemOrder = [[NSMutableArray alloc ] init ];
139
- touchbarDisabledItems = [[NSMutableSet alloc ] init ];
136
+ #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12_2
137
+ if (NSClassFromString (@" NSTouchBar" )) {
138
+ touchbarItemDict = [[NSMutableDictionary alloc ] init ];
139
+ touchbarItemOrder = [[NSMutableArray alloc ] init ];
140
+ touchbarDisabledItems = [[NSMutableSet alloc ] init ];
141
+ }
140
142
#endif
141
143
pid = processIdentifier;
142
144
creationDate = [[NSDate alloc ] init ];
@@ -186,7 +188,7 @@ - (void)dealloc
186
188
187
189
[toolbarItemDict release ]; toolbarItemDict = nil ;
188
190
[toolbar release ]; toolbar = nil ;
189
- #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_12
191
+ #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12_2
190
192
[touchbarItemDict release ]; touchbarItemDict = nil ;
191
193
[touchbarItemOrder release ]; touchbarItemOrder = nil ;
192
194
[touchbarDisabledItems release ]; touchbarDisabledItems = nil ;
@@ -502,7 +504,7 @@ - (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)theToolbar
502
504
{
503
505
return nil ;
504
506
}
505
- #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_12
507
+ #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12_2
506
508
- (NSTouchBar *)makeTouchBar
507
509
{
508
510
touchbar = [[NSTouchBar alloc ] init ];
@@ -1140,10 +1142,10 @@ - (void)addMenuWithDescriptor:(NSArray *)desc atIndex:(int)idx
1140
1142
1141
1143
return ;
1142
1144
}
1143
- # if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_12
1145
+
1144
1146
if ([rootName isEqual: MMTouchbarMenuName])
1145
1147
return ;
1146
- # endif
1148
+
1147
1149
// This is either a main menu item or a popup menu item.
1148
1150
NSString *title = [desc lastObject ];
1149
1151
NSMenuItem *item = [[NSMenuItem alloc ] init ];
@@ -1194,13 +1196,15 @@ - (void)addMenuItemWithDescriptor:(NSArray *)desc
1194
1196
[self addToolbarItemWithLabel: title tip: tip icon: icon atIndex: idx];
1195
1197
return ;
1196
1198
}
1197
- #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_12
1198
1199
if ([rootName isEqual: MMTouchbarMenuName]) {
1199
- if ([desc count ] == 2 )
1200
- [self addTouchbarItemWithLabel: title icon: icon atIndex: idx];
1200
+ #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12_2
1201
+ if (NSClassFromString (@" NSTouchBar" )) {
1202
+ if ([desc count ] == 2 )
1203
+ [self addTouchbarItemWithLabel: title icon: icon atIndex: idx];
1204
+ }
1205
+ #endif
1201
1206
return ;
1202
1207
}
1203
- #endif
1204
1208
NSMenu *parent = [self parentMenuForDescriptor: desc];
1205
1209
if (!parent) {
1206
1210
ASLogWarn (@" Menu item '%@ ' has no parent" ,
@@ -1263,17 +1267,19 @@ - (void)removeMenuItemWithDescriptor:(NSArray *)desc
1263
1267
}
1264
1268
return ;
1265
1269
}
1266
- #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_12
1267
1270
if ([rootName isEqual: MMTouchbarMenuName]){
1268
- if ([desc count ] == 2 ) {
1269
- [touchbarItemOrder removeObject: title];
1270
- [touchbarItemDict removeObjectForKey: title];
1271
- [touchbarDisabledItems removeObject: title];
1272
- [windowController setTouchBar: nil ];
1271
+ #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12_2
1272
+ if (NSClassFromString (@" NSTouchBar" )) {
1273
+ if ([desc count ] == 2 ) {
1274
+ [touchbarItemOrder removeObject: title];
1275
+ [touchbarItemDict removeObjectForKey: title];
1276
+ [touchbarDisabledItems removeObject: title];
1277
+ [windowController setTouchBar: nil ];
1278
+ }
1273
1279
}
1280
+ #endif
1274
1281
return ;
1275
1282
}
1276
- #endif
1277
1283
NSMenuItem *item = [self menuItemForDescriptor: desc];
1278
1284
if (!item) {
1279
1285
ASLogWarn (@" Failed to remove menu item, descriptor not found: %@ " ,
@@ -1308,19 +1314,22 @@ - (void)enableMenuItemWithDescriptor:(NSArray *)desc state:(BOOL)on
1308
1314
}
1309
1315
return ;
1310
1316
}
1311
- # if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_12
1317
+
1312
1318
if ([rootName isEqual: MMTouchbarMenuName]) {
1313
- if ([desc count ] == 2 ) {
1314
- NSString *title = [desc lastObject ];
1315
- if (on)
1316
- [touchbarDisabledItems removeObject: title];
1317
- else
1318
- [touchbarDisabledItems addObject: title];
1319
- [windowController setTouchBar: nil ];
1319
+ #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12_2
1320
+ if (NSClassFromString (@" NSTouchBar" )) {
1321
+ if ([desc count ] == 2 ) {
1322
+ NSString *title = [desc lastObject ];
1323
+ if (on)
1324
+ [touchbarDisabledItems removeObject: title];
1325
+ else
1326
+ [touchbarDisabledItems addObject: title];
1327
+ [windowController setTouchBar: nil ];
1328
+ }
1320
1329
}
1330
+ #endif
1321
1331
return ;
1322
1332
}
1323
- #endif
1324
1333
1325
1334
// Use tag to set whether item is enabled or disabled instead of
1326
1335
// calling setEnabled:. This way the menus can autoenable themselves
@@ -1398,7 +1407,7 @@ - (void)addToolbarItemWithLabel:(NSString *)label
1398
1407
1399
1408
[toolbar insertItemWithItemIdentifier: label atIndex: idx];
1400
1409
}
1401
- #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_12
1410
+ #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12_2
1402
1411
- (void )addTouchbarItemWithLabel:(NSString *)label
1403
1412
icon:(NSString *)icon
1404
1413
atIndex:(int )idx
0 commit comments