/[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.3 - (show annotations) (download)
Tue Sep 30 15:38:06 2003 UTC (20 years, 6 months ago) by esersale
Branch: MAIN
Changes since 1.2: +10 -17 lines
*** empty log message ***

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
419 [[NSNotificationCenter defaultCenter]
420 postNotificationName: GWFileSystemWillChangeNotification
421 object: notifObj];
422
423 RETAIN (self);
424
425 [[NSNotificationCenter defaultCenter]
426 postNotificationName: GWFileSystemDidChangeNotification
427 object: notifObj];
428
429 AUTORELEASE (self);
430
431 return;
432 }
433
434 title = NSLocalizedString(@"Error", @"");
435 msg1 = NSLocalizedString(@"You have not write permission\nfor ", @"");
436 msg2 = NSLocalizedString(@"Continue", @"");
437 if ([fm isWritableFileAtPath: path] == NO) {
438 NSRunAlertPanel(title, [NSString stringWithFormat: @"%@\"%@\"!\n", msg1, path], msg2, nil, nil);
439 CLEAREDITING;
440 } else if ([fm isWritableFileAtPath: basePath] == NO) {
441 NSRunAlertPanel(title, [NSString stringWithFormat: @"%@\"%@\"!\n", msg1, basePath], msg2, nil, nil);
442 CLEAREDITING;
443 }
444
445 notAllowSet = [NSCharacterSet characterSetWithCharactersInString: @"/\\*$|~\'\"`^!?"];
446 range = [newname rangeOfCharacterFromSet: notAllowSet];
447
448 if (range.length > 0) {
449 msg1 = NSLocalizedString(@"Invalid char in name", @"");
450 NSRunAlertPanel(title, msg1, msg2, nil, nil);
451 CLEAREDITING;
452 }
453
454 dirContents = [fm directoryContentsAtPath: basePath];
455
456 samename = NO;
457 for (i = 0; i < [dirContents count]; i++) {
458 if ([newname isEqualToString: [dirContents objectAtIndex:i]]) {
459 if ([newname isEqualToString: name]) {
460 CLEAREDITING;
461 } else {
462 samename = YES;
463 break;
464 }
465 }
466 }
467 if (samename == YES) {
468 NSString *msg3 = NSLocalizedString(@"The name ", @"");
469 msg1 = NSLocalizedString(@" is already in use!", @"");
470 NSRunAlertPanel(title, [NSString stringWithFormat: @"%@'%@'%@!", msg3, newname, msg1], msg2, nil, nil);
471 CLEAREDITING;
472 }
473
474 // e = [[self window] nextEventMatchingMask: NSLeftMouseUpMask | NSKeyUpMask];
475 // [[self window] flushWindow];
476
477 newpath = [basePath stringByAppendingPathComponent: newname];
478
479 notifObj = [NSMutableDictionary dictionaryWithCapacity: 1];
480 [notifObj setObject: GWorkspaceRenameOperation forKey: @"operation"];
481 [notifObj setObject: path forKey: @"source"];
482 [notifObj setObject: newpath forKey: @"destination"];
483 [notifObj setObject: [NSArray arrayWithObjects: @"", nil] forKey: @"files"];
484
485 [[NSNotificationCenter defaultCenter]
486 postNotificationName: GWFileSystemWillChangeNotification
487 object: notifObj];
488
489 [fm movePath: path toPath: newpath handler: self];
490
491 RETAIN (self);
492
493 [[NSNotificationCenter defaultCenter]
494 postNotificationName: GWFileSystemDidChangeNotification
495 object: notifObj];
496
497 AUTORELEASE (self);
498 }
499
500 - (BOOL)fileManager:(NSFileManager *)manager
501 shouldProceedAfterError:(NSDictionary *)errorDict
502 {
503 NSString *title = NSLocalizedString(@"Error", @"");
504 NSString *msg1 = NSLocalizedString(@"Cannot rename ", @"");
505 NSString *msg2 = NSLocalizedString(@"Continue", @"");
506
507 NSRunAlertPanel(title, [NSString stringWithFormat: @"%@'%@'!", msg1, name], msg2, nil, nil);
508 return NO;
509 }
510
511 - (void)fileManager:(NSFileManager *)manager willProcessPath:(NSString *)path
512 {
513 }
514
515 @end
516
517 @implementation SmallIcon (DraggingSource)
518
519 - (void)startExternalDragOnEvent:(NSEvent *)event
520 {
521 NSEvent *nextEvent;
522 NSPoint dragPoint;
523 NSPasteboard *pb;
524 NSArray *selection;
525 NSImage *dragIcon;
526
527 nextEvent = [[self window] nextEventMatchingMask:
528 NSLeftMouseUpMask | NSLeftMouseDraggedMask];
529
530 if([nextEvent type] != NSLeftMouseDragged) {
531 return;
532 }
533
534 dragPoint = [nextEvent locationInWindow];
535 dragPoint = [self convertPoint: dragPoint fromView: nil];
536
537 pb = [NSPasteboard pasteboardWithName: NSDragPboard];
538 [self declareAndSetShapeOnPasteboard: pb];
539
540 selection = [delegate getTheCurrentSelection];
541
542 if ([selection count] > 1) {
543 dragIcon = [NSImage imageNamed: @"MultipleSelection.tiff"];
544 } else {
545 dragIcon = [GWLib iconForFile: path ofType: type];
546 }
547
548 [self dragImage: dragIcon
549 at: dragPoint
550 offset: NSZeroSize
551 event: event
552 pasteboard: pb
553 source: self
554 slideBack: [[GWLib workspaceApp] animateSlideBack]];
555 }
556
557 - (void)draggedImage:(NSImage *)anImage
558 endedAt:(NSPoint)aPoint
559 deposited:(BOOL)flag
560 {
561 dragdelay = 0;
562 onSelf = NO;
563 }
564
565 - (void)declareAndSetShapeOnPasteboard:(NSPasteboard *)pb
566 {
567 NSArray *dndtypes;
568 NSArray *selection;
569
570 dndtypes = [NSArray arrayWithObject: NSFilenamesPboardType];
571 [pb declareTypes: dndtypes owner: nil];
572 selection = [delegate getTheCurrentSelection];
573
574 if ([pb setPropertyList: selection forType: NSFilenamesPboardType] == NO) {
575 return;
576 }
577 }
578
579 - (unsigned int)draggingSourceOperationMaskForLocal:(BOOL)flag
580 {
581 return NSDragOperationAll;
582 }
583
584 @end
585
586 @implementation SmallIcon (DraggingDestination)
587
588 - (unsigned int)draggingEntered:(id <NSDraggingInfo>)sender
589 {
590 NSPasteboard *pb;
591 NSDragOperation sourceDragMask;
592 NSArray *sourcePaths;
593 NSString *fromPath;
594 NSString *buff;
595 NSString *iconPath;
596 int i, count;
597
598 CHECK_LOCK_RET (NSDragOperationNone);
599
600 pb = [sender draggingPasteboard];
601 if([[pb types] indexOfObject: NSFilenamesPboardType] != NSNotFound) {
602 sourcePaths = [pb propertyListForType: NSFilenamesPboardType];
603 count = [sourcePaths count];
604
605 if ((count == 1) && ([path isEqualToString: [sourcePaths objectAtIndex: 0]])) {
606 onSelf = YES;
607 isDragTarget = YES;
608 return NSDragOperationAll;
609 }
610
611 if ((([type isEqualToString: NSDirectoryFileType] == NO)
612 && ([type isEqualToString: NSFilesystemFileType] == NO)) || isPakage) {
613 return NSDragOperationNone;
614 }
615
616 fromPath = [[sourcePaths objectAtIndex: 0] stringByDeletingLastPathComponent];
617
618 if (count == 0) {
619 return NSDragOperationNone;
620 }
621
622 if ([fm isWritableFileAtPath: path] == NO) {
623 return NSDragOperationNone;
624 }
625
626 if ([path isEqualToString: fromPath]) {
627 return NSDragOperationNone;
628 }
629
630 for (i = 0; i < count; i++) {
631 if ([path isEqualToString: [sourcePaths objectAtIndex: i]]) {
632 return NSDragOperationNone;
633 }
634 }
635
636 buff = [NSString stringWithString: path];
637 while (1) {
638 for (i = 0; i < count; i++) {
639 if ([buff isEqualToString: [sourcePaths objectAtIndex: i]]) {
640 return NSDragOperationNone;
641 }
642 }
643 if ([buff isEqualToString: fixPath(@"/", 0)] == YES) {
644 break;
645 }
646 buff = [buff stringByDeletingLastPathComponent];
647 }
648
649 isDragTarget = YES;
650
651 iconPath = [path stringByAppendingPathComponent: @".opendir.tiff"];
652
653 if ([fm isReadableFileAtPath: iconPath]) {
654 NSImage *img = [[NSImage alloc] initWithContentsOfFile: iconPath];
655
656 if (img) {
657 NSSize size = [img size];
658 [img setScalesWhenResized: YES];
659 [img setSize: NSMakeSize(size.width / 2, size.height / 2)];
660 ASSIGN (icon, img);
661 RELEASE (img);
662 } else {
663 ASSIGN (icon, [NSImage imageNamed: @"FileIcon_Directory_Open_Small.tiff"]);
664 }
665 } else {
666 ASSIGN (icon, [NSImage imageNamed: @"FileIcon_Directory_Open_Small.tiff"]);
667 }
668
669 [self setNeedsDisplay: YES];
670
671 sourceDragMask = [sender draggingSourceOperationMask];
672
673 if (sourceDragMask == NSDragOperationCopy) {
674 return NSDragOperationCopy;
675 } else if (sourceDragMask == NSDragOperationLink) {
676 return NSDragOperationLink;
677 } else {
678 return NSDragOperationAll;
679 }
680 }
681
682 return NSDragOperationNone;
683 }
684
685 - (unsigned int)draggingUpdated:(id <NSDraggingInfo>)sender
686 {
687 NSDragOperation sourceDragMask;
688
689 CHECK_LOCK_RET (NSDragOperationNone);
690
691 if (isPakage) {
692 return NSDragOperationNone;
693 }
694 if (isDragTarget == NO) {
695 return NSDragOperationNone;
696 }
697
698 sourceDragMask = [sender draggingSourceOperationMask];
699
700 if (sourceDragMask == NSDragOperationCopy) {
701 return NSDragOperationCopy;
702 } else if (sourceDragMask == NSDragOperationLink) {
703 return NSDragOperationLink;
704 } else {
705 return NSDragOperationAll;
706 }
707
708 return NSDragOperationNone;
709 }
710
711 - (void)draggingExited:(id <NSDraggingInfo>)sender
712 {
713 if(isDragTarget == YES) {
714 isDragTarget = NO;
715 if (onSelf == NO) {
716 ASSIGN (icon, [GWLib smallIconForFile: path]);
717 [self setNeedsDisplay: YES];
718 }
719 onSelf = NO;
720 }
721 }
722
723 - (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
724 {
725 CHECK_LOCK_RET (NO);
726 return isDragTarget;
727 }
728
729 - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
730 {
731 CHECK_LOCK_RET (NO);
732 return YES;
733 }
734
735 - (void)concludeDragOperation:(id <NSDraggingInfo>)sender
736 {
737 NSPasteboard *pb;
738 NSDragOperation sourceDragMask;
739 NSArray *sourcePaths;
740 NSString *operation, *source;
741 NSMutableArray *files;
742 NSMutableDictionary *opDict;
743 NSString *trashPath;
744 int i;
745
746 CHECK_LOCK;
747
748 isDragTarget = NO;
749
750 if (onSelf == YES) {
751 onSelf = NO;
752 return;
753 }
754
755 ASSIGN (icon, [GWLib smallIconForFile: path]);
756 [self setNeedsDisplay: YES];
757
758 sourceDragMask = [sender draggingSourceOperationMask];
759 pb = [sender draggingPasteboard];
760 sourcePaths = [pb propertyListForType: NSFilenamesPboardType];
761 source = [[sourcePaths objectAtIndex: 0] stringByDeletingLastPathComponent];
762
763 trashPath = [[GWLib workspaceApp] trashPath];
764
765 if ([source isEqualToString: trashPath]) {
766 operation = GWorkspaceRecycleOutOperation;
767 } else {
768 if (sourceDragMask == NSDragOperationCopy) {
769 operation = NSWorkspaceCopyOperation;
770 } else if (sourceDragMask == NSDragOperationLink) {
771 operation = NSWorkspaceLinkOperation;
772 } else {
773 operation = NSWorkspaceMoveOperation;
774 }
775 }
776
777 files = [NSMutableArray arrayWithCapacity: 1];
778 for(i = 0; i < [sourcePaths count]; i++) {
779 [files addObject: [[sourcePaths objectAtIndex: i] lastPathComponent]];
780 }
781
782 opDict = [NSMutableDictionary dictionaryWithCapacity: 4];
783 [opDict setObject: operation forKey: @"operation"];
784 [opDict setObject: source forKey: @"source"];
785 [opDict setObject: path forKey: @"destination"];
786 [opDict setObject: files forKey: @"files"];
787
788 [[GWLib workspaceApp] performFileOperationWithDictionary: opDict];
789 }
790
791 @end

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