From 2d945df60f198d98f5e7000202b54f26a8ca1278 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Mon, 9 Aug 2010 14:04:17 +0000 Subject: =?UTF-8?q?=E2=80=A2=20Quicklook=20generator=20-=20improved=20icon?= =?UTF-8?q?=20display=20by=20choosing=20an=20adequate=20=20image=20of=20of?= =?UTF-8?q?=20the=20icns=20file=20-=20set=20background=20to=20white=20for?= =?UTF-8?q?=20all=20different=20spf=20files=20to=20be=20consistent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/GeneratePreviewForURL.m | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'Source') diff --git a/Source/GeneratePreviewForURL.m b/Source/GeneratePreviewForURL.m index aaf8a903..9f44bdf9 100644 --- a/Source/GeneratePreviewForURL.m +++ b/Source/GeneratePreviewForURL.m @@ -63,8 +63,12 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, if (QLPreviewRequestIsCancelled(preview)) return noErr; - // Get current set file icon - NSImage *iconImage = [[NSWorkspace sharedWorkspace] iconForFile:[myURL path]]; + // Get current Sequel Pro's set of file icons + NSArray *iconImages = [[[NSWorkspace sharedWorkspace] iconForFile:[myURL path]] representations]; + + // just in case + if(!iconImages || [iconImages count] < 1) + iconImages = [NSArray arrayWithObject:[NSImage imageNamed:NSImageNameStopProgressTemplate]]; NSMutableString *html; NSString *template = nil; @@ -77,6 +81,12 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, // Dispatch different fiel extensions if([urlExtension isEqualToString:@"spf"]) { + NSImage *iconImage; + if([iconImages count] > 0) + iconImage = [iconImages objectAtIndex:1]; + else + iconImage = [iconImages objectAtIndex:0]; + NSError *readError = nil; NSString *convError = nil; NSPropertyListFormat format; @@ -151,6 +161,13 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, } else if([[spf objectForKey:@"format"] isEqualToString:@"content filters"]) { + + NSImage *iconImage; + if([iconImages count] > 0) + iconImage = [iconImages objectAtIndex:1]; + else + iconImage = [iconImages objectAtIndex:0]; + template = [NSString stringWithContentsOfFile:[[NSBundle bundleWithIdentifier:@"com.google.code.sequel-pro.qlgenerator"] pathForResource:@"SPQLPluginContentFiltersTemplate" ofType:@"html"] encoding:NSUTF8StringEncoding error:&templateReadError]; @@ -166,6 +183,13 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, } else if([[spf objectForKey:@"format"] isEqualToString:@"query favorites"]) { + + NSImage *iconImage; + if([iconImages count] > 0) + iconImage = [iconImages objectAtIndex:1]; + else + iconImage = [iconImages objectAtIndex:0]; + template = [NSString stringWithContentsOfFile:[[NSBundle bundleWithIdentifier:@"com.google.code.sequel-pro.qlgenerator"] pathForResource:@"SPQLPluginQueryFavoritesTemplate" ofType:@"html"] encoding:NSUTF8StringEncoding error:&templateReadError]; @@ -185,6 +209,9 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, } else if([urlExtension isEqualToString:@"sql"]) { + + NSImage *iconImage = [iconImages objectAtIndex:0]; + template = [NSString stringWithContentsOfFile:[[NSBundle bundleWithIdentifier:@"com.google.code.sequel-pro.qlgenerator"] pathForResource:@"SPQLPluginSQLTemplate" ofType:@"html"] encoding:NSUTF8StringEncoding error:&templateReadError]; -- cgit v1.2.3