On Wednesday, January 23, 2008, at 04:11PM, "Christiaan Hofman" <[EMAIL 
PROTECTED]> wrote:
>So if you want to properly follow datasource/delegate principles, drag/drop
>should be handled by the delegate or datasource, as for NSTableView.

Yeah, that's definitely a fair comment, and something I've debated with myself 
:).  In fact, I originally had internal copying of promised files and deleting 
files (with an alert), and switched to delegate methods to give a bit more 
flexibility and less annoyance in testing.  I also discovered that Finder 
handled that better than I could by just putting URLs on the pasteboard.

The difference between FileView and NSTableView is that the data is 
well-defined: it's a URL, and only a URL.  Since it's a URL, there are a 
limited number of things you can do: open, copy, move, link, delete.  I lumped 
trash in with delete, which I now think is confusing since it's sort of a move. 
 The current API was more inspired by IKImageBrowserView than NSTableView, 
since stuff like allowing the datasource to validate/retarget a drop seemed 
unnecessary.  Even IKImageBrowserView allows more data types, so has to be more 
generic.

I don't think your trashing changes are that bad, since the datasource could 
refuse the delete and then do whatever it wants...I just want to make sure we 
don't put too much controller stuff in there (and I recognize that's 
subjective).


>On Jan 23, 2008 9:39 PM, Christiaan Hofman <[EMAIL PROTECTED]> wrote:
>
>> But the delegate does not know the context (drag to trash, AOT any
>> other delete). So it cannot be in the editor. It should be
>> conditional on a delete though, just forgot the if-clause.
>>
>> I think it will be clear that we don't trash the file. It would be
>> wrong to do that without warning (Finder does not do that either) so
>> the user should never expect that. Showing an alert for every delete
>> is annoying and can't be disabled without being ambiguous.
>>
>> Irt would be nice if we could play the shredding sound.
>>
>> Christiaan
>>
>> On 23 Jan 2008, at 9:22 PM, Adam R. Maxwell wrote:
>>
>> > This sort of breaks the whole datasource/delegate principle.  I
>> > know the distinction between controller and view is a bit blurred
>> > overall in the view, but moving/trashing/deleting/warning should be
>> > the job of the object that gets the datasource message.  Here, even
>> > if deleteURLsAtIndexes: returns NO, an alert is still shown.  If
>> > the datasource deletes in response to the message, the view then
>> > tries to trash nonexistent files.
>> >
>> > It probably was wrong to implement drag-to-trash as just removing
>> > from the view, so something needs to change.  I think this should
>> > probably be in BibEditor for now, or use a separate
>> > fileView:trashURLsAtIndexes: method if we need to differentiate.
>> > I'm not sure that the distinction between delete key and drag-to-
>> > trash will be obvious to users, so it might be best just to show
>> > the alert for both cases?
>> >
>> > On Wednesday, January 23, 2008, at 10:25AM,
>> > <[EMAIL PROTECTED]> wrote:
>> >> Revision: 12641
>> >>          http://bibdesk.svn.sourceforge.net/bibdesk/?
>> >> rev=12641&view=rev
>> >> Author:   hofman
>> >> Date:     2008-01-23 10:24:44 -0800 (Wed, 23 Jan 2008)
>> >>
>> >> Log Message:
>> >> -----------
>> >> Show an alert to ask whether to trash files dragged to the trash.
>> >>
>> >> Modified Paths:
>> >> --------------
>> >>    trunk/bibdesk_vendorsrc/amaxwell/FileView/FileView.m
>> >>
>> >> Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FileView.m
>> >> ===================================================================
>> >> --- trunk/bibdesk_vendorsrc/amaxwell/FileView/FileView.m
>> >> 2008-01-23 17:52:59 UTC (rev 12640)
>> >> +++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FileView.m
>> >> 2008-01-23 18:24:44 UTC (rev 12641)
>> >> @@ -1317,13 +1317,41 @@
>> >>
>> >> #pragma mark Drag source
>> >>
>> >> +- (void)trashAlertDidEnd:(NSAlert *)alert returnCode:(int)
>> >> returnCode contextInfo:(void *)contextInfo
>> >> +{
>> >> +    NSArray *selectedURLs = [(NSArray *)contextInfo autorelease];
>> >> +    if (returnCode == NSAlertAlternateReturn) {
>> >> +        NSEnumerator *urlEnum = [selectedURLs objectEnumerator];
>> >> +        NSURL *url;
>> >> +        while (url = [urlEnum nextObject]) {
>> >> +            if ([url isFileURL] == NO || [url isEqual:[FVIcon
>> >> missingFileURL]]) continue;
>> >> +            NSString *path = [url path];
>> >> +            NSString *folderPath = [path
>> >> stringByDeletingLastPathComponent];
>> >> +            NSString *fileName = [path lastPathComponent];
>> >> +            int tag = 0;
>> >> +            [[NSWorkspace sharedWorkspace]
>> >> performFileOperation:NSWorkspaceRecycleOperation source:folderPath
>> >> destination:nil files:[NSArray arrayWithObjects:fileName, nil]
>> >> tag:&tag];
>> >> +        }
>> >> +    }
>> >> +}
>> >> +
>> >> - (void)draggedImage:(NSImage *)image endedAt:(NSPoint)screenPoint
>> >> operation:(NSDragOperation)operation;
>> >> {
>> >>     // only called if we originated the drag, so the row/column
>> >> must be valid
>> >>     if ((operation & NSDragOperationDelete) != 0 && [self
>> >> isEditable]) {
>> >> +        NSArray *selectedURLs = [[self _selectedURLs] copy];
>> >>         [[self dataSource] fileView:self
>> >> deleteURLsAtIndexes:_selectedIndexes];
>> >>         [self setSelectionIndexes:[NSIndexSet indexSet]];
>> >>         [self reloadIcons];
>> >> +        NSBundle *bundle = [NSBundle bundleForClass:[FileView
>> >> class]];
>> >> +        NSAlert *alert = [NSAlert
>> >> alertWithMessageText:NSLocalizedStringFromTableInBundle(@"Move
>> >> Files to Trash?", @"FileView", bundle, @"Message in alert dialog
>> >> when dragging files to the trash")
>> >> +
>> >> defaultButton:NSLocalizedStringFromTableInBundle(@"No",
>> >> @"FileView", bundle, @"Button title")
>> >> +
>> >> alternateButton:NSLocalizedStringFromTableInBundle(@"Yes",
>> >> @"FileView", bundle, @"Button title")
>> >> +                                           otherButton:nil
>> >> +
>> >> informativeTextWithFormat:NSLocalizedStringFromTableInBundle(@"Do
>> >> you want to move the removed files to the trash?", @"FileView",
>> >> bundle, @"Informative text in alert dialog when dragging files to
>> >> the trash")];
>> >> +        [alert beginSheetModalForWindow:[self window]
>> >> +                          modalDelegate:self
>> >> +                         didEndSelector:@selector
>> >> (trashAlertDidEnd:returnCode:contextInfo:)
>> >> +                            contextInfo:selectedURLs];
>> >>     }
>> >> }
>> >>
>> >>
>> >>
>> >> This was sent by the SourceForge.net collaborative development
>> >> platform, the world's largest Open Source development site.
>> >>
>> >> ---------------------------------------------------------------------
>> >> ----
>> >> This SF.net email is sponsored by: Microsoft
>> >> Defy all challenges. Microsoft(R) Visual Studio 2008.
>> >> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>> >> _______________________________________________
>> >> Bibdesk-commit mailing list
>> >> [EMAIL PROTECTED]
>> >> https://lists.sourceforge.net/lists/listinfo/bibdesk-commit
>> >>
>> >>
>> >
>> > ----------------------------------------------------------------------
>> > ---
>> > This SF.net email is sponsored by: Microsoft
>> > Defy all challenges. Microsoft(R) Visual Studio 2008.
>> > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>> > _______________________________________________
>> > Bibdesk-develop mailing list
>> > Bibdesk-develop@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/bibdesk-develop
>>
>>
>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bibdesk-develop mailing list
Bibdesk-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-develop

Reply via email to