Revision: 15544
          http://sourceforge.net/p/skim-app/code/15544
Author:   hofman
Date:     2025-06-24 16:26:00 +0000 (Tue, 24 Jun 2025)
Log Message:
-----------
make applicationWillNotTerminate a notification

Modified Paths:
--------------
    trunk/SKApplication.h
    trunk/SKApplication.m
    trunk/SKApplicationController.m

Modified: trunk/SKApplication.h
===================================================================
--- trunk/SKApplication.h       2025-06-24 16:16:49 UTC (rev 15543)
+++ trunk/SKApplication.h       2025-06-24 16:26:00 UTC (rev 15544)
@@ -41,11 +41,12 @@
 NS_ASSUME_NONNULL_BEGIN
 
 extern NSString *SKApplicationStartsTerminatingNotification;
+extern NSString *SKApplicationWillNotTerminateNotification;
 
 @protocol SKApplicationDelegate <NSApplicationDelegate>
 @optional
 - (void)applicationStartsTerminating:(NSNotification *)aNotification;
-- (void)applicationWillNotTerminate:(NSApplication *)application;
+- (void)applicationWillNotTerminate:(NSNotification *)aNotification;
 @end
 
 @class SPUStandardUpdaterController;

Modified: trunk/SKApplication.m
===================================================================
--- trunk/SKApplication.m       2025-06-24 16:16:49 UTC (rev 15543)
+++ trunk/SKApplication.m       2025-06-24 16:26:00 UTC (rev 15544)
@@ -45,6 +45,7 @@
 #import "SKPreferenceController.h"
 
 NSString *SKApplicationStartsTerminatingNotification = 
@"SKApplicationStartsTerminatingNotification";
+NSString *SKApplicationWillNotTerminateNotification = 
@"SKApplicationWillNotTerminateNotification";
 
 @implementation SKApplication
 
@@ -74,29 +75,33 @@
 }
 
 - (IBAction)terminate:(id)sender {
-    [[NSNotificationCenter defaultCenter] postNotification:[NSNotification 
notificationWithName:SKApplicationStartsTerminatingNotification object:self]];
+    [[NSNotificationCenter defaultCenter] 
postNotificationName:SKApplicationStartsTerminatingNotification object:self];
     [super terminate:sender];
 }
 
 // this is also called after NSDocumentController reviews unsaved documents
 - (void)replyToApplicationShouldTerminate:(BOOL)shouldTerminate {
-    if (shouldTerminate == NO && [[self delegate] 
respondsToSelector:@selector(applicationWillNotTerminate:)])
-        [[self delegate] applicationWillNotTerminate:self];
+    if (shouldTerminate == NO)
+        [[NSNotificationCenter defaultCenter] 
postNotificationName:SKApplicationWillNotTerminateNotification object:self];
     [super replyToApplicationShouldTerminate:shouldTerminate];
 }
 
-- (BOOL)willDragMouse {
-    return NSEventTypeLeftMouseDragged == [[self 
nextEventMatchingMask:(NSEventMaskLeftMouseUp | NSEventMaskLeftMouseDragged) 
untilDate:[NSDate distantFuture] inMode:NSEventTrackingRunLoopMode dequeue:NO] 
type];
-}
-
 - (void)setDelegate:(id<SKApplicationDelegate>)delegate {
     if ([[self delegate] 
respondsToSelector:@selector(applicationStartsTerminating:)])
         [[NSNotificationCenter defaultCenter] removeObserver:[self delegate] 
name:SKApplicationStartsTerminatingNotification object:self];
+    if ([[self delegate] 
respondsToSelector:@selector(applicationWillNotTerminate)])
+        [[NSNotificationCenter defaultCenter] removeObserver:[self delegate] 
name:SKApplicationWillNotTerminateNotification object:self];
     [super setDelegate:delegate];
     if ([delegate respondsToSelector:@selector(applicationStartsTerminating:)])
         [[NSNotificationCenter defaultCenter] addObserver:[self delegate] 
selector:@selector(applicationStartsTerminating:) 
name:SKApplicationStartsTerminatingNotification object:self];
+    if ([delegate respondsToSelector:@selector(applicationWillNotTerminate:)])
+        [[NSNotificationCenter defaultCenter] addObserver:[self delegate] 
selector:@selector(applicationStartsTerminating:) 
name:SKApplicationWillNotTerminateNotification object:self];
 }
 
+- (BOOL)willDragMouse {
+    return NSEventTypeLeftMouseDragged == [[self 
nextEventMatchingMask:(NSEventMaskLeftMouseUp | NSEventMaskLeftMouseDragged) 
untilDate:[NSDate distantFuture] inMode:NSEventTrackingRunLoopMode dequeue:NO] 
type];
+}
+
 #pragma mark Windows menu
 
 - (void)reorganizeWindowsItem:(NSWindow *)aWindow {

Modified: trunk/SKApplicationController.m
===================================================================
--- trunk/SKApplicationController.m     2025-06-24 16:16:49 UTC (rev 15543)
+++ trunk/SKApplicationController.m     2025-06-24 16:26:00 UTC (rev 15544)
@@ -307,7 +307,7 @@
     [self registerCurrentDocuments:nil];
 }
 
-- (void)applicationWillNotTerminate:(NSApplication *)application {
+- (void)applicationWillNotTerminate:(NSNotification *)aNotification {
     if (currentDocumentsTimer == nil)
         [self registerForCurrentDocumentsNotifications];
 }
@@ -319,6 +319,7 @@
                 [doc setInteractionMode:SKNormalMode];
                 break;
             } else {
+                return NSTerminateCancel;
                 DISPATCH_MAIN_AFTER_SEC(0.51, ^{
                     if ([doc interactionMode] != SKPresentationMode) {
                         [NSApp replyToApplicationShouldTerminate:YES];

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to