Revision: 27499
          http://sourceforge.net/p/bibdesk/svn/27499
Author:   hofman
Date:     2022-05-29 22:56:45 +0000 (Sun, 29 May 2022)
Log Message:
-----------
Pass UTI rather than MIME type to MIME icon initializer, avoid getting it 
twice. Inset network icon more.

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

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVMIMEIcon.h
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVMIMEIcon.h      2022-05-29 
16:33:56 UTC (rev 27498)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVMIMEIcon.h      2022-05-29 
22:56:45 UTC (rev 27499)
@@ -50,9 +50,9 @@
 // icons should only be created on the main thread
 
 // this class factory method uses a cached icon if available
-+ (id)newIconWithMIMEType:(NSString *)type;
++ (id)newIconWithType:(NSString *)type;
 
 // you probably want to use +newWithMIMEType:
-- (id)initWithMIMEType:(NSString *)type;
+- (id)initWithType:(NSString *)type;
 
 @end

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVMIMEIcon.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVMIMEIcon.m      2022-05-29 
16:33:56 UTC (rev 27498)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVMIMEIcon.m      2022-05-29 
22:56:45 UTC (rev 27499)
@@ -51,13 +51,13 @@
     _iconTable = [NSMutableDictionary new];
 }
 
-+ (id)newIconWithMIMEType:(NSString *)type;
++ (id)newIconWithType:(NSString *)type;
 {
     NSAssert2(pthread_main_np() != 0, @"*** threading violation *** +[%@ %@] 
requires main thread", self, NSStringFromSelector(_cmd));
     NSParameterAssert(nil != type);
     FVMIMEIcon *icon = [[_iconTable objectForKey:type] retain];
     if (nil == icon) {
-        icon = [[[self class] allocWithZone:[self zone]] 
initWithMIMEType:type];
+        icon = [[[self class] allocWithZone:[self zone]] initWithType:type];
         if (icon)
             [_iconTable setObject:icon forKey:type];
     }
@@ -64,13 +64,11 @@
     return icon;
 }
 
-- (id)initWithMIMEType:(NSString *)type;
+- (id)initWithType:(NSString *)type;
 {
     NSAssert2(pthread_main_np() != 0, @"*** threading violation *** +[%@ %@] 
requires main thread", self, NSStringFromSelector(_cmd));
     if (self = [super init]) {
-        CFTypeRef theUTI = 
UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, (CFStringRef)type, 
NULL);
-        _icon = [[[NSWorkspace sharedWorkspace] iconForFileType:(NSString 
*)theUTI ?: @""] retain];
-        if (theUTI) CFRelease(theUTI);
+        _icon = [[[NSWorkspace sharedWorkspace] iconForFileType:type] retain];
     }
     return self;
 }
@@ -96,7 +94,7 @@
     [_icon drawInRect:iconRect];
     
     // slight inset and draw partially transparent
-    NSRect networkRect = NSInsetRect(iconRect, iconRect.size.width / 7.0, 
iconRect.size.height / 7.0);
+    NSRect networkRect = NSInsetRect(iconRect, iconRect.size.width / 5.0, 
iconRect.size.height / 5.0);
     
     [_networkIcon drawInRect:networkRect fromRect:NSZeroRect 
operation:NSCompositeSourceOver fraction:0.6];
     

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVWebViewIcon.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVWebViewIcon.m   2022-05-29 
16:33:56 UTC (rev 27498)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVWebViewIcon.m   2022-05-29 
22:56:45 UTC (rev 27499)
@@ -291,7 +291,7 @@
     if ([_condLock tryLockWhenCondition:LOADING]) {
         _loadFailed = YES;
         [_fallbackIcon release];
-        _fallbackIcon = [FVMIMEIcon newIconWithMIMEType:type];
+        _fallbackIcon = [FVMIMEIcon newIconWithType:type ?: @""];
         [self unlock];
     }
 }
@@ -731,7 +731,7 @@
     }
     else if (NO == [[sender class] canShowMIMEType:type] ||
              (NULL != theUTI && FALSE == UTTypeConformsTo(theUTI, 
kUTTypeText))) {
-        [_icon _webViewReceivedUnsupportedMIMEType:type];
+        [_icon _webViewReceivedUnsupportedMIMEType:(NSString *)theUTI];
         // this triggers webView:didFailProvisionalLoadWithError:forFrame:
         [listener ignore];
     }

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



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to