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
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
</object> </object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<integer value="3"/>
<integer value="25"/> <integer value="25"/>
<integer value="2"/>
</object> </object>
<object class="NSArray" key="IBDocument.PluginDependencies"> <object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
...@@ -574,13 +574,13 @@ ...@@ -574,13 +574,13 @@
<object class="NSTextField" id="375510155"> <object class="NSTextField" id="375510155">
<reference key="NSNextResponder" ref="494472580"/> <reference key="NSNextResponder" ref="494472580"/>
<int key="NSvFlags">268</int> <int key="NSvFlags">268</int>
<string key="NSFrame">{{57, 28}, {335, 17}}</string> <string key="NSFrame">{{17, 20}, {444, 17}}</string>
<reference key="NSSuperview" ref="494472580"/> <reference key="NSSuperview" ref="494472580"/>
<int key="NSViewLayerContentsRedrawPolicy">2</int> <int key="NSViewLayerContentsRedrawPolicy">2</int>
<bool key="NSEnabled">YES</bool> <bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="709615775"> <object class="NSTextFieldCell" key="NSCell" id="709615775">
<int key="NSCellFlags">68288064</int> <int key="NSCellFlags">68288064</int>
<int key="NSCellFlags2">272630784</int> <int key="NSCellFlags2">138413056</int>
<string key="NSContents">bla bla bla.mov</string> <string key="NSContents">bla bla bla.mov</string>
<reference key="NSSupport" ref="1024428774"/> <reference key="NSSupport" ref="1024428774"/>
<reference key="NSControlView" ref="375510155"/> <reference key="NSControlView" ref="375510155"/>
...@@ -603,7 +603,7 @@ ...@@ -603,7 +603,7 @@
<string>NeXT TIFF v4.0 pasteboard type</string> <string>NeXT TIFF v4.0 pasteboard type</string>
</object> </object>
</object> </object>
<string key="NSFrame">{{20, 20}, {32, 32}}</string> <string key="NSFrame">{{207, 45}, {64, 64}}</string>
<reference key="NSSuperview" ref="494472580"/> <reference key="NSSuperview" ref="494472580"/>
<int key="NSViewLayerContentsRedrawPolicy">2</int> <int key="NSViewLayerContentsRedrawPolicy">2</int>
<bool key="NSEnabled">YES</bool> <bool key="NSEnabled">YES</bool>
...@@ -619,7 +619,7 @@ ...@@ -619,7 +619,7 @@
<bool key="NSEditable">YES</bool> <bool key="NSEditable">YES</bool>
</object> </object>
</object> </object>
<string key="NSFrameSize">{409, 72}</string> <string key="NSFrameSize">{478, 129}</string>
<reference key="NSSuperview"/> <reference key="NSSuperview"/>
<string key="NSReuseIdentifierKey">_NS:1109</string> <string key="NSReuseIdentifierKey">_NS:1109</string>
<string key="NSClassName">NSView</string> <string key="NSClassName">NSView</string>
...@@ -815,6 +815,14 @@ ...@@ -815,6 +815,14 @@
</object> </object>
<int key="connectionID">102</int> <int key="connectionID">102</int>
</object> </object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">o_drop_box</string>
<reference key="source" ref="203744709"/>
<reference key="destination" ref="90126139"/>
</object>
<int key="connectionID">103</int>
</object>
</object> </object>
<object class="IBMutableOrderedSet" key="objectRecords"> <object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects"> <object class="NSArray" key="orderedObjects">
...@@ -1207,6 +1215,7 @@ ...@@ -1207,6 +1215,7 @@
<string>27.IBViewBoundsToFrameTransform</string> <string>27.IBViewBoundsToFrameTransform</string>
<string>28.IBPluginDependency</string> <string>28.IBPluginDependency</string>
<string>29.IBPluginDependency</string> <string>29.IBPluginDependency</string>
<string>3.CustomClassName</string>
<string>3.IBPluginDependency</string> <string>3.IBPluginDependency</string>
<string>3.IBViewBoundsToFrameTransform</string> <string>3.IBViewBoundsToFrameTransform</string>
<string>32.IBPluginDependency</string> <string>32.IBPluginDependency</string>
...@@ -1214,6 +1223,7 @@ ...@@ -1214,6 +1223,7 @@
<string>35.IBPluginDependency</string> <string>35.IBPluginDependency</string>
<string>35.IBViewBoundsToFrameTransform</string> <string>35.IBViewBoundsToFrameTransform</string>
<string>36.IBPluginDependency</string> <string>36.IBPluginDependency</string>
<string>4.CustomClassName</string>
<string>4.IBPluginDependency</string> <string>4.IBPluginDependency</string>
<string>4.IBViewBoundsToFrameTransform</string> <string>4.IBViewBoundsToFrameTransform</string>
<string>47.IBPluginDependency</string> <string>47.IBPluginDependency</string>
...@@ -1231,6 +1241,7 @@ ...@@ -1231,6 +1241,7 @@
<string>54.IBPluginDependency</string> <string>54.IBPluginDependency</string>
<string>6.IBPluginDependency</string> <string>6.IBPluginDependency</string>
<string>6.IBViewBoundsToFrameTransform</string> <string>6.IBViewBoundsToFrameTransform</string>
<string>7.CustomClassName</string>
<string>7.IBPluginDependency</string> <string>7.IBPluginDependency</string>
<string>7.IBViewBoundsToFrameTransform</string> <string>7.IBViewBoundsToFrameTransform</string>
<string>79.IBPluginDependency</string> <string>79.IBPluginDependency</string>
...@@ -1286,19 +1297,20 @@ ...@@ -1286,19 +1297,20 @@
<bytes key="NSTransformStruct">P4AAAL+AAABD2IAAwigAAA</bytes> <bytes key="NSTransformStruct">P4AAAL+AAABD2IAAwigAAA</bytes>
</object> </object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{661, 1270}, {409, 72}}</string> <string>{{810, 1072}, {478, 129}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform"/> <object class="NSAffineTransform"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform"> <object class="NSAffineTransform">
<bytes key="NSTransformStruct">AUGgAABCNAAAA</bytes> <bytes key="NSTransformStruct">AUNfAABCNAAAA</bytes>
</object> </object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform"> <object class="NSAffineTransform">
<bytes key="NSTransformStruct">P4AAAL+AAABCZAAAwogAAA</bytes> <bytes key="NSTransformStruct">P4AAAL+AAABBiAAAwq4AAA</bytes>
</object> </object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>VLCDropEnabledBox</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform"> <object class="NSAffineTransform">
<bytes key="NSTransformStruct">AUGIAABDkigAA</bytes> <bytes key="NSTransformStruct">AUGIAABDkigAA</bytes>
...@@ -1312,6 +1324,7 @@ ...@@ -1312,6 +1324,7 @@
<bytes key="NSTransformStruct">P4AAAL+AAABBuAAAwpQAAA</bytes> <bytes key="NSTransformStruct">P4AAAL+AAABBuAAAwpQAAA</bytes>
</object> </object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>VLCDropEnabledImageView</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform"> <object class="NSAffineTransform">
<bytes key="NSTransformStruct">AUOAgABCogAAA</bytes> <bytes key="NSTransformStruct">AUOAgABCogAAA</bytes>
...@@ -1341,6 +1354,7 @@ ...@@ -1341,6 +1354,7 @@
<object class="NSAffineTransform"> <object class="NSAffineTransform">
<bytes key="NSTransformStruct">P4AAAL+AAABBcAAAw0sAAA</bytes> <bytes key="NSTransformStruct">P4AAAL+AAABBcAAAw0sAAA</bytes>
</object> </object>
<string>VLCDropEnabledButton</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform"> <object class="NSAffineTransform">
<bytes key="NSTransformStruct">P4AAAL+AAABDbAAAwigAAA</bytes> <bytes key="NSTransformStruct">P4AAAL+AAABDbAAAwigAAA</bytes>
...@@ -1366,7 +1380,7 @@ ...@@ -1366,7 +1380,7 @@
</object> </object>
</object> </object>
<nil key="sourceID"/> <nil key="sourceID"/>
<int key="maxID">102</int> <int key="maxID">103</int>
</object> </object>
<object class="IBClassDescriber" key="IBDocument.Classes"> <object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.1+"> <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.1+">
...@@ -1382,7 +1396,6 @@ ...@@ -1382,7 +1396,6 @@
<string>customizeProfile:</string> <string>customizeProfile:</string>
<string>openMedia:</string> <string>openMedia:</string>
<string>profileSelection:</string> <string>profileSelection:</string>
<string>toggleWindow:</string>
<string>windowButtonAction:</string> <string>windowButtonAction:</string>
</object> </object>
<object class="NSMutableArray" key="dict.values"> <object class="NSMutableArray" key="dict.values">
...@@ -1392,7 +1405,6 @@ ...@@ -1392,7 +1405,6 @@
<string>id</string> <string>id</string>
<string>id</string> <string>id</string>
<string>id</string> <string>id</string>
<string>id</string>
</object> </object>
</object> </object>
<object class="NSMutableDictionary" key="actionInfosByName"> <object class="NSMutableDictionary" key="actionInfosByName">
...@@ -1403,7 +1415,6 @@ ...@@ -1403,7 +1415,6 @@
<string>customizeProfile:</string> <string>customizeProfile:</string>
<string>openMedia:</string> <string>openMedia:</string>
<string>profileSelection:</string> <string>profileSelection:</string>
<string>toggleWindow:</string>
<string>windowButtonAction:</string> <string>windowButtonAction:</string>
</object> </object>
<object class="NSMutableArray" key="dict.values"> <object class="NSMutableArray" key="dict.values">
...@@ -1424,10 +1435,6 @@ ...@@ -1424,10 +1435,6 @@
<string key="name">profileSelection:</string> <string key="name">profileSelection:</string>
<string key="candidateClassName">id</string> <string key="candidateClassName">id</string>
</object> </object>
<object class="IBActionInfo">
<string key="name">toggleWindow:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo"> <object class="IBActionInfo">
<string key="name">windowButtonAction:</string> <string key="name">windowButtonAction:</string>
<string key="candidateClassName">id</string> <string key="candidateClassName">id</string>
...@@ -1444,6 +1451,7 @@ ...@@ -1444,6 +1451,7 @@
<string>o_destination_filename_stub_lbl</string> <string>o_destination_filename_stub_lbl</string>
<string>o_destination_icon_view</string> <string>o_destination_icon_view</string>
<string>o_destination_lbl</string> <string>o_destination_lbl</string>
<string>o_drop_box</string>
<string>o_drop_btn</string> <string>o_drop_btn</string>
<string>o_drop_image_view</string> <string>o_drop_image_view</string>
<string>o_drop_lbl</string> <string>o_drop_lbl</string>
...@@ -1475,6 +1483,7 @@ ...@@ -1475,6 +1483,7 @@
<string>id</string> <string>id</string>
<string>id</string> <string>id</string>
<string>id</string> <string>id</string>
<string>id</string>
</object> </object>
</object> </object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName"> <object class="NSMutableDictionary" key="toOneOutletInfosByName">
...@@ -1487,6 +1496,7 @@ ...@@ -1487,6 +1496,7 @@
<string>o_destination_filename_stub_lbl</string> <string>o_destination_filename_stub_lbl</string>
<string>o_destination_icon_view</string> <string>o_destination_icon_view</string>
<string>o_destination_lbl</string> <string>o_destination_lbl</string>
<string>o_drop_box</string>
<string>o_drop_btn</string> <string>o_drop_btn</string>
<string>o_drop_image_view</string> <string>o_drop_image_view</string>
<string>o_drop_lbl</string> <string>o_drop_lbl</string>
...@@ -1525,6 +1535,10 @@ ...@@ -1525,6 +1535,10 @@
<string key="name">o_destination_lbl</string> <string key="name">o_destination_lbl</string>
<string key="candidateClassName">id</string> <string key="candidateClassName">id</string>
</object> </object>
<object class="IBToOneOutletInfo">
<string key="name">o_drop_box</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo"> <object class="IBToOneOutletInfo">
<string key="name">o_drop_btn</string> <string key="name">o_drop_btn</string>
<string key="candidateClassName">id</string> <string key="candidateClassName">id</string>
...@@ -1571,11 +1585,26 @@ ...@@ -1571,11 +1585,26 @@
</object> </object>
</object> </object>
</object> </object>
<object class="IBClassDescriptionSource" key="sourceIdentifier"> <object class="IBClassDescriptionSource" key="sourceIdentifier" id="748209823">
<string key="majorKey">IBDocumentRelativeSource</string> <string key="majorKey">IBDocumentRelativeSource</string>
<string key="minorKey">../../../../../modules/gui/macosx/ConvertAndSave.h</string> <string key="minorKey">../../../../../modules/gui/macosx/ConvertAndSave.h</string>
</object> </object>
</object> </object>
<object class="IBPartialClassDescription">
<string key="className">VLCDropEnabledBox</string>
<string key="superclassName">NSBox</string>
<reference key="sourceIdentifier" ref="748209823"/>
</object>
<object class="IBPartialClassDescription">
<string key="className">VLCDropEnabledButton</string>
<string key="superclassName">NSButton</string>
<reference key="sourceIdentifier" ref="748209823"/>
</object>
<object class="IBPartialClassDescription">
<string key="className">VLCDropEnabledImageView</string>
<string key="superclassName">NSImageView</string>
<reference key="sourceIdentifier" ref="748209823"/>
</object>
</object> </object>
</object> </object>
<int key="IBDocument.localizationMode">0</int> <int key="IBDocument.localizationMode">0</int>
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
IBOutlet id o_drop_lbl; IBOutlet id o_drop_lbl;
IBOutlet id o_drop_image_view; IBOutlet id o_drop_image_view;
IBOutlet id o_drop_btn; IBOutlet id o_drop_btn;
IBOutlet id o_drop_box;
IBOutlet id o_profile_lbl; IBOutlet id o_profile_lbl;
IBOutlet id o_profile_pop; IBOutlet id o_profile_pop;
...@@ -47,7 +48,7 @@ ...@@ -47,7 +48,7 @@
IBOutlet id o_dropin_icon_view; IBOutlet id o_dropin_icon_view;
IBOutlet id o_dropin_media_lbl; IBOutlet id o_dropin_media_lbl;
NSString * MRL; NSString * _MRL;
} }
@property (readwrite, nonatomic, retain) NSString * MRL; @property (readwrite, nonatomic, retain) NSString * MRL;
...@@ -68,3 +69,11 @@ ...@@ -68,3 +69,11 @@
@interface VLCDropEnabledBox : NSBox @interface VLCDropEnabledBox : NSBox
@end @end
@interface VLCDropEnabledImageView : NSImageView
@end
@interface VLCDropEnabledButton : NSButton
@end
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
@implementation VLCConvertAndSave @implementation VLCConvertAndSave
@synthesize MRL; @synthesize MRL=_MRL;
static VLCConvertAndSave *_o_sharedInstance = nil; static VLCConvertAndSave *_o_sharedInstance = nil;
...@@ -79,9 +79,56 @@ static VLCConvertAndSave *_o_sharedInstance = nil; ...@@ -79,9 +79,56 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
- (void)updateDropView - (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 @end
...@@ -107,27 +154,71 @@ static VLCConvertAndSave *_o_sharedInstance = nil; ...@@ -107,27 +154,71 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{ {
NSPasteboard *o_paste = [sender draggingPasteboard]; return [[VLCConvertAndSave sharedInstance] performDragOperation: sender];
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 ) - (void)concludeDragOperation:(id <NSDraggingInfo>)sender
{ {
if( [o_desired_type isEqualToString:NSFilenamesPboardType] ) [self setNeedsDisplay:YES];
{ }
NSArray *o_values = [[o_paste propertyListForType: NSFilenamesPboardType] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
if ([o_values count] > 0) @end
{
id VLCCAS = [VLCConvertAndSave sharedInstance]; @implementation VLCDropEnabledImageView
[VLCCAS setMRL: [NSString stringWithUTF8String:make_URI([[o_values objectAtIndex:0] UTF8String], NULL)]];
[VLCCAS updateDropView]; - (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 YES;
} }
}
} - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
return NO; {
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 - (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