mirror of
https://github.com/transmission/transmission
synced 2024-12-25 01:03:01 +00:00
Pieces View is working again
This commit is contained in:
parent
4f3adfc8d7
commit
0ed7d6ab4a
4 changed files with 36 additions and 12 deletions
BIN
macosx/English.lproj/InfoWindow.nib/keyedobjects.nib
generated
BIN
macosx/English.lproj/InfoWindow.nib/keyedobjects.nib
generated
Binary file not shown.
|
@ -202,16 +202,27 @@
|
||||||
[fImageView setImage: [[fBack copy] autorelease]];
|
[fImageView setImage: [[fBack copy] autorelease]];
|
||||||
NSImage * image = [fImageView image];
|
NSImage * image = [fImageView image];
|
||||||
|
|
||||||
int8_t * pieces = malloc(fNumPieces);
|
int8_t * pieces;
|
||||||
|
float * piecesPercent;
|
||||||
|
|
||||||
BOOL showAvailablity = [[NSUserDefaults standardUserDefaults] boolForKey: @"PiecesViewShowAvailability"];
|
BOOL showAvailablity = [[NSUserDefaults standardUserDefaults] boolForKey: @"PiecesViewShowAvailability"];
|
||||||
|
|
||||||
if (showAvailablity)
|
if (showAvailablity)
|
||||||
|
{
|
||||||
|
pieces = malloc(fNumPieces);
|
||||||
[fTorrent getAvailability: pieces size: fNumPieces];
|
[fTorrent getAvailability: pieces size: fNumPieces];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
[fTorrent getAmountFinished: pieces size: fNumPieces];
|
{
|
||||||
|
piecesPercent = malloc(fNumPieces * sizeof(float));
|
||||||
|
[fTorrent getAmountFinished: piecesPercent size: fNumPieces];
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < fNumPieces; i++)
|
||||||
|
NSLog(@"%f", piecesPercent[i]);
|
||||||
|
}
|
||||||
|
|
||||||
int i, j, piece, index = -1;
|
int i, j, piece, index = -1;
|
||||||
|
float piecePercent;
|
||||||
NSPoint point;
|
NSPoint point;
|
||||||
NSRect rect = NSMakeRect(0, 0, fWidth, fWidth);
|
NSRect rect = NSMakeRect(0, 0, fWidth, fWidth);
|
||||||
NSImage * pieceImage;
|
NSImage * pieceImage;
|
||||||
|
@ -228,10 +239,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
pieceImage = nil;
|
pieceImage = nil;
|
||||||
piece = pieces[index];
|
|
||||||
|
|
||||||
if (showAvailablity)
|
if (showAvailablity)
|
||||||
{
|
{
|
||||||
|
piece = pieces[index];
|
||||||
if (piece < 0)
|
if (piece < 0)
|
||||||
{
|
{
|
||||||
if (first || fPieces[index] == -2)
|
if (first || fPieces[index] == -2)
|
||||||
|
@ -281,6 +292,7 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
piecePercent = piecesPercent[index];
|
||||||
/*if (i==0)
|
/*if (i==0)
|
||||||
pieceImage = fBlue1Piece;
|
pieceImage = fBlue1Piece;
|
||||||
else if (i==1)
|
else if (i==1)
|
||||||
|
@ -292,7 +304,7 @@
|
||||||
else if (i==4)
|
else if (i==4)
|
||||||
pieceImage = fBluePiece;
|
pieceImage = fBluePiece;
|
||||||
|
|
||||||
else */if (piece <= 0)
|
else */if (piecePercent <= 0.0)
|
||||||
{
|
{
|
||||||
if (first || fPieces[index] != 0)
|
if (first || fPieces[index] != 0)
|
||||||
{
|
{
|
||||||
|
@ -300,7 +312,7 @@
|
||||||
pieceImage = fWhitePiece;
|
pieceImage = fWhitePiece;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (piece < 25)
|
else if (piecePercent < 0.25)
|
||||||
{
|
{
|
||||||
if (first || fPieces[index] != 1)
|
if (first || fPieces[index] != 1)
|
||||||
{
|
{
|
||||||
|
@ -308,7 +320,7 @@
|
||||||
pieceImage = fBlue1Piece;
|
pieceImage = fBlue1Piece;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (piece < 50)
|
else if (piecePercent < 0.50)
|
||||||
{
|
{
|
||||||
if (first || fPieces[index] != 2)
|
if (first || fPieces[index] != 2)
|
||||||
{
|
{
|
||||||
|
@ -316,7 +328,7 @@
|
||||||
pieceImage = fBlue2Piece;
|
pieceImage = fBlue2Piece;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (piece < 75)
|
else if (piecePercent < 0.75)
|
||||||
{
|
{
|
||||||
if (first || fPieces[index] != 3)
|
if (first || fPieces[index] != 3)
|
||||||
{
|
{
|
||||||
|
@ -324,7 +336,7 @@
|
||||||
pieceImage = fBlue3Piece;
|
pieceImage = fBlue3Piece;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (piece < 100)
|
else if (piecePercent < 1.0)
|
||||||
{
|
{
|
||||||
if (first || fPieces[index] != 4)
|
if (first || fPieces[index] != 4)
|
||||||
{
|
{
|
||||||
|
@ -363,7 +375,19 @@
|
||||||
[fImageView setNeedsDisplay];
|
[fImageView setNeedsDisplay];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (showAvailablity)
|
||||||
free(pieces);
|
free(pieces);
|
||||||
|
else
|
||||||
|
free(piecesPercent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*- (void) toggleView: (id) sender
|
||||||
|
{
|
||||||
|
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
|
||||||
|
[defaults setBool: ![defaults boolForKey: @"PiecesViewShowAvailability"]
|
||||||
|
forKey: @"PiecesViewShowAvailability"];
|
||||||
|
|
||||||
|
[self updateView: YES];
|
||||||
|
}*/
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
- (NSString *) downloadFolder;
|
- (NSString *) downloadFolder;
|
||||||
|
|
||||||
- (void) getAvailability: (int8_t *) tab size: (int) size;
|
- (void) getAvailability: (int8_t *) tab size: (int) size;
|
||||||
- (void) getAmountFinished: (int8_t *) tab size: (int) size;
|
- (void) getAmountFinished: (float *) tab size: (int) size;
|
||||||
|
|
||||||
- (void) update;
|
- (void) update;
|
||||||
- (NSDictionary *) infoForCurrentView;
|
- (NSDictionary *) infoForCurrentView;
|
||||||
|
|
|
@ -164,7 +164,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||||
tr_torrentAvailability(fHandle, tab, size);
|
tr_torrentAvailability(fHandle, tab, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) getAmountFinished: (int8_t *) tab size: (int) size
|
- (void) getAmountFinished: (float *) tab size: (int) size
|
||||||
{
|
{
|
||||||
tr_torrentAmountFinished(fHandle, tab, size);
|
tr_torrentAmountFinished(fHandle, tab, size);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue