1
mirror of https://code.videolan.org/videolan/vlc synced 2024-09-12 13:44:56 +02:00

macosx/main menu: cosmetics

This commit is contained in:
Felix Paul Kühne 2019-04-16 22:39:31 +02:00
parent 98d9c145c8
commit a3ae8cd476
2 changed files with 68 additions and 60 deletions

View File

@ -283,21 +283,3 @@
- (IBAction)showPlaylist:(id)sender;
@end
/*****************************************************************************
*VLCAutoGeneratedMenuContent interface
*****************************************************************************
*This holds our data for autogenerated menus
*****************************************************************************/
@interface VLCAutoGeneratedMenuContent : NSObject
- (id)initWithVariableName: (const char *)name
ofObject: (vlc_object_t *)object
andValue: (vlc_value_t)value
ofType: (int)type;
- (const char *)name;
- (vlc_value_t)value;
- (vlc_object_t *)vlcObject;
- (int)type;
@end

View File

@ -57,6 +57,24 @@
#import <Sparkle/Sparkle.h>
#endif
@interface VLCAutoGeneratedMenuContent : NSObject
{
char *psz_name;
vlc_object_t *vlc_object;
vlc_value_t value;
int i_type;
}
- (id)initWithVariableName:(const char *)name
ofObject:(vlc_object_t *)object
andValue:(vlc_value_t)value
ofType:(int)type;
- (const char *)name;
- (vlc_value_t)value;
- (vlc_object_t *)vlcObject;
- (int)type;
@end
@interface VLCMainMenu() <NSMenuDelegate>
{
VLCAboutWindowController *_aboutWindowController;
@ -890,7 +908,10 @@
_subtitle_track.enabled = numberOfTracks > 0 ? YES : NO;
}
- (void)rebuildTracksMenu:(NSMenu *)menu withMetadata:(NSArray *)metadataArray count:(size_t)count category:(enum es_format_category_e)category
- (void)rebuildTracksMenu:(NSMenu *)menu
withMetadata:(NSArray *)metadataArray
count:(size_t)count
category:(enum es_format_category_e)category
{
[menu removeAllItems];
@ -1320,8 +1341,9 @@
- (IBAction)showPreferences:(id)sender
{
NSInteger i_level = [[[VLCMain sharedInstance] voutProvider] currentStatusWindowLevel];
[[[VLCMain sharedInstance] simplePreferences] showSimplePrefsWithLevel:i_level];
VLCMain *mainInstance = [VLCMain sharedInstance];
NSInteger i_level = [[mainInstance voutProvider] currentStatusWindowLevel];
[[mainInstance simplePreferences] showSimplePrefsWithLevel:i_level];
}
- (IBAction)openAddonManager:(id)sender
@ -1508,8 +1530,11 @@
if (i_type & VLC_VAR_HASCHOICE) {
NSMenu *menu = [menuItem submenu];
[self setupVarMenu:menu forMenuItem:menuItem target:p_object
var:psz_variable selector:pf_callback];
[self setupVarMenu:menu
forMenuItem:menuItem
target:p_object
var:psz_variable
selector:pf_callback];
free(text);
return;
@ -1521,24 +1546,29 @@
VLCAutoGeneratedMenuContent *data;
switch(i_type & VLC_VAR_TYPE) {
case VLC_VAR_VOID:
data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
andValue: val ofType: i_type];
data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName:psz_variable
ofObject:p_object
andValue:val
ofType:i_type];
[menuItem setRepresentedObject:data];
break;
case VLC_VAR_BOOL:
data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
andValue: val ofType: i_type];
data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName:psz_variable
ofObject:p_object
andValue:val
ofType:i_type];
[menuItem setRepresentedObject:data];
if (!(i_type & VLC_VAR_ISCOMMAND))
[menuItem setState: val.b_bool ? TRUE : FALSE ];
[menuItem setState:val.b_bool ? NSOnState : NSOffState];
break;
default:
break;
}
if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING) free(val.psz_string);
if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING)
free(val.psz_string);
free(text);
}
@ -1621,13 +1651,15 @@
title = _NS(text_list[i] ? text_list[i] : val_list[i].psz_string);
lmi = [menu addItemWithTitle:title action:pf_callback keyEquivalent:@""];
data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
andValue: val_list[i] ofType: i_type];
data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName:psz_variable
ofObject:p_object
andValue:val_list[i]
ofType:i_type];
[lmi setRepresentedObject:data];
[lmi setTarget:self];
if (!strcmp(val.psz_string, val_list[i].psz_string) && !(i_type & VLC_VAR_ISCOMMAND))
[lmi setState: TRUE ];
[lmi setState:NSOnState];
free(text_list[i]);
free(val_list[i].psz_string);
@ -1639,13 +1671,15 @@
_NS(text_list[i]) : [NSString stringWithFormat:@"%"PRId64, val_list[i].i_int];
lmi = [menu addItemWithTitle: title action: pf_callback keyEquivalent: @""];
data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
andValue: val_list[i] ofType: i_type];
data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName:psz_variable
ofObject:p_object
andValue:val_list[i]
ofType:i_type];
[lmi setRepresentedObject:data];
[lmi setTarget:self];
if (val_list[i].i_int == val.i_int && !(i_type & VLC_VAR_ISCOMMAND))
[lmi setState: TRUE ];
[lmi setState:NSOnState];
free(text_list[i]);
break;
@ -1666,12 +1700,13 @@
NSMenuItem *mi = (NSMenuItem *)sender;
VLCAutoGeneratedMenuContent *data = [mi representedObject];
[NSThread detachNewThreadSelector:@selector(toggleVarThread:)
toTarget: self withObject: data];
toTarget:self
withObject:data];
return;
}
- (int)toggleVarThread: (id)data
- (void)toggleVarThread:(id)data
{
@autoreleasepool {
vlc_object_t *p_object;
@ -1681,7 +1716,6 @@
p_object = [menuContent vlcObject];
var_Set(p_object, [menuContent name], [menuContent value]);
return true;
}
}
@ -1760,7 +1794,6 @@
vout_thread_t *p_vout = [_playerController videoOutputThreadForKeyWindow];
if (p_vout != NULL) {
// FIXME: re-write using VLCPlayerController
if (mi == _floatontop)
[mi setState: var_GetBool(p_vout, "video-on-top")];
@ -1796,7 +1829,6 @@
@end
/*****************************************************************************
*VLCAutoGeneratedMenuContent implementation
*****************************************************************************
@ -1804,18 +1836,12 @@
*the variable of the autogenerated menu
*****************************************************************************/
@interface VLCAutoGeneratedMenuContent ()
{
char *psz_name;
vlc_object_t *vlc_object;
vlc_value_t value;
int i_type;
}
@end
@implementation VLCAutoGeneratedMenuContent
-(id) initWithVariableName:(const char *)name ofObject:(vlc_object_t *)object
andValue:(vlc_value_t)val ofType:(int)type
-(id)initWithVariableName:(const char *)name
ofObject:(vlc_object_t *)object
andValue:(vlc_value_t)val
ofType:(int)type
{
self = [super init];