mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-21 10:05:32 +00:00
MacPDF: Add a toolbar with a standard sidebar button
This commit is contained in:
parent
1f1a596a46
commit
ae1b179474
|
@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@class MacPDFDocument;
|
||||
|
||||
@interface MacPDFWindowController : NSWindowController <MacPDFViewDelegate>
|
||||
@interface MacPDFWindowController : NSWindowController <MacPDFViewDelegate, NSToolbarDelegate>
|
||||
|
||||
- (instancetype)initWithDocument:(MacPDFDocument*)document;
|
||||
- (IBAction)showGoToPageDialog:(id)sender;
|
||||
|
|
|
@ -32,6 +32,11 @@
|
|||
window.contentView = _pdfView;
|
||||
[_pdfView setDelegate:self];
|
||||
|
||||
NSToolbar* toolbar = [[NSToolbar alloc] initWithIdentifier:@"MacPDFToolbar"];
|
||||
toolbar.delegate = self;
|
||||
toolbar.displayMode = NSToolbarDisplayModeIconOnly;
|
||||
[window setToolbar:toolbar];
|
||||
|
||||
_pdfDocument = document;
|
||||
return self;
|
||||
}
|
||||
|
@ -73,4 +78,25 @@
|
|||
[NSString stringWithFormat:@"Page %d of %d", [_pdfView page], _pdfDocument.pdf->get_page_count()]];
|
||||
}
|
||||
|
||||
#pragma mark - NSToolbarDelegate
|
||||
|
||||
- (NSArray<NSToolbarItemIdentifier>*)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar
|
||||
{
|
||||
return [self toolbarDefaultItemIdentifiers:toolbar];
|
||||
}
|
||||
|
||||
- (NSArray<NSToolbarItemIdentifier>*)toolbarDefaultItemIdentifiers:(NSToolbar*)toolbar
|
||||
{
|
||||
return @[ NSToolbarToggleSidebarItemIdentifier ];
|
||||
}
|
||||
|
||||
- (NSToolbarItem*)toolbar:(NSToolbar*)toolbar
|
||||
itemForItemIdentifier:(NSToolbarItemIdentifier)itemIdentifier
|
||||
willBeInsertedIntoToolbar:(BOOL)flag
|
||||
{
|
||||
// Not called for standard identifiers, but the implementation of the method must exist, or else:
|
||||
// ERROR: invalid delegate <MacPDFWindowController: 0x600003054c80> (does not implement all required methods)
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue