Skip to content
This repository has been archived by the owner on Mar 5, 2023. It is now read-only.

Commit

Permalink
Various updates for modern macOS. (#61)
Browse files Browse the repository at this point in the history
* Use resource bundle to support static linkage

* Update minimum target platform to OS X 10.10

* Use preference style for window toolbar in 11.0+
  • Loading branch information
GetToSet authored Dec 13, 2021
1 parent 45e5ff6 commit 135869c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
4 changes: 0 additions & 4 deletions Framework/MASPreferencesWindowController.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ extern NSString * const kMASPreferencesWindowControllerDidChangeViewNotification
* Window controller for managing Preference view controllers.
*/
__attribute__((__visibility__("default")))
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
@interface MASPreferencesWindowController : NSWindowController <NSToolbarDelegate, NSWindowDelegate>
#else
@interface MASPreferencesWindowController : NSWindowController
#endif
{
@private
NSMutableArray *_viewControllers;
Expand Down
16 changes: 15 additions & 1 deletion Framework/MASPreferencesWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ - (instancetype)initWithViewControllers:(NSArray *)viewControllers
- (instancetype)initWithViewControllers:(NSArray *)viewControllers title:(NSString *)title
{
NSParameterAssert(viewControllers.count > 0);
NSString *nibPath = [[NSBundle bundleForClass:MASPreferencesWindowController.class] pathForResource:@"MASPreferencesWindow" ofType:@"nib"];
NSString *nibPath = [[MASPreferencesWindowController resourceBundle] pathForResource:@"MASPreferencesWindow" ofType:@"nib"];
if ((self = [super initWithWindowNibPath:nibPath owner:self]))
{
_viewControllers = [viewControllers mutableCopy];
Expand Down Expand Up @@ -93,6 +93,12 @@ - (void)windowDidLoad
[self.window setFrameTopLeftPoint:NSPointFromString(origin)];
}

#ifdef MAC_OS_VERSION_11_0
if (@available(macOS 11.0, *)) {
[self.window setToolbarStyle:NSWindowToolbarStylePreference];
}
#endif

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidMove:) name:NSWindowDidMoveNotification object:self.window];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidResize:) name:NSWindowDidResizeNotification object:self.window];
}
Expand Down Expand Up @@ -345,4 +351,12 @@ - (IBAction)goPreviousTab:(id __unused)sender
[self selectControllerAtIndex:selectedIndex];
}

#pragma mark -
#pragma mark Helper Functions

+ (NSBundle *)resourceBundle {
NSBundle *moduleBundle = [NSBundle bundleForClass:MASPreferencesWindowController.class];
return [NSBundle bundleWithURL:[NSURL fileURLWithPath:[moduleBundle pathForResource:@"MASPreferences" ofType:@"bundle"]]];
}

@end
6 changes: 4 additions & 2 deletions MASPreferences.podspec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Pod::Spec.new do |s|
s.platform = :osx
s.platform = :osx, '10.10'
s.name = "MASPreferences"
s.version = "1.3"
s.summary = "Modern implementation of the Preferences window for OS X apps, used in TextMate, GitBox and Mou."
Expand All @@ -8,7 +8,9 @@ Pod::Spec.new do |s|
s.author = { "Vadim Shpakovski" => "[email protected]" }
s.source = { :git => 'https://github.com/shpakovski/MASPreferences.git', :tag => '1.3' }
s.source_files = 'Framework/*.{h,m}'
s.resources = 'Framework/en.lproj/*.xib'
s.resource_bundles = {
'MASPreferences' => ['Framework/en.lproj/*.xib']
}
s.exclude_files = 'README.md', 'LICENSE.md', 'MASPreferences.podspec'
s.requires_arc = true
end

0 comments on commit 135869c

Please sign in to comment.