[vlc-commits] macosx/main menu: remove dependency on core interaction singleton

Felix Paul Kühne git at videolan.org
Sat Apr 13 22:10:01 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Sat Apr 13 21:23:08 2019 +0200| [8651d45b69f315322a00bdc067e7b1901e426fdd] | committer: Felix Paul Kühne

macosx/main menu: remove dependency on core interaction singleton

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

 modules/gui/macosx/menus/VLCMainMenu.m            | 21 +++++++++++++++------
 modules/gui/macosx/playlist/VLCPlayerController.h |  5 +++++
 modules/gui/macosx/playlist/VLCPlayerController.m | 10 ++++++++++
 3 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/modules/gui/macosx/menus/VLCMainMenu.m b/modules/gui/macosx/menus/VLCMainMenu.m
index 4206a5b142..f04c7e35a0 100644
--- a/modules/gui/macosx/menus/VLCMainMenu.m
+++ b/modules/gui/macosx/menus/VLCMainMenu.m
@@ -23,7 +23,6 @@
 #import "VLCMainMenu.h"
 #import "main/VLCMain.h"
 
-#import "coreinteraction/VLCCoreInteraction.h"
 #import "coreinteraction/VLCVideoFilterHelper.h"
 
 #import "extensions/NSScreen+VLCAdditions.h"
@@ -804,8 +803,8 @@
 - (void)lockVideosAspectRatio:(id)sender
 {
     // FIXME: re-write the following using VLCPlayerController
-    [[VLCCoreInteraction sharedInstance] setAspectRatioIsLocked: ![sender state]];
-    [sender setState: [[VLCCoreInteraction sharedInstance] aspectRatioIsLocked]];
+    [_playerController setAspectRatioIsLocked: ![sender state]];
+    [sender setState: [_playerController aspectRatioIsLocked]];
 }
 
 - (IBAction)quitAfterPlayback:(id)sender
@@ -1166,8 +1165,18 @@
 
     i_returnValue = [openPanel runModal];
 
-    if (i_returnValue == NSModalResponseOK)
-        [[VLCCoreInteraction sharedInstance] addSubtitlesToCurrentInput:[openPanel URLs]];
+    if (i_returnValue == NSModalResponseOK) {
+        NSArray *URLs = [openPanel URLs];
+        NSUInteger count = [URLs count];
+        for (int i = 0; i < count ; i++) {
+            NSURL *url = URLs[i];
+            [_playerController addAssociatedMediaToCurrentFromURL:url
+                                                       ofCategory:SPU_ES
+                                                 shallSelectTrack:YES
+                                                  shallDisplayOSD:YES
+                                             shallVerifyExtension:NO];
+        }
+    }
 }
 
 - (void)switchSubtitleSize:(id)sender
@@ -1559,7 +1568,7 @@
         lmi_tmp2 = [menu addItemWithTitle: _NS("Lock Aspect Ratio") action: @selector(lockVideosAspectRatio:) keyEquivalent: @""];
         [lmi_tmp2 setTarget: self];
         [lmi_tmp2 setEnabled: YES];
-        [lmi_tmp2 setState: [[VLCCoreInteraction sharedInstance] aspectRatioIsLocked]];
+        [lmi_tmp2 setState: [_playerController aspectRatioIsLocked]];
         [parent setEnabled: YES];
         [menu addItem: [NSMenuItem separatorItem]];
     }
diff --git a/modules/gui/macosx/playlist/VLCPlayerController.h b/modules/gui/macosx/playlist/VLCPlayerController.h
index c0fc152547..ea06f81482 100644
--- a/modules/gui/macosx/playlist/VLCPlayerController.h
+++ b/modules/gui/macosx/playlist/VLCPlayerController.h
@@ -803,6 +803,11 @@ extern NSString *VLCPlayerMuteChanged;
  */
 - (void)setVideoFilterChain:(nullable NSString *)filterChain forType:(enum vlc_vout_filter_type)filterType;
 
+/**
+ * defines whether the vout windows lock on the video's AR or can be resized arbitrarily
+ */
+ at property (nonatomic, readwrite) BOOL aspectRatioIsLocked;
+
 #pragma mark - audio output properties
 
 /**
diff --git a/modules/gui/macosx/playlist/VLCPlayerController.m b/modules/gui/macosx/playlist/VLCPlayerController.m
index 22e44f492b..4f980ec536 100644
--- a/modules/gui/macosx/playlist/VLCPlayerController.m
+++ b/modules/gui/macosx/playlist/VLCPlayerController.m
@@ -1623,6 +1623,16 @@ static const struct vlc_player_aout_cbs player_aout_callbacks = {
     vlc_player_vout_SetFilter(_p_player, filterType, filterChain != nil ? [filterChain UTF8String] : NULL);
 }
 
+- (void)setAspectRatioIsLocked:(BOOL)b_value
+{
+    config_PutInt("macosx-lock-aspect-ratio", b_value);
+}
+
+- (BOOL)aspectRatioIsLocked
+{
+    return config_GetInt("macosx-lock-aspect-ratio");
+}
+
 #pragma mark - audio specific delegation
 
 - (void)volumeChanged:(float)volume



More information about the vlc-commits mailing list