/[gnustep]/gnustep/usr-apps/gworkspace/GWLib/BIcon.m
ViewVC logotype

Contents of /gnustep/usr-apps/gworkspace/GWLib/BIcon.m

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Mon Sep 29 13:20:28 2003 UTC (20 years, 7 months ago) by esersale
Branch: MAIN
Changes since 1.2: +37 -113 lines
*** empty log message ***

1 /* BIcon.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 #include "GWProtocol.h"
29 #include "GWFunctions.h"
30 #include "GWNotifications.h"
31 #include "GWLib.h"
32 #include "BIcon.h"
33 #include "BIconLabel.h"
34 #include "GNUstep.h"
35
36 #define CHECK_LOCK if (locked) return
37 #define CHECK_LOCK_RET(x) if (locked) return x
38
39 @implementation BIcon
40
41 - (void)dealloc
42 {
43 [[NSNotificationCenter defaultCenter] removeObserver: self];
44 TEST_RELEASE (paths);
45 TEST_RELEASE (fullpath);
46 TEST_RELEASE (name);
47 TEST_RELEASE (hostname);
48 TEST_RELEASE (type);
49 TEST_RELEASE (icon);
50 RELEASE (namelabel);
51 RELEASE (highlight);
52 RELEASE (arrow);
53 [super dealloc];
54 }
55
56 - (id)init
57 {
58 self = [super init];
59
60 if (self) {
61 #ifdef GNUSTEP
62 Class gwclass = [[NSBundle mainBundle] principalClass];
63 #else
64 Class gwclass = [[NSBundle mainBundle] classNamed: @"GWorkspace"];
65 #endif
66
67 gworkspace = (id<GWProtocol>)[gwclass gworkspace];
68
69 fm = [NSFileManager defaultManager];
70
71 ASSIGN (highlight, [NSImage imageNamed: @"CellHighlight.tiff"]);
72 ASSIGN (arrow, [NSImage imageNamed: @"common_3DArrowRight.tiff"]);
73
74 namelabel = [[BIconLabel alloc] initForIcon: self];
75 [namelabel setFont: [NSFont systemFontOfSize: 12]];
76 [namelabel setBezeled: NO];
77 [namelabel setEditable: NO];
78 [namelabel setSelectable: NO];
79 [namelabel setAlignment: NSCenterTextAlignment];
80 [namelabel setBackgroundColor: [NSColor windowBackgroundColor]];
81
82 contestualMenu = [gworkspace usesContestualMenu];
83
84 paths = nil;
85 fullpath = nil;
86 hostname = nil;
87 icon = nil;
88 isbranch = NO;
89 dimmed = NO;
90 locked = NO;
91 isPakage = NO;
92 singlepath = YES;
93 isSelect = NO;
94 dragdelay = 0;
95 isDragTarget = NO;
96 onSelf = NO;
97 isRootIcon = NO;
98
99 [self registerForDraggedTypes: [NSArray arrayWithObject: NSFilenamesPboardType]];
100 }
101
102 return self;
103 }
104
105 - (void)setPaths:(NSArray *)p
106 {
107 float width, labwidth;
108 int i, count;
109
110 if ([p isEqualToArray: paths]) {
111 return;
112 }
113
114 if (p == nil) {
115 TEST_RELEASE (paths);
116 paths = nil;
117 TEST_RELEASE (fullpath);
118 fullpath = nil;
119 ASSIGN (name, @"");
120 TEST_RELEASE (type);
121 type = nil;
122 isPakage = NO;
123 TEST_RELEASE (icon);
124 icon = nil;
125 dimmed = YES;
126 [self setNeedsDisplay: YES];
127 return;
128 }
129
130 dimmed = NO;
131
132 ASSIGN (paths, p);
133 count = [paths count];
134
135 if (count == 1) {
136 singlepath = YES;
137 ASSIGN (fullpath, [paths objectAtIndex: 0]);
138 if ([fullpath isEqualToString: fixPath(@"/", 0)]) {
139 ASSIGN (name, fullpath);
140 isRootIcon = YES;
141 } else {
142 ASSIGN (name, [fullpath lastPathComponent]);
143 isRootIcon = NO;
144 }
145
146 ASSIGN (type, [gworkspace typeOfFileAt: fullpath]);
147 isPakage = [gworkspace isPakageAtPath: fullpath];
148
149 } else {
150 fullpath = nil;
151 singlepath = NO;
152 ASSIGN (name, ([NSString stringWithFormat: @"%i items", count]));
153 type = nil;
154 isRootIcon = NO;
155 isPakage = NO;
156 }
157
158 if (singlepath == YES) {
159 ASSIGN (icon, [gworkspace iconForFile: fullpath ofType: type]);
160 } else {
161 ASSIGN (icon, [NSImage imageNamed: @"MultipleSelection.tiff"]);
162 }
163
164 width = [self frame].size.width;
165 labwidth = [[namelabel font] widthOfString: name] + 8;
166 if (labwidth > width) {
167 labwidth = width;
168 }
169 [namelabel setFrame: NSMakeRect(0, 0, labwidth, 14)];
170
171 if (isRootIcon == NO) {
172 [namelabel setStringValue: cutFileLabelText(name, namelabel, labwidth)];
173 } else {
174 NSHost *host = [NSHost currentHost];
175 NSString *hname = [host name];
176 NSRange range = [hname rangeOfString: @"."];
177
178 if (range.length != 0) {
179 hname = [hname substringToIndex: range.location];
180 }
181 ASSIGN (hostname, hname);
182 [namelabel setStringValue: hostname];
183 }
184
185 [self setLocked: NO];
186
187 for (i = 0; i < [paths count]; i++) {
188 NSString *path = [paths objectAtIndex: i];
189
190 if ([gworkspace isLockedPath: path]) {
191 [self setLocked: YES];
192 break;
193 }
194 }
195
196 [delegate icon: self setFrameOfLabel: namelabel];
197 [self setNeedsDisplay: YES];
198 }
199
200 - (void)setFrame:(NSRect)frameRect
201 {
202 float width, labwidth;
203
204 [super setFrame: frameRect];
205
206 width = [self frame].size.width;
207
208 if (isRootIcon == NO) {
209 labwidth = [[namelabel font] widthOfString: name] + 8;
210 } else {
211 labwidth = [[namelabel font] widthOfString: hostname] + 8;
212 }
213 if (labwidth > width) {
214 labwidth = width;
215 }
216
217 [namelabel setFrame: NSMakeRect(0, 0, labwidth, 14)];
218
219 if (isRootIcon == NO) {
220 [namelabel setStringValue: cutFileLabelText(name, namelabel, labwidth)];
221 } else {
222 [namelabel setStringValue: hostname];
223 }
224
225 [delegate icon: self setFrameOfLabel: namelabel];
226
227 [self setNeedsDisplay: YES];
228 }
229
230 - (void)select
231 {
232 if (isSelect || dimmed) {
233 return;
234 }
235
236 isSelect = YES;
237 [namelabel setBackgroundColor: [NSColor whiteColor]];
238 [delegate unselectOtherIcons: self];
239 [self setNeedsDisplay: YES];
240 [namelabel setNeedsDisplay: YES];
241 }
242
243 - (void)unselect
244 {
245 isSelect = NO;
246 [namelabel setBackgroundColor: [NSColor windowBackgroundColor]];
247 [self setNeedsDisplay: YES];
248 [namelabel setNeedsDisplay: YES];
249 }
250
251 - (void)renewIcon
252 {
253 if (singlepath == YES) {
254 ASSIGN (icon, [gworkspace iconForFile: fullpath ofType: type]);
255 } else {
256 ASSIGN (icon, [NSImage imageNamed: @"MultipleSelection.tiff"]);
257 }
258 [self setNeedsDisplay: YES];
259 }
260
261 - (void)openWithApp:(id)sender
262 {
263 NSString *appName = [[sender representedObject] objectForKey: @"appName"];
264 NSString *fullPath = [[sender representedObject] objectForKey: @"fullPath"];
265
266 [[NSWorkspace sharedWorkspace] openFile: fullPath withApplication: appName];
267 }
268
269 - (void)openWith:(id)sender
270 {
271 [gworkspace openSelectedPathsWith];
272 }
273
274 - (BOOL)isSelect
275 {
276 return isSelect;
277 }
278
279 - (NSTextField *)label
280 {
281 return namelabel;
282 }
283
284 - (void)setBranch:(BOOL)value
285 {
286 if (isbranch != value) {
287 isbranch = value;
288 [self setDimmed: NO];
289 [self setNeedsDisplay: YES];
290 }
291 }
292
293 - (BOOL)isBranch
294 {
295 return isbranch;
296 }
297
298 - (void)setDimmed:(BOOL)value
299 {
300 if (dimmed != value) {
301 dimmed = value;
302 }
303 }
304
305 - (BOOL)isDimmed
306 {
307 return dimmed;
308 }
309
310 - (void)setLocked:(BOOL)value
311 {
312 if (locked == value) {
313 return;
314 }
315 locked = value;
316 [namelabel setTextColor: (locked ? [NSColor disabledControlTextColor]
317 : [NSColor controlTextColor])];
318 [self setNeedsDisplay: YES];
319 [namelabel setNeedsDisplay: YES];
320 }
321
322 - (BOOL)isLocked
323 {
324 return locked;
325 }
326
327 - (BOOL)isRootIcon
328 {
329 return isRootIcon;
330 }
331
332 - (NSArray *)paths
333 {
334 return paths;
335 }
336
337 - (NSString *)name
338 {
339 return name;
340 }
341
342 - (NSString *)hostname
343 {
344 return hostname;
345 }
346
347 - (NSString *)type
348 {
349 return type;
350 }
351
352 - (NSImage *)icon
353 {
354 return icon;
355 }
356
357 - (NSSize)iconShift
358 {
359 NSRect r = [self frame];
360 NSSize s = [icon size];
361
362 return NSMakeSize((r.size.width - s.width) / 2, (r.size.height - s.height) / 2);
363 }
364
365 - (void)clickOnLabel
366 {
367 CHECK_LOCK;
368 [self select];
369 [delegate clickOnIcon: self];
370 }
371
372 - (void)mouseUp:(NSEvent *)theEvent
373 {
374 CHECK_LOCK;
375
376 if([theEvent clickCount] > 1) {
377 unsigned int modifier = [theEvent modifierFlags];
378 [delegate doubleClickOnIcon: self newViewer: (modifier == NSControlKeyMask)];
379 }
380 }
381
382 - (void)mouseDown:(NSEvent *)theEvent
383 {
384 NSEvent *nextEvent;
385 BOOL startdnd = NO;
386 NSPoint p;
387
388 CHECK_LOCK;
389
390 if (dimmed) {
391 return;
392 }
393
394 p = [theEvent locationInWindow];
395 p = [self convertPoint: p fromView: nil];
396
397 if (ONICON(p, [self frame].size, [icon size]) == NO) {
398 return;
399 }
400
401 if ([theEvent clickCount] == 1) {
402 if (isSelect == NO) {
403 [self select];
404 [delegate unselectNameEditor];
405 }
406
407 while (1) {
408 nextEvent = [[self window] nextEventMatchingMask:
409 NSLeftMouseUpMask | NSLeftMouseDraggedMask];
410
411 if ([nextEvent type] == NSLeftMouseUp) {
412 [delegate clickOnIcon: self];
413 break;
414
415 } else if ([nextEvent type] == NSLeftMouseDragged) {
416 if(dragdelay < 5) {
417 dragdelay++;
418 } else {
419 startdnd = YES;
420 break;
421 }
422 }
423 }
424
425 if (startdnd == YES) {
426 [self startExternalDragOnEvent: nextEvent];
427 }
428 }
429 }
430
431 - (NSMenu *)menuForEvent:(NSEvent *)theEvent
432 {
433 if (([theEvent type] != NSRightMouseDown) || (isSelect == NO)) {
434 return [super menuForEvent: theEvent];
435 } else if ([theEvent modifierFlags] == NSControlKeyMask) {
436 return [super menuForEvent: theEvent];
437 }
438 if ((name == nil) || ([[name pathExtension] length] == 0)) {
439 return [super menuForEvent: theEvent];
440 }
441 if (contestualMenu == NO) {
442 return [super menuForEvent: theEvent];
443 }
444
445 if ((type == NSPlainFileType) || ([type isEqual: NSShellCommandFileType])) {
446 NSMenu *menu = [[NSMenu alloc] initWithTitle: NSLocalizedString(@"Open with", @"")];
447 NSString *ext = [name pathExtension];
448 NSDictionary *apps = [[NSWorkspace sharedWorkspace] infoForExtension: ext];
449 NSEnumerator *app_enum = [[apps allKeys] objectEnumerator];
450 NSMenuItem *menuItem;
451 id key;
452
453 while ((key = [app_enum nextObject])) {
454 NSDictionary *dict = [apps objectForKey: key];
455 NSString *role = [dict objectForKey: @"NSRole"];
456 NSMutableDictionary *repObjDict = [NSMutableDictionary dictionary];
457
458 menuItem = [NSMenuItem new];
459
460 if (role) {
461 [menuItem setTitle: [NSString stringWithFormat: @"%@ - %@", key, role]];
462 } else {
463 [menuItem setTitle: [NSString stringWithFormat: @"%@", key]];
464 }
465
466 [menuItem setTarget: self];
467 [menuItem setAction: @selector(openWithApp:)];
468 [repObjDict setObject: key forKey: @"appName"];
469 [repObjDict setObject: fullpath forKey: @"fullPath"];
470 [menuItem setRepresentedObject: repObjDict];
471 [menu addItem: menuItem];
472 RELEASE (menuItem);
473 }
474
475 menuItem = [NSMenuItem new];
476 [menuItem setTitle: NSLocalizedString(@"Open with...", @"")];
477 [menuItem setTarget: self];
478 [menuItem setAction: @selector(openWith:)];
479 [menu addItem: menuItem];
480 RELEASE (menuItem);
481
482 AUTORELEASE (menu);
483 return menu;
484 }
485
486 return [super menuForEvent: theEvent];
487 }
488
489 /*
490 - (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent *)theEvent
491
492 Overridden by subclasses to allow the user to drag images from the receiver without its window moving forward and possibly obscuring the
493 destination, and without activating the application. If this method returns YES, the normal window ordering and activation mechanism is delayed
494 (not necessarily prevented) until the next mouse-up event. If it returns NO then normal ordering and activation occurs. Never invoke this
495 method directly; it's invoked automatically for each mouse-down event directed at the NSView.
496
497 An NSView subclass that allows dragging should implement this method to return YES if theEvent, an initial mouse-down event, is potentially
498 the beginning of a dragging session or of some other context where window ordering isn't appropriate. This method is invoked before a
499 mouseDown: message for theEvent is sent. NSView's implementation returns NO.
500
501 If, after delaying window ordering, the receiver actually initiates a dragging session or similar operation, it should also send a
502 preventWindowOrdering message to NSApp, which completely prevents the window from ordering forward and the activation from becoming
503 active. preventWindowOrdering is sent automatically by NSView's dragImage:... and dragFile:... methods.
504 */
505
506 - (BOOL)isSinglePath
507 {
508 return singlepath;
509 }
510
511 - (id)delegate
512 {
513 return delegate;
514 }
515
516 - (void)setDelegate:(id)aDelegate
517 {
518 ASSIGN (delegate, aDelegate);
519 AUTORELEASE (delegate);
520 }
521
522 - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
523 {
524 return YES;
525 }
526
527 - (void)drawRect:(NSRect)rect
528 {
529 if (dimmed == YES) {
530 return;
531 }
532
533 if(isSelect) {
534 [highlight compositeToPoint: ICONPOSITION(rect.size, [highlight size])
535 operation: NSCompositeSourceOver];
536 }
537
538 if (icon != nil) {
539 if (locked == NO) {
540 [icon compositeToPoint: ICONPOSITION(rect.size, [icon size])
541 operation: NSCompositeSourceOver];
542 } else {
543 [icon dissolveToPoint: ICONPOSITION(rect.size, [icon size]) fraction: 0.3];
544 }
545 }
546
547 if (isbranch == YES) {
548 [arrow compositeToPoint: NSMakePoint(rect.size.width - 15, 26)
549 operation: NSCompositeSourceOver];
550 }
551 }
552
553 @end
554
555
556 @implementation BIcon (DraggingSource)
557
558 - (void)startExternalDragOnEvent:(NSEvent *)event
559 {
560 NSEvent *nextEvent;
561 NSPoint dragPoint;
562 NSPasteboard *pb;
563
564 nextEvent = [[self window] nextEventMatchingMask:
565 NSLeftMouseUpMask | NSLeftMouseDraggedMask];
566
567 if([nextEvent type] != NSLeftMouseDragged) {
568 [self unselect];
569 return;
570 }
571
572 dragPoint = [nextEvent locationInWindow];
573 dragPoint = [self convertPoint: dragPoint fromView: nil];
574
575 pb = [NSPasteboard pasteboardWithName: NSDragPboard];
576 [self declareAndSetShapeOnPasteboard: pb];
577
578 [self dragImage: icon
579 at: dragPoint
580 offset: NSZeroSize
581 event: nextEvent
582 pasteboard: pb
583 source: self
584 slideBack: [gworkspace animateSlideBack]];
585 }
586
587 - (void)declareAndSetShapeOnPasteboard:(NSPasteboard *)pb
588 {
589 NSArray *dndtypes = [NSArray arrayWithObject: NSFilenamesPboardType];
590
591 [pb declareTypes: dndtypes owner: nil];
592
593 if ([pb setPropertyList: paths forType: NSFilenamesPboardType] == NO) {
594 return;
595 }
596 }
597
598 - (unsigned int)draggingSourceOperationMaskForLocal:(BOOL)flag
599 {
600 return NSDragOperationAll;
601 }
602
603 - (void)draggedImage:(NSImage *)anImage
604 endedAt:(NSPoint)aPoint
605 deposited:(BOOL)flag
606 {
607 dragdelay = 0;
608 onSelf = NO;
609 [self setNeedsDisplay: YES];
610 [delegate restoreSelectionAfterDndOfIcon: self];
611 }
612
613 @end
614
615
616 @implementation BIcon (DraggingDestination)
617
618 - (unsigned int)draggingEntered:(id <NSDraggingInfo>)sender
619 {
620 NSPasteboard *pb;
621 NSDragOperation sourceDragMask;
622 NSArray *sourcePaths;
623 NSString *fromPath;
624 NSString *buff;
625 NSString *iconPath;
626 int i, count;
627
628 CHECK_LOCK_RET (NSDragOperationNone);
629
630 isDragTarget = NO;
631
632 if ((([type isEqualToString: NSDirectoryFileType] == NO)
633 && ([type isEqualToString: NSFilesystemFileType] == NO)) || isPakage) {
634 return NSDragOperationNone;
635 }
636
637 pb = [sender draggingPasteboard];
638
639 if ([[pb types] indexOfObject: NSFilenamesPboardType] == NSNotFound) {
640 return NSDragOperationNone;
641 }
642
643 sourcePaths = [pb propertyListForType: NSFilenamesPboardType];
644
645 count = [sourcePaths count];
646 fromPath = [[sourcePaths objectAtIndex: 0] stringByDeletingLastPathComponent];
647
648 if (count == 0) {
649 return NSDragOperationNone;
650 }
651
652 if ([fm isWritableFileAtPath: fullpath] == NO) {
653 return NSDragOperationNone;
654 }
655
656 if ([paths isEqualToArray: sourcePaths]) {
657 onSelf = YES;
658 }
659
660 if ([fullpath isEqualToString: fromPath]) {
661 return NSDragOperationNone;
662 }
663
664 for (i = 0; i < count; i++) {
665 if ([fullpath isEqualToString: [sourcePaths objectAtIndex: i]]) {
666 return NSDragOperationNone;
667 }
668 }
669
670 buff = [NSString stringWithString: fullpath];
671 while (1) {
672 for (i = 0; i < count; i++) {
673 if ([buff isEqualToString: [sourcePaths objectAtIndex: i]]) {
674 return NSDragOperationNone;
675 }
676 }
677 if ([buff isEqualToString: fixPath(@"/", 0)] == YES) {
678 break;
679 }
680 buff = [buff stringByDeletingLastPathComponent];
681 }
682
683 isDragTarget = YES;
684
685 iconPath = [fullpath stringByAppendingPathComponent: @".opendir.tiff"];
686
687 if ([fm isReadableFileAtPath: iconPath]) {
688 NSImage *img = [[NSImage alloc] initWithContentsOfFile: iconPath];
689
690 if (img) {
691 ASSIGN (icon, img);
692 RELEASE (img);
693 } else {
694 ASSIGN (icon, [NSImage imageNamed: @"FileIcon_Directory_Open.tiff"]);
695 }
696 } else {
697 ASSIGN (icon, [NSImage imageNamed: @"FileIcon_Directory_Open.tiff"]);
698 }
699
700 [self setNeedsDisplay: YES];
701
702 sourceDragMask = [sender draggingSourceOperationMask];
703
704 if (sourceDragMask == NSDragOperationCopy) {
705 return NSDragOperationCopy;
706 } else if (sourceDragMask == NSDragOperationLink) {
707 return NSDragOperationLink;
708 } else {
709 return NSDragOperationAll;
710 }
711
712 return NSDragOperationNone;
713 }
714
715 - (unsigned int)draggingUpdated:(id <NSDraggingInfo>)sender
716 {
717 NSDragOperation sourceDragMask;
718
719 CHECK_LOCK_RET (NSDragOperationNone);
720
721 if (isPakage) {
722 return NSDragOperationNone;
723 }
724 if (isDragTarget == NO) {
725 return NSDragOperationNone;
726 }
727
728 sourceDragMask = [sender draggingSourceOperationMask];
729
730 if (sourceDragMask == NSDragOperationCopy) {
731 return NSDragOperationCopy;
732 } else if (sourceDragMask == NSDragOperationLink) {
733 return NSDragOperationLink;
734 } else {
735 return NSDragOperationAll;
736 }
737
738 return NSDragOperationNone;
739 }
740
741 - (void)draggingExited:(id <NSDraggingInfo>)sender
742 {
743 if(isDragTarget == YES) {
744 isDragTarget = NO;
745 onSelf = NO;
746 ASSIGN (icon, [gworkspace iconForFile: fullpath ofType: type]);
747 [self setNeedsDisplay: YES];
748 }
749 }
750
751 - (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
752 {
753 CHECK_LOCK_RET (NO);
754 return isDragTarget;
755 }
756
757 - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
758 {
759 CHECK_LOCK_RET (NO);
760 return YES;
761 }
762
763 - (void)concludeDragOperation:(id <NSDraggingInfo>)sender
764 {
765 NSPasteboard *pb;
766 NSDragOperation sourceDragMask;
767 NSArray *sourcePaths;
768 NSString *operation, *source;
769 NSMutableArray *files;
770 NSMutableDictionary *opDict;
771 NSString *trashPath;
772 int i;
773
774 CHECK_LOCK;
775
776 isDragTarget = NO;
777
778 if (onSelf == YES) {
779 onSelf = NO;
780 return;
781 }
782
783 ASSIGN (icon, [gworkspace iconForFile: fullpath ofType: type]);
784 [self setNeedsDisplay: YES];
785
786 sourceDragMask = [sender draggingSourceOperationMask];
787 pb = [sender draggingPasteboard];
788
789 sourcePaths = [pb propertyListForType: NSFilenamesPboardType];
790
791 source = [[sourcePaths objectAtIndex: 0] stringByDeletingLastPathComponent];
792
793 trashPath = [gworkspace trashPath];
794
795 if ([source isEqual: trashPath]) {
796 operation = GWorkspaceRecycleOutOperation;
797 } else {
798 if (sourceDragMask == NSDragOperationCopy) {
799 operation = NSWorkspaceCopyOperation;
800 } else if (sourceDragMask == NSDragOperationLink) {
801 operation = NSWorkspaceLinkOperation;
802 } else {
803 operation = NSWorkspaceMoveOperation;
804 }
805 }
806
807 files = [NSMutableArray arrayWithCapacity: 1];
808 for(i = 0; i < [sourcePaths count]; i++) {
809 [files addObject: [[sourcePaths objectAtIndex: i] lastPathComponent]];
810 }
811
812 opDict = [NSMutableDictionary dictionaryWithCapacity: 4];
813 [opDict setObject: operation forKey: @"operation"];
814 [opDict setObject: source forKey: @"source"];
815 [opDict setObject: fullpath forKey: @"destination"];
816 [opDict setObject: files forKey: @"files"];
817
818 [gworkspace performFileOperationWithDictionary: opDict];
819 }
820
821 @end
822

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