2020-03-05 13:33:11 +11:00
|
|
|
//! Certain enums that are useful (response types, etc).
|
|
|
|
|
2020-03-18 12:19:56 +11:00
|
|
|
use crate::foundation::{NSInteger, NSUInteger};
|
2020-03-05 13:33:11 +11:00
|
|
|
|
2021-03-16 11:09:50 +11:00
|
|
|
/// Represents a modal response for macOS modal dialogs.
|
2021-03-06 09:11:17 +11:00
|
|
|
#[derive(Copy, Clone, Debug)]
|
2020-03-05 13:33:11 +11:00
|
|
|
pub enum ModalResponse {
|
2021-03-16 11:09:50 +11:00
|
|
|
/// The user hit the "Ok" button.
|
2020-03-05 13:33:11 +11:00
|
|
|
Ok,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// Continue.
|
2020-03-05 13:33:11 +11:00
|
|
|
Continue,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// Canceled.
|
2020-03-05 13:33:11 +11:00
|
|
|
Canceled,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// Stopped.
|
2020-03-05 13:33:11 +11:00
|
|
|
Stopped,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// Aborted.
|
2020-03-05 13:33:11 +11:00
|
|
|
Aborted,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// The first button in the dialog was clicked.
|
2020-03-05 13:33:11 +11:00
|
|
|
FirstButtonReturned,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// The second button in the dialog was clicked.
|
2020-03-05 13:33:11 +11:00
|
|
|
SecondButtonReturned,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// The third button in the dialog was clicked.
|
2020-03-05 13:33:11 +11:00
|
|
|
ThirdButtonReturned
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<NSInteger> for ModalResponse {
|
|
|
|
fn from(i: NSInteger) -> Self {
|
|
|
|
match i {
|
|
|
|
1 => ModalResponse::Ok,
|
|
|
|
0 => ModalResponse::Canceled,
|
|
|
|
1000 => ModalResponse::FirstButtonReturned,
|
|
|
|
1001 => ModalResponse::SecondButtonReturned,
|
|
|
|
1002 => ModalResponse::ThirdButtonReturned,
|
|
|
|
-1000 => ModalResponse::Stopped,
|
|
|
|
-1001 => ModalResponse::Aborted,
|
|
|
|
-1002 => ModalResponse::Continue,
|
2021-01-19 19:11:52 +11:00
|
|
|
|
|
|
|
// @TODO: Definitely don't panic here, wtf was I thinking?
|
|
|
|
// Probably make this a ModalResponse::Unknown or something so a user can
|
|
|
|
// gracefully handle.
|
2022-07-16 00:14:02 +10:00
|
|
|
e => {
|
|
|
|
panic!("Unknown NSModalResponse sent back! {}", e);
|
|
|
|
}
|
2020-03-05 13:33:11 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-16 11:09:50 +11:00
|
|
|
/// Represents a type of search path used in file manager calls.
|
2021-03-06 09:11:17 +11:00
|
|
|
#[derive(Copy, Clone, Debug)]
|
2020-03-05 13:33:11 +11:00
|
|
|
pub enum SearchPathDomainMask {
|
2021-03-16 11:09:50 +11:00
|
|
|
/// User files and folders.
|
2020-03-05 13:33:11 +11:00
|
|
|
User,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// Local volume files and folders.
|
2020-03-05 13:33:11 +11:00
|
|
|
Local,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// Netowrk files and folders.
|
2020-03-05 13:33:11 +11:00
|
|
|
Network,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// Search all domains. Not typically used these days.
|
2020-03-05 13:33:11 +11:00
|
|
|
Domain,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// Search all domains. Not typically used these days.
|
2020-03-05 13:33:11 +11:00
|
|
|
AllDomains
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<SearchPathDomainMask> for NSUInteger {
|
|
|
|
fn from(mask: SearchPathDomainMask) -> Self {
|
|
|
|
match mask {
|
|
|
|
SearchPathDomainMask::User => 1,
|
|
|
|
SearchPathDomainMask::Local => 2,
|
|
|
|
SearchPathDomainMask::Network => 4,
|
|
|
|
SearchPathDomainMask::Domain => 8,
|
|
|
|
SearchPathDomainMask::AllDomains => 0x0ffff
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-16 11:09:50 +11:00
|
|
|
/// Represents a type of search path to use.
|
|
|
|
///
|
|
|
|
/// This enum is particularly useful for applications that need to exist both inside and outside of
|
|
|
|
/// the sandbox. For example: `SearchPathDirectory::Documents` will find the standard `Documents`
|
|
|
|
/// directory outside of the sandbox, but use the sandbox `Documents` directory in sandboxed
|
|
|
|
/// applications.
|
2021-03-06 09:11:17 +11:00
|
|
|
#[derive(Copy, Clone, Debug)]
|
2020-03-05 13:33:11 +11:00
|
|
|
pub enum SearchPathDirectory {
|
2021-03-16 11:09:50 +11:00
|
|
|
/// The applications folder.
|
2020-03-05 13:33:11 +11:00
|
|
|
Applications,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// Unsupported applications and demo versions. Not generally used these days.
|
2020-03-05 13:33:11 +11:00
|
|
|
DemoApplications,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// Developer applications (_/Developer/Applications_). Not generally used these days.
|
2020-03-05 13:33:11 +11:00
|
|
|
DeveloperApplications,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// System and network admin apps.
|
2020-03-05 13:33:11 +11:00
|
|
|
AdminApplications,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// User-visible docs, support, and config files.
|
2020-03-05 13:33:11 +11:00
|
|
|
Library,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// Dev resources. (_/Developer_)
|
2020-03-05 13:33:11 +11:00
|
|
|
Developer,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// User home directories. (_/Users_)
|
2020-03-05 13:33:11 +11:00
|
|
|
User,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// Documentation.
|
2020-03-05 13:33:11 +11:00
|
|
|
Documentation,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// Documents directory.
|
2020-03-05 13:33:11 +11:00
|
|
|
Documents,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// Core Services (_/System/Library/CoreServices_)
|
2020-03-05 13:33:11 +11:00
|
|
|
CoreServices,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// User's autosaved documents (_/Library/Autosave Information_)
|
2020-03-05 13:33:11 +11:00
|
|
|
AutosavedInformation,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// The current user's Desktop directory.
|
2020-03-05 13:33:11 +11:00
|
|
|
Desktop,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// Discardable cache files. (_/Library/Caches_)
|
2020-03-05 13:33:11 +11:00
|
|
|
Caches,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// App support files (_/Library/Application Support_)
|
2020-03-05 13:33:11 +11:00
|
|
|
ApplicationSupport,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// The curent user's Downloads directory.
|
2020-03-05 13:33:11 +11:00
|
|
|
Downloads,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// Input methods (_/Library/Input Methods_)
|
2020-03-05 13:33:11 +11:00
|
|
|
InputMethods,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// The current user's Movies directory.
|
2020-03-05 13:33:11 +11:00
|
|
|
Movies,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// The current user's Music directory.
|
2020-03-05 13:33:11 +11:00
|
|
|
Music,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// The current user's pictures directory.
|
2020-03-05 13:33:11 +11:00
|
|
|
Pictures,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// System PPD files (_/Library/Printers/PPDs_)
|
2020-03-05 13:33:11 +11:00
|
|
|
PrinterDescription,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// The current user's public sharing directory.
|
2020-03-05 13:33:11 +11:00
|
|
|
SharedPublic,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// The Preferences Pane directory, where system preferences files live.
|
|
|
|
/// (_/Library/PreferencePanes_)
|
2020-03-05 13:33:11 +11:00
|
|
|
PreferencePanes,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
2022-07-11 01:15:29 +10:00
|
|
|
/// The user scripts folder for the calling application
|
2021-03-16 11:09:50 +11:00
|
|
|
/// (_~/Library/Application Scripts/<code-signing-id>_).
|
2020-03-05 13:33:11 +11:00
|
|
|
ApplicationScripts,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// Constant used in creating a temp directory.
|
2020-03-05 13:33:11 +11:00
|
|
|
ItemReplacement,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// All directories where apps can be stored.
|
2020-03-05 13:33:11 +11:00
|
|
|
AllApplications,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// All directories where resources can be stored.
|
2020-03-05 13:33:11 +11:00
|
|
|
AllLibraries,
|
2021-03-16 11:09:50 +11:00
|
|
|
|
|
|
|
/// The Trash directory.
|
2020-03-05 13:33:11 +11:00
|
|
|
Trash
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<SearchPathDirectory> for NSUInteger {
|
|
|
|
fn from(directory: SearchPathDirectory) -> Self {
|
|
|
|
match directory {
|
|
|
|
SearchPathDirectory::Applications => 1,
|
|
|
|
SearchPathDirectory::DemoApplications => 2,
|
|
|
|
SearchPathDirectory::DeveloperApplications => 3,
|
|
|
|
SearchPathDirectory::AdminApplications => 4,
|
|
|
|
SearchPathDirectory::Library => 5,
|
|
|
|
SearchPathDirectory::Developer => 6,
|
|
|
|
SearchPathDirectory::User => 7,
|
|
|
|
SearchPathDirectory::Documentation => 8,
|
|
|
|
SearchPathDirectory::Documents => 9,
|
|
|
|
SearchPathDirectory::CoreServices => 10,
|
|
|
|
SearchPathDirectory::AutosavedInformation => 11,
|
|
|
|
SearchPathDirectory::Desktop => 12,
|
|
|
|
SearchPathDirectory::Caches => 13,
|
|
|
|
SearchPathDirectory::ApplicationSupport => 14,
|
|
|
|
SearchPathDirectory::Downloads => 15,
|
|
|
|
SearchPathDirectory::InputMethods => 16,
|
|
|
|
SearchPathDirectory::Movies => 17,
|
|
|
|
SearchPathDirectory::Music => 18,
|
|
|
|
SearchPathDirectory::Pictures => 19,
|
|
|
|
SearchPathDirectory::PrinterDescription => 20,
|
|
|
|
SearchPathDirectory::SharedPublic => 21,
|
|
|
|
SearchPathDirectory::PreferencePanes => 22,
|
|
|
|
SearchPathDirectory::ApplicationScripts => 23,
|
|
|
|
SearchPathDirectory::ItemReplacement => 99,
|
|
|
|
SearchPathDirectory::AllApplications => 100,
|
|
|
|
SearchPathDirectory::AllLibraries => 101,
|
|
|
|
SearchPathDirectory::Trash => 102
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|