Ladybird/AppKit: Display a tool tip on the tab mute button

This commit is contained in:
Timothy Flynn 2024-03-30 11:02:10 -04:00 committed by Andreas Kling
parent 9e4ffbcf70
commit f374e64dfc

View file

@ -192,6 +192,7 @@ static constexpr CGFloat const WINDOW_HEIGHT = 800;
case Web::HTML::AudioPlayState::Playing: case Web::HTML::AudioPlayState::Playing:
[button setImage:[self iconForPageMuteState]]; [button setImage:[self iconForPageMuteState]];
[button setToolTip:[self toolTipForPageMuteState]];
break; break;
} }
} }
@ -210,6 +211,20 @@ static constexpr CGFloat const WINDOW_HEIGHT = 800;
VERIFY_NOT_REACHED(); VERIFY_NOT_REACHED();
} }
- (NSString*)toolTipForPageMuteState
{
auto& view = [[self web_view] view];
switch (view.page_mute_state()) {
case Web::HTML::MuteState::Muted:
return @"Unmute tab";
case Web::HTML::MuteState::Unmuted:
return @"Mute tab";
}
VERIFY_NOT_REACHED();
}
- (void)onContentScroll:(NSNotification*)notification - (void)onContentScroll:(NSNotification*)notification
{ {
[[self web_view] handleScroll]; [[self web_view] handleScroll];
@ -321,6 +336,8 @@ static constexpr CGFloat const WINDOW_HEIGHT = 800;
auto* button = [NSButton buttonWithImage:[self iconForPageMuteState] auto* button = [NSButton buttonWithImage:[self iconForPageMuteState]
target:self target:self
action:@selector(togglePageMuteState:)]; action:@selector(togglePageMuteState:)];
[button setToolTip:[self toolTipForPageMuteState]];
[[self tab] setAccessoryView:button]; [[self tab] setAccessoryView:button];
break; break;
} }