Revision: 6782
          http://skim-app.svn.sourceforge.net/skim-app/?rev=6782&view=rev
Author:   hofman
Date:     2010-09-07 14:32:39 +0000 (Tue, 07 Sep 2010)

Log Message:
-----------
create folder bookmark from scripting when there's no file but a label. Check 
whether the file or data is a URL.

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

Modified: trunk/SKBookmark.m
===================================================================
--- trunk/SKBookmark.m  2010-09-07 13:00:53 UTC (rev 6781)
+++ trunk/SKBookmark.m  2010-09-07 14:32:39 UTC (rev 6782)
@@ -255,14 +255,17 @@
     if ([key isEqualToString:@"bookmarks"]) {
         SKBookmark *bookmark = nil;
         FourCharCode type = [[properties 
objectForKey:@"scriptingBookmarkType"] unsignedIntValue];
-        if (type == 0 && ([contentsValue isKindOfClass:[NSURL class]] || 
[properties objectForKey:@"scriptingFile"]))
-            type = SKScriptingBookmarkTypeBookmark;
+        if (type == 0) {
+            if (contentsValue || [properties objectForKey:@"scriptingFile"])
+                type = SKScriptingBookmarkTypeBookmark;
+            else if ([properties objectForKey:@"label"])
+                type = SKScriptingBookmarkTypeFolder;
+        }
         switch (type) {
             case SKScriptingBookmarkTypeBookmark:
             {
-                NSString *aPath = [[properties objectForKey:@"scriptingFile"] 
path];
-                if (aPath == nil && [contentsValue isKindOfClass:[NSURL 
class]])
-                    aPath = [contentsValue path];
+                NSURL *aURL = [properties objectForKey:@"scriptingFile"] ?: 
contentsValue;
+                NSString *aPath = [aURL respondsToSelector:@selector(path)] ? 
[aURL path] : nil;
                 NSString *aLabel = [properties objectForKey:@"label"] ?: 
[aPath lastPathComponent] ?: @"";
                 if (aPath == nil) {
                     [[NSScriptCommand currentCommand] 
setScriptErrorNumber:NSArgumentsWrongScriptError];
@@ -287,7 +290,7 @@
                 break;
             default:
                 [[NSScriptCommand currentCommand] 
setScriptErrorNumber:NSArgumentsWrongScriptError];
-                [[NSScriptCommand currentCommand] setScriptErrorString:@"New 
bookmark require a supported bookmark type."];
+                [[NSScriptCommand currentCommand] setScriptErrorString:@"New 
bookmark requires a supported bookmark type."];
                 break;
         }
         return bookmark;


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

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to