[vlc-commits] macosx: move re-useable code from menu to core interaction object

Felix Paul Kühne git at videolan.org
Fri May 16 22:34:56 CEST 2014


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Fri May 16 22:17:56 2014 +0200| [f690d54a0f58b5198712d8ff0d05729499067572] | committer: Felix Paul Kühne

macosx: move re-useable code from menu to core interaction object

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

 modules/gui/macosx/CoreInteraction.h |    1 +
 modules/gui/macosx/CoreInteraction.m |   19 +++++++++++++++++++
 modules/gui/macosx/MainMenu.m        |   19 ++++---------------
 3 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/modules/gui/macosx/CoreInteraction.h b/modules/gui/macosx/CoreInteraction.h
index f6a8dc4..8ae0957 100644
--- a/modules/gui/macosx/CoreInteraction.h
+++ b/modules/gui/macosx/CoreInteraction.h
@@ -73,6 +73,7 @@
 - (void)volumeDown;
 - (void)toggleMute;
 
+- (void)addSubtitlesToCurrentInput:(NSArray *)paths;
 - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
 
 - (void)toggleFullscreen;
diff --git a/modules/gui/macosx/CoreInteraction.m b/modules/gui/macosx/CoreInteraction.m
index 2329416..78f4ac1 100644
--- a/modules/gui/macosx/CoreInteraction.m
+++ b/modules/gui/macosx/CoreInteraction.m
@@ -546,6 +546,25 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
     return f_maxVolume;
 }
 
+- (void)addSubtitlesToCurrentInput:(NSArray *)paths
+{
+    input_thread_t * p_input = pl_CurrentInput(VLCIntf);
+    if (!p_input)
+        return;
+
+    NSUInteger count = [paths count];
+
+    for (int i = 0; i < count ; i++) {
+        const char *path = [[[paths objectAtIndex:i] path] UTF8String];
+        msg_Dbg(VLCIntf, "loading subs from %s", path);
+
+        int i_result = input_AddSubtitleOSD(p_input, path, true, true);
+        if (i_result != VLC_SUCCESS)
+            msg_Warn(VLCIntf, "unable to load subtitles from '%s'", path);
+    }
+    vlc_object_release(p_input);
+}
+
 #pragma mark -
 #pragma mark drag and drop support for VLCVoutView, VLCDragDropView and VLCThreePartDropView
 - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
diff --git a/modules/gui/macosx/MainMenu.m b/modules/gui/macosx/MainMenu.m
index 8c21735..e71d805 100644
--- a/modules/gui/macosx/MainMenu.m
+++ b/modules/gui/macosx/MainMenu.m
@@ -24,6 +24,7 @@
 #import "MainMenu.h"
 #import <vlc_common.h>
 #import <vlc_playlist.h>
+#import <vlc_input.h>
 
 #import "intf.h"
 #import "open.h"
@@ -970,24 +971,12 @@ static VLCMainMenu *_o_sharedInstance = nil;
     o_url = [o_url URLByDeletingLastPathComponent];
     [openPanel setDirectoryURL: o_url];
     free(path);
+    vlc_object_release(p_input);
 
     i_returnValue = [openPanel runModal];
 
-    if (i_returnValue == NSOKButton) {
-        NSUInteger c = 0;
-        if (!p_input)
-            return;
-
-        c = [[openPanel URLs] count];
-
-        for (int i = 0; i < c ; i++) {
-            msg_Dbg(VLCIntf, "loading subs from %s", [[[[openPanel URLs] objectAtIndex:i] path] UTF8String]);
-            if (input_AddSubtitle(p_input, [[[[openPanel URLs] objectAtIndex:i] path] UTF8String], TRUE))
-                msg_Warn(VLCIntf, "unable to load subtitles from '%s'",
-                         [[[[openPanel URLs] objectAtIndex:i] path] UTF8String]);
-        }
-    }
-    vlc_object_release(p_input);
+    if (i_returnValue == NSOKButton)
+        [[VLCCoreInteraction sharedInstance] addSubtitlesToCurrentInput:[openPanel URLs]];
 }
 
 - (IBAction)switchSubtitleOption:(id)sender



More information about the vlc-commits mailing list