mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:57:45 +00:00
MacPDF: Add a toolbar with a standard sidebar button
This commit is contained in:
parent
1f1a596a46
commit
ae1b179474
2 changed files with 27 additions and 1 deletions
|
@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@class MacPDFDocument;
|
@class MacPDFDocument;
|
||||||
|
|
||||||
@interface MacPDFWindowController : NSWindowController <MacPDFViewDelegate>
|
@interface MacPDFWindowController : NSWindowController <MacPDFViewDelegate, NSToolbarDelegate>
|
||||||
|
|
||||||
- (instancetype)initWithDocument:(MacPDFDocument*)document;
|
- (instancetype)initWithDocument:(MacPDFDocument*)document;
|
||||||
- (IBAction)showGoToPageDialog:(id)sender;
|
- (IBAction)showGoToPageDialog:(id)sender;
|
||||||
|
|
|
@ -32,6 +32,11 @@
|
||||||
window.contentView = _pdfView;
|
window.contentView = _pdfView;
|
||||||
[_pdfView setDelegate:self];
|
[_pdfView setDelegate:self];
|
||||||
|
|
||||||
|
NSToolbar* toolbar = [[NSToolbar alloc] initWithIdentifier:@"MacPDFToolbar"];
|
||||||
|
toolbar.delegate = self;
|
||||||
|
toolbar.displayMode = NSToolbarDisplayModeIconOnly;
|
||||||
|
[window setToolbar:toolbar];
|
||||||
|
|
||||||
_pdfDocument = document;
|
_pdfDocument = document;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -73,4 +78,25 @@
|
||||||
[NSString stringWithFormat:@"Page %d of %d", [_pdfView page], _pdfDocument.pdf->get_page_count()]];
|
[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
|
@end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue