Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@
<action selector="moveSelectedFilesAgain:" target="207" id="cVY-9b-EDj"/>
</connections>
</menuItem>
<menuItem title="Copy To..." tag="14" id="e4f-92-7kq">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="copySelectedFiles:" target="207" id="a1b-45-7c2"/>
</connections>
</menuItem>
<menuItem title="Copy To Folder Again" tag="15" keyEquivalent="c" id="b2k-58-4mj">
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
<connections>
<action selector="copySelectedFilesAgain:" target="207" id="e5p-33-1uv"/>
</connections>
</menuItem>
<menuItem title="Move To Trash" tag="2" id="343">
<string key="keyEquivalent" base64-UTF8="YES">
CA
Expand Down
2 changes: 2 additions & 0 deletions CreeveyController.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ NSDirectoryEnumerator *CreeveyEnumerator(NSString *path, BOOL recurseSubfolders)
- (IBAction)setDesktopPicture:(id)sender;
- (IBAction)moveSelectedFiles:(id)sender;
- (IBAction)moveSelectedFilesAgain:(id)sender;
- (IBAction)copySelectedFiles:(id)sender;
- (IBAction)copySelectedFilesAgain:(id)sender;
- (IBAction)moveToTrash:(id)sender;
- (IBAction)transformJpeg:(id)sender;
- (IBAction)sortThumbnails:(id)sender;
Expand Down
75 changes: 73 additions & 2 deletions CreeveyController.m
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ - (void)applicationWillFinishLaunching:(NSNotification *)notification {
[filetypes removeObject:type];
}
[self updateMoveToMenuItem];
[self updateCopyToMenuItem];
[self updateAlternateSlideshowMenuItem];
[self updateAppearance];

Expand Down Expand Up @@ -484,6 +485,15 @@ - (void)updateMoveToMenuItem {
item.title = [NSString stringWithFormat:NSLocalizedString(@"Move to “%@” Again", @"File menu"), name];
}

- (void)updateCopyToMenuItem {
NSString *path = [NSUserDefaults.standardUserDefaults stringForKey:@"lastUsedCopyToFolder"];
if (path == nil) return;
NSMenu *m = [NSApp.mainMenu itemWithTag:FILE_MENU].submenu;
NSMenuItem *item = [m itemWithTag:COPY_TO_AGAIN];
NSString *name = [NSFileManager.defaultManager displayNameAtPath:path];
item.title = [NSString stringWithFormat:NSLocalizedString(@"Copy to “%@” Again", @"File menu"), name];
}

- (void)updateAlternateSlideshowMenuItem {
NSMenu *m = [NSApp.mainMenu itemWithTag:SLIDESHOW_MENU].submenu;
NSMenuItem *item = [m itemWithTag:BEGIN_SLIDESHOW_ALTERNATE];
Expand Down Expand Up @@ -524,6 +534,36 @@ - (void)moveSelectedFilesTo:(NSURL *)dest {
[creeveyWindows makeObjectsPerformSelector:@selector(filesWereUndeleted:) withObject:[moved valueForKey:@"path"]];
}

- (void)copySelectedFilesTo:(NSURL *)dest {
NSString *curr = slidesWindow.isMainWindow ? slidesWindow.basePath : frontWindow.path;
if ([dest isEqual:[NSURL fileURLWithPath:curr]]) return;

NSArray *files = slidesWindow.isMainWindow ? @[slidesWindow.currentFile] : frontWindow.currentSelection;
NSMutableArray<NSString*> *paths = [NSMutableArray array];
NSMutableArray<NSURL*> *copied = [NSMutableArray arrayWithCapacity:files.count];
NSMutableArray<NSString*> *notCopied = [NSMutableArray array];

NSError * __autoreleasing err;
for (NSString *f in files) {
NSURL *destUrl = [dest URLByAppendingPathComponent:f.lastPathComponent];
if ([NSFileManager.defaultManager copyItemAtPath:f toPath:destUrl.path error:&err]) {
[paths addObject:f];
[copied addObject:destUrl];
} else {
[notCopied addObject:f];
}
}
if (notCopied.count) {
NSAlert *alert = [[NSAlert alloc] init];
if (notCopied.count == 1) {
alert.informativeText = [NSString stringWithFormat:NSLocalizedString(@"The file “%@” could not be copied because of an error: %@", @""), notCopied[0].lastPathComponent, err.localizedDescription];
} else {
alert.informativeText = [NSString stringWithFormat:NSLocalizedString(@"%lu files could not be copied because of an error.",@""), notCopied.count];
}
[alert runModal];
}
}

- (IBAction)moveSelectedFiles:(id)sender {
NSOpenPanel *op = [NSOpenPanel openPanel];
op.canChooseFiles = NO;
Expand All @@ -541,6 +581,23 @@ - (IBAction)moveSelectedFilesAgain:(id)sender {
[self moveSelectedFilesTo:dest];
}

- (IBAction)copySelectedFiles:(id)sender {
NSOpenPanel *op = [NSOpenPanel openPanel];
op.canChooseFiles = NO;
op.canChooseDirectories = YES;
if ([op runModal] != NSModalResponseOK) return;
NSURL *dest = op.URL;
[self copySelectedFilesTo:dest];
[NSUserDefaults.standardUserDefaults setObject:dest.path forKey:@"lastUsedCopyToFolder"];
[self updateCopyToMenuItem];
}

- (IBAction)copySelectedFilesAgain:(id)sender {
NSString *folder = [NSUserDefaults.standardUserDefaults stringForKey:@"lastUsedCopyToFolder"];
NSURL *dest = [NSURL fileURLWithPath:folder isDirectory:YES];
[self copySelectedFilesTo:dest];
}

// returns 1 if successful
// unsuccessful: 0 user wants to continue; 2 cancel/abort
- (char)trashFile:(NSString *)fullpath numLeft:(NSUInteger)numFiles resultingURL:(NSURL **)newURL {
Expand Down Expand Up @@ -838,6 +895,8 @@ -(void)applicationDidChangeScreenParameters:(NSNotification *)notification {
BEGIN_SLIDESHOW_ALTERNATE,
MOVE_TO,
MOVE_TO_AGAIN,
COPY_TO,
COPY_TO_AGAIN,
JPEG_OP = 100,
ROTATE_L = 107,
ROTATE_R = 105,
Expand Down Expand Up @@ -875,6 +934,7 @@ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem {
NSUInteger numSelected = frontWindow ? frontWindow.selectedIndexes.count : 0;
BOOL writable, isjpeg;
NSString *moveTo;
NSString *copyTo;

switch (test_t) {
case NEW_TAB:
Expand All @@ -883,6 +943,9 @@ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem {
moveTo = [NSUserDefaults.standardUserDefaults stringForKey:@"lastUsedMoveToFolder"];
// fall through
case MOVE_TO:
case COPY_TO_AGAIN:
copyTo = [NSUserDefaults.standardUserDefaults stringForKey:@"lastUsedCopyToFolder"];
case COPY_TO:
case MOVE_TO_TRASH:
case JPEG_OP:
// only when slides isn't loading cache!
Expand All @@ -893,8 +956,16 @@ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem {
[NSFileManager.defaultManager isDeletableFileAtPath:
slidesWindow.currentFile]
: numSelected > 0 && frontWindow && frontWindow.currentFilesDeletable;
if (t != JPEG_OP) return writable && (t == MOVE_TO_AGAIN ? moveTo != nil : YES);

if (t != JPEG_OP) {
if (t == MOVE_TO_AGAIN) {
return writable && moveTo != nil;
} else if (t == COPY_TO_AGAIN) {
return writable && copyTo != nil;
} else {
return writable && YES;
}
}

isjpeg = slidesWindow.isMainWindow
? slidesWindow.currentFile && FileIsJPEG(slidesWindow.currentFile)
: numSelected > 0 && frontWindow && FilesContainJPEG(frontWindow.currentSelection);
Expand Down
16 changes: 16 additions & 0 deletions Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@
}
}
}
},
"%lu files could not be copied because of an error." : {

},
"%lu files could not be moved because of an error." : {
"localizations" : {
Expand Down Expand Up @@ -908,6 +911,9 @@
}
}
},
"Copy to “%@” Again" : {
"comment" : "File menu"
},
"Could not check for update - an error occurred while connecting to the server." : {
"localizations" : {
"de" : {
Expand Down Expand Up @@ -2056,6 +2062,16 @@
}
}
},
"The file “%@” could not be copied because of an error: %@" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "The file “%1$@” could not be copied because of an error: %2$@"
}
}
}
},
"The file “%@” could not be moved because of an error: %@" : {
"localizations" : {
"de" : {
Expand Down
24 changes: 24 additions & 0 deletions mul.lproj/MainMenu.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -3847,6 +3847,18 @@
}
}
},
"b2k-58-4mj.title" : {
"comment" : "Class = \"NSMenuItem\"; title = \"Copy To Folder Again\"; ObjectID = \"b2k-58-4mj\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Copy To Folder Again"
}
}
}
},
"c0g-qO-OVm.title" : {
"comment" : "Class = \"NSMenuItem\"; title = \"Move To Folder Again\"; ObjectID = \"c0g-qO-OVm\";",
"extractionState" : "extracted_with_value",
Expand Down Expand Up @@ -3889,6 +3901,18 @@
}
}
},
"e4f-92-7kq.title" : {
"comment" : "Class = \"NSMenuItem\"; title = \"Copy To...\"; ObjectID = \"e4f-92-7kq\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Copy To..."
}
}
}
},
"FZ5-3D-1VQ.title" : {
"comment" : "Class = \"NSMenuItem\"; title = \"Begin Slideshow In Window\"; ObjectID = \"FZ5-3D-1VQ\";",
"extractionState" : "extracted_with_value",
Expand Down