Revision: 13598
          http://sourceforge.net/p/skim-app/code/13598
Author:   hofman
Date:     2023-08-21 16:43:28 +0000 (Mon, 21 Aug 2023)
Log Message:
-----------
notify add/remove of temporary annotation, we may not be able to find the 
window controller form the pdfview

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

Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m   2023-08-20 23:15:39 UTC (rev 13597)
+++ trunk/SKMainWindowController_UI.m   2023-08-21 16:43:28 UTC (rev 13598)
@@ -2013,20 +2013,24 @@
     PDFAnnotation *annotation = [[notification userInfo] 
objectForKey:SKPDFViewAnnotationKey];
     PDFPage *page = [[notification userInfo] objectForKey:SKPDFViewPageKey];
     
-    if ([annotation isSkimNote] && mwcFlags.addOrRemoveNotesInBulk == 0) {
-        mwcFlags.updatingNoteSelection = 1;
-        [[self mutableArrayValueForKey:NOTES_KEY] addObject:annotation];
-        [rightSideController.noteArrayController rearrangeObjects]; // doesn't 
seem to be done automatically
-        mwcFlags.updatingNoteSelection = 0;
-        [rightSideController.noteOutlineView reloadData];
-    }
-    if (page) {
+    if ([[[notification userInfo] objectForKey:SKPDFViewTemporaryKey] 
boolValue] == NO) {
+        if ([annotation isSkimNote] && mwcFlags.addOrRemoveNotesInBulk == 0) {
+            mwcFlags.updatingNoteSelection = 1;
+            [[self mutableArrayValueForKey:NOTES_KEY] addObject:annotation];
+            [rightSideController.noteArrayController rearrangeObjects]; // 
doesn't seem to be done automatically
+            mwcFlags.updatingNoteSelection = 0;
+            [rightSideController.noteOutlineView reloadData];
+        }
+        if (page) {
+            [self updateThumbnailAtPageIndex:[page pageIndex]];
+            for (SKSnapshotWindowController *wc in snapshots) {
+                if ([wc isPageVisible:page])
+                    [self snapshotNeedsUpdate:wc];
+            }
+            [secondaryPdfView setNeedsDisplayForAnnotation:annotation 
onPage:page];
+        }
+    } else if (page) {
         [self updateThumbnailAtPageIndex:[page pageIndex]];
-        for (SKSnapshotWindowController *wc in snapshots) {
-            if ([wc isPageVisible:page])
-                [self snapshotNeedsUpdate:wc];
-        }
-        [secondaryPdfView setNeedsDisplayForAnnotation:annotation onPage:page];
     }
 }
 
@@ -2034,25 +2038,29 @@
     PDFAnnotation *annotation = [[notification userInfo] 
objectForKey:SKPDFViewAnnotationKey];
     PDFPage *page = [[notification userInfo] objectForKey:SKPDFViewPageKey];
     
-    if ([annotation isSkimNote] && mwcFlags.addOrRemoveNotesInBulk == 0) {
-        if ([[self selectedNotes] containsObject:annotation])
-            [rightSideController.noteOutlineView deselectAll:self];
-        
-        [[self windowControllerForNote:annotation] close];
-        
-        mwcFlags.updatingNoteSelection = 1;
-        [[self mutableArrayValueForKey:NOTES_KEY] removeObject:annotation];
-        [rightSideController.noteArrayController rearrangeObjects]; // doesn't 
seem to be done automatically
-        mwcFlags.updatingNoteSelection = 0;
-        [rightSideController.noteOutlineView reloadData];
-    }
-    if (page) {
+    if ([[[notification userInfo] objectForKey:SKPDFViewTemporaryKey] 
boolValue]) {
+        if ([annotation isSkimNote] && mwcFlags.addOrRemoveNotesInBulk == 0) {
+            if ([[self selectedNotes] containsObject:annotation])
+                [rightSideController.noteOutlineView deselectAll:self];
+            
+            [[self windowControllerForNote:annotation] close];
+            
+            mwcFlags.updatingNoteSelection = 1;
+            [[self mutableArrayValueForKey:NOTES_KEY] removeObject:annotation];
+            [rightSideController.noteArrayController rearrangeObjects]; // 
doesn't seem to be done automatically
+            mwcFlags.updatingNoteSelection = 0;
+            [rightSideController.noteOutlineView reloadData];
+        }
+        if (page) {
+            [self updateThumbnailAtPageIndex:[page pageIndex]];
+            for (SKSnapshotWindowController *wc in snapshots) {
+                if ([wc isPageVisible:page])
+                    [self snapshotNeedsUpdate:wc];
+            }
+            [secondaryPdfView setNeedsDisplayForAnnotation:annotation 
onPage:page];
+        }
+    } else if (page) {
         [self updateThumbnailAtPageIndex:[page pageIndex]];
-        for (SKSnapshotWindowController *wc in snapshots) {
-            if ([wc isPageVisible:page])
-                [self snapshotNeedsUpdate:wc];
-        }
-        [secondaryPdfView setNeedsDisplayForAnnotation:annotation onPage:page];
     }
 }
 

