Add preference to skip hidden files during sync.
[pithos-macos] / pithos-macos / PithosBrowserController.m
index b8d04d3..a929b9b 100644 (file)
     [browser setAllowsMultipleSelection:YES];
     [browser setAllowsEmptySelection:YES];
     [browser setAllowsTypeSelect:YES];
+    [browser setDoubleAction:@selector(browserDoubleAction:)];
     
     moveNetworkQueue = [[ASINetworkQueue alloc] init];
     moveNetworkQueue.shouldCancelAllRequestsOnFailure = NO;
@@ -938,6 +939,29 @@ forDraggedRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)column {
 }
 
 #pragma mark -
+#pragma mark NSBrowser Actions
+
+- (void)browserDoubleAction:(id)sender {
+    NSInteger column = [browser clickedColumn];
+    NSInteger row = [browser clickedRow];
+    if ((column == -1) || (row == -1))
+        return;
+    NSIndexPath *clickedNodeIndexPath = [[browser indexPathForColumn:column] indexPathByAddingIndex:row];
+    NSArray *menuNodesIndexPaths = [browser selectionIndexPaths];
+    NSMutableArray *menuNodes = [NSMutableArray arrayWithCapacity:[menuNodesIndexPaths count]];
+    if ([menuNodesIndexPaths containsObject:clickedNodeIndexPath]) {
+        for (NSIndexPath *nodeIndexPath in menuNodesIndexPaths) {
+            [menuNodes addObject:[browser itemAtIndexPath:nodeIndexPath]];
+        }
+    } else {
+        [menuNodes addObject:[browser itemAtIndexPath:clickedNodeIndexPath]];
+    }
+    NSMenuItem *menuItem = [[[NSMenuItem alloc] init] autorelease];
+    menuItem.representedObject = menuNodes;
+    [self menuDownload:menuItem];
+}
+
+#pragma mark -
 #pragma mark Drag and Drop methods
 
 - (void)downloadNode:(PithosNode *)node toDirectory:(NSString *)dirPath withNewFileName:(NSString *)newFileName 
@@ -2149,15 +2173,26 @@ forDraggedRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)column {
         NSInteger column = [browser clickedColumn];
         NSInteger row = [browser clickedRow];
         if ((column == -1) || (row == -1)) {
-            // General context menu
-            NSArray *menuNodesIndexPaths = [browser selectionIndexPaths];
-            if ([menuNodesIndexPaths count] == 0) {
-                menuNode = [browser parentForItemsInColumn:0];
-            } else if (([menuNodesIndexPaths count] != 1) || 
-                       ([[browser itemAtIndexPath:[menuNodesIndexPaths objectAtIndex:0]] class] == [PithosObjectNode class])) {
-                menuNode = [browser parentForItemsInColumn:([[menuNodesIndexPaths objectAtIndex:0] length] - 1)];
+            if (column == -1) {
+                // General context menu
+                NSArray *menuNodesIndexPaths = [browser selectionIndexPaths];
+                if ([menuNodesIndexPaths count] == 0) {
+                    menuNode = [browser parentForItemsInColumn:0];
+                } else if (([menuNodesIndexPaths count] != 1) || 
+                           ([[browser itemAtIndexPath:[menuNodesIndexPaths objectAtIndex:0]] class] == [PithosObjectNode class])) {
+                    menuNode = [browser parentForItemsInColumn:([[menuNodesIndexPaths objectAtIndex:0] length] - 1)];
+                } else {
+                    menuNode = [browser itemAtIndexPath:[menuNodesIndexPaths objectAtIndex:0]];
+                }
             } else {
-                menuNode = [browser itemAtIndexPath:[menuNodesIndexPaths objectAtIndex:0]];
+                menuNode = [browser parentForItemsInColumn:column];
+                if ([menuNode class] == [PithosObjectNode class]) {
+                    // Node context menu
+                    menuNodes = [NSMutableArray arrayWithObject:menuNode];
+                    nodeContextMenu = YES;
+                }
+                // else 
+                // General context menu
             }
         } else {
             // Node context menu