diff --git a/Meta/Lagom/Contrib/MacPDF/CMakeLists.txt b/Meta/Lagom/Contrib/MacPDF/CMakeLists.txt index a37f9f68bd..b5695ae6fa 100644 --- a/Meta/Lagom/Contrib/MacPDF/CMakeLists.txt +++ b/Meta/Lagom/Contrib/MacPDF/CMakeLists.txt @@ -19,6 +19,7 @@ add_executable(MacPDF MACOSX_BUNDLE AppDelegate.mm MacPDFDocument.mm MacPDFView.mm + MacPDFWindowController.mm ) target_compile_options(MacPDF PRIVATE -fobjc-arc diff --git a/Meta/Lagom/Contrib/MacPDF/MacPDFDocument.mm b/Meta/Lagom/Contrib/MacPDF/MacPDFDocument.mm index 80644a24a5..021701572e 100644 --- a/Meta/Lagom/Contrib/MacPDF/MacPDFDocument.mm +++ b/Meta/Lagom/Contrib/MacPDF/MacPDFDocument.mm @@ -8,6 +8,7 @@ #import +#import "MacPDFWindowController.h" #include @interface MacPDFDocument () @@ -71,9 +72,9 @@ } } -- (NSString*)windowNibName +- (void)makeWindowControllers { - return @"MacPDFDocument"; + [self addWindowController:[[MacPDFWindowController alloc] initWithDocument:self]]; } - (void)windowControllerDidLoadNib:(NSWindowController*)aController diff --git a/Meta/Lagom/Contrib/MacPDF/MacPDFWindowController.h b/Meta/Lagom/Contrib/MacPDF/MacPDFWindowController.h new file mode 100644 index 0000000000..5861eddc59 --- /dev/null +++ b/Meta/Lagom/Contrib/MacPDF/MacPDFWindowController.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023, Nico Weber + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include "CocoaWrapper.h" + +NS_ASSUME_NONNULL_BEGIN + +@class MacPDFDocument; + +@interface MacPDFWindowController : NSWindowController + +- (instancetype)initWithDocument:(MacPDFDocument*)document; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Meta/Lagom/Contrib/MacPDF/MacPDFWindowController.mm b/Meta/Lagom/Contrib/MacPDF/MacPDFWindowController.mm new file mode 100644 index 0000000000..c75795a9dc --- /dev/null +++ b/Meta/Lagom/Contrib/MacPDF/MacPDFWindowController.mm @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2023, Nico Weber + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#import "MacPDFWindowController.h" + +@implementation MacPDFWindowController + +- (instancetype)initWithDocument:(MacPDFDocument*)document +{ + if (self = [super initWithWindowNibName:@"MacPDFDocument" owner:self]; !self) + return nil; + + return self; +} + + +@end