mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-09-02 14:42:47 +02:00
Update Quick Look to support macOS 15
This commit is contained in:
70
Makefile
70
Makefile
@@ -342,12 +342,6 @@ LDFLAGS += -mno-outline
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
STRIP := strip
|
STRIP := strip
|
||||||
CODESIGN := true
|
|
||||||
ifeq ($(PLATFORM),Darwin)
|
|
||||||
LDFLAGS += -Wl,-exported_symbols_list,$(NULL)
|
|
||||||
STRIP := strip -x
|
|
||||||
CODESIGN := codesign -fs -
|
|
||||||
endif
|
|
||||||
LDFLAGS += -flto
|
LDFLAGS += -flto
|
||||||
CFLAGS += -flto
|
CFLAGS += -flto
|
||||||
LDFLAGS += -Wno-lto-type-mismatch # For GCC's LTO
|
LDFLAGS += -Wno-lto-type-mismatch # For GCC's LTO
|
||||||
@@ -356,6 +350,13 @@ else
|
|||||||
$(error Invalid value for CONF: $(CONF). Use "debug", "release" or "native_release")
|
$(error Invalid value for CONF: $(CONF). Use "debug", "release" or "native_release")
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
CODESIGN := true
|
||||||
|
ifeq ($(PLATFORM),Darwin)
|
||||||
|
LDFLAGS += -Wl,-exported_symbols_list,$(NULL)
|
||||||
|
STRIP := strip -x
|
||||||
|
CODESIGN := codesign -fs -
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(PLATFORM),windows32)
|
ifeq ($(PLATFORM),windows32)
|
||||||
LDFLAGS += -fuse-ld=lld
|
LDFLAGS += -fuse-ld=lld
|
||||||
endif
|
endif
|
||||||
@@ -540,7 +541,9 @@ $(BIN)/SameBoy.app: $(BIN)/SameBoy.app/Contents/MacOS/SameBoy \
|
|||||||
$(BIN)/SameBoy.app/Contents/Resources/sgb_boot.bin \
|
$(BIN)/SameBoy.app/Contents/Resources/sgb_boot.bin \
|
||||||
$(BIN)/SameBoy.app/Contents/Resources/sgb2_boot.bin \
|
$(BIN)/SameBoy.app/Contents/Resources/sgb2_boot.bin \
|
||||||
$(patsubst %.xib,%.nib,$(addprefix $(BIN)/SameBoy.app/Contents/Resources/,$(shell cd Cocoa;ls *.xib))) \
|
$(patsubst %.xib,%.nib,$(addprefix $(BIN)/SameBoy.app/Contents/Resources/,$(shell cd Cocoa;ls *.xib))) \
|
||||||
$(BIN)/SameBoy.qlgenerator \
|
$(BIN)/SameBoy.app/Contents/Library/QuickLook/SameBoy.qlgenerator \
|
||||||
|
$(BIN)/SameBoy.app/Contents/PlugIns/Thumbnailer.appex \
|
||||||
|
$(BIN)/SameBoy.app/Contents/PlugIns/Previewer.appex \
|
||||||
Shaders
|
Shaders
|
||||||
$(MKDIR) -p $(BIN)/SameBoy.app/Contents/Resources
|
$(MKDIR) -p $(BIN)/SameBoy.app/Contents/Resources
|
||||||
cp Cocoa/*.icns Cocoa/*.png Misc/registers.sym $(BIN)/SameBoy.app/Contents/Resources/
|
cp Cocoa/*.icns Cocoa/*.png Misc/registers.sym $(BIN)/SameBoy.app/Contents/Resources/
|
||||||
@@ -549,20 +552,19 @@ $(BIN)/SameBoy.app: $(BIN)/SameBoy.app/Contents/MacOS/SameBoy \
|
|||||||
$(MKDIR) -p $(BIN)/SameBoy.app/Contents/Resources/Shaders
|
$(MKDIR) -p $(BIN)/SameBoy.app/Contents/Resources/Shaders
|
||||||
cp Shaders/*.fsh Shaders/*.metal $(BIN)/SameBoy.app/Contents/Resources/Shaders
|
cp Shaders/*.fsh Shaders/*.metal $(BIN)/SameBoy.app/Contents/Resources/Shaders
|
||||||
$(MKDIR) -p $(BIN)/SameBoy.app/Contents/Library/QuickLook/
|
$(MKDIR) -p $(BIN)/SameBoy.app/Contents/Library/QuickLook/
|
||||||
cp -rf $(BIN)/SameBoy.qlgenerator $(BIN)/SameBoy.app/Contents/Library/QuickLook/
|
|
||||||
ifeq ($(CONF), release)
|
ifeq ($(CONF), release)
|
||||||
$(CODESIGN) $@
|
$(CODESIGN) $@
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# We place the dylib inside the Quick Look plugin, because Quick Look plugins run in a very strict sandbox
|
# We place the dylib inside the Quick Look plugin, because Quick Look plugins run in a very strict sandbox
|
||||||
|
|
||||||
$(BIN)/SameBoy.app/Contents/MacOS/SameBoy: $(BIN)/SameBoy.qlgenerator/Contents/MacOS/SameBoy.dylib
|
$(BIN)/SameBoy.app/Contents/MacOS/SameBoy: $(BIN)/SameBoy.app/Contents/Library/QuickLook/SameBoy.qlgenerator/Contents/MacOS/SameBoy.dylib
|
||||||
-@$(MKDIR) -p $(dir $@)
|
-@$(MKDIR) -p $(dir $@)
|
||||||
$(CC) $^ -o $@ $(LDFLAGS) $(FAT_FLAGS) -rpath @executable_path/../Library/QuickLook/SameBoy.qlgenerator/ -Wl,-reexport_library,$^
|
$(CC) $^ -o $@ $(LDFLAGS) $(FAT_FLAGS) -rpath @executable_path/../Library/QuickLook/SameBoy.qlgenerator/ -Wl,-reexport_library,$^
|
||||||
|
|
||||||
$(BIN)/SameBoy.qlgenerator/Contents/MacOS/SameBoy.dylib: $(COCOA_OBJECTS) $(CORE_OBJECTS) $(QUICKLOOK_OBJECTS)
|
$(BIN)/SameBoy.app/Contents/Library/QuickLook/SameBoy.qlgenerator/Contents/MacOS/SameBoy.dylib: $(COCOA_OBJECTS) $(CORE_OBJECTS) $(QUICKLOOK_OBJECTS)
|
||||||
-@$(MKDIR) -p $(dir $@)
|
-@$(MKDIR) -p $(dir $@)
|
||||||
$(CC) $^ -o $@ $(LDFLAGS) $(FAT_FLAGS) -shared -install_name @rpath/Contents/MacOS/SameBoy.dylib -framework OpenGL -framework AudioUnit -framework AVFoundation -framework CoreVideo -framework CoreMedia -framework IOKit -framework PreferencePanes -framework Carbon -framework QuartzCore -framework Security -framework WebKit -weak_framework Metal -weak_framework MetalKit -framework Quicklook -framework AppKit -Wl,-exported_symbols_list,QuickLook/exports.sym -Wl,-exported_symbol,_main
|
$(CC) $^ -o $@ $(LDFLAGS) $(FAT_FLAGS) -shared -install_name @rpath/Contents/MacOS/SameBoy.dylib -framework OpenGL -framework AudioUnit -framework AVFoundation -framework CoreVideo -framework CoreMedia -framework IOKit -framework PreferencePanes -framework Carbon -framework QuartzCore -framework Security -framework WebKit -weak_framework Metal -weak_framework MetalKit -weak_framework QuickLookThumbnailing -weak_framework QuickLookUI -framework Quicklook -framework AppKit -Wl,-exported_symbols_list,QuickLook/exports.sym -Wl,-exported_symbol,_main
|
||||||
ifeq ($(CONF), release)
|
ifeq ($(CONF), release)
|
||||||
$(STRIP) $@
|
$(STRIP) $@
|
||||||
$(CODESIGN) $@
|
$(CODESIGN) $@
|
||||||
@@ -574,29 +576,55 @@ $(BIN)/SameBoy.app/Contents/Resources/%.nib: Cocoa/%.xib
|
|||||||
$(BIN)/SameBoy-iOS.app/%.storyboardc: iOS/%.storyboard
|
$(BIN)/SameBoy-iOS.app/%.storyboardc: iOS/%.storyboard
|
||||||
ibtool --target-device iphone --target-device ipad --minimum-deployment-target $(IOS_MIN) --compile $@ $^ 2>&1 | cat -
|
ibtool --target-device iphone --target-device ipad --minimum-deployment-target $(IOS_MIN) --compile $@ $^ 2>&1 | cat -
|
||||||
|
|
||||||
# Quick Look generator
|
# Quick Look generators
|
||||||
|
|
||||||
$(BIN)/SameBoy.qlgenerator: $(BIN)/SameBoy.qlgenerator/Contents/MacOS/SameBoyQL \
|
$(BIN)/SameBoy.app/Contents/Library/QuickLook/SameBoy.qlgenerator: $(BIN)/SameBoy.app/Contents/Library/QuickLook/SameBoy.qlgenerator/Contents/MacOS/SameBoyQL \
|
||||||
$(shell ls QuickLook/*.png) \
|
$(shell ls QuickLook/*.png) \
|
||||||
QuickLook/Info.plist \
|
QuickLook/Info.plist \
|
||||||
$(BIN)/SameBoy.qlgenerator/Contents/Resources/cgb_boot_fast.bin
|
$(BIN)/SameBoy.app/Contents/Library/QuickLook/SameBoy.qlgenerator/Contents/Resources/cgb_boot_fast.bin
|
||||||
$(MKDIR) -p $(BIN)/SameBoy.qlgenerator/Contents/Resources
|
$(MKDIR) -p $(BIN)/SameBoy.app/Contents/Library/QuickLook/SameBoy.qlgenerator/Contents/Resources
|
||||||
cp QuickLook/*.png $(BIN)/SameBoy.qlgenerator/Contents/Resources/
|
cp QuickLook/*.png $(BIN)/SameBoy.app/Contents/Library/QuickLook/SameBoy.qlgenerator/Contents/Resources/
|
||||||
sed "s/@VERSION/$(VERSION)/;s/@COPYRIGHT_YEAR/$(COPYRIGHT_YEAR)/" < QuickLook/Info.plist > $(BIN)/SameBoy.qlgenerator/Contents/Info.plist
|
sed "s/@VERSION/$(VERSION)/;s/@COPYRIGHT_YEAR/$(COPYRIGHT_YEAR)/" < QuickLook/Info.plist > $(BIN)/SameBoy.app/Contents/Library/QuickLook/SameBoy.qlgenerator/Contents/Info.plist
|
||||||
ifeq ($(CONF), release)
|
ifeq ($(CONF), release)
|
||||||
$(CODESIGN) $@
|
$(CODESIGN) $@
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(BIN)/SameBoy.qlgenerator/Contents/MacOS/SameBoyQL: $(BIN)/SameBoy.qlgenerator/Contents/MacOS/SameBoy.dylib
|
$(BIN)/SameBoy.app/Contents/Library/QuickLook/SameBoy.qlgenerator/Contents/MacOS/SameBoyQL: $(BIN)/SameBoy.app/Contents/Library/QuickLook/SameBoy.qlgenerator/Contents/MacOS/SameBoy.dylib
|
||||||
-@$(MKDIR) -p $(dir $@)
|
-@$(MKDIR) -p $(dir $@)
|
||||||
$(CC) -o $@ $(LDFLAGS) $(FAT_FLAGS) -bundle -Wl,-reexport_library,$^ -rpath @loader_path/../../
|
$(CC) -o $@ $(LDFLAGS) $(FAT_FLAGS) -bundle -Wl,-reexport_library,$^ -rpath @loader_path/../../
|
||||||
ifeq ($(CONF), release)
|
ifeq ($(CONF), release)
|
||||||
$(STRIP) $@
|
$(STRIP) $@
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
$(BIN)/SameBoy.app/Contents/PlugIns/Thumbnailer.appex: $(BIN)/SameBoy.app/Contents/PlugIns/Thumbnailer.appex/Contents/MacOS/Thumbnailer \
|
||||||
|
QuickLook/Thumbnailer.plist \
|
||||||
|
QuickLook/plugin.entitlements
|
||||||
|
sed "s/@VERSION/$(VERSION)/;s/@COPYRIGHT_YEAR/$(COPYRIGHT_YEAR)/" < QuickLook/Thumbnailer.plist > $(BIN)/SameBoy.app/Contents/PlugIns/Thumbnailer.appex/Contents/Info.plist
|
||||||
|
$(CODESIGN) --entitlements QuickLook/plugin.entitlements $@
|
||||||
|
|
||||||
|
$(BIN)/SameBoy.app/Contents/PlugIns/Thumbnailer.appex/Contents/MacOS/Thumbnailer: $(BIN)/SameBoy.app/Contents/Library/QuickLook/SameBoy.qlgenerator/Contents/MacOS/SameBoy.dylib
|
||||||
|
-@$(MKDIR) -p $(dir $@)
|
||||||
|
$(CC) -o $@ $(LDFLAGS) $(FAT_FLAGS) -e _NSExtensionMain -framework Foundation -Wl,-reexport_library,$^ -rpath @loader_path/../../../../Library/QuickLook/SameBoy.qlgenerator/
|
||||||
|
ifeq ($(CONF), release)
|
||||||
|
$(STRIP) $@
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(BIN)/SameBoy.app/Contents/PlugIns/Previewer.appex: $(BIN)/SameBoy.app/Contents/PlugIns/Previewer.appex/Contents/MacOS/Previewer \
|
||||||
|
QuickLook/Previewer.plist \
|
||||||
|
QuickLook/plugin.entitlements
|
||||||
|
sed "s/@VERSION/$(VERSION)/;s/@COPYRIGHT_YEAR/$(COPYRIGHT_YEAR)/" < QuickLook/Previewer.plist > $(BIN)/SameBoy.app/Contents/PlugIns/Previewer.appex/Contents/Info.plist
|
||||||
|
$(CODESIGN) --entitlements QuickLook/plugin.entitlements $@
|
||||||
|
|
||||||
|
$(BIN)/SameBoy.app/Contents/PlugIns/Previewer.appex/Contents/MacOS/Previewer: $(BIN)/SameBoy.app/Contents/Library/QuickLook/SameBoy.qlgenerator/Contents/MacOS/SameBoy.dylib
|
||||||
|
-@$(MKDIR) -p $(dir $@)
|
||||||
|
$(CC) -o $@ $(LDFLAGS) $(FAT_FLAGS) -e _NSExtensionMain -framework Foundation -Wl,-reexport_library,$^ -rpath @loader_path/../../../../Library/QuickLook/SameBoy.qlgenerator/
|
||||||
|
ifeq ($(CONF), release)
|
||||||
|
$(STRIP) $@
|
||||||
|
endif
|
||||||
|
|
||||||
# cgb_boot_fast.bin is not a standard boot ROM, we don't expect it to exist in the user-provided
|
# cgb_boot_fast.bin is not a standard boot ROM, we don't expect it to exist in the user-provided
|
||||||
# boot ROM directory.
|
# boot ROM directory.
|
||||||
$(BIN)/SameBoy.qlgenerator/Contents/Resources/cgb_boot_fast.bin: $(BIN)/BootROMs/cgb_boot_fast.bin
|
$(BIN)/SameBoy.app/Contents/Library/QuickLook/SameBoy.qlgenerator/Contents/Resources/cgb_boot_fast.bin: $(BIN)/BootROMs/cgb_boot_fast.bin
|
||||||
-@$(MKDIR) -p $(dir $@)
|
-@$(MKDIR) -p $(dir $@)
|
||||||
cp -f $^ $@
|
cp -f $^ $@
|
||||||
|
|
||||||
|
6
QuickLook/GBPreviewProvider.h
Normal file
6
QuickLook/GBPreviewProvider.h
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#import <Quartz/Quartz.h>
|
||||||
|
|
||||||
|
API_AVAILABLE(macos(12.0))
|
||||||
|
@interface GBPreviewProvider : QLPreviewProvider <QLPreviewingController>
|
||||||
|
@end
|
20
QuickLook/GBPreviewProvider.m
Normal file
20
QuickLook/GBPreviewProvider.m
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#import "GBPreviewProvider.h"
|
||||||
|
|
||||||
|
extern OSStatus GBQuickLookRender(CGContextRef cgContext, CFURLRef url, bool showBorder);
|
||||||
|
|
||||||
|
@implementation GBPreviewProvider
|
||||||
|
|
||||||
|
- (void)providePreviewForFileRequest:(QLFilePreviewRequest *)request completionHandler:(void (^)(QLPreviewReply *reply, NSError *error))handler
|
||||||
|
{
|
||||||
|
QLPreviewReply* reply = [[QLPreviewReply alloc] initWithContextSize:CGSizeMake(640, 576)
|
||||||
|
isBitmap:true
|
||||||
|
drawingBlock:^BOOL (CGContextRef context, QLPreviewReply *reply, NSError **error) {
|
||||||
|
return !GBQuickLookRender(context, (__bridge CFURLRef)request.fileURL, false);
|
||||||
|
|
||||||
|
}];
|
||||||
|
|
||||||
|
handler(reply, nil);
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
5
QuickLook/GBThumbnailProvider.h
Normal file
5
QuickLook/GBThumbnailProvider.h
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#import <QuickLookThumbnailing/QuickLookThumbnailing.h>
|
||||||
|
|
||||||
|
API_AVAILABLE(macos(10.15))
|
||||||
|
@interface GBThumbnailProvider : QLThumbnailProvider
|
||||||
|
@end
|
27
QuickLook/GBThumbnailProvider.m
Normal file
27
QuickLook/GBThumbnailProvider.m
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#import "GBThumbnailProvider.h"
|
||||||
|
|
||||||
|
extern OSStatus GBQuickLookRender(CGContextRef cgContext, CFURLRef url, bool showBorder);
|
||||||
|
|
||||||
|
@interface QLThumbnailReply (private)
|
||||||
|
@property unsigned iconFlavor;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation GBThumbnailProvider
|
||||||
|
|
||||||
|
- (void)provideThumbnailForFileRequest:(QLFileThumbnailRequest *)request completionHandler:(void (^)(QLThumbnailReply *, NSError *))handler
|
||||||
|
{
|
||||||
|
CGSize size = {64, 64};
|
||||||
|
CGSize maximumSize = request.maximumSize;
|
||||||
|
while (size.width < maximumSize.width / 2 &&
|
||||||
|
size.width < maximumSize.height / 2) {
|
||||||
|
size.width *= 2;
|
||||||
|
}
|
||||||
|
size.height = size.width;
|
||||||
|
QLThumbnailReply *reply = [QLThumbnailReply replyWithContextSize:size drawingBlock: ^BOOL(CGContextRef context) {
|
||||||
|
return !GBQuickLookRender(context, (__bridge CFURLRef)request.fileURL, true);
|
||||||
|
}];
|
||||||
|
reply.iconFlavor = 0;
|
||||||
|
handler(reply, nil);
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@@ -14,7 +14,7 @@
|
|||||||
<string>com.github.liji32.sameboy.gb</string>
|
<string>com.github.liji32.sameboy.gb</string>
|
||||||
<string>com.github.liji32.sameboy.gbc</string>
|
<string>com.github.liji32.sameboy.gbc</string>
|
||||||
<string>com.github.liji32.sameboy.isx</string>
|
<string>com.github.liji32.sameboy.isx</string>
|
||||||
<string>public.gbrom</string>
|
<string>public.gbrom</string>
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
<key>CFBundleName</key>
|
<key>CFBundleName</key>
|
||||||
<string>SameBoy</string>
|
<string>SameBoy</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>Version @VERSION</string>
|
<string>@VERSION</string>
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFPlugInDynamicRegisterFunction</key>
|
<key>CFPlugInDynamicRegisterFunction</key>
|
||||||
|
45
QuickLook/Previewer.plist
Normal file
45
QuickLook/Previewer.plist
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDisplayName</key>
|
||||||
|
<string>Previewer</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>Previewer</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>com.github.liji32.sameboy.ios.Previewer</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>Previewer</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>XPC!</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>@VERSION</string>
|
||||||
|
<key>CFBundleSupportedPlatforms</key>
|
||||||
|
<array>
|
||||||
|
<string>MacOSX</string>
|
||||||
|
</array>
|
||||||
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
<string>12.0</string>
|
||||||
|
<key>NSExtension</key>
|
||||||
|
<dict>
|
||||||
|
<key>NSExtensionAttributes</key>
|
||||||
|
<dict>
|
||||||
|
<key>QLSupportedContentTypes</key>
|
||||||
|
<array>
|
||||||
|
<string>com.github.liji32.sameboy.gb</string>
|
||||||
|
<string>com.github.liji32.sameboy.gbc</string>
|
||||||
|
<string>com.github.liji32.sameboy.isx</string>
|
||||||
|
<string>public.gbrom</string>
|
||||||
|
</array>
|
||||||
|
<key>QLIsDataBasedPreview</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
<key>NSExtensionPointIdentifier</key>
|
||||||
|
<string>com.apple.quicklook.preview</string>
|
||||||
|
<key>NSExtensionPrincipalClass</key>
|
||||||
|
<string>GBPreviewProvider</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
45
QuickLook/Thumbnailer.plist
Normal file
45
QuickLook/Thumbnailer.plist
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDisplayName</key>
|
||||||
|
<string>Thumbnailer</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>Thumbnailer</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>com.github.liji32.sameboy.ios.Thumbnailer</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>Thumbnailer</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>XPC!</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>@VERSION</string>
|
||||||
|
<key>CFBundleSupportedPlatforms</key>
|
||||||
|
<array>
|
||||||
|
<string>MacOSX</string>
|
||||||
|
</array>
|
||||||
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
<string>12.0</string>
|
||||||
|
<key>NSExtension</key>
|
||||||
|
<dict>
|
||||||
|
<key>NSExtensionAttributes</key>
|
||||||
|
<dict>
|
||||||
|
<key>QLSupportedContentTypes</key>
|
||||||
|
<array>
|
||||||
|
<string>com.github.liji32.sameboy.gb</string>
|
||||||
|
<string>com.github.liji32.sameboy.gbc</string>
|
||||||
|
<string>com.github.liji32.sameboy.isx</string>
|
||||||
|
<string>public.gbrom</string>
|
||||||
|
</array>
|
||||||
|
<key>QLThumbnailMinimumDimension</key>
|
||||||
|
<integer>64</integer>
|
||||||
|
</dict>
|
||||||
|
<key>NSExtensionPointIdentifier</key>
|
||||||
|
<string>com.apple.quicklook.thumbnail</string>
|
||||||
|
<key>NSExtensionPrincipalClass</key>
|
||||||
|
<string>GBThumbnailProvider</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
@@ -2,7 +2,7 @@
|
|||||||
#include <Cocoa/Cocoa.h>
|
#include <Cocoa/Cocoa.h>
|
||||||
#include "get_image_for_rom.h"
|
#include "get_image_for_rom.h"
|
||||||
|
|
||||||
static OSStatus render(CGContextRef cgContext, CFURLRef url, bool showBorder)
|
OSStatus GBQuickLookRender(CGContextRef cgContext, CFURLRef url, bool showBorder)
|
||||||
{
|
{
|
||||||
/* Load the template NSImages when generating the first thumbnail */
|
/* Load the template NSImages when generating the first thumbnail */
|
||||||
static NSImage *template = nil;
|
static NSImage *template = nil;
|
||||||
@@ -11,7 +11,7 @@ static OSStatus render(CGContextRef cgContext, CFURLRef url, bool showBorder)
|
|||||||
static NSBundle *bundle = nil;
|
static NSBundle *bundle = nil;
|
||||||
static dispatch_once_t onceToken;
|
static dispatch_once_t onceToken;
|
||||||
dispatch_once(&onceToken, ^{
|
dispatch_once(&onceToken, ^{
|
||||||
bundle = [NSBundle bundleWithIdentifier:@"com.github.liji32.sameboy.previewer"];
|
bundle = [NSBundle bundleForClass:NSClassFromString(@"GBPanel")];
|
||||||
});
|
});
|
||||||
if (showBorder) {
|
if (showBorder) {
|
||||||
static dispatch_once_t onceToken;
|
static dispatch_once_t onceToken;
|
||||||
@@ -53,11 +53,13 @@ static OSStatus render(CGContextRef cgContext, CFURLRef url, bool showBorder)
|
|||||||
[NSGraphicsContext setCurrentContext:context];
|
[NSGraphicsContext setCurrentContext:context];
|
||||||
|
|
||||||
|
|
||||||
|
double ratio = CGBitmapContextGetWidth(cgContext) / 1024.0;
|
||||||
|
|
||||||
/* Convert the screenshot to a magnified NSImage */
|
/* Convert the screenshot to a magnified NSImage */
|
||||||
NSImage *screenshot = [[NSImage alloc] initWithCGImage:iref size:NSMakeSize(160, 144)];
|
NSImage *screenshot = [[NSImage alloc] initWithCGImage:iref size:NSMakeSize(160, 144)];
|
||||||
/* Draw the screenshot */
|
/* Draw the screenshot */
|
||||||
if (showBorder) {
|
if (showBorder) {
|
||||||
[screenshot drawInRect:NSMakeRect(192, 150, 640, 576)];
|
[screenshot drawInRect:NSMakeRect(192 * ratio, 150 * ratio, 640 * ratio, 576 * ratio)];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
[screenshot drawInRect:NSMakeRect(0, 0, 640, 576)];
|
[screenshot drawInRect:NSMakeRect(0, 0, 640, 576)];
|
||||||
@@ -82,7 +84,7 @@ static OSStatus render(CGContextRef cgContext, CFURLRef url, bool showBorder)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Mask it with the template (The middle part of the template image is transparent) */
|
/* Mask it with the template (The middle part of the template image is transparent) */
|
||||||
[effectiveTemplate drawInRect:(NSRect){{0, 0}, template.size}];
|
[effectiveTemplate drawInRect:(NSRect){{0, 0}, {CGBitmapContextGetWidth(cgContext), CGBitmapContextGetHeight(cgContext)}}];
|
||||||
}
|
}
|
||||||
|
|
||||||
CGColorSpaceRelease(colorSpaceRef);
|
CGColorSpaceRelease(colorSpaceRef);
|
||||||
@@ -96,7 +98,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
|
|||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
CGContextRef cgContext = QLPreviewRequestCreateContext(preview, ((NSSize){640, 576}), true, nil);
|
CGContextRef cgContext = QLPreviewRequestCreateContext(preview, ((NSSize){640, 576}), true, nil);
|
||||||
if (render(cgContext, url, false) == noErr) {
|
if (GBQuickLookRender(cgContext, url, false) == noErr) {
|
||||||
QLPreviewRequestFlushContext(preview, cgContext);
|
QLPreviewRequestFlushContext(preview, cgContext);
|
||||||
CGContextRelease(cgContext);
|
CGContextRelease(cgContext);
|
||||||
return noErr;
|
return noErr;
|
||||||
@@ -111,7 +113,7 @@ OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thum
|
|||||||
extern NSString *kQLThumbnailPropertyIconFlavorKey;
|
extern NSString *kQLThumbnailPropertyIconFlavorKey;
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
CGContextRef cgContext = QLThumbnailRequestCreateContext(thumbnail, ((NSSize){1024, 1024}), true, (__bridge CFDictionaryRef)(@{kQLThumbnailPropertyIconFlavorKey : @(0)}));
|
CGContextRef cgContext = QLThumbnailRequestCreateContext(thumbnail, ((NSSize){1024, 1024}), true, (__bridge CFDictionaryRef)(@{kQLThumbnailPropertyIconFlavorKey : @(0)}));
|
||||||
if (render(cgContext, url, true) == noErr) {
|
if (GBQuickLookRender(cgContext, url, true) == noErr) {
|
||||||
QLThumbnailRequestFlushContext(thumbnail, cgContext);
|
QLThumbnailRequestFlushContext(thumbnail, cgContext);
|
||||||
CGContextRelease(cgContext);
|
CGContextRelease(cgContext);
|
||||||
return noErr;
|
return noErr;
|
||||||
|
10
QuickLook/plugin.entitlements
Normal file
10
QuickLook/plugin.entitlements
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>com.apple.security.app-sandbox</key>
|
||||||
|
<true/>
|
||||||
|
<key>com.apple.security.files.user-selected.read-only</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
Reference in New Issue
Block a user