Skip to content
This repository
Browse code

Don't accept drops of paths which have already been configured.'

  • Loading branch information...
commit b31d9dc192476c7b9e8aad5516453b6977dfb76a 1 parent d27f6b3
Manfred Stienstra Manfred authored

Showing 2 changed files with 14 additions and 4 deletions. Show diff stats Hide diff stats

  1. +13 3 app/controllers/PassengerPref.m
  2. +1 1  doc/TODO
16 app/controllers/PassengerPref.m
@@ -98,6 +98,17 @@ - (void) authorizationViewDidDeauthorize:(SFAuthorizationView *)authorizationVie
98 98
99 99 #pragma NSTableViewDataSource protocol methods
100 100
  101 +- (BOOL) hasApplicationWithPath:(id)path {
  102 + Application *application;
  103 +
  104 + for (application in applications) {
  105 + if ([[application path] isEqualToString:path]) {
  106 + return YES;
  107 + }
  108 + }
  109 + return NO;
  110 +}
  111 +
101 112 - (NSDragOperation) tableView:(NSTableView *)aTableView validateDrop:(id)info proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)operation {
102 113 id items, path;
103 114 NSFileManager *fileManager = [[NSFileManager alloc] init];
@@ -109,8 +120,7 @@ - (NSDragOperation) tableView:(NSTableView *)aTableView validateDrop:(id)info pr
109 120
110 121 items = [[info draggingPasteboard] propertyListForType:NSFilenamesPboardType];
111 122 for (path in items) {
112   - if (![fileManager fileExistsAtPath:path isDirectory:&isDir] || !isDir) {
113   - NSLog(@"%@ %d", path, isDir);
  123 + if (![fileManager fileExistsAtPath:path isDirectory:&isDir] || !isDir || [self hasApplicationWithPath:path]) {
114 124 return NSDragOperationNone;
115 125 }
116 126 }
@@ -133,7 +143,7 @@ - (BOOL) tableView:(NSTableView *)aTableView acceptDrop:(id)info row:(NSInteger)
133 143 [applicationsController addObjects:droppedApplications];
134 144 [applicationsController setSelectedObjects:[NSArray arrayWithObjects:[droppedApplications lastObject], nil]];
135 145 [self apply:self];
136   -
  146 +
137 147 return YES;
138 148 }
139 149
2  doc/TODO
... ... @@ -1,5 +1,5 @@
  1 +- ppane shouldn't accept duplicate applications
1 2 - Disable debug logging unless in debug mode
2   -- Prevent duplicate folders. When the user tries to add a duplicate folder, select the configuration for the application that uses this folder in the source list.
3 3 - Do not accept characters in the Address and Aliases fields that can't be used for the domain name (including whitespace in the address field).
4 4 - Check for duplicate addresses and aliases after Apply has been clicked. Show a sheet with the following alert:
5 5 - The changes could not be applied because the address “cj.local” ia already in use.

0 comments on commit b31d9dc

Please sign in to comment.
Something went wrong with that request. Please try again.