[vlc-commits] macosx/main menu: cosmetics

Felix Paul Kühne git at videolan.org
Tue Apr 16 23:13:13 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Tue Apr 16 22:39:31 2019 +0200| [a3ae8cd47652dd08e9391b46065569b849c8d154] | committer: Felix Paul Kühne

macosx/main menu: cosmetics

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a3ae8cd47652dd08e9391b46065569b849c8d154
---

 modules/gui/macosx/menus/VLCMainMenu.h |  18 ------
 modules/gui/macosx/menus/VLCMainMenu.m | 110 ++++++++++++++++++++-------------
 2 files changed, 68 insertions(+), 60 deletions(-)

diff --git a/modules/gui/macosx/menus/VLCMainMenu.h b/modules/gui/macosx/menus/VLCMainMenu.h
index cf9fb9b73e..57050e67aa 100644
--- a/modules/gui/macosx/menus/VLCMainMenu.h
+++ b/modules/gui/macosx/menus/VLCMainMenu.h
@@ -283,21 +283,3 @@
 - (IBAction)showPlaylist:(id)sender;
 
 @end
-
-/*****************************************************************************
- *VLCAutoGeneratedMenuContent interface
- *****************************************************************************
- *This holds our data for autogenerated menus
- *****************************************************************************/
- at 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;
-
- at end
diff --git a/modules/gui/macosx/menus/VLCMainMenu.m b/modules/gui/macosx/menus/VLCMainMenu.m
index fd60e48dfd..e5be19c726 100644
--- a/modules/gui/macosx/menus/VLCMainMenu.m
+++ b/modules/gui/macosx/menus/VLCMainMenu.m
@@ -57,6 +57,24 @@
 #import <Sparkle/Sparkle.h>
 #endif
 
+ at 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;
+
+ at end
+
 @interface VLCMainMenu() <NSMenuDelegate>
 {
     VLCAboutWindowController *_aboutWindowController;
@@ -186,7 +204,7 @@
     /* 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.
@@ -637,7 +655,7 @@
                            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];
     }
@@ -857,7 +875,7 @@
     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)
@@ -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,30 +1546,35 @@
     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
@@ -1608,7 +1638,7 @@
     }
 
     /* make (un)sensitive */
-    [parent setEnabled: (count > 1)];
+    [parent setEnabled:(count > 1)];
 
     for (i = 0; i < count; i++) {
         NSMenuItem *lmi;
@@ -1620,14 +1650,16 @@
 
                 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);
@@ -1636,16 +1668,18 @@
             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;
@@ -1665,13 +1699,14 @@
 {
     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;
@@ -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
  *****************************************************************************/
 
- at interface VLCAutoGeneratedMenuContent ()
-{
-    char *psz_name;
-    vlc_object_t *vlc_object;
-    vlc_value_t value;
-    int i_type;
-}
- at 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];
 



More information about the vlc-commits mailing list