use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
extern_protocol!(
pub unsafe trait NSWindowRestoration: NSObjectProtocol + MainThreadOnly {
#[cfg(all(
feature = "NSResponder",
feature = "NSUserInterfaceItemIdentification",
feature = "NSWindow",
feature = "block2"
))]
#[unsafe(method(restoreWindowWithIdentifier:state:completionHandler:))]
#[unsafe(method_family = none)]
unsafe fn restoreWindowWithIdentifier_state_completionHandler(
identifier: &NSUserInterfaceItemIdentifier,
state: &NSCoder,
completion_handler: &block2::DynBlock<dyn Fn(*mut NSWindow, *mut NSError)>,
mtm: MainThreadMarker,
);
}
);
#[cfg(feature = "NSDocumentController")]
impl NSDocumentController {
extern_methods!();
}
#[cfg(feature = "NSDocumentController")]
extern_conformance!(
unsafe impl NSWindowRestoration for NSDocumentController {}
);
#[cfg(all(feature = "NSApplication", feature = "NSResponder"))]
impl NSApplication {
extern_methods!(
#[cfg(all(
feature = "NSUserInterfaceItemIdentification",
feature = "NSWindow",
feature = "block2"
))]
#[unsafe(method(restoreWindowWithIdentifier:state:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn restoreWindowWithIdentifier_state_completionHandler(
&self,
identifier: &NSUserInterfaceItemIdentifier,
state: &NSCoder,
completion_handler: &block2::DynBlock<dyn Fn(*mut NSWindow, *mut NSError)>,
) -> bool;
);
}
extern "C" {
pub static NSApplicationDidFinishRestoringWindowsNotification: &'static NSNotificationName;
}
#[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
impl NSWindow {
extern_methods!(
#[unsafe(method(isRestorable))]
#[unsafe(method_family = none)]
pub fn isRestorable(&self) -> bool;
#[unsafe(method(setRestorable:))]
#[unsafe(method_family = none)]
pub fn setRestorable(&self, restorable: bool);
#[unsafe(method(restorationClass))]
#[unsafe(method_family = none)]
pub unsafe fn restorationClass(&self) -> Option<&'static AnyClass>;
#[unsafe(method(setRestorationClass:))]
#[unsafe(method_family = none)]
pub unsafe fn setRestorationClass(&self, restoration_class: Option<&AnyClass>);
#[unsafe(method(disableSnapshotRestoration))]
#[unsafe(method_family = none)]
pub fn disableSnapshotRestoration(&self);
#[unsafe(method(enableSnapshotRestoration))]
#[unsafe(method_family = none)]
pub fn enableSnapshotRestoration(&self);
);
}
#[cfg(feature = "NSResponder")]
impl NSResponder {
extern_methods!(
#[unsafe(method(encodeRestorableStateWithCoder:))]
#[unsafe(method_family = none)]
pub unsafe fn encodeRestorableStateWithCoder(&self, coder: &NSCoder);
#[unsafe(method(encodeRestorableStateWithCoder:backgroundQueue:))]
#[unsafe(method_family = none)]
pub unsafe fn encodeRestorableStateWithCoder_backgroundQueue(
&self,
coder: &NSCoder,
queue: &NSOperationQueue,
);
#[unsafe(method(restoreStateWithCoder:))]
#[unsafe(method_family = none)]
pub unsafe fn restoreStateWithCoder(&self, coder: &NSCoder);
#[unsafe(method(invalidateRestorableState))]
#[unsafe(method_family = none)]
pub fn invalidateRestorableState(&self);
#[unsafe(method(restorableStateKeyPaths))]
#[unsafe(method_family = none)]
pub fn restorableStateKeyPaths(mtm: MainThreadMarker) -> Retained<NSArray<NSString>>;
#[unsafe(method(allowedClassesForRestorableStateKeyPath:))]
#[unsafe(method_family = none)]
pub fn allowedClassesForRestorableStateKeyPath(
key_path: &NSString,
mtm: MainThreadMarker,
) -> Retained<NSArray<AnyClass>>;
);
}
#[cfg(all(feature = "NSApplication", feature = "NSResponder"))]
impl NSApplication {
extern_methods!(
#[unsafe(method(extendStateRestoration))]
#[unsafe(method_family = none)]
pub fn extendStateRestoration(&self);
#[unsafe(method(completeStateRestoration))]
#[unsafe(method_family = none)]
pub fn completeStateRestoration(&self);
);
}
#[cfg(feature = "NSDocument")]
impl NSDocument {
extern_methods!(
#[cfg(all(
feature = "NSResponder",
feature = "NSUserInterfaceItemIdentification",
feature = "NSWindow",
feature = "block2"
))]
#[unsafe(method(restoreDocumentWindowWithIdentifier:state:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn restoreDocumentWindowWithIdentifier_state_completionHandler(
&self,
identifier: &NSUserInterfaceItemIdentifier,
state: &NSCoder,
completion_handler: &block2::DynBlock<dyn Fn(*mut NSWindow, *mut NSError)>,
);
#[unsafe(method(encodeRestorableStateWithCoder:))]
#[unsafe(method_family = none)]
pub unsafe fn encodeRestorableStateWithCoder(&self, coder: &NSCoder);
#[unsafe(method(encodeRestorableStateWithCoder:backgroundQueue:))]
#[unsafe(method_family = none)]
pub unsafe fn encodeRestorableStateWithCoder_backgroundQueue(
&self,
coder: &NSCoder,
queue: &NSOperationQueue,
);
#[unsafe(method(restoreStateWithCoder:))]
#[unsafe(method_family = none)]
pub unsafe fn restoreStateWithCoder(&self, coder: &NSCoder);
#[unsafe(method(invalidateRestorableState))]
#[unsafe(method_family = none)]
pub fn invalidateRestorableState(&self);
#[unsafe(method(restorableStateKeyPaths))]
#[unsafe(method_family = none)]
pub fn restorableStateKeyPaths(mtm: MainThreadMarker) -> Retained<NSArray<NSString>>;
#[unsafe(method(allowedClassesForRestorableStateKeyPath:))]
#[unsafe(method_family = none)]
pub fn allowedClassesForRestorableStateKeyPath(
key_path: &NSString,
mtm: MainThreadMarker,
) -> Retained<NSArray<AnyClass>>;
);
}