Revision: 13658
          http://sourceforge.net/p/skim-app/code/13658
Author:   hofman
Date:     2023-09-11 08:50:32 +0000 (Mon, 11 Sep 2023)
Log Message:
-----------
Allow adding notes for search results in all tool modes. Don't allow selecting 
search result except for text tool mode. Rename property.

Modified Paths:
--------------
    trunk/SKMainToolbarController.m
    trunk/SKMainTouchBarController.m
    trunk/SKMainWindowController_Actions.m
    trunk/SKMainWindowController_UI.m
    trunk/SKPDFView.h
    trunk/SKPDFView.m

Modified: trunk/SKMainToolbarController.m
===================================================================
--- trunk/SKMainToolbarController.m     2023-09-10 22:55:14 UTC (rev 13657)
+++ trunk/SKMainToolbarController.m     2023-09-11 08:50:32 UTC (rev 13658)
@@ -1044,13 +1044,13 @@
     } else if ([identifier 
isEqualToString:SKDocumentToolbarToolModeItemIdentifier]) {
         return [mainController hasOverview] == NO;
     } else if ([identifier 
isEqualToString:SKDocumentToolbarNewTextNoteItemIdentifier] || [identifier 
isEqualToString:SKDocumentToolbarNewCircleNoteItemIdentifier] || [identifier 
isEqualToString:SKDocumentToolbarNewLineItemIdentifier]) {
-        return [mainController hasOverview] == NO && [mainController.pdfView 
canAddNotes];
+        return [mainController hasOverview] == NO && [mainController.pdfView 
canSelectNote];
     } else if ([identifier 
isEqualToString:SKDocumentToolbarNewMarkupItemIdentifier]) {
-        return [mainController hasOverview] == NO && [mainController.pdfView 
canAddNotes];
+        return [mainController hasOverview] == NO && [mainController.pdfView 
canSelectNote];
     } else if ([identifier 
isEqualToString:SKDocumentToolbarNewLineItemIdentifier]) {
-        return [mainController hasOverview] == NO && [mainController.pdfView 
canAddNotes];
+        return [mainController hasOverview] == NO && [mainController.pdfView 
canSelectNote];
     } else if ([identifier 
isEqualToString:SKDocumentToolbarNewNoteItemIdentifier]) {
-        return [mainController hasOverview] == NO && [mainController.pdfView 
canAddNotes];
+        return [mainController hasOverview] == NO && [mainController.pdfView 
canSelectNote];
     } else if ([identifier 
isEqualToString:SKDocumentToolbarFullScreenItemIdentifier]) {
         return [mainController canEnterFullscreen] || [mainController 
canExitFullscreen];
     } else if ([identifier 
isEqualToString:SKDocumentToolbarPresentationItemIdentifier]) {
@@ -1074,10 +1074,10 @@
         return [mainController interactionMode] != SKPresentationMode && 
[mainController hasOverview] == NO && [mainController.pdfView.document 
allowsNotes] && ([mainController.pdfView toolMode] == SKTextToolMode || 
[mainController.pdfView toolMode] == SKNoteToolMode) && [mainController.pdfView 
hideNotes] == NO;
     } else if (action == @selector(createNewCircleNote:)) {
         [menuItem setState:[[circleNoteButton cell] tagForSegment:0] == 
[menuItem tag] ? NSOnState : NSOffState];
-        return [mainController hasOverview] == NO && [mainController.pdfView 
canAddNotes];
+        return [mainController hasOverview] == NO && [mainController.pdfView 
canSelectNote];
     } else if (action == @selector(createNewMarkupNote:)) {
         [menuItem setState:[[markupNoteButton cell] tagForSegment:0] == 
[menuItem tag] ? NSOnState : NSOffState];
-        return [mainController hasOverview] == NO && [mainController.pdfView 
canAddNotes];
+        return [mainController hasOverview] == NO && [mainController.pdfView 
canSelectNote];
     } else if (action == @selector(toggleFullScreen:)) {
         return [mainController canEnterFullscreen] || [mainController 
canExitFullscreen];
     } else if (action == @selector(togglePresentation:)) {
@@ -1253,7 +1253,7 @@
 }
 
 - (void)createNewNoteWithType:(NSInteger)type forButton:(NSSegmentedControl 
*)button {
-    if ([mainController.pdfView canAddNotes]) {
+    if ([mainController.pdfView canSelectNote]) {
         [mainController.pdfView addAnnotationWithType:type];
         if (type != [[button cell] tagForSegment:0]) {
             [[button cell] setTag:type forSegment:0];
@@ -1279,7 +1279,7 @@
 }
 
 - (IBAction)createNewNote:(id)sender {
-    if ([mainController.pdfView canAddNotes]) {
+    if ([mainController.pdfView canSelectNote]) {
         NSInteger type = [sender selectedTag];
         [mainController.pdfView addAnnotationWithType:type];
     } else NSBeep();

Modified: trunk/SKMainTouchBarController.m
===================================================================
--- trunk/SKMainTouchBarController.m    2023-09-10 22:55:14 UTC (rev 13657)
+++ trunk/SKMainTouchBarController.m    2023-09-11 08:50:32 UTC (rev 13658)
@@ -380,7 +380,7 @@
 }
 
 - (void)createNewNote:(id)sender {
-    if ([mainController.pdfView canAddNotes]) {
+    if ([mainController.pdfView canSelectNote]) {
         NSInteger type = [sender selectedSegment];
         [mainController.pdfView addAnnotationWithType:type];
     } else NSBeep();
@@ -413,7 +413,7 @@
 
 - (void)handleToolModeChangedNotification:(NSNotification *)notification {
     [toolModeButton selectSegmentWithTag:[mainController.pdfView toolMode]];
-    [noteButton setEnabled:[mainController.pdfView canAddNotes]];
+    [noteButton setEnabled:[mainController.pdfView canSelectNote]];
     if ([mainController.pdfView toolMode] == SKNoteToolMode) {
         [annotationModeButton selectSegmentWithTag:[mainController.pdfView 
annotationMode]];
     } else {

Modified: trunk/SKMainWindowController_Actions.m
===================================================================
--- trunk/SKMainWindowController_Actions.m      2023-09-10 22:55:14 UTC (rev 
13657)
+++ trunk/SKMainWindowController_Actions.m      2023-09-11 08:50:32 UTC (rev 
13658)
@@ -185,7 +185,7 @@
 }
 
 - (IBAction)createNewNote:(id)sender{
-    if ([pdfView canAddNotes])
+    if ([pdfView canSelectNote])
         [pdfView addAnnotationWithType:[sender tag]];
     else NSBeep();
 }

Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m   2023-09-10 22:55:14 UTC (rev 13657)
+++ trunk/SKMainWindowController_UI.m   2023-09-11 08:50:32 UTC (rev 13658)
@@ -1067,7 +1067,7 @@
 - (void)editNoteTextFromTable:(id)sender {
     PDFAnnotation *annotation = [sender representedObject];
     [pdfView scrollAnnotationToVisible:annotation];
-    if ([pdfView canAddNotes])
+    if ([pdfView canSelectNote])
         [pdfView setCurrentAnnotation:annotation];
     [self showNote:annotation];
     SKNoteWindowController *noteController = (SKNoteWindowController *)[self 
windowControllerForNote:annotation];
@@ -1202,9 +1202,11 @@
             if ([rowIndexes containsIndex:row] == NO)
                 rowIndexes = [NSIndexSet indexSetWithIndex:row];
             NSArray *selections = [[leftSideController.findArrayController 
arrangedObjects] objectsAtIndexes:rowIndexes];
-            item = [menu addItemWithTitle:NSLocalizedString(@"Select", @"Menu 
item title") action:@selector(selectSelections:) target:self];
-            [item setRepresentedObject:selections];
-            if ([pdfView canAddNotes]) {
+            if ([pdfView toolMode] == SKTextToolMode) {
+                item = [menu addItemWithTitle:NSLocalizedString(@"Select", 
@"Menu item title") action:@selector(selectSelections:) target:self];
+                [item setRepresentedObject:selections];
+            }
+            if ([pdfView hideNotes] == NO) {
                 item = [menu addItemWithTitle:NSLocalizedString(@"New Circle", 
@"Menu item title") action:@selector(addAnnotationForContext:) target:pdfView 
tag:SKCircleNote];
                 [item setRepresentedObject:selections];
                 item = [menu addItemWithTitle:NSLocalizedString(@"New Box", 
@"Menu item title") action:@selector(addAnnotationForContext:) target:pdfView 
tag:SKSquareNote];
@@ -1224,9 +1226,11 @@
             if ([rowIndexes containsIndex:row] == NO)
                 rowIndexes = [NSIndexSet indexSetWithIndex:row];
             NSArray *selections = 
[[[leftSideController.groupedFindArrayController arrangedObjects] 
objectsAtIndexes:rowIndexes] valueForKeyPath:@"@unionOfArrays.matches"];
-            item = [menu addItemWithTitle:NSLocalizedString(@"Select", @"Menu 
item title") action:@selector(selectSelections:) target:self];
-            [item setRepresentedObject:selections];
-            if ([pdfView canAddNotes]) {
+            if ([pdfView toolMode] == SKTextToolMode) {
+                item = [menu addItemWithTitle:NSLocalizedString(@"Select", 
@"Menu item title") action:@selector(selectSelections:) target:self];
+                [item setRepresentedObject:selections];
+            }
+            if ([pdfView hideNotes] == NO) {
                 item = [menu addItemWithTitle:NSLocalizedString(@"New Circle", 
@"Menu item title") action:@selector(addAnnotationForContext:) target:pdfView 
tag:SKCircleNote];
                 [item setRepresentedObject:selections];
                 item = [menu addItemWithTitle:NSLocalizedString(@"New Box", 
@"Menu item title") action:@selector(addAnnotationForContext:) target:pdfView 
tag:SKSquareNote];
@@ -1295,7 +1299,7 @@
                     if ([pdfView currentAnnotation] == annotation) {
                         item = [menu 
addItemWithTitle:NSLocalizedString(@"Deselect", @"Menu item title") 
action:@selector(deselectNote:) target:self];
                         [item setRepresentedObject:annotation];
-                    } else if ([pdfView canAddNotes]) {
+                    } else if ([pdfView canSelectNote]) {
                         item = [menu 
addItemWithTitle:NSLocalizedString(@"Select", @"Menu item title") 
action:@selector(selectNote:) target:self];
                         [item setRepresentedObject:annotation];
                     }
@@ -1679,7 +1683,7 @@
 - (BOOL)validateMenuItem:(NSMenuItem *)menuItem {
     SEL action = [menuItem action];
     if (action == @selector(createNewNote:)) {
-        return [pdfView canAddNotes];
+        return [pdfView canSelectNote];
     } else if (action == @selector(editNote:)) {
         PDFAnnotation *annotation = [pdfView currentAnnotation];
         return [self interactionMode] != SKPresentationMode && [self 
hasOverview] == NO && [annotation isSkimNote] && [annotation isEditable];

Modified: trunk/SKPDFView.h
===================================================================
--- trunk/SKPDFView.h   2023-09-10 22:55:14 UTC (rev 13657)
+++ trunk/SKPDFView.h   2023-09-11 08:50:32 UTC (rev 13658)
@@ -187,7 +187,7 @@
 @property (nonatomic, retain) PDFPage *currentSelectionPage;
 @property (nonatomic, readonly) CGFloat currentMagnification;
 @property (nonatomic) BOOL hideNotes;
-@property (nonatomic, readonly) BOOL canAddNotes;
+@property (nonatomic, readonly) BOOL canSelectNote;
 @property (nonatomic, readonly) BOOL hasReadingBar;
 @property (readonly) SKReadingBar *readingBar;
 @property (nonatomic) CGFloat pacerSpeed;

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2023-09-10 22:55:14 UTC (rev 13657)
+++ trunk/SKPDFView.m   2023-09-11 08:50:32 UTC (rev 13658)
@@ -270,7 +270,7 @@
 @implementation SKPDFView
 
 @synthesize toolMode, annotationMode, temporaryToolMode, interactionMode, 
currentAnnotation, readingBar, pacerSpeed, transitionController, 
typeSelectHelper, syncDot, zooming;
-@dynamic extendedDisplayMode, displaysHorizontally, displaysRightToLeft, 
hideNotes, canAddNotes, hasReadingBar, hasPacer, currentSelectionPage, 
currentSelectionRect, currentMagnification, needsRewind, editing;
+@dynamic extendedDisplayMode, displaysHorizontally, displaysRightToLeft, 
hideNotes, canSelectNote, hasReadingBar, hasPacer, currentSelectionPage, 
currentSelectionRect, currentMagnification, needsRewind, editing;
 
 + (void)initialize {
     SKINITIALIZE;
@@ -1062,7 +1062,7 @@
         [[self undoManager] setActionName:actionName];
 }
 
-- (BOOL)canAddNotes {
+- (BOOL)canSelectNote {
     return pdfvFlags.hideNotes == NO && interactionMode != SKPresentationMode 
&& (toolMode == SKTextToolMode || toolMode == SKNoteToolMode) && [[self 
document] allowsNotes];
 }
 
@@ -2224,7 +2224,7 @@
     item = [menu insertItemWithTitle:NSLocalizedString(@"Take Snapshot", 
@"Menu item title") action:@selector(takeSnapshot:) target:self atIndex:0];
     [item setRepresentedObject:pointValue];
     
-    if ([self canAddNotes]) {
+    if ([self canSelectNote]) {
         
         [menu insertItem:[NSMenuItem separatorItem] atIndex:0];
         
@@ -2893,7 +2893,7 @@
     if (annotation == nil || [self isEditingAnnotation:annotation])
         return;
     
-    if ([self canAddNotes] && [self window]) {
+    if ([self canSelectNote] && [self window]) {
         if (currentAnnotation != annotation)
             [self setCurrentAnnotation:annotation];
         [self editCurrentAnnotation:nil];
@@ -3486,11 +3486,11 @@
             return YES;
         return NO;
     } else if (action == @selector(paste:)) {
-        return [self canAddNotes] && [[NSPasteboard generalPasteboard] 
canReadObjectForClasses:@[[PDFAnnotation class], [NSString class]] options:@{}];
+        return [self canSelectNote] && [[NSPasteboard generalPasteboard] 
canReadObjectForClasses:@[[PDFAnnotation class], [NSString class]] options:@{}];
     } else if (action == @selector(alternatePaste:)) {
-        return [self canAddNotes] && [[NSPasteboard generalPasteboard] 
canReadObjectForClasses:@[[PDFAnnotation class], [NSAttributedString class], 
[NSString class]] options:@{}];
+        return [self canSelectNote] && [[NSPasteboard generalPasteboard] 
canReadObjectForClasses:@[[PDFAnnotation class], [NSAttributedString class], 
[NSString class]] options:@{}];
     } else if (action == @selector(pasteAsPlainText:)) {
-        return [self canAddNotes] && [[NSPasteboard generalPasteboard] 
canReadObjectForClasses:@[[NSAttributedString class], [NSString class]] 
options:@{}];
+        return [self canSelectNote] && [[NSPasteboard generalPasteboard] 
canReadObjectForClasses:@[[NSAttributedString class], [NSString class]] 
options:@{}];
     } else if (action == @selector(delete:)) {
         return [currentAnnotation isSkimNote];
     } else if (action == @selector(selectAll:)) {

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