Revision: 12257
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=12257&view=rev
Author:   amaxwell
Date:     2008-01-04 11:22:08 -0800 (Fri, 04 Jan 2008)

Log Message:
-----------
Handle a Quick Look of multiple selected items using qlmanage on 10.5, and 
degrade to using the first file URL selected on 10.4.

Modified Paths:
--------------
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPreviewer.h
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPreviewer.m
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FileView.m

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPreviewer.h
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPreviewer.h     2008-01-04 
18:52:34 UTC (rev 12256)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPreviewer.h     2008-01-04 
19:22:08 UTC (rev 12257)
@@ -52,7 +52,15 @@
     
     NSTask                     *qlTask;
 }
+
+// this uses Quick Look as a fallback on 10.5, and uses our pseudo-Quick Look 
the rest of the time (which allows copy-paste)
 + (void)previewURL:(NSURL *)absoluteURL;
+
+// on 10.5, this uses Quick Look unconditionally to preview all items, so you 
get the cool slideshow features (but no copy-paste)
+// on 10.4, it just previews the first URL in the list
+// non file: URLs are ignored in either case
++ (void)previewFileURLs:(NSArray *)absoluteURLs;
+
 + (BOOL)isPreviewing;
 + (void)setWebViewContextMenuDelegate:(id)anObject;
 @end

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPreviewer.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPreviewer.m     2008-01-04 
18:52:34 UTC (rev 12256)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPreviewer.m     2008-01-04 
19:22:08 UTC (rev 12257)
@@ -57,6 +57,11 @@
     [[self sharedInstance] previewURL:absoluteURL];
 }
 
++ (void)previewFileURLs:(NSArray *)absoluteURLs;
+{
+    [[self sharedInstance] previewFileURLs:absoluteURLs];
+}
+
 + (BOOL)isPreviewing;
 {
     return [[self sharedInstance] isPreviewing];
@@ -293,6 +298,42 @@
     }
 }
 
+- (void)previewFileURLs:(NSArray *)absoluteURLs;
+{
+    if ([qlTask isRunning]) {
+        [qlTask terminate];
+        [qlTask release];
+        
+        // set to nil, since we may alternate between QL and our own previewing
+        qlTask = nil;
+    }
+    
+    NSMutableArray *paths = [NSMutableArray array];
+    NSUInteger cnt = [absoluteURLs count];
+    
+    // ignore non-file URLs; this isn't technically necessary for our 
pseudo-Quick Look, but it's consistent
+    while (cnt--)
+        if ([[absoluteURLs objectAtIndex:cnt] isFileURL])
+            [paths insertObject:[[absoluteURLs objectAtIndex:cnt] path] 
atIndex:0];
+    
+    if ([paths count] && [[NSFileManager defaultManager] 
isExecutableFileAtPath:@"/usr/bin/qlmanage"]) {
+        
+        NSMutableArray *args = paths;
+        [args insertObject:@"-p" atIndex:0];
+        
+        qlTask = [[NSTask alloc] init];
+        [qlTask setLaunchPath:@"/usr/bin/qlmanage"];
+        [qlTask setArguments:args];
+        // qlmanage is really verbose, so don't fill the log with its spew
+        [qlTask setStandardError:[NSFileHandle fileHandleWithNullDevice]];
+        [qlTask setStandardOutput:[NSFileHandle fileHandleWithNullDevice]];
+        [qlTask launch];
+    }
+    else if([paths count]) {
+        [[self class] previewURL:[NSURL fileURLWithPath:[paths 
objectAtIndex:0]]];
+    }
+}
+
 - (void)previewURL:(NSURL *)absoluteURL;
 {
     

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FileView.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FileView.m        2008-01-04 
18:52:34 UTC (rev 12256)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FileView.m        2008-01-04 
19:22:08 UTC (rev 12257)
@@ -2055,8 +2055,14 @@
 
 - (IBAction)previewAction:(id)sender;
 {
-    [FVPreviewer setWebViewContextMenuDelegate:[self delegate]];
-    [FVPreviewer previewURL:[[self _selectedURLs] lastObject]];
+    if ([_selectedIndexes count] == 1) {
+        [FVPreviewer setWebViewContextMenuDelegate:[self delegate]];
+        [FVPreviewer previewURL:[[self _selectedURLs] lastObject]];
+    }
+    else {
+        [FVPreviewer setWebViewContextMenuDelegate:nil];
+        [FVPreviewer previewFileURLs:[self _selectedURLs]];
+    }
 }
 
 - (IBAction)delete:(id)sender;
@@ -2116,7 +2122,7 @@
     else if (action == @selector(selectAll:))
         return ([self numberOfIcons] > 0);
     else if (action == @selector(previewAction:))
-        return (nil != aURL) && [_selectedIndexes count] == 1;
+        return (nil != aURL) && [_selectedIndexes count] >= 1;
     else if (action == @selector(paste:))
         return [self isEditable];
     // need to handle print: and other actions


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

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to