Camino only - Bug 364198: Allow the site icon for local files to act as a proxy for the file. r=smorgan sr=pink.

This commit is contained in:
stridey%gmail.com 2007-02-02 21:23:50 +00:00
Родитель 0fd88b54c4
Коммит 8c61d81f9f
6 изменённых файлов: 42 добавлений и 25 удалений

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

@ -279,7 +279,7 @@
if (localFlag)
return (NSDragOperationCopy | NSDragOperationGeneric | NSDragOperationMove);
return (NSDragOperationDelete | NSDragOperationGeneric);
return (NSDragOperationCopy | NSDragOperationGeneric | NSDragOperationLink | NSDragOperationDelete);
}
- (void)mouseDragged:(NSEvent*)aEvent

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

@ -1056,7 +1056,7 @@ const int kOutlineViewLeftMargin = 19; // determined empirically, since it doesn
if (localFlag)
return (NSDragOperationCopy | NSDragOperationGeneric | NSDragOperationMove);
return (NSDragOperationDelete | NSDragOperationGeneric);
return (NSDragOperationCopy | NSDragOperationLink | NSDragOperationDelete | NSDragOperationGeneric);
}
return NSDragOperationGeneric;

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

@ -205,9 +205,12 @@ const int kMenuTruncationChars = 60;
// NSDraggingSource methods
- (unsigned int)draggingSourceOperationMaskForLocal:(BOOL)flag
- (unsigned int)draggingSourceOperationMaskForLocal:(BOOL)isLocal
{
return NSDragOperationGeneric | NSDragOperationCopy;
if (isLocal)
return (NSDragOperationGeneric | NSDragOperationCopy);
return (NSDragOperationGeneric | NSDragOperationCopy | NSDragOperationLink);
}
// NSResponder methods

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

@ -76,8 +76,8 @@
{
if (isLocal)
return NSDragOperationGeneric;
else
return NSDragOperationCopy;
return (NSDragOperationLink | NSDragOperationCopy);
}
- (void)mouseDown:(NSEvent *)theEvent

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

@ -53,6 +53,7 @@ NSString* const kWebURLsWithTitlesPboardType = @"WebURLsWithTitlesPboardType";
NSArray* allTypes = [additionalTypes arrayByAddingObjectsFromArray:
[NSArray arrayWithObjects:
kWebURLsWithTitlesPboardType,
NSFilenamesPboardType,
NSURLPboardType,
NSStringPboardType,
kCorePasteboardFlavorType_url,
@ -63,7 +64,7 @@ NSString* const kWebURLsWithTitlesPboardType = @"WebURLsWithTitlesPboardType";
//
// Copy a single URL (with an optional title) to the clipboard in all relevant
// formats. Convinience methods for clients that can only ever deal with one
// formats. Convenience method for clients that can only ever deal with one
// URL and shouldn't have to build up the arrays for setURLs:withTitles:.
//
- (void)setDataForURL:(NSString*)url title:(NSString*)title
@ -81,40 +82,50 @@ NSString* const kWebURLsWithTitlesPboardType = @"WebURLsWithTitlesPboardType";
// using all the available formats.
// The title array should be nil, or must have the same length as the URL array.
//
- (void) setURLs:(NSArray*)inUrls withTitles:(NSArray*)inTitles
- (void)setURLs:(NSArray*)inUrls withTitles:(NSArray*)inTitles
{
unsigned int urlCount = [inUrls count];
// Best format that we know about is Safari's URL + title arrays - build these up
NSMutableArray* tmpTitleArray = inTitles;
if (!inTitles) {
tmpTitleArray = [NSMutableArray array];
for ( unsigned int i = 0; i < [inUrls count]; ++i )
for (unsigned int i = 0; i < urlCount; ++i)
[tmpTitleArray addObject:@""];
}
NSMutableArray* filePaths = [NSMutableArray array];
for (unsigned int i = 0; i < urlCount; ++i) {
NSURL* url = [NSURL URLWithString:[inUrls objectAtIndex:i]];
if ([url isFileURL])
[filePaths addObject:[url path]];
}
[self setPropertyList:filePaths forType:NSFilenamesPboardType];
NSMutableArray* clipboardData = [NSMutableArray array];
[clipboardData addObject:[NSArray arrayWithArray:inUrls]];
[clipboardData addObject:tmpTitleArray];
[self setPropertyList:clipboardData forType:kWebURLsWithTitlesPboardType];
if ([inUrls count] == 1) {
if (urlCount == 1) {
NSString* title = @"";
if (inTitles)
title = [inTitles objectAtIndex:0];
NSString* url = [inUrls objectAtIndex:0];
[[NSURL URLWithString:url] writeToPasteboard: self];
[self setString:url forType: NSStringPboardType];
[[NSURL URLWithString:url] writeToPasteboard:self];
[self setString:url forType:NSStringPboardType];
const char* tempCString = [url UTF8String];
[self setData:[NSData dataWithBytes:tempCString length:strlen(tempCString)] forType: kCorePasteboardFlavorType_url];
[self setData:[NSData dataWithBytes:tempCString length:strlen(tempCString)] forType:kCorePasteboardFlavorType_url];
if (inTitles)
tempCString = [title UTF8String];
[self setData:[NSData dataWithBytes:tempCString length:strlen(tempCString)] forType: kCorePasteboardFlavorType_urln];
[self setData:[NSData dataWithBytes:tempCString length:strlen(tempCString)] forType:kCorePasteboardFlavorType_urln];
}
else if ([inUrls count] > 1)
else if (urlCount > 1)
{
// With multiple URLs there aren't many other formats we can use
// Just write a string of each URL (ignoring titles) on a separate line
@ -123,14 +134,14 @@ NSString* const kWebURLsWithTitlesPboardType = @"WebURLsWithTitlesPboardType";
// but we have to put something in the carbon style flavors, otherwise apps will think
// there is data there, but get nothing
NSString* firstURL = [inUrls objectAtIndex:0];
NSString* firstTitle = ([inTitles count] > 0) ? [inTitles objectAtIndex:0] : @"";
NSString* firstURL = [inUrls objectAtIndex:0];
NSString* firstTitle = ([inTitles count] > 0) ? [inTitles objectAtIndex:0] : @"";
const char* tempCString = [firstURL UTF8String];
[self setData:[NSData dataWithBytes:tempCString length:strlen(tempCString)] forType: kCorePasteboardFlavorType_url];
[self setData:[NSData dataWithBytes:tempCString length:strlen(tempCString)] forType:kCorePasteboardFlavorType_url];
tempCString = [firstTitle UTF8String]; // not i18n friendly
[self setData:[NSData dataWithBytes:tempCString length:strlen(tempCString)] forType: kCorePasteboardFlavorType_urln];
[self setData:[NSData dataWithBytes:tempCString length:strlen(tempCString)] forType:kCorePasteboardFlavorType_urln];
}
}

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

@ -468,7 +468,10 @@ static NSString* const kExpandedHistoryStatesDefaultsKey = @"history_expand_stat
- (unsigned int)outlineView:(NSOutlineView *)outlineView draggingSourceOperationMaskForLocal:(BOOL)localFlag
{
return NSDragOperationGeneric;
if (localFlag)
return NSDragOperationGeneric;
return (NSDragOperationGeneric | NSDragOperationCopy | NSDragOperationLink);
}
- (void)outlineViewItemDidExpand:(NSNotification *)notification