Commit 4ee84122 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: Convert & Save dialog: finished drag & drop support in the input box

parent dbd8e30b
......@@ -32,6 +32,7 @@
IBOutlet id o_drop_lbl;
IBOutlet id o_drop_image_view;
IBOutlet id o_drop_btn;
IBOutlet id o_drop_box;
IBOutlet id o_profile_lbl;
IBOutlet id o_profile_pop;
......@@ -47,7 +48,7 @@
IBOutlet id o_dropin_icon_view;
IBOutlet id o_dropin_media_lbl;
NSString * MRL;
NSString * _MRL;
}
@property (readwrite, nonatomic, retain) NSString * MRL;
......@@ -68,3 +69,11 @@
@interface VLCDropEnabledBox : NSBox
@end
@interface VLCDropEnabledImageView : NSImageView
@end
@interface VLCDropEnabledButton : NSButton
@end
......@@ -27,7 +27,7 @@
@implementation VLCConvertAndSave
@synthesize MRL;
@synthesize MRL=_MRL;
static VLCConvertAndSave *_o_sharedInstance = nil;
......@@ -79,9 +79,56 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
- (void)updateDropView
{
if ([_MRL length] > 0)
{
NSString * path = [[NSURL URLWithString:_MRL] path];
[o_dropin_media_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath: path]];
NSImage * image = [[NSWorkspace sharedWorkspace] iconForFile: path];
[image setSize:NSMakeSize(64,64)];
[o_dropin_icon_view setImage: image];
if (![o_dropin_view superview]) {
NSRect boxFrame = [o_drop_box frame];
NSRect subViewFrame = [o_dropin_view frame];
subViewFrame.origin.x = (boxFrame.size.width - subViewFrame.size.width) / 2;
subViewFrame.origin.y = (boxFrame.size.height - subViewFrame.size.height) / 2;
[o_dropin_view setFrame: subViewFrame];
[[o_drop_image_view animator] setHidden: YES];
[o_drop_box performSelector:@selector(addSubview:) withObject:o_dropin_view afterDelay:0.4];
}
}
else
{
[o_dropin_view removeFromSuperview];
[[o_drop_image_view animator] setHidden: NO];
}
}
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
NSPasteboard *o_paste = [sender draggingPasteboard];
NSArray *o_types = [NSArray arrayWithObject: NSFilenamesPboardType];
NSString *o_desired_type = [o_paste availableTypeFromArray:o_types];
NSData *o_carried_data = [o_paste dataForType:o_desired_type];
if( o_carried_data )
{
if( [o_desired_type isEqualToString:NSFilenamesPboardType] )
{
NSArray *o_values = [[o_paste propertyListForType: NSFilenamesPboardType] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
if ([o_values count] > 0)
{
[self setMRL: [NSString stringWithUTF8String:make_URI([[o_values objectAtIndex:0] UTF8String], NULL)]];
[self updateDropView];
return YES;
}
}
}
return NO;
}
@end
......@@ -107,27 +154,71 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
NSPasteboard *o_paste = [sender draggingPasteboard];
NSArray *o_types = [NSArray arrayWithObject: NSFilenamesPboardType];
NSString *o_desired_type = [o_paste availableTypeFromArray:o_types];
NSData *o_carried_data = [o_paste dataForType:o_desired_type];
return [[VLCConvertAndSave sharedInstance] performDragOperation: sender];
}
if( o_carried_data )
{
if( [o_desired_type isEqualToString:NSFilenamesPboardType] )
{
NSArray *o_values = [[o_paste propertyListForType: NSFilenamesPboardType] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
- (void)concludeDragOperation:(id <NSDraggingInfo>)sender
{
[self setNeedsDisplay:YES];
}
if ([o_values count] > 0)
{
id VLCCAS = [VLCConvertAndSave sharedInstance];
[VLCCAS setMRL: [NSString stringWithUTF8String:make_URI([[o_values objectAtIndex:0] UTF8String], NULL)]];
[VLCCAS updateDropView];
@end
@implementation VLCDropEnabledImageView
- (void)awakeFromNib
{
[self registerForDraggedTypes:[NSArray arrayWithObject: NSFilenamesPboardType]];
}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
if ((NSDragOperationGeneric & [sender draggingSourceOperationMask]) == NSDragOperationGeneric)
return NSDragOperationGeneric;
return NSDragOperationNone;
}
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
{
return YES;
}
}
}
return NO;
}
- (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 arrayWithObject: NSFilenamesPboardType]];
}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
if ((NSDragOperationGeneric & [sender draggingSourceOperationMask]) == NSDragOperationGeneric)
return NSDragOperationGeneric;
return NSDragOperationNone;
}
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
{
return YES;
}
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
return [[VLCConvertAndSave sharedInstance] performDragOperation: sender];
}
- (void)concludeDragOperation:(id <NSDraggingInfo>)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