Revision: 2682
          http://skim-app.svn.sourceforge.net/skim-app/?rev=2682&view=rev
Author:   hofman
Date:     2007-08-18 11:50:01 -0700 (Sat, 18 Aug 2007)

Log Message:
-----------
Open bookmark by double-clicking on a row.

Modified Paths:
--------------
    trunk/Dutch.lproj/BookmarksWindow.nib/keyedobjects.nib
    trunk/English.lproj/BookmarksWindow.nib/keyedobjects.nib
    trunk/French.lproj/BookmarksWindow.nib/keyedobjects.nib
    trunk/Italian.lproj/BookmarksWindow.nib/keyedobjects.nib
    trunk/SKApplicationController.m
    trunk/SKBookmarkController.h
    trunk/SKBookmarkController.m
    trunk/Skim.xcodeproj/project.pbxproj

Added Paths:
-----------
    trunk/NSFileManager_SKExtensions.h
    trunk/NSFileManager_SKExtensions.m

Modified: trunk/Dutch.lproj/BookmarksWindow.nib/keyedobjects.nib
===================================================================
(Binary files differ)

Modified: trunk/English.lproj/BookmarksWindow.nib/keyedobjects.nib
===================================================================
(Binary files differ)

Modified: trunk/French.lproj/BookmarksWindow.nib/keyedobjects.nib
===================================================================
(Binary files differ)

Modified: trunk/Italian.lproj/BookmarksWindow.nib/keyedobjects.nib
===================================================================
(Binary files differ)

