Revision: 14769
          http://sourceforge.net/p/skim-app/code/14769
Author:   hofman
Date:     2024-11-30 16:03:09 +0000 (Sat, 30 Nov 2024)
Log Message:
-----------
separate method to run dialog to ask for option

Modified Paths:
--------------
    trunk/SKMainDocument.m

Modified: trunk/SKMainDocument.m
===================================================================
--- trunk/SKMainDocument.m      2024-11-30 15:50:52 UTC (rev 14768)
+++ trunk/SKMainDocument.m      2024-11-30 16:03:09 UTC (rev 14769)
@@ -255,6 +255,18 @@
     [[self mainWindowController] applyOptions:options];
 }
 
+- (NSInteger)definitiveOption:(NSInteger)option usingMessageText:(NSString 
*)messageText informativeText:(NSString *)informativeText {
+    if (option == SKOptionAsk) {
+        NSAlert *alert = [[NSAlert alloc] init];
+        [alert setMessageText:messageText];
+        [alert setInformativeText:informativeText];
+        [[alert addButtonWithTitle:NSLocalizedString(@"Yes", @"Button title")] 
setTag:SKOptionAlways];
+        [[alert addButtonWithTitle:NSLocalizedString(@"No", @"Button title")] 
setTag:SKOptionNever];
+        option = [alert runModal];
+    }
+    return option;
+}
+
 #pragma mark Writing
 
 - (NSString *)fileType {
@@ -900,17 +912,7 @@
             if (pdfDoc && readOption != SKOptionNever) {
                 NSURL *notesURL = [absoluteURL 
URLReplacingPathExtension:@"skim"];
                 if ([notesURL checkResourceIsReachableAndReturnError:NULL]) {
-                    if (readOption == SKOptionAsk) {
-                        NSAlert *alert = [[NSAlert alloc] init];
-                        [alert setMessageText:NSLocalizedString(@"Found 
Separate Notes", @"Message in alert dialog") ];
-                        if (foundEANotes)
-                            [alert setInformativeText:NSLocalizedString(@"A 
Skim notes file with the same name was found.  Do you want Skim to read the 
notes from this file?", @"Informative text in alert dialog")];
-                        else
-                            [alert setInformativeText:[NSString 
stringWithFormat:NSLocalizedString(@"Unable to read notes for %@, but a Skim 
notes file with the same name was found.  Do you want Skim to read the notes 
from this file?", @"Informative text in alert dialog"), [[absoluteURL path] 
stringByAbbreviatingWithTildeInPath]]];
-                        [[alert addButtonWithTitle:NSLocalizedString(@"Yes", 
@"Button title")] setTag:SKOptionAlways];
-                        [[alert addButtonWithTitle:NSLocalizedString(@"No", 
@"Button title")] setTag:SKOptionNever];
-                        readOption = [alert runModal];
-                    }
+                    readOption = [self definitiveOption:readOption 
usingMessageText:NSLocalizedString(@"Found Separate Notes", @"Message in alert 
dialog") informativeText:foundEANotes ? NSLocalizedString(@"A Skim notes file 
with the same name was found.  Do you want Skim to read the notes from this 
file?", @"Informative text in alert dialog") : [NSString 
stringWithFormat:NSLocalizedString(@"Unable to read notes for %@, but a Skim 
notes file with the same name was found.  Do you want Skim to read the notes 
from this file?", @"Informative text in alert dialog"), [[absoluteURL path] 
stringByAbbreviatingWithTildeInPath]]];
                     if (readOption == SKOptionAlways) {
                         array = [[NSFileManager defaultManager] 
readSkimNotesFromSkimFileAtURL:notesURL error:NULL];
                         if ([array count] && [array isEqualToArray:[tmpData 
noteDicts]] == NO) {
@@ -1641,14 +1643,7 @@
 
 - (void)savePasswordInKeychain:(NSString *)password {
     NSInteger saveOption = [[NSUserDefaults standardUserDefaults] 
integerForKey:SKSavePasswordOptionKey];
-    if (saveOption == SKOptionAsk) {
-        NSAlert *alert = [[NSAlert alloc] init];
-        [alert setMessageText:[NSString 
stringWithFormat:NSLocalizedString(@"Remember Password?", @"Message in alert 
dialog"), nil]];
-        [alert setInformativeText:NSLocalizedString(@"Do you want to save this 
password in your Keychain?", @"Informative text in alert dialog")];
-        [[alert addButtonWithTitle:NSLocalizedString(@"Yes", @"Button title")] 
setTag:SKOptionAlways];
-        [[alert addButtonWithTitle:NSLocalizedString(@"No", @"Button title")] 
setTag:SKOptionNever];
-        saveOption = [alert runModal];
-    }
+    saveOption = [self definitiveOption:saveOption 
usingMessageText:NSLocalizedString(@"Remember Password?", @"Message in alert 
dialog") informativeText:NSLocalizedString(@"Do you want to save this password 
in your Keychain?", @"Informative text in alert dialog")];
     if (saveOption == SKOptionAlways)
         [self _savePasswordInKeychain:password];
 }

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