]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/ConvertAndSave.m
macosx: implement simpler and generic drop view for all drag / drop operations
[vlc] / modules / gui / macosx / ConvertAndSave.m
index 010422d9d3815486e60d658506f1060b90161544..2f5d9b0758b8789b5b0199726709d9469c40f25d 100644 (file)
@@ -190,7 +190,8 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
     [_customize_aud_samplerate_lbl setStringValue: _NS("Samplerate")];
     [_customize_subs_ckb setTitle: _NS("Subtitles")];
     [_customize_subs_overlay_ckb setTitle: _NS("Overlay subtitles on the video")];
-    [_stream_ok_btn setTitle:_NS("OK")];
+    [_stream_ok_btn setTitle: _NS("Apply")];
+    [_stream_cancel_btn setTitle: _NS("Cancel")];
     [_stream_destination_lbl setStringValue:_NS("Stream Destination")];
     [_stream_announcement_lbl setStringValue:_NS("Stream Announcement")];
     [_stream_type_lbl setStringValue:_NS("Type")];
@@ -260,6 +261,10 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
 
     [_ok_btn setEnabled: NO];
 
+    // setup drop view
+    [_drop_box enablePlaylistItems];
+    [_drop_box setDropHandler: self];
+
     [self resetCustomizationSheetBasedOnProfile:[self.profileValueList objectAtIndex:0]];
 }
 
@@ -457,6 +462,12 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
 
 - (IBAction)closeStreamPanel:(id)sender
 {
+    [_stream_panel orderOut:sender];
+    [NSApp endSheet: _stream_panel];
+
+    if (sender == _stream_cancel_btn)
+        return;
+
     /* provide a summary of the user selections */
     NSMutableString * labelContent = [[NSMutableString alloc] initWithFormat:_NS("%@ stream to %@:%@"), [_stream_type_pop titleOfSelectedItem], [_stream_address_fld stringValue], [_stream_port_fld stringValue]];
 
@@ -491,9 +502,6 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
     /* store destination for further reference and update UI */
     [self setOutputDestination: [_stream_address_fld stringValue]];
     [self updateOKButton];
-
-    [_stream_panel orderOut:sender];
-    [NSApp endSheet: _stream_panel];
 }
 
 - (IBAction)streamTypeToggle:(id)sender
@@ -572,7 +580,7 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
                     if (p_item) {
                         if (p_item->p_input) {
                             if (p_item->p_input->psz_uri != nil) {
-                                [self setMRL: [NSString stringWithFormat:@"%s", p_item->p_input->psz_uri]];
+                                [self setMRL: toNSStr(p_item->p_input->psz_uri)];
                                 [self updateDropView];
                                 [self updateOKButton];
 
@@ -916,9 +924,6 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
             if(haveVideo)
                 [composedOptions appendString:@","];
             [composedOptions appendFormat:@"acodec=%@", [self.currentProfile objectAtIndex:10]];
-
-
-            [composedOptions appendFormat:@"acodec=%@", [self.currentProfile objectAtIndex:10]];
             [composedOptions appendFormat:@",ab=%@", [self.currentProfile objectAtIndex:11]]; // bitrate
             [composedOptions appendFormat:@",channels=%@", [self.currentProfile objectAtIndex:12]]; // channel number
             [composedOptions appendFormat:@",samplerate=%@", [self.currentProfile objectAtIndex:13]]; // sample rate
@@ -1056,130 +1061,3 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
 }
 
 @end
-
-# pragma mark -
-# pragma mark Drag and drop handling
-
-@implementation VLCDropEnabledBox
-
-- (void)awakeFromNib
-{
-    [self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, @"VLCPlaylistItemPboardType", nil]];
-}
-
-- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
-{
-    b_activeDragAndDrop = YES;
-    [self setNeedsDisplay:YES];
-
-    [[NSCursor dragCopyCursor] set];
-
-    if ((NSDragOperationGeneric & [sender draggingSourceOperationMask]) == NSDragOperationGeneric)
-        return NSDragOperationGeneric;
-
-    return NSDragOperationNone;
-}
-
-- (void)draggingEnded:(id < NSDraggingInfo >)sender
-{
-    [[NSCursor arrowCursor] set];
-    b_activeDragAndDrop = NO;
-    [self setNeedsDisplay:YES];
-}
-
-- (void)draggingExited:(id < NSDraggingInfo >)sender
-{
-    [[NSCursor arrowCursor] set];
-    b_activeDragAndDrop = NO;
-    [self setNeedsDisplay:YES];
-}
-
-- (void)drawRect:(NSRect)dirtyRect
-{
-    if (b_activeDragAndDrop) {
-        [[NSColor colorWithCalibratedRed:(.154/.255) green:(.154/.255) blue:(.154/.255) alpha:1.] setFill];
-        NSRect frameRect = [[self contentView] bounds];
-        frameRect.origin.x += 10;
-        frameRect.origin.y += 10;
-        frameRect.size.width -= 17;
-        frameRect.size.height -= 17;
-        NSFrameRectWithWidthUsingOperation(frameRect, 4., NSCompositeHighlight);
-    }
-
-    [super drawRect:dirtyRect];
-}
-
-- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
-{
-    return YES;
-}
-
-- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
-{
-    return [[VLCConvertAndSave sharedInstance] performDragOperation: sender];
-}
-
-- (void)concludeDragOperation:(id <NSDraggingInfo>)sender
-{
-    [self setNeedsDisplay:YES];
-}
-
-@end
-
-@implementation VLCDropEnabledImageView
-
-- (void)awakeFromNib
-{
-    [self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, @"VLCPlaylistItemPboardType", nil]];
-}
-
-- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
-{
-    return [[[self superview] superview] draggingEntered:sender];
-}
-
-- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
-{
-    return YES;
-}
-
-- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
-{
-    return [[VLCConvertAndSave sharedInstance] performDragOperation: sender];
-}
-
-- (void)concludeDragOperation:(id <NSDraggingInfo>)sender
-{
-    [self setNeedsDisplay:YES];
-}
-
-@end
-
-@implementation VLCDropEnabledButton
-
-- (void)awakeFromNib
-{
-    [self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, @"VLCPlaylistItemPboardType", nil]];
-}
-
-- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
-{
-    return [[[self superview] superview] draggingEntered:sender];
-}
-
-- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
-{
-    return YES;
-}
-
-- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
-{
-    return [[VLCConvertAndSave sharedInstance] performDragOperation: sender];
-}
-
-- (void)concludeDragOperation:(id <NSDraggingInfo>)sender
-{
-    [self setNeedsDisplay:YES];
-}
-
-@end