Revision: 12996
http://bibdesk.svn.sourceforge.net/bibdesk/?rev=12996&view=rev
Author: hofman
Date: 2008-03-07 10:06:04 -0800 (Fri, 07 Mar 2008)
Log Message:
-----------
Replace icon types by boolean ivars. Bring back HTML text icons for 10.4
workaround of crasher.
Modified Paths:
--------------
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon_Private.h
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.h
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.h
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVWebViewIcon.m
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon_Private.h
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon_Private.h 2008-03-07
16:17:29 UTC (rev 12995)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon_Private.h 2008-03-07
18:06:04 UTC (rev 12996)
@@ -46,13 +46,6 @@
#import <libkern/OSAtomic.h>
#import "FVUtilities.h"
-// For subclasses that handle multiple types with minor variation. This is
deprecated; it used have half-a-dozen types, but most of it is now handled by
members of the class cluster, so the enum may eventually go away entirely.
-enum {
- FVPDFType,
- FVPostscriptType
-};
-typedef NSUInteger FVIconType;
-
// Desired size: should be the same size passed to -[FVIcon
needsRenderForSize:] and -[FVIcon _drawingRectWithRect:], not the return value
of _drawingRectWithRect:. Thumbnail size: current size of the instance's
thumbnail image, if it has one (and if not, it shouldn't be calling this).
static inline bool FVShouldDrawFullImageWithThumbnailSize(const NSSize
desiredSize, const NSSize thumbnailSize)
{
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.h
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.h 2008-03-07
16:17:29 UTC (rev 12995)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.h 2008-03-07
18:06:04 UTC (rev 12996)
@@ -50,7 +50,7 @@
CGImageRef _thumbnail;
NSSize _thumbnailSize;
NSSize _desiredSize;
- FVIconType _iconType;
+ BOOL _isPostscript;
BOOL _inDiskCache;
char *_diskCacheName;
pthread_mutex_t _mutex;
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.m 2008-03-07
16:17:29 UTC (rev 12995)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.m 2008-03-07
18:06:04 UTC (rev 12996)
@@ -104,7 +104,7 @@
NSParameterAssert([aURL isFileURL]);
self = [self initWithPDFAtURL:aURL];
if (self) {
- _iconType = FVPostscriptType;
+ _isPostscript = YES;
}
return self;
}
@@ -141,7 +141,7 @@
_fullSize = _paperSize;
_thumbnailSize = _fullSize;
_diskCacheName = [FVIconCache createDiskCacheNameWithURL:aURL];
- _iconType = FVPDFType;
+ _isPostscript = NO;
_pdfDoc = NULL;
_pdfPage = NULL;
_thumbnail = NULL;
@@ -178,17 +178,14 @@
- (BOOL)canReleaseResources;
{
- if (FVPostscriptType != _iconType)
- return (NULL != _pdfDoc || NULL != _thumbnail);
- else
- return (NULL != _thumbnail);
+ return _isPostscript ? (NULL != _thumbnail) : (NULL != _pdfDoc || NULL !=
_thumbnail);
}
- (void)releaseResources
{
if ([self tryLock]) {
// Too expensive to create from PostScript on the fly, and PS is not
that common; however, a CGPDFDocument data provider is the same size as the
file on disk, so we want to get rid of them unless we're drawing full
resolution.
- if (FVPostscriptType != _iconType) {
+ if (_isPostscript != NO) {
CGPDFDocumentRelease(_pdfDoc);
_pdfDoc = NULL;
_pdfPage = NULL;
@@ -269,10 +266,7 @@
if (NULL == _pdfPage) {
if (NULL == _pdfDoc) {
- if (FVPostscriptType == _iconType)
- _pdfDoc = createCGPDFDocumentWithPostScriptURL(_fileURL);
- else
- _pdfDoc = CGPDFDocumentCreateWithURL((CFURLRef)_fileURL);
+ _pdfDoc = _isPostscript ?
createCGPDFDocumentWithPostScriptURL(_fileURL) :
CGPDFDocumentCreateWithURL((CFURLRef)_fileURL);
_pageCount = CGPDFDocumentGetNumberOfPages(_pdfDoc);
}
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.h
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.h 2008-03-07
16:17:29 UTC (rev 12995)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.h 2008-03-07
18:06:04 UTC (rev 12996)
@@ -50,7 +50,7 @@
NSSize _desiredSize;
NSURL *_fileURL;
char *_diskCacheName;
- FVIconType _iconType;
+ BOOL _isHTML;
BOOL _drawsLinkBadge;
pthread_mutex_t _mutex;
}
@@ -58,5 +58,6 @@
+ (BOOL)canInitWithUTI:(NSString *)aUTI;
+ (BOOL)canInitWithURL:(NSURL *)aURL;
- (id)initWithTextAtURL:(NSURL *)aURL;
+- (id)initWithHTMLAtURL:(NSURL *)aURL;
@end
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.m 2008-03-07
16:17:29 UTC (rev 12995)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.m 2008-03-07
18:06:04 UTC (rev 12996)
@@ -187,7 +187,8 @@
_fullImage = NULL;
_thumbnail = NULL;
_diskCacheName = [FVIconCache createDiskCacheNameWithURL:_fileURL];
-
+ _isHTML = NO;
+
NSInteger rc = pthread_mutex_init(&_mutex, NULL);
if (rc)
perror("pthread_mutex_init");
@@ -195,6 +196,15 @@
return self;
}
+// return the same thing as text; just a container for the URL, until actually
asked to render the text file
+- (id)initWithHTMLAtURL:(NSURL *)aURL;
+{
+ if (self = [self initWithTextAtURL:aURL]) {
+ _isHTML = YES;
+ }
+ return self;
+}
+
- (void)dealloc
{
pthread_mutex_destroy(&_mutex);
@@ -291,6 +301,16 @@
[self unlock];
}
+- (void)_loadHTML:(NSMutableDictionary *)HTMLDict {
+ NSDictionary *documentAttributes = nil;
+ NSAttributedString *attrString = [[NSAttributedString alloc]
initWithURL:_fileURL documentAttributes:&documentAttributes];
+ if (attrString)
+ [HTMLDict setObject:attrString forKey:@"attributedString"];
+ if (documentAttributes)
+ [HTMLDict setObject:documentAttributes forKey:@"documentAttributes"];
+ [attrString release];
+}
+
- (void)renderOffscreen
{
// hold the lock to let needsRenderForSize: know that this icon doesn't
need rendering
@@ -336,8 +356,17 @@
// no need to lock for -fileURL since it's invariant
NSDictionary *documentAttributes = nil;
- NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc]
initWithURL:_fileURL documentAttributes:&documentAttributes];
+ NSMutableAttributedString *attrString = nil;
+ if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_4 && _isHTML) {
+ NSMutableDictionary *HTMLDict = [NSMutableDictionary dictionary];
+ [self performSelectorOnMainThread:@selector(_loadHTML:)
withObject:HTMLDict waitUntilDone:YES];
+ attrString = [[HTMLDict objectForKey:@"attributedString"] mutableCopy];
+ documentAttributes = [HTMLDict objectForKey:@"documentAttributes"];
+ } else {
+ attrString = [[NSMutableAttributedString alloc] initWithURL:_fileURL
documentAttributes:&documentAttributes];
+ }
+
CGAffineTransform pageTransform = _paperTransform;
NSSize containerSize = _containerSize;
NSSize paperSize = _paperSize;
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVWebViewIcon.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVWebViewIcon.m 2008-03-07
16:17:29 UTC (rev 12995)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVWebViewIcon.m 2008-03-07
18:06:04 UTC (rev 12996)
@@ -105,7 +105,7 @@
NSZone *zone = [self zone];
[self release];
if ([aURL isFileURL])
- self = [[FVTextIcon allocWithZone:zone] initWithURL:aURL];
+ self = [[FVTextIcon allocWithZone:zone] initWithHTMLAtURL:aURL];
else
self = [[FVFinderIcon allocWithZone:zone]
initWithFinderIconOfURL:aURL];
}
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 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit