3 * Copyright (c) 2019, Blue Static <https://www.bluestatic.org>
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6 * General Public License as published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
10 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along with this program; if not,
14 * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 #import "FileAccessController.h"
21 #import "AppDelegate.h"
22 #import "PreferenceNames.h"
23 #import "PreferencesController.h"
25 @implementation FileAccessController
{
26 // Self-owned window controller reference. Cleared when |-windowWillClose:|.
27 FileAccessController
* __strong _selfRef
;
30 + (void)maybeShowFileAccessDialog
32 NSUserDefaults
* defaults
= [NSUserDefaults standardUserDefaults
];
33 NSDictionary
* fileAccesses
= [defaults objectForKey
:kPrefFileAccessBookmarks
];
34 // TODO: Re-prompt after some amount of time.
35 if ([fileAccesses count
] == 0 &&
36 ![defaults objectForKey
:kPrefFileAccessStartupShowDate
]) {
37 [defaults setObject
:[NSDate date
] forKey
:kPrefFileAccessStartupShowDate
];
38 [self showFileAccessDialog
];
42 + (void)showFileAccessDialog
44 FileAccessController
* controller
= [[FileAccessController alloc
] init
];
45 [controller.window center
];
46 [controller showWindow
:self];
51 if ((self = [self initWithWindowNibName
:@
"FileAccess"])) {
57 - (IBAction
)openFileAccess
:(id)sender
60 PreferencesController
* prefs
= [[AppDelegate instance
] prefsController
];
61 [prefs showPreferencesWindow
];
62 [prefs showFileAccess
:sender
];
65 - (void)windowWillClose
:(NSNotification
*)notification
72 #endif // USE_APP_SANDBOX