objc2_app_kit/generated/
NSWindowRestoration.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_protocol!(
11    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nswindowrestoration?language=objc)
12    pub unsafe trait NSWindowRestoration: NSObjectProtocol + MainThreadOnly {
13        #[cfg(all(
14            feature = "NSResponder",
15            feature = "NSUserInterfaceItemIdentification",
16            feature = "NSWindow",
17            feature = "block2"
18        ))]
19        #[unsafe(method(restoreWindowWithIdentifier:state:completionHandler:))]
20        #[unsafe(method_family = none)]
21        unsafe fn restoreWindowWithIdentifier_state_completionHandler(
22            identifier: &NSUserInterfaceItemIdentifier,
23            state: &NSCoder,
24            completion_handler: &block2::Block<dyn Fn(*mut NSWindow, *mut NSError)>,
25            mtm: MainThreadMarker,
26        );
27    }
28);
29
30/// NSWindowRestoration.
31#[cfg(feature = "NSDocumentController")]
32impl NSDocumentController {
33    extern_methods!();
34}
35
36#[cfg(feature = "NSDocumentController")]
37unsafe impl NSWindowRestoration for NSDocumentController {}
38
39/// NSWindowRestoration.
40#[cfg(all(feature = "NSApplication", feature = "NSResponder"))]
41impl NSApplication {
42    extern_methods!(
43        #[cfg(all(
44            feature = "NSUserInterfaceItemIdentification",
45            feature = "NSWindow",
46            feature = "block2"
47        ))]
48        #[unsafe(method(restoreWindowWithIdentifier:state:completionHandler:))]
49        #[unsafe(method_family = none)]
50        pub unsafe fn restoreWindowWithIdentifier_state_completionHandler(
51            &self,
52            identifier: &NSUserInterfaceItemIdentifier,
53            state: &NSCoder,
54            completion_handler: &block2::Block<dyn Fn(*mut NSWindow, *mut NSError)>,
55        ) -> bool;
56    );
57}
58
59extern "C" {
60    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationdidfinishrestoringwindowsnotification?language=objc)
61    pub static NSApplicationDidFinishRestoringWindowsNotification: &'static NSNotificationName;
62}
63
64/// NSUserInterfaceRestoration.
65#[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
66impl NSWindow {
67    extern_methods!(
68        #[unsafe(method(isRestorable))]
69        #[unsafe(method_family = none)]
70        pub unsafe fn isRestorable(&self) -> bool;
71
72        /// Setter for [`isRestorable`][Self::isRestorable].
73        #[unsafe(method(setRestorable:))]
74        #[unsafe(method_family = none)]
75        pub unsafe fn setRestorable(&self, restorable: bool);
76
77        #[unsafe(method(restorationClass))]
78        #[unsafe(method_family = none)]
79        pub unsafe fn restorationClass(&self) -> Option<&'static AnyClass>;
80
81        /// Setter for [`restorationClass`][Self::restorationClass].
82        #[unsafe(method(setRestorationClass:))]
83        #[unsafe(method_family = none)]
84        pub unsafe fn setRestorationClass(&self, restoration_class: Option<&AnyClass>);
85
86        #[unsafe(method(disableSnapshotRestoration))]
87        #[unsafe(method_family = none)]
88        pub unsafe fn disableSnapshotRestoration(&self);
89
90        #[unsafe(method(enableSnapshotRestoration))]
91        #[unsafe(method_family = none)]
92        pub unsafe fn enableSnapshotRestoration(&self);
93    );
94}
95
96/// NSRestorableState.
97#[cfg(feature = "NSResponder")]
98impl NSResponder {
99    extern_methods!(
100        #[unsafe(method(encodeRestorableStateWithCoder:))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn encodeRestorableStateWithCoder(&self, coder: &NSCoder);
103
104        #[unsafe(method(encodeRestorableStateWithCoder:backgroundQueue:))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn encodeRestorableStateWithCoder_backgroundQueue(
107            &self,
108            coder: &NSCoder,
109            queue: &NSOperationQueue,
110        );
111
112        #[unsafe(method(restoreStateWithCoder:))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn restoreStateWithCoder(&self, coder: &NSCoder);
115
116        #[unsafe(method(invalidateRestorableState))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn invalidateRestorableState(&self);
119
120        #[unsafe(method(restorableStateKeyPaths))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn restorableStateKeyPaths(mtm: MainThreadMarker)
123            -> Retained<NSArray<NSString>>;
124
125        /// When secure state restoration is used, values at restorableStateKeyPaths must support NSSecureCoding and this method will be consulted when restoring state. Any values not of an allowed class will not be set.
126        #[unsafe(method(allowedClassesForRestorableStateKeyPath:))]
127        #[unsafe(method_family = none)]
128        pub unsafe fn allowedClassesForRestorableStateKeyPath(
129            key_path: &NSString,
130            mtm: MainThreadMarker,
131        ) -> Retained<NSArray<AnyClass>>;
132    );
133}
134
135/// NSRestorableStateExtension.
136#[cfg(all(feature = "NSApplication", feature = "NSResponder"))]
137impl NSApplication {
138    extern_methods!(
139        #[unsafe(method(extendStateRestoration))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn extendStateRestoration(&self);
142
143        #[unsafe(method(completeStateRestoration))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn completeStateRestoration(&self);
146    );
147}
148
149/// NSRestorableState.
150#[cfg(feature = "NSDocument")]
151impl NSDocument {
152    extern_methods!(
153        #[cfg(all(
154            feature = "NSResponder",
155            feature = "NSUserInterfaceItemIdentification",
156            feature = "NSWindow",
157            feature = "block2"
158        ))]
159        #[unsafe(method(restoreDocumentWindowWithIdentifier:state:completionHandler:))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn restoreDocumentWindowWithIdentifier_state_completionHandler(
162            &self,
163            identifier: &NSUserInterfaceItemIdentifier,
164            state: &NSCoder,
165            completion_handler: &block2::Block<dyn Fn(*mut NSWindow, *mut NSError)>,
166        );
167
168        #[unsafe(method(encodeRestorableStateWithCoder:))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn encodeRestorableStateWithCoder(&self, coder: &NSCoder);
171
172        #[unsafe(method(encodeRestorableStateWithCoder:backgroundQueue:))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn encodeRestorableStateWithCoder_backgroundQueue(
175            &self,
176            coder: &NSCoder,
177            queue: &NSOperationQueue,
178        );
179
180        #[unsafe(method(restoreStateWithCoder:))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn restoreStateWithCoder(&self, coder: &NSCoder);
183
184        #[unsafe(method(invalidateRestorableState))]
185        #[unsafe(method_family = none)]
186        pub unsafe fn invalidateRestorableState(&self);
187
188        #[unsafe(method(restorableStateKeyPaths))]
189        #[unsafe(method_family = none)]
190        pub unsafe fn restorableStateKeyPaths(mtm: MainThreadMarker)
191            -> Retained<NSArray<NSString>>;
192
193        #[unsafe(method(allowedClassesForRestorableStateKeyPath:))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn allowedClassesForRestorableStateKeyPath(
196            key_path: &NSString,
197            mtm: MainThreadMarker,
198        ) -> Retained<NSArray<AnyClass>>;
199    );
200}