From e8d065739ca5ff5dad8966ed8e803d7b4fe54b53 Mon Sep 17 00:00:00 2001
From: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
Date: Wed, 9 Jan 2019 13:21:38 -0500
Subject: [PATCH] sandbox: folder for exported account

This patch change default folder of exported account to download
directory instead of home directory that is application container for
sandboxed application.

Change-Id: I893f8d2557aba37e561b776b5524447202263731
---
 src/AccRingGeneralVC.mm |  1 -
 src/BackupAccountWC.mm  | 15 ++++++++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/AccRingGeneralVC.mm b/src/AccRingGeneralVC.mm
index c6e6f651..974d0325 100644
--- a/src/AccRingGeneralVC.mm
+++ b/src/AccRingGeneralVC.mm
@@ -36,7 +36,6 @@
 #import <interfaces/pixmapmanipulatori.h>
 
 #import "RegisterNameWC.h"
-#import "RestoreAccountWC.h"
 #import "BackupAccountWC.h"
 #import "views/NSColor+RingTheme.h"
 #import "views/NSImage+Extensions.h"
diff --git a/src/BackupAccountWC.mm b/src/BackupAccountWC.mm
index 55b674df..5422d865 100644
--- a/src/BackupAccountWC.mm
+++ b/src/BackupAccountWC.mm
@@ -53,7 +53,12 @@
 - (void)windowDidLoad
 {
     [super windowDidLoad];
-    [path setURL: [NSURL fileURLWithPath:NSHomeDirectory()]];
+    NSArray * paths = NSSearchPathForDirectoriesInDomains (NSDownloadsDirectory, NSUserDomainMask, YES);
+    if(paths.count <= 0) {
+        return;
+    }
+    NSString * downloadPath = [paths objectAtIndex:0];
+    [path setURL: [NSURL URLWithString: downloadPath]];
 }
 
 - (void)setDelegate:(id <BackupAccountDelegate>)aDelegate
@@ -107,10 +112,14 @@
 }
 - (void)pathControl:(NSPathControl *)pathControl willDisplayOpenPanel:(NSOpenPanel *)openPanel
 {
-    NSLog(@"willDisplayOpenPanel");
     [openPanel setAllowsMultipleSelection:NO];
     [openPanel setResolvesAliases:YES];
-    [openPanel setDirectory:NSHomeDirectory()];
+    NSArray * paths = NSSearchPathForDirectoriesInDomains (NSDownloadsDirectory, NSUserDomainMask, YES);
+    if(paths.count <= 0) {
+        return;
+    }
+    NSString * downloadPath = [paths objectAtIndex:0];
+    [openPanel setDirectoryURL:[NSURL URLWithString: downloadPath]];
     [openPanel setDelegate:self];
 }
 
-- 
GitLab