Revision: 13621
          http://sourceforge.net/p/skim-app/code/13621
Author:   hofman
Date:     2023-08-31 09:35:13 +0000 (Thu, 31 Aug 2023)
Log Message:
-----------
let main window controller observe open/close undo group, as it always knows 
the undoManager

Modified Paths:
--------------
    trunk/SKMainWindowController_UI.m
    trunk/SKPDFView.h
    trunk/SKPDFView.m

Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m   2023-08-31 08:58:07 UTC (rev 13620)
+++ trunk/SKMainWindowController_UI.m   2023-08-31 09:35:13 UTC (rev 13621)
@@ -2133,6 +2133,10 @@
     [self updatePageLabels];
 }
 
+- (void)handleOpenOrCloseUndoGroupNotification:(NSNotification *)notification {
+    [pdfView undoManagerDidOpenOrCloseUndoGroup];
+}
+
 #pragma mark Observer registration
 
 - (void)registerForNotifications {
@@ -2167,8 +2171,12 @@
     [nc addObserver:self 
selector:@selector(handleNoteViewFrameDidChangeNotification:) 
                              name:NSViewFrameDidChangeNotification 
object:[rightSideController.noteOutlineView enclosingScrollView]];
     //  UndoManager
-    [nc addObserver:self selector:@selector(observeUndoManagerCheckpoint:) 
+    [nc addObserver:self selector:@selector(observeUndoManagerCheckpoint:)
                              name:NSUndoManagerCheckpointNotification 
object:[[self document] undoManager]];
+    [nc addObserver:self 
selector:@selector(handleOpenOrCloseUndoGroupNotification:)
+                             name:NSUndoManagerDidOpenUndoGroupNotification 
object:[[self document] undoManager]];
+    [nc addObserver:self 
selector:@selector(handleOpenOrCloseUndoGroupNotification:)
+                             name:NSUndoManagerDidCloseUndoGroupNotification 
object:[[self document] undoManager]];
     //  SKDocumentController
     [nc addObserver:self 
selector:@selector(handleWillRemoveDocumentNotification:)
                              
name:SKDocumentControllerWillRemoveDocumentNotification object:nil];

Modified: trunk/SKPDFView.h
===================================================================
--- trunk/SKPDFView.h   2023-08-31 08:58:07 UTC (rev 13620)
+++ trunk/SKPDFView.h   2023-08-31 09:35:13 UTC (rev 13621)
@@ -272,6 +272,8 @@
 
 - (NSString *)currentColorDefaultKeyForAlternate:(BOOL)isAlt;
 
+- (void)undoManagerDidOpenOrCloseUndoGroup;
+
 @end
 
 #pragma mark -

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2023-08-31 08:58:07 UTC (rev 13620)
+++ trunk/SKPDFView.m   2023-08-31 09:35:13 UTC (rev 13621)
@@ -265,7 +265,6 @@
 
 - (void)handlePageChangedNotification:(NSNotification *)notification;
 - (void)handleScaleChangedNotification:(NSNotification *)notification;
-- (void)handleUndoGroupOpenedOrClosedNotification:(NSNotification 
*)notification;
 
 @end
 
@@ -3354,10 +3353,6 @@
         [self setAutoScales:YES];
 }
 
-- (void)handleUndoGroupOpenedOrClosedNotification:(NSNotification 
*)notification {
-    pdfvFlags.wantsNewUndoGroup = NO;
-}
-
 - (void)handleKeyStateChangedNotification:(NSNotification *)notification {
     atomic_store(&inKeyWindow, [[self window] isKeyWindow]);
     if (RUNNING_BEFORE(10_12) || RUNNING_AFTER(10_14)) {
@@ -3387,6 +3382,10 @@
     [self setTemporaryToolMode:SKNoToolMode];
 }
 
+- (void)undoManagerDidOpenOrCloseUndoGroup {
+    pdfvFlags.wantsNewUndoGroup = NO;
+}
+
 #pragma mark Key and window changes
 
 - (void)viewWillMoveToWindow:(NSWindow *)newWindow {
@@ -5479,14 +5478,6 @@
     if ([self delegate] && newDelegate == nil)
         [self cleanup];
     [super setDelegate:newDelegate];
-    if ([self delegate]) {
-        NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
-        NSUndoManager *undoManager = [self undoManager];
-        [nc addObserver:self 
selector:@selector(handleUndoGroupOpenedOrClosedNotification:)
-                                                     
name:NSUndoManagerDidOpenUndoGroupNotification object:undoManager];
-        [nc addObserver:self 
selector:@selector(handleUndoGroupOpenedOrClosedNotification:)
-                                                     
name:NSUndoManagerDidCloseUndoGroupNotification object:undoManager];
-    }
 }
 
 - (NSString *)currentColorDefaultKeyForAlternate:(BOOL)isAlt {

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

Reply via email to