Skip to content

Commit

Permalink
badge text now includes an ellipsis if it's still checking for H.264 …
Browse files Browse the repository at this point in the history
…variants; extra contextual items now appear if H.264 is confirmed but HD H.264 is still being checked
  • Loading branch information
Simone Manganelli authored and Simone Manganelli committed Jul 23, 2009
1 parent 57930e9 commit f1d8c95
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
1 change: 1 addition & 0 deletions Plugin/Plugin.h
Expand Up @@ -54,6 +54,7 @@ THE SOFTWARE.
NSString *_launchedAppBundleIdentifier;

BOOL _contextMenuIsVisible;
BOOL _receivedAllResponses;
NSURLConnection *connections[2];
unsigned expectedResponses;
NSTimer *_delayingTimer;
Expand Down
34 changes: 23 additions & 11 deletions Plugin/Plugin.m
Expand Up @@ -751,21 +751,30 @@ - (void) _loadInvisibleContentForWindow: (NSNotification*) notification

- (NSString*) badgeLabelText
{
if( [ self _useHDH264Version ] && [self _hasHDH264Version])
if( [ self _useHDH264Version ] && [self _hasHDH264Version]) {
return NSLocalizedString( @"HD H.264", @"HD H.264 badge text" );
if( [ self _useH264Version ] && [self _hasH264Version])
return NSLocalizedString( @"H.264", @"H.264 badge text" );
else if( _fromYouTube && _videoId)
} else if( [ self _useH264Version ] && [self _hasH264Version]) {
if (_receivedAllResponses) {
return NSLocalizedString( @"H.264", @"H.264 badge text" );
} else {
return NSLocalizedString( @"H.264…", @"H.264 badge waiting text" );
}
} else if( _fromYouTube && _videoId) {
// we check the video ID too because if it's a flash ad on YouTube.com,
// we don't want to identify it as an actual YouTube video -- but if
// the flash object actually has a video ID parameter, it means its
// a bona fide YouTube video

return NSLocalizedString( @"YouTube", @"YouTube badge text" );
else if( _badgeText )
if (_receivedAllResponses) {
return NSLocalizedString( @"YouTube", @"YouTube badge text" );
} else {
return NSLocalizedString( @"YouTube…", @"YouTube badge waiting text" );
}
} else if( _badgeText ) {
return _badgeText;
else
} else {
return NSLocalizedString( @"Flash", @"Flash badge text" );
}
}

- (void) _drawBadgeWithPressed: (BOOL) pressed
Expand Down Expand Up @@ -1158,24 +1167,27 @@ - (void)_checkForH264VideoVariants
}

expectedResponses = 2;
_receivedAllResponses = NO;
}
}

- (void)finishedWithConnection:(NSURLConnection *)connection
{
BOOL receivedAllResponses = YES;
BOOL didReceiveAllResponses = YES;

for (int i = 0; i < 2; ++i) {
if (connection == connections[i]) {
[connection cancel];
[connection release];
connections[i] = nil;
} else if (connections[i])
receivedAllResponses = NO;
didReceiveAllResponses = NO;
}

if (receivedAllResponses)
[self setUpExtraMenuItems];
if (didReceiveAllResponses) _receivedAllResponses = YES;

[self setUpExtraMenuItems];
[self setNeedsDisplay:YES];
}

- (void)connection:(NSURLConnection *)connection
Expand Down

0 comments on commit f1d8c95

Please sign in to comment.