Revision: 16137
http://sourceforge.net/p/skim-app/code/16137
Author: hofman
Date: 2026-04-01 14:40:46 +0000 (Wed, 01 Apr 2026)
Log Message:
-----------
use notifications to notify changes to canSelectNotes in pdfview and to
hasOverview in main wwindow controller, observed by note toolbar and touch bar
Modified Paths:
--------------
trunk/SKMainTouchBarController.h
trunk/SKMainTouchBarController.m
trunk/SKMainWindowController.h
trunk/SKMainWindowController.m
trunk/SKMainWindowController_Actions.m
trunk/SKNoteToolbarController.h
trunk/SKNoteToolbarController.m
trunk/SKPDFView.h
trunk/SKPDFView.m
Modified: trunk/SKMainTouchBarController.h
===================================================================
--- trunk/SKMainTouchBarController.h 2026-03-31 22:21:23 UTC (rev 16136)
+++ trunk/SKMainTouchBarController.h 2026-04-01 14:40:46 UTC (rev 16137)
@@ -61,10 +61,7 @@
- (NSTouchBar *)makeTouchBar;
-- (void)handleToolModeChangedNotification:(nullable NSNotification
*)notification;
- (void)interactionModeChanged;
-- (void)overviewChanged;
-- (void)canSelectNoteChanged;
@end
Modified: trunk/SKMainTouchBarController.m
===================================================================
--- trunk/SKMainTouchBarController.m 2026-03-31 22:21:23 UTC (rev 16136)
+++ trunk/SKMainTouchBarController.m 2026-04-01 14:40:46 UTC (rev 16137)
@@ -81,6 +81,8 @@
- (void)handlePageChangedNotification:(NSNotification *)notification;
- (void)handleToolModeChangedNotification:(NSNotification *)notification;
- (void)handleAnnotationModeChangedNotification:(NSNotification *)notification;
+- (void)handleCanSelectNoteChangedNotification:(NSNotification *)notification;
+- (void)handleOverviewChangedNotification:(NSNotification *)notification;
@end
@@ -145,7 +147,7 @@
zoomInActualOutButton = [NSSegmentedControl
segmentedControlWithImages:images trackingMode:NSSegmentSwitchTrackingMomentary
target:self action:@selector(zoomInActualOut:)];
[zoomInActualOutButton
setSegmentStyle:NSSegmentStyleSeparated];
[self handleScaleChangedNotification:nil];
- [self overviewChanged];
+ [self handleOverviewChangedNotification:nil];
}
item = [[NSCustomTouchBarItem alloc]
initWithIdentifier:identifier];
[(NSCustomTouchBarItem *)item setView:zoomInActualOutButton];
@@ -415,6 +417,10 @@
[annotationModeButton selectSegmentWithTag:[mainController.pdfView
annotationMode]];
}
+- (void)handleCanSelectNoteChangedNotification:(NSNotification *)notification {
+ [noteButton setEnabled:[mainController interactionMode] !=
SKPresentationMode && [mainController hasOverview] == NO &&
[mainController.pdfView canSelectNote]];
+}
+
- (void)interactionModeChanged {
SKInteractionMode mode = [mainController interactionMode];
@@ -424,11 +430,11 @@
BOOL enabled = mode != SKPresentationMode && [mainController hasOverview]
== NO;
[toolModeButton setEnabled:enabled];
[annotationModeButton setEnabled:enabled];
- [noteButton setEnabled:enabled];
+ [noteButton setEnabled:enabled && [mainController.pdfView canSelectNote]];
[self handleScaleChangedNotification:nil];
}
-- (void)overviewChanged {
+- (void)handleOverviewChangedNotification:(NSNotification *)notification {
BOOL showPDF = [mainController hasOverview] == NO;
BOOL enabled = [mainController interactionMode] != SKPresentationMode &&
showPDF;
@@ -439,10 +445,6 @@
[zoomInActualOutButton setEnabled:showPDF];
}
-- (void)canSelectNoteChanged {
- [noteButton setEnabled:[mainController interactionMode] !=
SKPresentationMode && [mainController hasOverview] == NO &&
[mainController.pdfView canSelectNote]];
-}
-
- (void)registerForNotifications {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
@@ -456,6 +458,10 @@
name:SKPDFViewTemporaryToolModeChangedNotification
object:mainController.pdfView];
[nc addObserver:self
selector:@selector(handleAnnotationModeChangedNotification:)
name:SKPDFViewAnnotationModeChangedNotification
object:mainController.pdfView];
+ [nc addObserver:self
selector:@selector(handleCanSelectNoteChangedNotification:)
+ name:SKPDFViewCanSelectNoteDidChangeNotification
object:mainController.pdfView];
+ [nc addObserver:self selector:@selector(handleOverviewChangedNotification:)
+ name:SKMainWindowControllerDidShowOrHideOverviewNotification
object:mainController.pdfView];
}
@end
Modified: trunk/SKMainWindowController.h
===================================================================
--- trunk/SKMainWindowController.h 2026-03-31 22:21:23 UTC (rev 16136)
+++ trunk/SKMainWindowController.h 2026-04-01 14:40:46 UTC (rev 16137)
@@ -67,6 +67,8 @@
SKWindowOptionFit
};
+extern NSNotificationName const
SKMainWindowControllerDidShowOrHideOverviewNotification;
+
@class PDFAnnotation, PDFSelection, SKGroupedSearchResult;
@class SKSecondaryPDFView, SKPresentationView, SKStatusBar, SKFindController,
SKSplitView, SKFieldEditor, SKOverviewView, SKSideWindow;
@class SKLeftSideViewController, SKRightSideViewController,
SKMainToolbarController, SKMainTouchBarController, SKNoteToolbarController,
SKProgressController, SKNoteTypeSheetController, SKSnapshotWindowController,
SKTransitionController;
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2026-03-31 22:21:23 UTC (rev 16136)
+++ trunk/SKMainWindowController.m 2026-04-01 14:40:46 UTC (rev 16137)
@@ -186,6 +186,8 @@
#define SKTitleAndToolbarStyleKey @"SKTitleAndToolbarStyle"
+NSNotificationName const
SKMainWindowControllerDidShowOrHideOverviewNotification =
@"SKMainWindowControllerDidShowOrHideOverviewNotification";
+
#pragma mark -
static SKDestination destinationFromSetup(NSDictionary *setup);
@@ -1729,8 +1731,7 @@
[NSCursor setHiddenUntilMouseMoves:NO];
[[self window] makeFirstResponder:overviewView];
[[self window] recalculateKeyViewLoop];
- [touchBarController overviewChanged];
- [noteToolbarController validateButtons];
+ [[NSNotificationCenter defaultCenter]
postNotificationName:SKMainWindowControllerDidShowOrHideOverviewNotification
object:self];
}
- (void)hideOverviewAnimating:(BOOL)animate completionHandler:(void
(^)(void))handler {
@@ -1775,8 +1776,7 @@
if (handler)
handler();
}
- [touchBarController overviewChanged];
- [noteToolbarController validateButtons];
+ [[NSNotificationCenter defaultCenter]
postNotificationName:SKMainWindowControllerDidShowOrHideOverviewNotification
object:self];
if ([splitViewController
respondsToSelector:@selector(_setHasItemToRevealOnEdgeHover:)]) {
[splitViewController _setHasItemToRevealOnEdgeHover:NO];
[splitViewController _setHasItemToRevealOnEdgeHover:YES];
Modified: trunk/SKMainWindowController_Actions.m
===================================================================
--- trunk/SKMainWindowController_Actions.m 2026-03-31 22:21:23 UTC (rev
16136)
+++ trunk/SKMainWindowController_Actions.m 2026-04-01 14:40:46 UTC (rev
16137)
@@ -283,8 +283,6 @@
if ([pdfView hideNotes] == NO)
[pdfView setCurrentAnnotation:nil];
[pdfView setHideNotes:[pdfView hideNotes] == NO];
- [touchBarController canSelectNoteChanged];
- [noteToolbarController validateButtons];
}
- (IBAction)takeSnapshot:(id)sender{
Modified: trunk/SKNoteToolbarController.h
===================================================================
--- trunk/SKNoteToolbarController.h 2026-03-31 22:21:23 UTC (rev 16136)
+++ trunk/SKNoteToolbarController.h 2026-04-01 14:40:46 UTC (rev 16137)
@@ -58,8 +58,6 @@
- (void)selectFontSize:(nullable id)sender;
- (void)selectLineWidth:(nullable id)sender;
-- (void)validateButtons;
-
@end
NS_ASSUME_NONNULL_END
Modified: trunk/SKNoteToolbarController.m
===================================================================
--- trunk/SKNoteToolbarController.m 2026-03-31 22:21:23 UTC (rev 16136)
+++ trunk/SKNoteToolbarController.m 2026-04-01 14:40:46 UTC (rev 16137)
@@ -55,6 +55,7 @@
@interface SKNoteToolbarController ()
- (void)updateSizeMode;
+- (void)handleValidationChangedNotification:(NSNotification *)notification;
@end
@implementation SKNoteToolbarController
@@ -134,7 +135,9 @@
}
[fontsButton setMenu:menu forSegment:0];
- [self validateButtons];
+ [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleValidationChangedNotification:)
name:SKPDFViewCanSelectNoteDidChangeNotification object:mainController.pdfView];
+ [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleValidationChangedNotification:)
name:SKMainWindowControllerDidShowOrHideOverviewNotification
object:mainController];
+ [self handleValidationChangedNotification:nil];
NSView *view = [[NSView alloc] init];
[view addSubview:noteButton];
@@ -162,6 +165,7 @@
- (void)setMainController:(SKMainWindowController *)newMainController {
if (mainController) {
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
if (noteButton) {
@try { [[[mainController window] toolbar] removeObserver:self
forKeyPath:@"sizeMode" context:&SKToolbarObservationContext]; }
@catch (id e) {}
@@ -244,7 +248,7 @@
[linesButton setControlSize:controlSize];
}
-- (void)validateButtons {
+- (void)handleValidationChangedNotification:(NSNotification *)notification {
[noteButton setEnabled:[mainController hasOverview] == NO &&
[mainController.pdfView canSelectNote]];
}
Modified: trunk/SKPDFView.h
===================================================================
--- trunk/SKPDFView.h 2026-03-31 22:21:23 UTC (rev 16136)
+++ trunk/SKPDFView.h 2026-04-01 14:40:46 UTC (rev 16137)
@@ -58,6 +58,7 @@
extern NSNotificationName const SKPDFViewSelectionChangedNotification;
extern NSNotificationName const SKPDFViewMagnificationChangedNotification;
extern NSNotificationName const SKPDFViewPacerStartedOrStoppedNotification;
+extern NSNotificationName const SKPDFViewCanSelectNoteDidChangeNotification;
extern NSString * const SKPDFViewAnnotationKey;
extern NSString * const SKPDFViewPageKey;
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2026-03-31 22:21:23 UTC (rev 16136)
+++ trunk/SKPDFView.m 2026-04-01 14:40:46 UTC (rev 16137)
@@ -118,6 +118,7 @@
NSNotificationName const SKPDFViewSelectionChangedNotification =
@"SKPDFViewSelectionChangedNotification";
NSNotificationName const SKPDFViewMagnificationChangedNotification =
@"SKPDFViewMagnificationChangedNotification";
NSNotificationName const SKPDFViewPacerStartedOrStoppedNotification =
@"SKPDFViewPacerStartedOrStoppedNotification";
+NSNotificationName const SKPDFViewCanSelectNoteDidChangeNotification =
@"SKPDFViewCanSelectNoteDidChangeNotification";
NSString * const SKPDFViewAnnotationKey = @"annotation";
NSString * const SKPDFViewPageKey = @"page";
@@ -607,6 +608,8 @@
}
[loupeController updateContents];
+
+ [[NSNotificationCenter defaultCenter]
postNotificationName:SKPDFViewCanSelectNoteDidChangeNotification object:self];
}
- (void)setBackgroundColor:(NSColor *)newBackgroundColor {
@@ -643,6 +646,7 @@
[[NSUserDefaults standardUserDefaults] setInteger:toolMode
forKey:SKLastToolModeKey];
[[NSNotificationCenter defaultCenter]
postNotificationName:SKPDFViewToolModeChangedNotification object:self];
+ [[NSNotificationCenter defaultCenter]
postNotificationName:SKPDFViewCanSelectNoteDidChangeNotification object:self];
[self setCursorForMouse:nil];
[self resetPDFToolTipRects];
if (toolMode == SKToolModeMagnify && [[NSUserDefaults
standardUserDefaults] boolForKey:SKMagnifyWithMousePressedKey] == NO)
@@ -861,6 +865,11 @@
return undoManager;
}
+- (void)setHideNotes:(BOOL)flag {
+ hideNotes = flag;
+ [[NSNotificationCenter defaultCenter]
postNotificationName:SKPDFViewCanSelectNoteDidChangeNotification object:self];
+}
+
- (BOOL)canAddNotes {
return hideNotes == NO && [[self document] allowsNotes];
}
@@ -3121,6 +3130,8 @@
name:SKPDFDocumentWillMoveAnnotationNotification
object:pdfDoc];
[nc addObserver:self
selector:@selector(handleDidMoveAnnotationNotification:)
name:SKPDFDocumentDidMoveAnnotationNotification
object:pdfDoc];
+ [nc addObserver:self
selector:@selector(handleDocumentDidUnlockNotification:)
+ name:PDFDocumentDidUnlockNotification
object:pdfDoc];
}
- (void)unregisterForDocumentNotifications {
@@ -3131,6 +3142,7 @@
[nc removeObserver:self name:SKPDFDocumentDidRemoveAnnotationNotification
object:pdfDoc];
[nc removeObserver:self name:SKPDFDocumentWillMoveAnnotationNotification
object:pdfDoc];
[nc removeObserver:self name:SKPDFDocumentDidMoveAnnotationNotification
object:pdfDoc];
+ [nc removeObserver:self name:PDFDocumentDidUnlockNotification
object:pdfDoc];
}
- (void)handlePageChangedNotification:(NSNotification *)notification {
@@ -3177,6 +3189,10 @@
wantsNewUndoGroup = NO;
}
+- (void)handleDocumentDidUnlockNotification:(NSNotification *)notification {
+ [[NSNotificationCenter defaultCenter]
postNotificationName:SKPDFViewCanSelectNoteDidChangeNotification object:self];
+}
+
#pragma mark Key and window changes
- (void)viewWillMoveToWindow:(NSWindow *)newWindow {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit