Commit f690d54a authored by Felix Paul Kühne's avatar Felix Paul Kühne

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

parent 487825a5
......@@ -73,6 +73,7 @@
- (void)volumeDown;
- (void)toggleMute;
- (void)addSubtitlesToCurrentInput:(NSArray *)paths;
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
- (void)toggleFullscreen;
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment