From 3bcb8929bde40316ff11f0265e06757239a30856 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Mon, 21 Sep 2009 03:44:24 +0000 Subject: [PATCH] #2436 on 10.6 let's try showing favicons in the info panel's tracker table --- macosx/InfoWindowController.h | 3 + macosx/InfoWindowController.m | 73 ++++++++++++- macosx/en.lproj/InfoWindow.xib | 191 ++++++++++++++++++++++++++++----- 3 files changed, 235 insertions(+), 32 deletions(-) diff --git a/macosx/InfoWindowController.h b/macosx/InfoWindowController.h index 687a61915..5efa2415c 100644 --- a/macosx/InfoWindowController.h +++ b/macosx/InfoWindowController.h @@ -77,6 +77,9 @@ * fUploadLimitLabel, * fDownloadLimitLabel, * fPeersConnectLabel, * fPeersConnectField; + NSCache * fTrackerIconCache; + NSMutableSet * fTrackerIconLoaded; + NSString * fInitialString; QLPreviewPanel * fPreviewPanel; diff --git a/macosx/InfoWindowController.m b/macosx/InfoWindowController.m index a29ec967f..43f67f510 100644 --- a/macosx/InfoWindowController.m +++ b/macosx/InfoWindowController.m @@ -192,6 +192,14 @@ typedef enum [self setWebSeedTableHidden: YES animate: NO]; + if ([NSApp isOnSnowLeopardOrBetter]) + { + fTrackerIconCache = [[NSCache alloc] init]; + fTrackerIconLoaded = [[NSMutableSet alloc] init]; + } + else + [fTrackerTable removeTableColumn: [fTrackerTable tableColumnWithIdentifier: @"Icon"]]; + //set blank inspector [self setInfoForTorrents: [NSArray array]]; @@ -229,6 +237,9 @@ typedef enum [fWebSeedTableAnimation release]; + [fTrackerIconCache release]; + [fTrackerIconLoaded release]; + [fPreviewPanel release]; [super dealloc]; @@ -483,7 +494,7 @@ typedef enum [fTrackerAddRemoveControl setEnabled: YES forSegment: TRACKER_ADD_TAG]; [fTrackerAddRemoveControl setEnabled: NO forSegment: TRACKER_REMOVE_TAG]; - + [fFileFilterField setEnabled: [torrent isFolder]]; } @@ -907,15 +918,69 @@ typedef enum } else if (tableView == fTrackerTable) { + NSString * ident = [column identifier]; id item = [fTrackers objectAtIndex: row]; - if ([item isKindOfClass: [NSNumber class]]) - return [NSString stringWithFormat: NSLocalizedString(@"Tier %d", "Inspector -> tracker table"), [item integerValue]]; - else + + if ([ident isEqualToString: @"Icon"]) + { + NSAssert([item isKindOfClass: [NSString class]], @"Value passed to tracker table's icon row is not a string!"); + + NSURL * address = [NSURL URLWithString: item]; + NSArray * hostComponents = [[address host] componentsSeparatedByString: @"."]; + + //let's try getting the favicon without using any subdomains + NSURL * favIconUrl; + if ([hostComponents count] > 1) + favIconUrl = [NSURL URLWithString: [NSString stringWithFormat: @"%@://%@.%@/favicon.ico", [address scheme], + [hostComponents objectAtIndex: [hostComponents count] - 2], [hostComponents lastObject]]]; + else + favIconUrl = [NSURL URLWithString: [NSString stringWithFormat: @"%@://%@/favicon.ico", [address scheme], + [hostComponents lastObject]]]; + + NSImage * icon = nil; + if ([fTrackerIconLoaded containsObject: favIconUrl]) + icon = [fTrackerIconCache objectForKey: favIconUrl]; + else + [NSThread detachNewThreadSelector: @selector(loadTrackerIcon:) toTarget: self withObject: favIconUrl]; + + return icon; + } + if ([ident isEqualToString: @"Address"]) return item; + else + return [NSString stringWithFormat: NSLocalizedString(@"Tier %d", "Inspector -> tracker table"), [item integerValue]]; } return nil; } +- (void) loadTrackerIcon: (NSURL *) favIconUrl +{ + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + + [fTrackerIconLoaded addObject: favIconUrl]; + + NSImage * icon = [[NSImage alloc] initWithContentsOfURL: favIconUrl]; + if (icon) + { + [fTrackerIconCache setObject: icon forKey: favIconUrl]; + [icon release]; + } + + [pool drain]; +} + +- (NSCell *)tableView: (NSTableView *) tableView dataCellForTableColumn: (NSTableColumn *) tableColumn row: (NSInteger) row +{ + if (tableView == fTrackerTable) + { + //group row the full column width + if (!tableColumn && [[fTrackers objectAtIndex: row] isKindOfClass: [NSNumber class]]) + return [[tableView tableColumnWithIdentifier: @"Address"] dataCell]; + } + + return nil; +} + - (void) tableView: (NSTableView *) tableView willDisplayCell: (id) cell forTableColumn: (NSTableColumn *) tableColumn row: (NSInteger) row { diff --git a/macosx/en.lproj/InfoWindow.xib b/macosx/en.lproj/InfoWindow.xib index 8c195b561..2640df840 100644 --- a/macosx/en.lproj/InfoWindow.xib +++ b/macosx/en.lproj/InfoWindow.xib @@ -2,9 +2,9 @@ 1050 - 10A432 + 10B504 732 - 1038 + 1038.2 437.00 com.apple.InterfaceBuilder.CocoaPlugin @@ -12,8 +12,7 @@ YES - - + YES @@ -423,7 +422,7 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA {1.79769e+308, 1.79769e+308} - + 258 YES @@ -914,7 +913,6 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA {{1, 1}, {245, 56}} - @@ -947,7 +945,6 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA {{82, 108}, {258, 58}} - 18 @@ -955,7 +952,6 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA {350, 252} - NSView @@ -1646,7 +1642,7 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA NSResponder - + 274 YES @@ -2033,8 +2029,46 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA YES + + Icon + 14 + 14 + 14 + + 75628096 + 2048 + + + + 6 + System + headerColor + + + + 6 + System + headerTextColor + + + + + 67239424 + 33554432 + + 0 + 3 + 0 + NO + + 3 + YES + YES + + - 357 + Address + 178 40 1000 @@ -2046,12 +2080,7 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 3 MC4zMzMzMzI5OQA - - 6 - System - headerTextColor - - + 337772096 @@ -2090,7 +2119,7 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 14 - 440401920 + 306184192 4 @@ -2177,13 +2206,14 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA {382, 352} + NSView NSResponder - + 274 YES @@ -2202,12 +2232,14 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 256 {338, 172} + YES 256 {338, 17} + @@ -2215,6 +2247,7 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA -2147483392 {{-22, 0}, {12, 17}} + YES @@ -2228,12 +2261,7 @@ AAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSBDb21wdXRlciwgSW5jLiwgMjAwNQAAAAA 2048 IP Address - - 6 - System - headerColor - - + @@ -2640,6 +2668,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA {{1, 17}, {338, 172}} + @@ -2650,6 +2679,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA -2147483392 {{328, 17}, {11, 117}} + 256 _doScroller: @@ -2660,6 +2690,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA -2147483392 {{1, 134}, {327, 11}} + 257 _doScroller: @@ -2674,6 +2705,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA {{1, 0}, {338, 17}} + @@ -2683,6 +2715,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA {{10, 77}, {340, 190}} + 562 @@ -2707,12 +2740,14 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA 256 {338, 48} + YES 256 {338, 17} + @@ -2720,6 +2755,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA -2147483392 {{-22, 0}, {12, 17}} + YES @@ -2804,6 +2840,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA {{1, 17}, {338, 48}} + @@ -2814,6 +2851,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA -2147483392 {{328, 17}, {11, 37}} + 256 _doScroller: @@ -2824,6 +2862,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA -2147483392 {{1, 54}, {327, 11}} + 257 _doScroller: @@ -2838,6 +2877,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA {{1, 0}, {338, 17}} + @@ -2847,6 +2887,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA {{10, 271}, {340, 66}} + 562 @@ -2861,6 +2902,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA 292 {{10, 26}, {53, 14}} + YES 67239424 @@ -2877,6 +2919,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA 292 {{64, 26}, {65, 14}} + YES 67239424 @@ -2894,6 +2937,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA 289 {{225, 26}, {85, 14}} + YES 67239424 @@ -2910,6 +2954,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA 289 {{230, 42}, {80, 14}} + YES 67239424 @@ -2926,6 +2971,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA 289 {{311, 26}, {55, 14}} + YES 69336577 @@ -2943,6 +2989,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA 289 {{311, 42}, {55, 14}} + YES 69336577 @@ -2960,6 +3007,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA 292 {{24, 42}, {39, 14}} + YES 67239424 @@ -2976,6 +3024,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA 292 {{64, 42}, {65, 14}} + YES 67239424 @@ -2993,6 +3042,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA 289 {{205, 10}, {105, 14}} + YES 67239424 @@ -3009,6 +3059,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA 289 {{311, 10}, {55, 14}} + YES 69336577 @@ -3026,6 +3077,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA 290 {{2, 58}, {356, 14}} + YES 67239488 @@ -3043,6 +3095,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA 292 {{19, 10}, {44, 14}} + YES 67239424 @@ -3059,6 +3112,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA 292 {{64, 10}, {65, 14}} + YES 67239424 @@ -3073,6 +3127,8 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA {360, 342} + + NSView NSResponder @@ -3340,7 +3396,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA NSResponder - + 258 YES @@ -3996,7 +4052,6 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA {351, 219} - NSView @@ -6481,8 +6536,8 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA - + Tracker @@ -6810,6 +6865,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA YES + @@ -7060,6 +7116,20 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA + + 1823 + + + YES + + + + + + 1825 + + + @@ -7477,6 +7547,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA 1816.IBPluginDependency 1817.IBPluginDependency 1818.IBPluginDependency + 1825.IBPluginDependency 28.IBPluginDependency 28.ImportedFromIB2 29.IBPluginDependency @@ -7989,6 +8060,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -8103,7 +8175,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA - 1822 + 1825 @@ -8931,6 +9003,69 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA Growl.framework/Headers/GrowlApplicationBridge.h + + NSObject + + IBFrameworkSource + ImageKit.framework/Headers/IKImageBrowserView.h + + + + NSObject + + IBFrameworkSource + ImageKit.framework/Headers/IKSaveOptions.h + + + + NSObject + + IBFrameworkSource + ImageKit.framework/Headers/ImageKitDeprecated.h + + + + NSObject + + IBFrameworkSource + PDFKit.framework/Headers/PDFDocument.h + + + + NSObject + + IBFrameworkSource + PDFKit.framework/Headers/PDFView.h + + + + NSObject + + IBFrameworkSource + QuartzComposer.framework/Headers/QCCompositionParameterView.h + + + + NSObject + + IBFrameworkSource + QuartzComposer.framework/Headers/QCCompositionPickerView.h + + + + NSObject + + IBFrameworkSource + QuartzFilters.framework/Headers/QuartzFilterManager.h + + + + NSObject + + IBFrameworkSource + QuickLookUI.framework/Headers/QLPreviewPanel.h + + NSObject