Camino only - Allow downloads to be dragged from the download manager. r=froodian sr=pink

This commit is contained in:
stuart.morgan%alumni.case.edu 2007-11-03 19:54:12 +00:00
Родитель c19ff92447
Коммит b4d7c68da3
5 изменённых файлов: 194 добавлений и 43 удалений

Просмотреть файл

@ -1,18 +1,92 @@
{
IBClasses = (
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{CLASS = ProgressView; LANGUAGE = ObjC; SUPERCLASS = NSView; },
{
ACTIONS = {close = id; open = id; reveal = id; stop = id; toggleDisclosure = id; };
CLASS = ProgressViewController;
LANGUAGE = ObjC;
OUTLETS = {
mCompletedView = NSView;
mProgressBar = NSProgressIndicator;
mProgressView = NSView;
};
SUPERCLASS = NSObject;
}
);
IBVersion = 1;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBClasses</key>
<array>
<dict>
<key>CLASS</key>
<string>NSMenu</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSObject</string>
<key>LANGUAGE</key>
<string>ObjC</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>cancel</key>
<string>id</string>
<key>close</key>
<string>id</string>
<key>open</key>
<string>id</string>
<key>pause</key>
<string>id</string>
<key>remove</key>
<string>id</string>
<key>resume</key>
<string>id</string>
<key>reveal</key>
<string>id</string>
<key>stop</key>
<string>id</string>
<key>toggleDisclosure</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>ProgressViewController</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>mCompletedView</key>
<string>ProgressView</string>
<key>mProgressBar</key>
<string>NSProgressIndicator</string>
<key>mProgressView</key>
<string>ProgressView</string>
</dict>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSView</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSResponder</string>
</dict>
<dict>
<key>CLASS</key>
<string>ProgressView</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>mFileIconView</key>
<string>NSImageView</string>
</dict>
<key>SUPERCLASS</key>
<string>NSView</string>
</dict>
<dict>
<key>CLASS</key>
<string>FirstResponder</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
</array>
<key>IBVersion</key>
<string>1</string>
</dict>
</plist>

Просмотреть файл

@ -1,23 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>35 161 448 284 0 0 1600 1002 </string>
<key>IBEditorPositions</key>
<dict>
<key>5</key>
<string>606 622 346 92 0 0 1600 1002 </string>
<key>71</key>
<string>606 622 346 92 0 0 1600 1002 </string>
</dict>
<key>IBFramework Version</key>
<string>437.0</string>
<key>IBLockedObjects</key>
<array>
<integer>5</integer>
</array>
<string>629</string>
<key>IBLastKnownRelativeProjectPath</key>
<string>../../../../Camino.xcodeproj</string>
<key>IBOldestOS</key>
<integer>3</integer>
<key>IBOpenObjects</key>
<array/>
<key>IBSystem Version</key>
<string>8F46</string>
<string>9A581</string>
<key>targetFramework</key>
<string>IBCocoaFramework</string>
</dict>
</plist>

Двоичные данные
camino/resources/localized/English.lproj/ProgressView.nib/keyedobjects.nib сгенерированный

Двоичный файл не отображается.

Просмотреть файл

@ -56,8 +56,10 @@ extern NSString* const kDownloadInstanceCancelledNotificationName;
@interface ProgressView : NSView
{
@private
int mLastModifier;
IBOutlet NSImageView* mFileIconView;
ProgressViewController* mProgressController; // WEAK reference
NSEvent* mFileIconMouseDownEvent; // STRONG reference
int mLastModifier;
}
// returns the most recent modifier key used during the last

Просмотреть файл

@ -52,7 +52,6 @@ NSString* const kDownloadInstanceCancelledNotificationName = @"DownloadInstanceC
@end
@implementation ProgressView
- (id)initWithFrame:(NSRect)frame
@ -65,6 +64,12 @@ NSString* const kDownloadInstanceCancelledNotificationName = @"DownloadInstanceC
return self;
}
- (void)dealloc
{
[mFileIconMouseDownEvent release];
[super dealloc];
}
-(void)drawRect:(NSRect)rect
{
if ([self isSelected]) {
@ -93,14 +98,89 @@ NSString* const kDownloadInstanceCancelledNotificationName = @"DownloadInstanceC
}
}
[self setSelected:shouldSelect];
[[NSNotificationCenter defaultCenter] postNotificationName:kDownloadInstanceSelectedNotificationName object:self];
[[NSNotificationCenter defaultCenter] postNotificationName:kDownloadInstanceSelectedNotificationName
object:self];
// after we've processed selection and modifiers, see if it's a double-click. If so,
// send a notification off to the controller which will handle it accordingly. Doing it after
// processing the modifiers allows someone to shift-dblClick and open all selected items
// in the list in one action.
if ([theEvent type] == NSLeftMouseDown && [theEvent clickCount] == 2)
[[NSNotificationCenter defaultCenter] postNotificationName:kDownloadInstanceOpenedNotificationName object:self];
[mFileIconMouseDownEvent release];
mFileIconMouseDownEvent = nil;
if ([theEvent type] == NSLeftMouseDown) {
// See if it's a double-click; if so, send a notification off to the
// controller which will handle it accordingly. Doing it after processing
// the modifiers allows someone to shift-dblClick and open all selected
// items in the list in one action.
if ([theEvent clickCount] == 2) {
[[NSNotificationCenter defaultCenter] postNotificationName:kDownloadInstanceOpenedNotificationName
object:self];
}
// If not, and the download isn't active, see if it's a click on the icon.
else if (![mProgressController isActive]) {
NSPoint clickPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];
if (NSPointInRect(clickPoint, [mFileIconView frame]))
mFileIconMouseDownEvent = [theEvent retain];
}
}
}
- (BOOL)acceptsFirstMouse:(NSEvent*)theEvent {
// Allow click-through on the file icon to allow dragging files even if the
// view is in a background window.
NSPoint clickPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];
return NSPointInRect(clickPoint, [mFileIconView frame]);
}
- (void)mouseDragged:(NSEvent*)aEvent
{
if (!mFileIconMouseDownEvent)
return;
// Check that the controller thinks this view represents a file we know about,
// but also that the file is actually still there in case the controller's
// information is stale.
if (![mProgressController fileExists])
return;
NSString* filePath = [mProgressController representedFilePath];
if (!(filePath && [[NSFileManager defaultManager] fileExistsAtPath:filePath]))
return;
NSPasteboard* pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
[pasteboard declareTypes:[NSArray arrayWithObject:NSFilenamesPboardType] owner:nil];
[pasteboard setPropertyList:[NSArray arrayWithObject:filePath] forType:NSFilenamesPboardType];
NSRect fileIconFrame = [mFileIconView frame];
NSImage* dragImage = [[[NSImage alloc] initWithSize:fileIconFrame.size] autorelease];
[dragImage lockFocus];
NSRect imageRect = NSMakeRect(0, 0, fileIconFrame.size.width, fileIconFrame.size.height);
[[mFileIconView image] drawAtPoint:NSMakePoint(0, 0)
fromRect:imageRect
operation:NSCompositeCopy
fraction:0.8];
[dragImage unlockFocus];
NSPoint clickLocation = [self convertPoint:[mFileIconMouseDownEvent locationInWindow] fromView:nil];
[self dragImage:dragImage
at:fileIconFrame.origin
offset:NSMakeSize(clickLocation.x - fileIconFrame.origin.x,
clickLocation.y - fileIconFrame.origin.y)
event:mFileIconMouseDownEvent
pasteboard:pasteboard
source:self
slideBack:YES];
}
- (unsigned int)draggingSourceOperationMaskForLocal:(BOOL)localFlag
{
return NSDragOperationEvery;
}
- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation
{
if (operation == NSDragOperationDelete) {
[mProgressController deleteFile];
[mProgressController remove:self];
}
if (operation == NSDragOperationMove)
[mProgressController remove:self];
}
-(int)lastModifier