Added: trunk/NSFileManager_SKExtensions.h
===================================================================
--- trunk/NSFileManager_SKExtensions.h                          (rev 0)
+++ trunk/NSFileManager_SKExtensions.h  2007-08-18 18:50:01 UTC (rev 2682)
@@ -0,0 +1,44 @@
+//
+//  NSFileManager_SKExtensions.h
+//  Skim
+//
+//  Created by Christiaan Hofman on 8/18/07.
+/*
+ This software is Copyright (c) 2007
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+    contributors may be used to endorse or promote products derived
+    from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Cocoa/Cocoa.h>
+
+
[EMAIL PROTECTED] NSFileManager (SKExtensions)
+- (BOOL)fileIsInTrash:(NSURL *)fileURL;
[EMAIL PROTECTED]

Added: trunk/NSFileManager_SKExtensions.m
===================================================================
--- trunk/NSFileManager_SKExtensions.m                          (rev 0)
+++ trunk/NSFileManager_SKExtensions.m  2007-08-18 18:50:01 UTC (rev 2682)
@@ -0,0 +1,63 @@
+//
+//  NSFileManager_SKExtensions.m
+//  Skim
+//
+//  Created by Christiaan Hofman on 8/18/07.
+/*
+ This software is Copyright (c) 2007
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+    contributors may be used to endorse or promote products derived
+    from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "NSFileManager_SKExtensions.h"
+#import <Carbon/Carbon.h>
+
[EMAIL PROTECTED] NSFileManager (SKExtensions)
+
+- (BOOL)fileIsInTrash:(NSURL *)fileURL {
+    NSCParameterAssert([fileURL isFileURL]);    
+    FSRef parentRef;
+    CFURLRef parentURL = 
CFURLCreateCopyDeletingLastPathComponent(CFGetAllocator((CFURLRef)fileURL), 
(CFURLRef)fileURL);
+    [(id)parentURL autorelease];
+    if (CFURLGetFSRef(parentURL, &parentRef)) {
+        OSStatus err;
+        FSRef fsRef;
+        err = FSFindFolder(kUserDomain, kTrashFolderType, TRUE, &fsRef);
+        if (noErr == err && noErr == FSCompareFSRefs(&fsRef, &parentRef))
+            return YES;
+        
+        err = FSFindFolder(kOnAppropriateDisk, kSystemTrashFolderType, TRUE, 
&fsRef);
+        if (noErr == err && noErr == FSCompareFSRefs(&fsRef, &parentRef))
+            return YES;
+    }
+    return NO;
+}
+
[EMAIL PROTECTED]

Modified: trunk/SKApplicationController.m
===================================================================
--- trunk/SKApplicationController.m     2007-08-18 17:05:16 UTC (rev 2681)
+++ trunk/SKApplicationController.m     2007-08-18 18:50:01 UTC (rev 2682)
@@ -55,6 +55,7 @@
 #import "SKDownloadController.h"
 #import "NSURL_SKExtensions.h"
 #import "SKDocumentController.h"
+#import "NSFileManager_SKExtensions.h"
 
 
 @implementation SKApplicationController
@@ -88,26 +89,6 @@
     [[NSUserDefaultsController sharedUserDefaultsController] 
setInitialValues:initialValuesDict];
 }
 
-static BOOL fileIsInTrash(NSURL *fileURL)
-{
-    NSCParameterAssert([fileURL isFileURL]);    
-    FSRef parentRef;
-    CFURLRef parentURL = 
CFURLCreateCopyDeletingLastPathComponent(CFGetAllocator((CFURLRef)fileURL), 
(CFURLRef)fileURL);
-    [(id)parentURL autorelease];
-    if (CFURLGetFSRef(parentURL, &parentRef)) {
-        OSStatus err;
-        FSRef fsRef;
-        err = FSFindFolder(kUserDomain, kTrashFolderType, TRUE, &fsRef);
-        if (noErr == err && noErr == FSCompareFSRefs(&fsRef, &parentRef))
-            return YES;
-        
-        err = FSFindFolder(kOnAppropriateDisk, kSystemTrashFolderType, TRUE, 
&fsRef);
-        if (noErr == err && noErr == FSCompareFSRefs(&fsRef, &parentRef))
-            return YES;
-    }
-    return NO;
-}
-
 - (void)awakeFromNib {
     NSMenu *viewMenu = [[[NSApp mainMenu] itemAtIndex:4] submenu];
     int i, count = [viewMenu numberOfItems];
@@ -137,7 +118,7 @@
             fileURL = [[BDAlias aliasWithData:[dict objectForKey:@"_BDAlias"]] 
fileURL];
             if(fileURL == nil && [dict objectForKey:@"fileName"])
                 fileURL = [NSURL fileURLWithPath:[dict 
objectForKey:@"fileName"]];
-            if(fileURL && NO == fileIsInTrash(fileURL)) {
+            if(fileURL && NO == [[NSFileManager defaultManager] 
fileIsInTrash:fileURL]) {
                 if (document = [[NSDocumentController 
sharedDocumentController] openDocumentWithContentsOfURL:fileURL display:NO 
error:&error]) {
                     [document makeWindowControllers];
                     if ([document 
respondsToSelector:@selector(mainWindowController)])
@@ -234,19 +215,8 @@
     int i = [sender tag];
     NSArray *bookmarks = [[SKBookmarkController sharedBookmarkController] 
bookmarks];
     NSDictionary *bm = [bookmarks objectAtIndex:i];
-    id document = nil;
-    NSURL *fileURL = [[BDAlias aliasWithData:[bm objectForKey:@"_BDAlias"]] 
fileURL];
-    NSError *error;
     
-    if (fileURL == nil && [bm objectForKey:@"path"])
-        fileURL = [NSURL fileURLWithPath:[bm objectForKey:@"path"]];
-    if (fileURL && NO == fileIsInTrash(fileURL)) {
-        if (document = [[NSDocumentController sharedDocumentController] 
openDocumentWithContentsOfURL:fileURL display:YES error:&error]) {
-            [[document mainWindowController] setPageNumber:[[bm 
objectForKey:@"pageIndex"] unsignedIntValue] + 1];
-        } else {
-            [NSApp presentError:error];
-        }
-    }
+    [[SKBookmarkController sharedBookmarkController] openBookmarks:[NSArray 
arrayWithObjects:bm, nil]];
 }
 
 #pragma mark Support

Modified: trunk/SKBookmarkController.h
===================================================================
--- trunk/SKBookmarkController.h        2007-08-18 17:05:16 UTC (rev 2681)
+++ trunk/SKBookmarkController.h        2007-08-18 18:50:01 UTC (rev 2682)
@@ -52,9 +52,11 @@
 - (id)objectInBookmarksAtIndex:(unsigned)index;
 - (void)insertObject:(id)obj inBookmarksAtIndex:(unsigned)index;
 - (void)removeObjectFromBookmarksAtIndex:(unsigned)index;
+
 - (void)addBookmarkForPath:(NSString *)path pageIndex:(unsigned)pageIndex 
label:(NSString *)label;
 - (void)saveBookmarks;
 - (NSString *)bookmarksFilePath;
+- (void)openBookmarks:(NSArray *)items;
 
 - (NSArray *)recentDocuments;
 - (void)addRecentDocumentForPath:(NSString *)path 
pageIndex:(unsigned)pageIndex snapshots:(NSArray *)setups;

Modified: trunk/SKBookmarkController.m
===================================================================
--- trunk/SKBookmarkController.m        2007-08-18 17:05:16 UTC (rev 2681)
+++ trunk/SKBookmarkController.m        2007-08-18 18:50:01 UTC (rev 2682)
@@ -38,6 +38,9 @@
 
 #import "SKBookmarkController.h"
 #import "BDAlias.h"
+#import "SKDocument.h"
+#import "SKMainWindowController.h"
+#import "NSFileManager_SKExtensions.h"
 
 @implementation SKBookmarkController
 
@@ -226,6 +229,27 @@
     [self saveBookmarks];
 }
 
+- (void)openBookmarks:(NSArray *)items {
+    NSEnumerator *bmEnum = [items objectEnumerator];
+    NSDictionary *bm;
+    
+    while (bm = [bmEnum nextObject]) {
+        id document = nil;
+        NSURL *fileURL = [[BDAlias aliasWithData:[bm 
objectForKey:@"_BDAlias"]] fileURL];
+        NSError *error;
+        
+        if (fileURL == nil && [bm objectForKey:@"path"])
+            fileURL = [NSURL fileURLWithPath:[bm objectForKey:@"path"]];
+        if (fileURL && NO == [[NSFileManager defaultManager] 
fileIsInTrash:fileURL]) {
+            if (document = [[NSDocumentController sharedDocumentController] 
openDocumentWithContentsOfURL:fileURL display:YES error:&error]) {
+                [[document mainWindowController] setPageNumber:[[bm 
objectForKey:@"pageIndex"] unsignedIntValue] + 1];
+            } else {
+                [NSApp presentError:error];
+            }
+        }
+    }
+}
+
 @end
 
 

Modified: trunk/Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/Skim.xcodeproj/project.pbxproj        2007-08-18 17:05:16 UTC (rev 
2681)
+++ trunk/Skim.xcodeproj/project.pbxproj        2007-08-18 18:50:01 UTC (rev 
2682)
@@ -176,6 +176,7 @@
                CEF711A10B90B714003A2771 /* 
NSUserDefaultsController_SKExtensions.m in Sources */ = {isa = PBXBuildFile; 
fileRef = CEF711A00B90B714003A2771 /* NSUserDefaultsController_SKExtensions.m 
*/; };
                CEF7175C0B90DEEF003A2771 /* ReleaseNotes.nib in Resources */ = 
{isa = PBXBuildFile; fileRef = CEF717560B90DEEF003A2771 /* ReleaseNotes.nib */; 
};
                CEF7175F0B90DF10003A2771 /* SKReleaseNotesController.m in 
Sources */ = {isa = PBXBuildFile; fileRef = CEF7175E0B90DF10003A2771 /* 
SKReleaseNotesController.m */; };
+               CEF839B30C77742A00A3AD51 /* NSFileManager_SKExtensions.m in 
Sources */ = {isa = PBXBuildFile; fileRef = CEF839B10C77742A00A3AD51 /* 
NSFileManager_SKExtensions.m */; };
                CEFD68740C01D4080027B933 /* SkimImporter.mdimporter in 
CopyFiles */ = {isa = PBXBuildFile; fileRef = CEFD68690C01D3BB0027B933 /* 
SkimImporter.mdimporter */; };
                CEFDF8BE0B3848C40091C61A /* SKNavigationWindow.m in Sources */ 
