Skip to content

Commit

Permalink
Removed Advanced preferences section and added Big Sur compatible icons
Browse files Browse the repository at this point in the history
  • Loading branch information
hjuutilainen committed Nov 15, 2020
1 parent d60c731 commit 32b2a49
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 48 deletions.
31 changes: 18 additions & 13 deletions SUS Inspector/UI Controllers/SIPreferencesController.m
Original file line number Diff line number Diff line change
Expand Up @@ -147,22 +147,23 @@ - (void)awakeFromNib
{
self.items = [[NSMutableDictionary alloc] init];

NSImage *prefsIcon;
if (@available(macOS 11.0, *)) {
prefsIcon = [NSImage imageWithSystemSymbolName:@"gearshape" accessibilityDescription:@"Gear shape"];
} else {
prefsIcon = [NSImage imageNamed:@"NSPreferencesGeneral"];
}

NSToolbarItem *generalItem = [self toolbarItemWithIdentifier:@"General"];
[generalItem setToolTip:NSLocalizedString(@"General preference options.", nil)];
[generalItem setImage:[NSImage imageNamed:@"NSPreferencesGeneral"]];
[generalItem setImage:prefsIcon];
[self.items setObject:generalItem forKey:@"General"];

NSToolbarItem *munkiItem = [self toolbarItemWithIdentifier:@"Munki"];
[munkiItem setToolTip:NSLocalizedString(@"Munki preference options.", nil)];
[munkiItem setImage:[NSImage imageNamed:@"NSPreferencesGeneral"]];
[munkiItem setImage:prefsIcon];
[self.items setObject:munkiItem forKey:@"Munki"];


NSToolbarItem *advancedItem = [self toolbarItemWithIdentifier:@"Advanced"];
[advancedItem setToolTip:NSLocalizedString(@"Advanced options.", nil)];
[advancedItem setImage:[NSImage imageNamed:@"NSAdvanced"]];
[self.items setObject:advancedItem forKey:@"Advanced"];

//any other items you want to add, do so here.
//after you are done, just do all the toolbar stuff.
//myWindow is an outlet pointing to the Preferences Window you made to hold all these custom views.
Expand All @@ -172,8 +173,14 @@ - (void)awakeFromNib
[self.toolbar setAllowsUserCustomization:NO];
[self.toolbar setAutosavesConfiguration:NO];
[self.window setToolbar:self.toolbar];
[self.window setShowsResizeIndicator:NO];
[self.window setShowsToolbarButton:NO];
if (@available(macOS 11.0, *)) {
[self.window setToolbarStyle:NSWindowToolbarStylePreference];
} else {
// Fallback on earlier versions
}
self.window.styleMask |= NSWindowStyleMaskClosable;
self.window.styleMask &= ~NSWindowStyleMaskResizable;

[self.window center];
[self.window makeKeyAndOrderFront:self];
[self switchViews:nil];
Expand Down Expand Up @@ -202,8 +209,6 @@ - (void)switchViews:(NSToolbarItem *)item
prefsView = self.generalView;
} else if ([sender isEqualToString:@"Munki"]) {
prefsView = self.munkiView;
} else if ([sender isEqualToString:@"Advanced"]) {
prefsView = self.advancedView;
} else {
prefsView = self.generalView;
}
Expand Down Expand Up @@ -236,7 +241,7 @@ - (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)theToolbar

- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar*)theToolbar
{
return [NSArray arrayWithObjects:@"General", @"Munki", @"Advanced", nil];
return @[@"General", @"Munki"];
}

- (NSArray *)toolbarSelectableItemIdentifiers: (NSToolbar *)toolbar
Expand Down
Loading

0 comments on commit 32b2a49

Please sign in to comment.