Modified: trunk/SKPDFView.h
===================================================================
--- trunk/SKPDFView.h   2023-08-20 23:15:39 UTC (rev 13597)
+++ trunk/SKPDFView.h   2023-08-21 16:43:28 UTC (rev 13598)
@@ -64,6 +64,7 @@
 extern NSString *SKPDFViewPageKey;
 extern NSString *SKPDFViewOldPageKey;
 extern NSString *SKPDFViewNewPageKey;
+extern NSString *SKPDFViewTemporaryKey;
 
 typedef NS_ENUM(NSInteger, SKToolMode) {
     SKTextToolMode,

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2023-08-20 23:15:39 UTC (rev 13597)
+++ trunk/SKPDFView.m   2023-08-21 16:43:28 UTC (rev 13598)
@@ -131,6 +131,7 @@
 NSString *SKPDFViewPageKey = @"page";
 NSString *SKPDFViewOldPageKey = @"oldPage";
 NSString *SKPDFViewNewPageKey = @"newPage";
+NSString *SKPDFViewTemporaryKey = @"temporary";
 
 #define SKMoveReadingBarModifiersKey @"SKMoveReadingBarModifiers"
 #define SKResizeReadingBarModifiersKey @"SKResizeReadingBarModifiers"
@@ -2936,7 +2937,7 @@
         [self resetPDFToolTipRects];
     if ([self isEditingAnnotation:annotation])
         [editor layoutWithEvent:nil];
-    [[NSNotificationCenter defaultCenter] 
postNotificationName:SKPDFViewDidMoveAnnotationNotification object:self 
userInfo:@{SKPDFViewOldPageKey:oldPage, SKPDFViewNewPageKey:page, 
SKPDFViewAnnotationKey:annotation}];                
+    [[NSNotificationCenter defaultCenter] 
postNotificationName:SKPDFViewDidMoveAnnotationNotification object:self 
userInfo:@{SKPDFViewOldPageKey:oldPage, SKPDFViewNewPageKey:page, 
SKPDFViewAnnotationKey:annotation}];
     [oldPage release];
 }
 
@@ -2949,7 +2950,7 @@
     [page addAnnotation:annotation];
     [self setNeedsDisplayForAnnotation:annotation];
     [self annotationsChangedOnPage:page];
-    [(SKMainWindowController *)[[self window] windowController] 
updateThumbnailAtPageIndex:[page pageIndex]];
+    [[NSNotificationCenter defaultCenter] 
postNotificationName:SKPDFViewDidAddAnnotationNotification object:self 
userInfo:@{SKPDFViewAnnotationKey:annotation, SKPDFViewPageKey:page, 
SKPDFViewTemporaryKey:@YES}];
 }
 
 - (void)removeTemporaryAnnotation:(PDFAnnotation *)annotation {
@@ -2962,7 +2963,7 @@
     [page removeAnnotation:wasAnnotation];
     [self annotationsChangedOnPage:page];
     [wasAnnotation release];
-    [(SKMainWindowController *)[[self window] windowController] 
updateThumbnailAtPageIndex:[page pageIndex]];
+    [[NSNotificationCenter defaultCenter] 
postNotificationName:SKPDFViewDidRemoveAnnotationNotification object:self 
userInfo:@{SKPDFViewAnnotationKey:wasAnnotation, SKPDFViewPageKey:page, 
SKPDFViewTemporaryKey:@YES}];
     [page release];
 }
 

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