[vlc-commits] macosx/main menu: show renderer type to ease selection between similarly named devices
Felix Paul Kühne
git at videolan.org
Mon Sep 2 11:57:48 CEST 2019
vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Sat Aug 31 12:47:26 2019 +0200| [e63e5bee08eb6e4cc9911690d871cc827c7b26d2] | committer: Felix Paul Kühne
macosx/main menu: show renderer type to ease selection between similarly named devices
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e63e5bee08eb6e4cc9911690d871cc827c7b26d2
---
.../gui/macosx/menus/renderers/VLCRendererItem.h | 2 ++
.../gui/macosx/menus/renderers/VLCRendererItem.m | 11 +++++++++++
.../menus/renderers/VLCRendererMenuController.m | 23 +++++++++++++++-------
3 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/modules/gui/macosx/menus/renderers/VLCRendererItem.h b/modules/gui/macosx/menus/renderers/VLCRendererItem.h
index 23a375c9ca..6b711dd810 100644
--- a/modules/gui/macosx/menus/renderers/VLCRendererItem.h
+++ b/modules/gui/macosx/menus/renderers/VLCRendererItem.h
@@ -58,6 +58,8 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (readonly) NSString *type;
+ at property (readonly) NSString *userReadableType;
+
/**
The iconURI of the renderer item
*/
diff --git a/modules/gui/macosx/menus/renderers/VLCRendererItem.m b/modules/gui/macosx/menus/renderers/VLCRendererItem.m
index 2eba69d174..fadbdf86a4 100644
--- a/modules/gui/macosx/menus/renderers/VLCRendererItem.m
+++ b/modules/gui/macosx/menus/renderers/VLCRendererItem.m
@@ -73,6 +73,17 @@
return toNSStr(vlc_renderer_item_type(_rendererItem));
}
+- (NSString *)userReadableType
+{
+ NSString *type = [self type];
+ if ([type isEqualToString:@"stream_out_dlna"]) {
+ return @"DLNA";
+ } else if ([type isEqualToString:@"chromecast"]) {
+ return @"Chromecast";
+ }
+ return type;
+}
+
- (int)capabilityFlags
{
return vlc_renderer_item_flags(_rendererItem);
diff --git a/modules/gui/macosx/menus/renderers/VLCRendererMenuController.m b/modules/gui/macosx/menus/renderers/VLCRendererMenuController.m
index 149bef848e..e80817b8cb 100644
--- a/modules/gui/macosx/menus/renderers/VLCRendererMenuController.m
+++ b/modules/gui/macosx/menus/renderers/VLCRendererMenuController.m
@@ -107,15 +107,24 @@
}
// Create a menu item
- NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:item.name
- action:@selector(selectRenderer:)
- keyEquivalent:@""];
+ NSMenuItem *menuItem = [[NSMenuItem alloc] init];
+ menuItem.target = self;
+ menuItem.action = @selector(selectRenderer:);
+ menuItem.keyEquivalent = @"";
if (item.capabilityFlags & VLC_RENDERER_CAN_VIDEO)
- [menuItem setImage:[NSImage imageNamed:@"sidebar-movie"]];
+ menuItem.image = [NSImage imageNamed:@"sidebar-movie"];
else
- [menuItem setImage:[NSImage imageNamed:@"sidebar-music"]];
- [menuItem setTarget:self];
- [menuItem setRepresentedObject:item];
+ menuItem.image = [NSImage imageNamed:@"sidebar-music"];
+ menuItem.representedObject = item;
+
+ NSString *unformattedTitle = [NSString stringWithFormat:@"%@ %@", item.name, item.userReadableType];
+ NSMutableAttributedString *title = [[NSMutableAttributedString alloc] initWithString:unformattedTitle
+ attributes:nil];
+ [title addAttributes:@{NSBaselineOffsetAttributeName : @(2),
+ NSFontAttributeName : [NSFont boldSystemFontOfSize:8]}
+ range:[unformattedTitle rangeOfString:item.userReadableType options:NSBackwardsSearch]];
+ menuItem.attributedTitle = title;
+
[_rendererMenu insertItem:menuItem atIndex:[_rendererMenu indexOfItem:_rendererNoneItem] + 1];
}
More information about the vlc-commits
mailing list