/[gnustep]/gnustep/usr-apps/gworkspace/Viewers/SmallIconsViewer/SmallIcon.m
ViewVC logotype

Contents of /gnustep/usr-apps/gworkspace/Viewers/SmallIconsViewer/SmallIcon.m

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations) (download)
Sat Oct 4 14:45:18 2003 UTC (20 years, 6 months ago) by esersale
Branch: MAIN
Changes since 1.3: +2 -0 lines

2003-10-03 Enrico Sersale  <enrico@imago.ro>

  * GWorkspace/FileOperations/FileOperation.m
    -calculateNumFiles doesn't block anymore.
    the stop button now works.

  * Viewers/SmallIconsViewer/SmallIconsPanel.m
    in -selectIconWithPath: now the view scroll to show the icon.
-

1 /* SmallIcon.m
2 *
3 * Copyright (C) 2003 Free Software Foundation, Inc.
4 *
5 * Author: Enrico Sersale <enrico@imago.ro>
6 * Date: August 2001
7 *
8 * This file is part of the GNUstep GWorkspace application
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 */
24
25
26 #include <Foundation/Foundation.h>
27 #include <AppKit/AppKit.h>
28 #ifdef GNUSTEP
29 #include "GWLib.h"
30 #include "GWProtocol.h"
31 #include "GWFunctions.h"
32 #include "GWNotifications.h"
33 #else
34 #include <GWorkspace/GWLib.h>
35 #include <GWorkspace/GWProtocol.h>
36 #include <GWorkspace/GWFunctions.h>
37 #include <GWorkspace/GWNotifications.h>
38 #endif
39 #include "SmallIcon.h"
40 #include "SmallIconLabel.h"
41 #include "GNUstep.h"
42
43 #define CHECK_LOCK if (locked) return
44 #define CHECK_LOCK_RET(x) if (locked) return x
45
46 @implementation SmallIcon
47
48 - (void)dealloc
49 {
50 RELEASE (path);
51 RELEASE (name);
52 RELEASE (type);
53 RELEASE (namelabel);
54 RELEASE (icon);
55 RELEASE (highlight);
56 [super dealloc];
57 }
58
59 - (id)initForPath:(NSString *)apath delegate:(id)adelegate
60 {
61 self = [super init];
62 if (self) {
63 NSString *defApp = nil, *t = nil;
64
65 ASSIGN (path, apath);
66 [self setDelegate: adelegate];
67
68 [self setFrame: NSMakeRect(0, 0, 32, 26)];
69 isSelect = NO;
70 locked = NO;
71
72 fm = [NSFileManager defaultManager];
73
74 ASSIGN (name, [path lastPathComponent]);
75
76 [[NSWorkspace sharedWorkspace] getInfoForFile: path
77 application: &defApp
78 type: &t];
79 ASSIGN (type, t);
80 isPakage = [GWLib isPakageAtPath: path];
81
82 ASSIGN (icon, [GWLib smallIconForFile: path]);
83 ASSIGN (highlight, [NSImage imageNamed: @"SmallCellHighlight.tiff"]);
84
85 namelabel = [[SmallIconLabel alloc] initForIcon: self];
86 [namelabel setFont: [NSFont systemFontOfSize: 12]];
87 [namelabel setBezeled: NO];
88 [namelabel setEditable: NO];
89 [namelabel setSelectable: NO];
90 [namelabel setAlignment: NSLeftTextAlignment];
91 [namelabel setBackgroundColor: [NSColor windowBackgroundColor]];
92 [namelabel setTextColor: [NSColor controlTextColor]];
93 [namelabel setStringValue: name];
94
95 [self registerForDraggedTypes: [NSArray arrayWithObjects: NSFilenamesPboardType, nil]];
96
97 position = NSMakePoint(0, 0);
98 center = NSMakePoint(0, 0);
99 gridindex = -1;
100 dragdelay = 0;
101 isDragTarget = NO;
102 onSelf = NO;
103 }
104
105 return self;
106 }
107
108 - (id)initForPath:(NSString *)apath
109 gridIndex:(int)index
110 delegate:(id)adelegate
111 {
112 [self initForPath: apath delegate: adelegate];
113 gridindex = index;
114 return self;
115 }
116
117 - (void)setPath:(NSString *)apath
118 {
119 NSString *defApp = nil, *t = nil;
120
121 ASSIGN (path, apath);
122 ASSIGN (icon, [GWLib smallIconForFile: path]);
123
124 [[NSWorkspace sharedWorkspace] getInfoForFile: path
125 application: &defApp
126 type: &t];
127 ASSIGN (type, t);
128 isPakage = [GWLib isPakageAtPath: path];
129 ASSIGN (name, [path lastPathComponent]);
130 [namelabel setStringValue: name];
131 [self setLabelFrame];
132 }
133
134 - (void)select
135 {
136 if (isSelect) {
137 return;
138 }
139 if ([fm fileExistsAtPath: path] == NO) {
140 return;
141 }
142 isSelect = YES;
143 [namelabel setBackgroundColor: [NSColor whiteColor]];
144 [self setNeedsDisplay: YES];
145 [(NSView *)delegate setNeedsDisplayInRect: [namelabel frame]];
146 [delegate unselectIconsDifferentFrom: self];
147 [delegate setTheCurrentSelection];
148 }
149
150 - (void)unselect
151 {
152 if (isSelect == NO) {
153 return;
154 }
155 isSelect = NO;
156 [self setNeedsDisplay: YES];
157 [namelabel setBackgroundColor: [NSColor windowBackgroundColor]];
158 [namelabel setEditable: NO];
159 [namelabel setSelectable: NO];
160 [(NSView *)delegate setNeedsDisplayInRect: [namelabel frame]];
161 [delegate setTheCurrentSelection];
162 }
163
164 - (void)clickOnLabel
165 {
166 CHECK_LOCK;
167 [self select];
168 [namelabel setSelectable: YES];
169 [namelabel setEditable: YES];
170 }
171
172 - (void)setLabelFrame
173 {
174 NSPoint p = [namelabel frame].origin;
175 labelWidth = [[NSFont systemFontOfSize: 12] widthOfString: name] + 8;
176 [namelabel setFrame: NSMakeRect(p.x, p.y, labelWidth, 14)];
177 [namelabel setNeedsDisplay: YES];
178 }
179
180 - (void)setPosition:(NSPoint)pos
181 {
182 position = NSMakePoint(pos.x, pos.y);
183 center = NSMakePoint(_frame.origin.x + (_frame.size.width / 2),
184 _frame.origin.y + (_frame.size.height / 2));
185 }
186
187 - (void)setPosition:(NSPoint)pos gridIndex:(int)index
188 {
189 [self setPosition: pos];
190 gridindex = index;
191 }
192
193 - (NSPoint)position
194 {
195 return position;
196 }
197
198 - (NSPoint)center
199 {
200 return center;
201 }
202
203 - (void)setGridIndex:(int)index
204 {
205 gridindex = index;
206 }
207
208 - (int)gridindex
209 {
210 return gridindex;
211 }
212
213 - (NSTextField *)label
214 {
215 return namelabel;
216 }
217
218 - (NSString *)type
219 {
220 return type;
221 }
222
223 - (NSString *)path
224 {
225 return path;
226 }
227
228 - (NSString *)myName
229 {
230 return name;
231 }
232
233 - (int)labelWidth
234 {
235 return labelWidth;
236 }
237
238 - (NSSize)iconShift
239 {
240 NSRect r = [self frame];
241 NSSize s = [icon size];
242
243 return NSMakeSize((r.size.width - s.width) / 2, (r.size.height - s.height) / 2);
244 }
245
246 - (BOOL)isSelect
247 {
248 return isSelect;
249 }
250
251 - (void)setLocked:(BOOL)value
252 {
253 if (locked == value) {
254 return;
255 }
256 locked = value;
257 [namelabel setTextColor: (locked ? [NSColor disabledControlTextColor]
258 : [NSColor controlTextColor])];
259 [namelabel setEditable: !locked];
260 [namelabel setSelectable: !locked];
261 [self setNeedsDisplay: YES];
262 [namelabel setNeedsDisplay: YES];
263 }
264
265 - (BOOL)isLocked
266 {
267 return locked;
268 }
269
270 - (id)delegate
271 {
272 return delegate;
273 }
274
275 - (void)setDelegate:(id)aDelegate
276 {
277 delegate = aDelegate;
278 }
279
280 - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
281 {
282 return YES;
283 }
284
285 - (void)setFrame:(NSRect)frameRect
286 {
287 [super setFrame: frameRect];
288 [self setLabelFrame];
289 }
290
291 - (void)drawRect:(NSRect)rect
292 {
293 NSRect r = [self bounds];
294 NSSize s = [icon size];
295 NSPoint p = NSMakePoint((r.size.width - s.width) / 2, (r.size.height - s.height) / 2);
296
297 if(isSelect) {
298 [highlight compositeToPoint: NSZeroPoint operation: NSCompositeSourceOver];
299 }
300
301 if (icon != nil) {
302 if (locked) {
303 [icon dissolveToPoint: p fraction: 0.3];
304 } else {
305 [icon compositeToPoint: p operation: NSCompositeSourceOver];
306 }
307 }
308 }
309
310 - (void)mouseUp:(NSEvent *)theEvent
311 {
312 int count = [theEvent clickCount];
313
314 CHECK_LOCK;
315
316 if(count > 1) {
317 unsigned int modifier = [theEvent modifierFlags];
318
319 if ([fm fileExistsAtPath: path] == NO) {
320 return;
321 }
322
323 [delegate openTheCurrentSelection: [NSArray arrayWithObject: path]
324 newViewer: (modifier == NSControlKeyMask)];
325 }
326 }
327
328 - (void)mouseDown:(NSEvent *)theEvent
329 {
330 int count = [theEvent clickCount];
331
332 CHECK_LOCK;
333
334 if(count == 1) {
335 if([theEvent modifierFlags] == 2) {
336 [delegate setShiftClickValue: YES];
337 if (isSelect == YES) {
338 [self unselect];
339 return;
340 } else {
341 [self select];
342 }
343 } else {
344 [delegate setShiftClickValue: NO];
345 if (isSelect == NO) {
346 [self select];
347 }
348 }
349 }
350 }
351
352 - (void)mouseDragged:(NSEvent *)theEvent
353 {
354 if ([fm fileExistsAtPath: path] == NO) {
355 return;
356 }
357
358 if(dragdelay < 5) {
359 dragdelay++;
360 return;
361 }
362
363 [self startExternalDragOnEvent: theEvent];
364 }
365
366 - (NSMenu *)menuForEvent:(NSEvent *)theEvent
367 {
368 if (([theEvent type] == NSRightMouseDown) && isSelect) {
369 return [delegate menuForRightMouseEvent: theEvent];
370 }
371
372 return [super menuForEvent: theEvent];
373 }
374
375 //
376 // SmallIconLabel delegate methods
377 //
378 - (void)controlTextDidChange:(NSNotification *)aNotification
379 {
380 NSDictionary *info = [aNotification userInfo];
381 NSText *text = [info objectForKey: @"NSFieldEditor"];
382 NSString *current = [text string];
383 NSPoint p = [namelabel frame].origin;
384
385 labelWidth = [[NSFont systemFontOfSize: 12] widthOfString: current] + 8;
386 [namelabel setFrame: NSMakeRect(p.x, p.y, labelWidth, 14)];
387 }
388
389 - (void)controlTextDidEndEditing:(NSNotification *)aNotification
390 {
391 NSDictionary *info;
392 NSString *basePath, *newpath, *newname;
393 NSString *title, *msg1, *msg2;
394 NSMutableDictionary *notifObj;
395 NSArray *dirContents;
396 NSCharacterSet *notAllowSet;
397 NSRange range;
398 BOOL samename;
399 // NSEvent *e;
400 int i;
401
402 #define CLEAREDITING \
403 [namelabel setStringValue: name]; \
404 [self setLabelFrame]; \
405 return
406
407 info = [aNotification userInfo];
408 newname = [[info objectForKey: @"NSFieldEditor"] string];
409
410 basePath = [path stringByDeletingLastPathComponent]; // QUA
411
412 if ([fm fileExistsAtPath: path] == NO) {
413 notifObj = [NSMutableDictionary dictionaryWithCapacity: 1];
414 [notifObj setObject: NSWorkspaceDestroyOperation forKey: @"operation"];
415 [notifObj setObject: basePath forKey: @"source"];
416 [notifObj setObject: basePath forKey: @"destination"];
417 [notifObj setObject: [NSArray arrayWithObjects: path, nil] forKey: @"files"];
418 [notifObj setObject: [NSArray arrayWithObjects: path, nil] forKey: @"origfiles"];
419
420 [[NSNotificationCenter defaultCenter]
421 postNotificationName: GWFileSystemWillChangeNotification
422 object: notifObj];
423
424 RETAIN (self);
425
426 [[NSNotificationCenter defaultCenter]
427 postNotificationName: GWFileSystemDidChangeNotification
428 object: notifObj];
429
430 AUTORELEASE (self);
431
432 return;
433 }
434
435 title = NSLocalizedString(@"Error", @"");
436 msg1 = NSLocalizedString(@"You have not write permission\nfor ", @"");
437 msg2 = NSLocalizedString(@"Continue", @"");
438 if ([fm isWritableFileAtPath: path] == NO) {
439 NSRunAlertPanel(title, [NSString stringWithFormat: @"%@\"%@\"!\n", msg1, path], msg2, nil, nil);
440 CLEAREDITING;
441 } else if ([fm isWritableFileAtPath: basePath] == NO) {
442 NSRunAlertPanel(title, [NSString stringWithFormat: @"%@\"%@\"!\n", msg1, basePath], msg2, nil, nil);
443 CLEAREDITING;
444 }
445
446 notAllowSet = [NSCharacterSet characterSetWithCharactersInString: @"/\\*$|~\'\"`^!?"];
447 range = [newname rangeOfCharacterFromSet: notAllowSet];
448
449 if (range.length > 0) {
450 msg1 = NSLocalizedString(@"Invalid char in name", @"");
451 NSRunAlertPanel(title, msg1, msg2, nil, nil);
452 CLEAREDITING;
453 }
454
455 dirContents = [fm directoryContentsAtPath: basePath];
456
457 samename = NO;
458 for (i = 0; i < [dirContents count]; i++) {
459 if ([newname isEqualToString: [dirContents objectAtIndex:i]]) {
460 if ([newname isEqualToString: name]) {
461 CLEAREDITING;
462 } else {
463 samename = YES;
464 break;
465 }
466 }
467 }
468 if (samename == YES) {
469 NSString *msg3 = NSLocalizedString(@"The name ", @"");
470 msg1 = NSLocalizedString(@" is already in use!", @"");
471 NSRunAlertPanel(title, [NSString stringWithFormat: @"%@'%@'%@!", msg3, newname, msg1], msg2, nil, nil);
472 CLEAREDITING;
473 }
474
475 // e = [[self window] nextEventMatchingMask: NSLeftMouseUpMask | NSKeyUpMask];
476 // [[self window] flushWindow];
477
478 newpath = [basePath stringByAppendingPathComponent: newname];
479
480 notifObj = [NSMutableDictionary dictionaryWithCapacity: 1];
481 [notifObj setObject: GWorkspaceRenameOperation forKey: @"operation"];
482 [notifObj setObject: path forKey: @"source"];
483 [notifObj setObject: newpath forKey: @"destination"];
484 [notifObj setObject: [NSArray arrayWithObjects: @"", nil] forKey: @"files"];
485 [notifObj setObject: [NSArray arrayWithObjects: @"", nil] forKey: @"origfiles"];
486
487 [[NSNotificationCenter defaultCenter]
488 postNotificationName: GWFileSystemWillChangeNotification
489 object: notifObj];
490
491 [fm movePath: path toPath: newpath handler: self];
492
493 RETAIN (self);
494
495 [[NSNotificationCenter defaultCenter]
496 postNotificationName: GWFileSystemDidChangeNotification
497 object: notifObj];
498
499 AUTORELEASE (self);
500 }
501
502 - (BOOL)fileManager:(NSFileManager *)manager
503 shouldProceedAfterError:(NSDictionary *)errorDict
504 {
505 NSString *title = NSLocalizedString(@"Error", @"");
506 NSString *msg1 = NSLocalizedString(@"Cannot rename ", @"");
507 NSString *msg2 = NSLocalizedString(@"Continue", @"");
508
509 NSRunAlertPanel(title, [NSString stringWithFormat: @"%@'%@'!", msg1, name], msg2, nil, nil);
510 return NO;
511 }
512
513 - (void)fileManager:(NSFileManager *)manager willProcessPath:(NSString *)path
514 {
515 }
516
517 @end
518
519 @implementation SmallIcon (DraggingSource)
520
521 - (void)startExternalDragOnEvent:(NSEvent *)event
522 {
523 NSEvent *nextEvent;
524 NSPoint dragPoint;
525 NSPasteboard *pb;
526 NSArray *selection;
527 NSImage *dragIcon;
528
529 nextEvent = [[self window] nextEventMatchingMask:
530 NSLeftMouseUpMask | NSLeftMouseDraggedMask];
531
532 if([nextEvent type] != NSLeftMouseDragged) {
533 return;
534 }
535
536 dragPoint = [nextEvent locationInWindow];
537 dragPoint = [self convertPoint: dragPoint fromView: nil];
538
539 pb = [NSPasteboard pasteboardWithName: NSDragPboard];
540 [self declareAndSetShapeOnPasteboard: pb];
541
542 selection = [delegate getTheCurrentSelection];
543
544 if ([selection count] > 1) {
545 dragIcon = [NSImage imageNamed: @"MultipleSelection.tiff"];
546 } else {
547 dragIcon = [GWLib iconForFile: path ofType: type];
548 }
549
550 [self dragImage: dragIcon
551 at: dragPoint
552 offset: NSZeroSize
553 event: event
554 pasteboard: pb
555 source: self
556 slideBack: [[GWLib workspaceApp] animateSlideBack]];
557 }
558
559 - (void)draggedImage:(NSImage *)anImage
560 endedAt:(NSPoint)aPoint
561 deposited:(BOOL)flag
562 {
563 dragdelay = 0;
564 onSelf = NO;
565 }
566
567 - (void)declareAndSetShapeOnPasteboard:(NSPasteboard *)pb
568 {
569 NSArray *dndtypes;
570 NSArray *selection;
571
572 dndtypes = [NSArray arrayWithObject: NSFilenamesPboardType];
573 [pb declareTypes: dndtypes owner: nil];
574 selection = [delegate getTheCurrentSelection];
575
576 if ([pb setPropertyList: selection forType: NSFilenamesPboardType] == NO) {
577 return;
578 }
579 }
580
581 - (unsigned int)draggingSourceOperationMaskForLocal:(BOOL)flag
582 {
583 return NSDragOperationAll;
584 }
585
586 @end
587
588 @implementation SmallIcon (DraggingDestination)
589
590 - (unsigned int)draggingEntered:(id <NSDraggingInfo>)sender
591 {
592 NSPasteboard *pb;
593 NSDragOperation sourceDragMask;
594 NSArray *sourcePaths;
595 NSString *fromPath;
596 NSString *buff;
597 NSString *iconPath;
598 int i, count;
599
600 CHECK_LOCK_RET (NSDragOperationNone);
601
602 pb = [sender draggingPasteboard];
603 if([[pb types] indexOfObject: NSFilenamesPboardType] != NSNotFound) {
604 sourcePaths = [pb propertyListForType: NSFilenamesPboardType];
605 count = [sourcePaths count];
606
607 if ((count == 1) && ([path isEqualToString: [sourcePaths objectAtIndex: 0]])) {
608 onSelf = YES;
609 isDragTarget = YES;
610 return NSDragOperationAll;
611 }
612
613 if ((([type isEqualToString: NSDirectoryFileType] == NO)
614 && ([type isEqualToString: NSFilesystemFileType] == NO)) || isPakage) {
615 return NSDragOperationNone;
616 }
617
618 fromPath = [[sourcePaths objectAtIndex: 0] stringByDeletingLastPathComponent];
619
620 if (count == 0) {
621 return NSDragOperationNone;
622 }
623
624 if ([fm isWritableFileAtPath: path] == NO) {
625 return NSDragOperationNone;
626 }
627
628 if ([path isEqualToString: fromPath]) {
629 return NSDragOperationNone;
630 }
631
632 for (i = 0; i < count; i++) {
633 if ([path isEqualToString: [sourcePaths objectAtIndex: i]]) {
634 return NSDragOperationNone;
635 }
636 }
637
638 buff = [NSString stringWithString: path];
639 while (1) {
640 for (i = 0; i < count; i++) {
641 if ([buff isEqualToString: [sourcePaths objectAtIndex: i]]) {
642 return NSDragOperationNone;
643 }
644 }
645 if ([buff isEqualToString: fixPath(@"/", 0)] == YES) {
646 break;
647 }
648 buff = [buff stringByDeletingLastPathComponent];
649 }
650
651 isDragTarget = YES;
652
653 iconPath = [path stringByAppendingPathComponent: @".opendir.tiff"];
654
655 if ([fm isReadableFileAtPath: iconPath]) {
656 NSImage *img = [[NSImage alloc] initWithContentsOfFile: iconPath];
657
658 if (img) {
659 NSSize size = [img size];
660 [img setScalesWhenResized: YES];
661 [img setSize: NSMakeSize(size.width / 2, size.height / 2)];
662 ASSIGN (icon, img);
663 RELEASE (img);
664 } else {
665 ASSIGN (icon, [NSImage imageNamed: @"FileIcon_Directory_Open_Small.tiff"]);
666 }
667 } else {
668 ASSIGN (icon, [NSImage imageNamed: @"FileIcon_Directory_Open_Small.tiff"]);
669 }
670
671 [self setNeedsDisplay: YES];
672
673 sourceDragMask = [sender draggingSourceOperationMask];
674
675 if (sourceDragMask == NSDragOperationCopy) {
676 return NSDragOperationCopy;
677 } else if (sourceDragMask == NSDragOperationLink) {
678 return NSDragOperationLink;
679 } else {
680 return NSDragOperationAll;
681 }
682 }
683
684 return NSDragOperationNone;
685 }
686
687 - (unsigned int)draggingUpdated:(id <NSDraggingInfo>)sender
688 {
689 NSDragOperation sourceDragMask;
690
691 CHECK_LOCK_RET (NSDragOperationNone);
692
693 if (isPakage) {
694 return NSDragOperationNone;
695 }
696 if (isDragTarget == NO) {
697 return NSDragOperationNone;
698 }
699
700 sourceDragMask = [sender draggingSourceOperationMask];
701
702 if (sourceDragMask == NSDragOperationCopy) {
703 return NSDragOperationCopy;
704 } else if (sourceDragMask == NSDragOperationLink) {
705 return NSDragOperationLink;
706 } else {
707 return NSDragOperationAll;
708 }
709
710 return NSDragOperationNone;
711 }
712
713 - (void)draggingExited:(id <NSDraggingInfo>)sender
714 {
715 if(isDragTarget == YES) {
716 isDragTarget = NO;
717 if (onSelf == NO) {
718 ASSIGN (icon, [GWLib smallIconForFile: path]);
719 [self setNeedsDisplay: YES];
720 }
721 onSelf = NO;
722 }
723 }
724
725 - (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
726 {
727 CHECK_LOCK_RET (NO);
728 return isDragTarget;
729 }
730
731 - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
732 {
733 CHECK_LOCK_RET (NO);
734 return YES;
735 }
736
737 - (void)concludeDragOperation:(id <NSDraggingInfo>)sender
738 {
739 NSPasteboard *pb;
740 NSDragOperation sourceDragMask;
741 NSArray *sourcePaths;
742 NSString *operation, *source;
743 NSMutableArray *files;
744 NSMutableDictionary *opDict;
745 NSString *trashPath;
746 int i;
747
748 CHECK_LOCK;
749
750 isDragTarget = NO;
751
752 if (onSelf == YES) {
753 onSelf = NO;
754 return;
755 }
756
757 ASSIGN (icon, [GWLib smallIconForFile: path]);
758 [self setNeedsDisplay: YES];
759
760 sourceDragMask = [sender draggingSourceOperationMask];
761 pb = [sender draggingPasteboard];
762 sourcePaths = [pb propertyListForType: NSFilenamesPboardType];
763 source = [[sourcePaths objectAtIndex: 0] stringByDeletingLastPathComponent];
764
765 trashPath = [[GWLib workspaceApp] trashPath];
766
767 if ([source isEqualToString: trashPath]) {
768 operation = GWorkspaceRecycleOutOperation;
769 } else {
770 if (sourceDragMask == NSDragOperationCopy) {
771 operation = NSWorkspaceCopyOperation;
772 } else if (sourceDragMask == NSDragOperationLink) {
773 operation = NSWorkspaceLinkOperation;
774 } else {
775 operation = NSWorkspaceMoveOperation;
776 }
777 }
778
779 files = [NSMutableArray arrayWithCapacity: 1];
780 for(i = 0; i < [sourcePaths count]; i++) {
781 [files addObject: [[sourcePaths objectAtIndex: i] lastPathComponent]];
782 }
783
784 opDict = [NSMutableDictionary dictionaryWithCapacity: 4];
785 [opDict setObject: operation forKey: @"operation"];
786 [opDict setObject: source forKey: @"source"];
787 [opDict setObject: path forKey: @"destination"];
788 [opDict setObject: files forKey: @"files"];
789
790 [[GWLib workspaceApp] performFileOperationWithDictionary: opDict];
791 }
792
793 @end

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26