macosx/main menu: cosmetics
authorFelix Paul Kühne <felix@feepk.net>
Tue, 16 Apr 2019 20:39:31 +0000 (22:39 +0200)
committerFelix Paul Kühne <felix@feepk.net>
Tue, 16 Apr 2019 21:12:49 +0000 (23:12 +0200)
modules/gui/macosx/menus/VLCMainMenu.h
modules/gui/macosx/menus/VLCMainMenu.m

index cf9fb9b..57050e6 100644 (file)
 - (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
index fd60e48..e5be19c 100644 (file)
 #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;
     /* Let the ExtensionsManager itself build the menu */
     VLCExtensionsManager *extMgr = [[VLCMain sharedInstance] extensionsManager];
     [extMgr buildMenu:_extensionsMenu];
-    [_extensions setEnabled: ([_extensionsMenu numberOfItems] > 0)];
+    [_extensions setEnabled:([_extensionsMenu numberOfItems] > 0)];
 
     // FIXME: Implement preference for autoloading extensions on mac
     // FIXME: this is definitely the wrong place to do this.
                            action:@selector(toggleFullscreenDevice:)
                     keyEquivalent:@""];
         menuItem = [submenu itemAtIndex:i+1];
-        [menuItem setTag: (int)[[screens objectAtIndex:i] displayID]];
+        [menuItem setTag:(int)[[screens objectAtIndex:i] displayID]];
         [menuItem setEnabled: YES];
         [menuItem setTarget: self];
     }
     vlc_tick_t length = _playerController.length;
     [_timeSelectionPanel setMaxTime:(int)SEC_FROM_VLC_TICK(length)];
     vlc_tick_t time = _playerController.time;
-    [_timeSelectionPanel setPosition: (int)SEC_FROM_VLC_TICK(time)];
+    [_timeSelectionPanel setPosition:(int)SEC_FROM_VLC_TICK(time)];
     [_timeSelectionPanel runModalForWindow:[NSApp mainWindow]
                          completionHandler:^(NSInteger returnCode, int64_t returnTime) {
                              if (returnCode != NSModalResponseOK)
     _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];
 
 
 - (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
     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;
     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);
 }
 
 
 - (void)setupVarMenu:(NSMenu *)menu
-         forMenuItem: (NSMenuItem *)parent
+         forMenuItem:(NSMenuItem *)parent
               target:(vlc_object_t *)p_object
                  var:(const char *)psz_variable
             selector:(SEL)pf_callback
     }
 
     /* make (un)sensitive */
-    [parent setEnabled: (count > 1)];
+    [parent setEnabled:(count > 1)];
 
     for (i = 0; i < count; i++) {
         NSMenuItem *lmi;
 
                 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];
+                lmi = [menu addItemWithTitle:title action:pf_callback keyEquivalent:@""];
+                data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName:psz_variable
+                                                                        ofObject:p_object
+                                                                        andValue:val_list[i]
+                                                                          ofType:i_type];
                 [lmi setRepresentedObject:data];
-                [lmi setTarget: self];
+                [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);
             case VLC_VAR_INTEGER:
 
                 title = text_list[i] ?
-                _NS(text_list[i]) : [NSString stringWithFormat: @"%"PRId64, val_list[i].i_int];
+                _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];
+                [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;
 {
     NSMenuItem *mi = (NSMenuItem *)sender;
     VLCAutoGeneratedMenuContent *data = [mi representedObject];
-    [NSThread detachNewThreadSelector: @selector(toggleVarThread:)
-                             toTarget: self withObject: data];
+    [NSThread detachNewThreadSelector:@selector(toggleVarThread:)
+                             toTarget:self
+                           withObject:data];
 
     return;
 }
 
-- (int)toggleVarThread: (id)data
+- (void)toggleVarThread:(id)data
 {
     @autoreleasepool {
         vlc_object_t *p_object;
 
         p_object = [menuContent vlcObject];
         var_Set(p_object, [menuContent name], [menuContent value]);
-        return true;
     }
 }
 
 
         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")];
 
 
 @end
 
-
 /*****************************************************************************
  *VLCAutoGeneratedMenuContent implementation
  *****************************************************************************
  *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];