= {isa = PBXBuildFile; fileRef = CEFDF8BD0B3848C40091C61A /* 
SKNavigationWindow.m */; };
                F92DB5AC0B36FE1F002A26E9 /* BDSKHeaderPopUpButtonCell.m in 
Sources */ = {isa = PBXBuildFile; fileRef = F92DB5A90B36FE1F002A26E9 /* 
BDSKHeaderPopUpButtonCell.m */; };
@@ -575,6 +576,8 @@
                CEF717570B90DEEF003A2771 /* English */ = {isa = 
PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = 
English.lproj/ReleaseNotes.nib; sourceTree = "<group>"; };
                CEF7175D0B90DF10003A2771 /* SKReleaseNotesController.h */ = 
{isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; 
path = SKReleaseNotesController.h; sourceTree = "<group>"; };
                CEF7175E0B90DF10003A2771 /* SKReleaseNotesController.m */ = 
{isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = 
sourcecode.c.objc; path = SKReleaseNotesController.m; sourceTree = "<group>"; };
+               CEF839B00C77742A00A3AD51 /* NSFileManager_SKExtensions.h */ = 
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; 
path = NSFileManager_SKExtensions.h; sourceTree = "<group>"; };
+               CEF839B10C77742A00A3AD51 /* NSFileManager_SKExtensions.m */ = 
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.c.objc; path = NSFileManager_SKExtensions.m; sourceTree = "<group>"; 
};
                CEFD68610C01D3BB0027B933 /* SkimImporter.xcodeproj */ = {isa = 
PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = 
SkimImporter.xcodeproj; path = SkimImporter/SkimImporter.xcodeproj; sourceTree 
= "<group>"; };
                CEFDF8BC0B3848C40091C61A /* SKNavigationWindow.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
SKNavigationWindow.h; sourceTree = "<group>"; };
                CEFDF8BD0B3848C40091C61A /* SKNavigationWindow.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= SKNavigationWindow.m; sourceTree = "<group>"; };
@@ -778,6 +781,8 @@
                                CE2DE4ED0B85DB6300D0DA12 /* 
NSCursor_SKExtensions.m */,
                                CE5487BA0B35A20A00F8AFB6 /* 
NSFileManager_ExtendedAttributes.h */,
                                CE5487BB0B35A20A00F8AFB6 /* 
NSFileManager_ExtendedAttributes.m */,
+                               CEF839B00C77742A00A3AD51 /* 
NSFileManager_SKExtensions.h */,
+                               CEF839B10C77742A00A3AD51 /* 
NSFileManager_SKExtensions.m */,
                                CECDC4FC0C5966A80026AAEC /* 
NSImage_SKExtensions.h */,
                                CECDC4FD0C5966A80026AAEC /* 
NSImage_SKExtensions.m */,
                                CE6C03EE0BEDF759007BF0B5 /* 
NSParagraphStyle_SKExtensions.h */,
@@ -1450,6 +1455,7 @@
                                CEAA559E0C6DE235006BD633 /* SKDownload.m in 
Sources */,
                                CEAA55B70C6DE452006BD633 /* SKProgressCell.m in 
Sources */,
                                CEAA67260C70A882006BD633 /* 
NSURL_SKExtensions.m in Sources */,
+                               CEF839B30C77742A00A3AD51 /* 
NSFileManager_SKExtensions.m in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };


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: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to