From e94e0e72f4e0ef60c0d2c39dc6eaff9787c6a973 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Tue, 29 Aug 2006 00:09:49 +0000 Subject: [PATCH] Display an error image on the torrent icon when there is an error with the torrent. --- Transmission.xcodeproj/project.pbxproj | 4 ++ macosx/Images/Error.tiff | Bin 0 -> 4608 bytes macosx/Torrent.h | 1 + macosx/Torrent.m | 5 ++ macosx/TorrentCell.h | 5 ++ macosx/TorrentCell.m | 82 ++++++++++++------------- 6 files changed, 55 insertions(+), 42 deletions(-) create mode 100644 macosx/Images/Error.tiff diff --git a/Transmission.xcodeproj/project.pbxproj b/Transmission.xcodeproj/project.pbxproj index 78ef6efb6..cd8e9c265 100644 --- a/Transmission.xcodeproj/project.pbxproj +++ b/Transmission.xcodeproj/project.pbxproj @@ -116,6 +116,7 @@ A25FCDE00A37695F002BCBBE /* ResumeSelected.png in CopyFiles */ = {isa = PBXBuildFile; fileRef = A25FCDDE0A37695F002BCBBE /* ResumeSelected.png */; }; A25FCDEF0A3769A6002BCBBE /* PauseSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = A25FCDDD0A37695F002BCBBE /* PauseSelected.png */; }; A25FCDF00A3769AC002BCBBE /* ResumeSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = A25FCDDE0A37695F002BCBBE /* ResumeSelected.png */; }; + A260C9AC0AA3B8D700FDC1B7 /* Error.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A260C9AB0AA3B8D700FDC1B7 /* Error.tiff */; }; A261F1DC0A69A1610002815A /* Growl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A261F1DB0A69A1610002815A /* Growl.framework */; }; A261F1E40A69A1B10002815A /* Growl.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = A261F1DB0A69A1610002815A /* Growl.framework */; }; A26D450B0A0503AC00A10BB3 /* peermessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D1838A309DEC0430047D688 /* peermessages.h */; }; @@ -321,6 +322,7 @@ A259316A0A73B2CC002F4FE7 /* Transmission Help */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "Transmission Help"; path = "macosx/Transmission Help"; sourceTree = ""; }; A25FCDDD0A37695F002BCBBE /* PauseSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = PauseSelected.png; path = macosx/Images/PauseSelected.png; sourceTree = ""; }; A25FCDDE0A37695F002BCBBE /* ResumeSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ResumeSelected.png; path = macosx/Images/ResumeSelected.png; sourceTree = ""; }; + A260C9AB0AA3B8D700FDC1B7 /* Error.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = Error.tiff; path = macosx/Images/Error.tiff; sourceTree = ""; }; A261F1DB0A69A1610002815A /* Growl.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Growl.framework; path = macosx/Growl.framework; sourceTree = ""; }; A2710E740A86796000CE4F7D /* PrefsWindow.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = PrefsWindow.h; path = macosx/PrefsWindow.h; sourceTree = ""; }; A2710E750A86796000CE4F7D /* PrefsWindow.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = PrefsWindow.m; path = macosx/PrefsWindow.m; sourceTree = ""; }; @@ -453,6 +455,7 @@ A2305A7D0A3DC9E400AB2D77 /* ProgressBarBlue.png */, A2305A7E0A3DC9E400AB2D77 /* ProgressBarGray.png */, A2305A7F0A3DC9E400AB2D77 /* ProgressBarGreen.png */, + A260C9AB0AA3B8D700FDC1B7 /* Error.tiff */, A2D4F0840A915F7200890C32 /* GreenDot.tiff */, A2D4F0820A915F6600890C32 /* RedDot.tiff */, A20AB97A0A5C622A004F81FA /* SmallTurtle.png */, @@ -777,6 +780,7 @@ A2D4F0830A915F6600890C32 /* RedDot.tiff in Resources */, A2D4F0850A915F7200890C32 /* GreenDot.tiff in Resources */, A21567ED0A9A5034004DECD6 /* MessageWindow.nib in Resources */, + A260C9AC0AA3B8D700FDC1B7 /* Error.tiff in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/macosx/Images/Error.tiff b/macosx/Images/Error.tiff new file mode 100644 index 0000000000000000000000000000000000000000..0e452dd8390f407f74915cd8bbe7ba63c92602a3 GIT binary patch literal 4608 zcmcgwdu&r>6#w1s0U1_?z!(on111Gz?KV)ex()@y!=yR^bumO4TY;u*-J`m?nBYH( zk3>v}5u$&9#>7a}p!}f$R7M64CuLB^djnsfPDTP5b4ZWpe7(2rMhBy8e9N!*>p9;! zzjMz0zH@Kqa$yFbIRMi^02$HiaHzk+If1IuGOycjS>aygsdQR9cYJTPc*>pDXCH9o zx~k^6S9=!L*SMF|Ke4o|-dk2sZkO=Ybk;Ix*O`&PIeJQuOu zYEeu4UZ=IhRc!J5d~3WOza`&RkW(U9@mlh14_b>d3Tw(&Iu<`RU-!n} zoYvKTf0e^-udA!G)y=Z`YF63v3JMDBx%u||{2X49Q~PqIzci3jSv!@pDR0vm+Zjv&an1!iVTF^zu zL39Gt`ZbQHrt*2YL*vaFY@m}7ZsC`C$wDl@6ZB(8Ve+MexTN?c1|5gKLTgG2(uX>R z*Q>FfPU*aoyPiLt2D#?onW5y*G-KR_W^}5Yk1+Rp%T!TeUJT(;L<`Edvu^<1a+*|Xh*9i9zg}4s97j}Pw zChmXI^9FTPFGoGKMe0n)9_>Z1z8t+TvKQMBE}D&ngGrt-9GSm2;+(3z?6)Jcdh>_> zBRZ57*^7J+c5Fri*MK|w;EXlP@FKNG?ystU%RPMGx#q^`{*|bO_k^59sZl$^jy%j8 z4EAB^7}53v&MLp0n>ueT8qt;020PKkJ)A%5gkRQh4BIy1+ri*3TMDnrUGfs&!f}{! zVONa*uaEhj=sKPM+G$+NpALSnNq(fKA>-sOw5ivu;38`n1^hJZ8*Izw>tJ9|-KbaV~mk&F<9Y>Wv@hLF+ zuJ9js#rQ+Bi9{y%#)v_Wgf@ROIZnFt5}k5kK2?hj3+bHmn1QfuCP#&0Eo;e2Krlkar%*^&sQIPNF|I zN6x;;^!K6bY&eGXFX8=x@Go$nSlNrOM36k?c`N-U^a#h1%U4|{x-5b?l?kqg6`k44h z1j$qK-p~E_+_u>HYk!;QXI&?264|n>vk@0ZnK3?54D!7CZW9_+EhWE15N^5e4Se3@ znP-fy--!0{84#VUNn|TBj%{r@)+OS1+OdG`!^(&FNrWKFCC}Yl`+qMQ>_nYGqDHQX z=wwYITV3||PIQdW(+Kq8H|^boR%I{#`@??L36JnMG8)ntsYH8qndtkoHRK%Md)4@~55MMp67P`M z4+KUG`*^)T;t|;ZY`b=&=OHUfn4fstatus == TR_STATUS_PAUSE; } +- (BOOL) isError +{ + return fStat->error & TR_ETRACKER; +} + - (BOOL) justFinished { return tr_getFinished(fHandle); diff --git a/macosx/TorrentCell.h b/macosx/TorrentCell.h index f270d7540..03eb74165 100644 --- a/macosx/TorrentCell.h +++ b/macosx/TorrentCell.h @@ -32,6 +32,11 @@ { Torrent * fTorrent; BOOL fStatusRegular; + + NSImage * fProgressWhite, * fProgressBlue, * fProgressGray, * fProgressGreen, + * fProgressAdvanced, * fProgressEndWhite, * fProgressEndBlue, + * fProgressEndGray, * fProgressEndGreen, * fProgressEndAdvanced, + * fErrorImage; NSUserDefaults * fDefaults; } diff --git a/macosx/TorrentCell.m b/macosx/TorrentCell.m index 252a4b399..66eefd212 100644 --- a/macosx/TorrentCell.m +++ b/macosx/TorrentCell.m @@ -38,10 +38,6 @@ @implementation TorrentCell -static NSImage * fProgressWhite, * fProgressBlue, * fProgressGray, * fProgressGreen, - * fProgressAdvanced, * fProgressEndWhite, * fProgressEndBlue, - * fProgressEndGray, * fProgressEndGreen, * fProgressEndAdvanced; - // Used to optimize drawing. They contain packed RGBA pixels for every color needed. #define BE OSSwapBigToHostConstInt32 static uint32_t kBorder[] = @@ -68,44 +64,36 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 fStatusRegular = [fDefaults boolForKey: @"SmallStatusRegular"]; NSSize startSize = NSMakeSize(100.0, BAR_HEIGHT); - if (!fProgressWhite) - { - fProgressWhite = [NSImage imageNamed: @"ProgressBarWhite.png"]; - [fProgressWhite setScalesWhenResized: YES]; - } - if (!fProgressBlue) - { - fProgressBlue = [NSImage imageNamed: @"ProgressBarBlue.png"]; - [fProgressBlue setScalesWhenResized: YES]; - [fProgressBlue setSize: startSize]; - } - if (!fProgressGray) - { - fProgressGray = [NSImage imageNamed: @"ProgressBarGray.png"]; - [fProgressGray setScalesWhenResized: YES]; - [fProgressGray setSize: startSize]; - } - if (!fProgressGreen) - { - fProgressGreen = [NSImage imageNamed: @"ProgressBarGreen.png"]; - [fProgressGreen setScalesWhenResized: YES]; - } - if (!fProgressAdvanced) - { - fProgressAdvanced = [NSImage imageNamed: @"ProgressBarAdvanced.png"]; - [fProgressAdvanced setScalesWhenResized: YES]; - } - if (!fProgressEndWhite) - fProgressEndWhite = [NSImage imageNamed: @"ProgressBarEndWhite.png"]; - if (!fProgressEndBlue) - fProgressEndBlue = [NSImage imageNamed: @"ProgressBarEndBlue.png"]; - if (!fProgressEndGray) - fProgressEndGray = [NSImage imageNamed: @"ProgressBarEndGray.png"]; - if (!fProgressEndGreen) - fProgressEndGreen = [NSImage imageNamed: @"ProgressBarEndGreen.png"]; - if (!fProgressEndAdvanced) - fProgressEndAdvanced = [NSImage imageNamed: @"ProgressBarEndAdvanced.png"]; + fProgressWhite = [NSImage imageNamed: @"ProgressBarWhite.png"]; + [fProgressWhite setScalesWhenResized: YES]; + + + fProgressBlue = [NSImage imageNamed: @"ProgressBarBlue.png"]; + [fProgressBlue setScalesWhenResized: YES]; + [fProgressBlue setSize: startSize]; + + fProgressGray = [NSImage imageNamed: @"ProgressBarGray.png"]; + [fProgressGray setScalesWhenResized: YES]; + [fProgressGray setSize: startSize]; + + fProgressGreen = [NSImage imageNamed: @"ProgressBarGreen.png"]; + [fProgressGreen setScalesWhenResized: YES]; + + fProgressAdvanced = [NSImage imageNamed: @"ProgressBarAdvanced.png"]; + [fProgressAdvanced setScalesWhenResized: YES]; + + + fProgressEndWhite = [NSImage imageNamed: @"ProgressBarEndWhite.png"]; + fProgressEndBlue = [NSImage imageNamed: @"ProgressBarEndBlue.png"]; + fProgressEndGray = [NSImage imageNamed: @"ProgressBarEndGray.png"]; + fProgressEndGreen = [NSImage imageNamed: @"ProgressBarEndGreen.png"]; + fProgressEndAdvanced = [NSImage imageNamed: @"ProgressBarEndAdvanced.png"]; + + fErrorImage = [NSImage imageNamed: @"Error.tiff"]; + [fErrorImage setFlipped: YES]; + [fErrorImage setScalesWhenResized: YES]; + [fErrorImage setSize: NSMakeSize(16.0, 16.0)]; } return self; } @@ -313,6 +301,16 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 [icon drawAtPoint: pen fromRect: NSMakeRect(0, 0, iconSize.width, iconSize.height) operation: NSCompositeSourceOver fraction: 1.0]; + + //error badge + if ([fTorrent isError]) + { + NSSize errorIconSize = [fErrorImage size]; + [fErrorImage drawAtPoint: NSMakePoint(pen.x + iconSize.width - errorIconSize.width, + pen.y + iconSize.height - errorIconSize.height) + fromRect: NSMakeRect(0, 0, errorIconSize.width, errorIconSize.height) + operation: NSCompositeSourceOver fraction: 1.0]; + } float mainWidth = cellFrame.size.width - iconSize.width - 3.0 * PADDING - EXTRA_NAME_SHIFT; @@ -351,7 +349,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 else //small size { //icon - NSImage * icon = [fTorrent iconSmall]; + NSImage * icon = ![fTorrent isError] ? [fTorrent iconSmall] : fErrorImage; NSSize iconSize = [icon size]; pen.x += PADDING;