Revision: 6910
          http://skim-app.svn.sourceforge.net/skim-app/?rev=6910&view=rev
Author:   hofman
Date:     2010-11-30 18:02:42 +0000 (Tue, 30 Nov 2010)

Log Message:
-----------
warn before opening more than 10 documents from a folder

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

Modified: trunk/SKDocumentController.m
===================================================================
--- trunk/SKDocumentController.m        2010-11-30 12:38:33 UTC (rev 6909)
+++ trunk/SKDocumentController.m        2010-11-30 18:02:42 UTC (rev 6910)
@@ -308,17 +308,32 @@
         NSString *basePath = [absoluteURL path];
         NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] 
enumeratorAtPath:basePath];
         NSString *path;
+        NSMutableArray *urls = [NSMutableArray array];
         
         while (path = [dirEnum nextObject]) {
             NSURL *url = [NSURL fileURLWithPath:[basePath 
stringByAppendingPathComponent:path]];
-            if ([self documentClassForContentsOfURL:url]) {
-                // if we had a previous error and the caller isn't ignoring 
errors, we should inform the user now, as we will lose this error
-                if (outError && error)
-                    [self presentError:error];
-                if (doc = [self openDocumentWithContentsOfURL:url 
display:displayDocument error:&error])
-                    error = nil;
-            }
+            if ([self documentClassForContentsOfURL:url])
+                [urls addObject:url];
         }
+        
+        if ([urls count] > 10) {
+            NSAlert *alert = [NSAlert alertWithMessageText:[NSString 
stringWithFormat:NSLocalizedString(@"Are you sure you want to open %lu 
documents?", @"Message in alert dialog"), (unsigned long)[urls count]]
+                                             
defaultButton:NSLocalizedString(@"Cancel", @"Button title")
+                                           
alternateButton:NSLocalizedString(@"Open", @"Button title")
+                                               otherButton:nil
+                                 
informativeTextWithFormat:NSLocalizedString(@"Each document opens in a separate 
window.", @"Informative text in alert dialog")];
+            
+            if (NSAlertDefaultReturn == [alert runModal])
+                [urls removeAllObjects];
+        }
+        
+        for (NSURL *url in urls) {
+            // if we had a previous error and the caller isn't ignoring 
errors, we should inform the user now, as we will lose this error
+            if (outError && error)
+                [self presentError:error];
+            if (doc = [self openDocumentWithContentsOfURL:url 
display:displayDocument error:&error])
+                error = nil;
+        }
         if (doc == nil && outError)
             *outError = error ?: [NSError 
errorWithDomain:SKDocumentErrorDomain code:SKReadFileError 
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Unable 
to load file", @"Error description"), NSLocalizedDescriptionKey, nil]];
         return doc;


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

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to