[vlc-commits] macosx: simple prefs: Replace huge define by block / inline function
David Fuhrmann
git at videolan.org
Sun Jun 10 11:03:05 CEST 2018
vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Sat Jun 9 20:08:46 2018 +0200| [ea8ed957e480c46436a4e8b4edc9ad2945b2345a] | committer: David Fuhrmann
macosx: simple prefs: Replace huge define by block / inline function
One should not have such huge defines.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ea8ed957e480c46436a4e8b4edc9ad2945b2345a
---
modules/gui/macosx/VLCSimplePrefsController.m | 60 +++++++++++++--------------
1 file changed, 28 insertions(+), 32 deletions(-)
diff --git a/modules/gui/macosx/VLCSimplePrefsController.m b/modules/gui/macosx/VLCSimplePrefsController.m
index 63de13b3ba..018bac43a1 100644
--- a/modules/gui/macosx/VLCSimplePrefsController.m
+++ b/modules/gui/macosx/VLCSimplePrefsController.m
@@ -1295,38 +1295,34 @@ static inline void save_string_list(intf_thread_t * p_intf, id object, const cha
- (IBAction)urlHandlerAction:(id)sender
{
if (sender == _input_urlhandlerButton) {
- NSArray *handlers;
- NSString *handler;
- NSString *rawhandler;
- NSMutableArray *rawHandlers;
- NSUInteger count;
-
-#define fillUrlHandlerPopup( protocol, object ) \
- handlers = (__bridge_transfer NSArray *)LSCopyAllHandlersForURLScheme(CFSTR( protocol )); \
- rawHandlers = [[NSMutableArray alloc] init]; \
- [object removeAllItems]; \
- count = [handlers count]; \
- for (NSUInteger x = 0; x < count; x++) { \
- rawhandler = [handlers objectAtIndex:x]; \
- handler = [self applicationNameForBundleIdentifier:rawhandler]; \
- if (handler && ![handler isEqualToString:@""]) { \
- [object addItemWithTitle:handler]; \
- [[object lastItem] setImage: [self iconForBundleIdentifier:[handlers objectAtIndex:x]]]; \
- [rawHandlers addObject: rawhandler]; \
- } \
- } \
- [object selectItemAtIndex: [rawHandlers indexOfObject:(__bridge_transfer id)LSCopyDefaultHandlerForURLScheme(CFSTR( protocol ))]];
-
- fillUrlHandlerPopup( "ftp", _urlhandler_ftpPopup);
- fillUrlHandlerPopup( "mms", _urlhandler_mmsPopup);
- fillUrlHandlerPopup( "rtmp", _urlhandler_rtmpPopup);
- fillUrlHandlerPopup( "rtp", _urlhandler_rtpPopup);
- fillUrlHandlerPopup( "rtsp", _urlhandler_rtspPopup);
- fillUrlHandlerPopup( "sftp", _urlhandler_sftpPopup);
- fillUrlHandlerPopup( "smb", _urlhandler_smbPopup);
- fillUrlHandlerPopup( "udp", _urlhandler_udpPopup);
-
-#undef fillUrlHandlerPopup
+
+ void (^fillUrlHandlerPopup)(NSString*, NSPopUpButton*) = ^void(NSString *protocol, NSPopUpButton *object) {
+
+ NSArray *handlers = (__bridge_transfer NSArray *)LSCopyAllHandlersForURLScheme((__bridge CFStringRef)protocol);
+ NSMutableArray *rawHandlers = [[NSMutableArray alloc] init];
+ [object removeAllItems];
+ NSUInteger count = [handlers count];
+ for (NSUInteger x = 0; x < count; x++) {
+ NSString *rawhandler = [handlers objectAtIndex:x];
+ NSString *handler = [self applicationNameForBundleIdentifier:rawhandler];
+ if (handler && ![handler isEqualToString:@""]) {
+ [object addItemWithTitle:handler];
+ [[object lastItem] setImage: [self iconForBundleIdentifier:[handlers objectAtIndex:x]]];
+ [rawHandlers addObject: rawhandler];
+ }
+ }
+ [object selectItemAtIndex: [rawHandlers indexOfObject:(__bridge_transfer id)LSCopyDefaultHandlerForURLScheme((__bridge CFStringRef)protocol)]];
+ };
+
+ fillUrlHandlerPopup(@"ftp", _urlhandler_ftpPopup);
+ fillUrlHandlerPopup(@"mms", _urlhandler_mmsPopup);
+ fillUrlHandlerPopup(@"rtmp", _urlhandler_rtmpPopup);
+ fillUrlHandlerPopup(@"rtp", _urlhandler_rtpPopup);
+ fillUrlHandlerPopup(@"rtsp", _urlhandler_rtspPopup);
+ fillUrlHandlerPopup(@"sftp", _urlhandler_sftpPopup);
+ fillUrlHandlerPopup(@"smb", _urlhandler_smbPopup);
+ fillUrlHandlerPopup(@"udp", _urlhandler_udpPopup);
+
[NSApp beginSheet:_urlhandler_win modalForWindow:self.window modalDelegate:self didEndSelector:NULL contextInfo:nil];
} else {
More information about the vlc-commits
mailing list