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        /// # Safety
20        ///
21        /// `state` possibly has further requirements.
22        #[unsafe(method(restoreWindowWithIdentifier:state:completionHandler:))]
23        #[unsafe(method_family = none)]
24        unsafe fn restoreWindowWithIdentifier_state_completionHandler(
25            identifier: &NSUserInterfaceItemIdentifier,
26            state: &NSCoder,
27            completion_handler: &block2::DynBlock<dyn Fn(*mut NSWindow, *mut NSError)>,
28            mtm: MainThreadMarker,
29        );
30    }
31);
32
33/// NSWindowRestoration.
34#[cfg(feature = "NSDocumentController")]
35impl NSDocumentController {
36    extern_methods!();
37}
38
39#[cfg(feature = "NSDocumentController")]
40extern_conformance!(
41    unsafe impl NSWindowRestoration for NSDocumentController {}
42);
43
44/// NSWindowRestoration.
45#[cfg(all(feature = "NSApplication", feature = "NSResponder"))]
46impl NSApplication {
47    extern_methods!(
48        #[cfg(all(
49            feature = "NSUserInterfaceItemIdentification",
50            feature = "NSWindow",
51            feature = "block2"
52        ))]
53        /// # Safety
54        ///
55        /// `state` possibly has further requirements.
56        #[unsafe(method(restoreWindowWithIdentifier:state:completionHandler:))]
57        #[unsafe(method_family = none)]
58        pub unsafe fn restoreWindowWithIdentifier_state_completionHandler(
59            &self,
60            identifier: &NSUserInterfaceItemIdentifier,
61            state: &NSCoder,
62            completion_handler: &block2::DynBlock<dyn Fn(*mut NSWindow, *mut NSError)>,
63        ) -> bool;
64    );
65}
66
67extern "C" {
68    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsapplicationdidfinishrestoringwindowsnotification?language=objc)
69    pub static NSApplicationDidFinishRestoringWindowsNotification: &'static NSNotificationName;
70}
71
72/// NSUserInterfaceRestoration.
73#[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
74impl NSWindow {
75    extern_methods!(
76        #[unsafe(method(isRestorable))]
77        #[unsafe(method_family = none)]
78        pub fn isRestorable(&self) -> bool;
79
80        /// Setter for [`isRestorable`][Self::isRestorable].
81        #[unsafe(method(setRestorable:))]
82        #[unsafe(method_family = none)]
83        pub fn setRestorable(&self, restorable: bool);
84
85        /// # Safety
86        ///
87        /// This is not retained internally, you must ensure the object is still alive.
88        #[unsafe(method(restorationClass))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn restorationClass(&self) -> Option<&'static AnyClass>;
91
92        /// Setter for [`restorationClass`][Self::restorationClass].
93        ///
94        /// # Safety
95        ///
96        /// - `restoration_class` must implement NSWindowRestoration.
97        /// - This is unretained, you must ensure the object is kept alive while in use.
98        #[unsafe(method(setRestorationClass:))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn setRestorationClass(&self, restoration_class: Option<&AnyClass>);
101
102        #[unsafe(method(disableSnapshotRestoration))]
103        #[unsafe(method_family = none)]
104        pub fn disableSnapshotRestoration(&self);
105
106        #[unsafe(method(enableSnapshotRestoration))]
107        #[unsafe(method_family = none)]
108        pub fn enableSnapshotRestoration(&self);
109    );
110}
111
112/// NSRestorableState.
113#[cfg(feature = "NSResponder")]
114impl NSResponder {
115    extern_methods!(
116        /// # Safety
117        ///
118        /// `coder` possibly has further requirements.
119        #[unsafe(method(encodeRestorableStateWithCoder:))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn encodeRestorableStateWithCoder(&self, coder: &NSCoder);
122
123        /// # Safety
124        ///
125        /// - `coder` possibly has further requirements.
126        /// - `queue` possibly has additional threading requirements.
127        #[unsafe(method(encodeRestorableStateWithCoder:backgroundQueue:))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn encodeRestorableStateWithCoder_backgroundQueue(
130            &self,
131            coder: &NSCoder,
132            queue: &NSOperationQueue,
133        );
134
135        /// # Safety
136        ///
137        /// `coder` possibly has further requirements.
138        #[unsafe(method(restoreStateWithCoder:))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn restoreStateWithCoder(&self, coder: &NSCoder);
141
142        #[unsafe(method(invalidateRestorableState))]
143        #[unsafe(method_family = none)]
144        pub fn invalidateRestorableState(&self);
145
146        #[unsafe(method(restorableStateKeyPaths))]
147        #[unsafe(method_family = none)]
148        pub fn restorableStateKeyPaths(mtm: MainThreadMarker) -> Retained<NSArray<NSString>>;
149
150        /// 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.
151        #[unsafe(method(allowedClassesForRestorableStateKeyPath:))]
152        #[unsafe(method_family = none)]
153        pub fn allowedClassesForRestorableStateKeyPath(
154            key_path: &NSString,
155            mtm: MainThreadMarker,
156        ) -> Retained<NSArray<AnyClass>>;
157    );
158}
159
160/// NSRestorableStateExtension.
161#[cfg(all(feature = "NSApplication", feature = "NSResponder"))]
162impl NSApplication {
163    extern_methods!(
164        #[unsafe(method(extendStateRestoration))]
165        #[unsafe(method_family = none)]
166        pub fn extendStateRestoration(&self);
167
168        #[unsafe(method(completeStateRestoration))]
169        #[unsafe(method_family = none)]
170        pub fn completeStateRestoration(&self);
171    );
172}
173
174/// NSRestorableState.
175#[cfg(feature = "NSDocument")]
176impl NSDocument {
177    extern_methods!(
178        #[cfg(all(
179            feature = "NSResponder",
180            feature = "NSUserInterfaceItemIdentification",
181            feature = "NSWindow",
182            feature = "block2"
183        ))]
184        /// # Safety
185        ///
186        /// `state` possibly has further requirements.
187        #[unsafe(method(restoreDocumentWindowWithIdentifier:state:completionHandler:))]
188        #[unsafe(method_family = none)]
189        pub unsafe fn restoreDocumentWindowWithIdentifier_state_completionHandler(
190            &self,
191            identifier: &NSUserInterfaceItemIdentifier,
192            state: &NSCoder,
193            completion_handler: &block2::DynBlock<dyn Fn(*mut NSWindow, *mut NSError)>,
194        );
195
196        /// # Safety
197        ///
198        /// `coder` possibly has further requirements.
199        #[unsafe(method(encodeRestorableStateWithCoder:))]
200        #[unsafe(method_family = none)]
201        pub unsafe fn encodeRestorableStateWithCoder(&self, coder: &NSCoder);
202
203        /// # Safety
204        ///
205        /// - `coder` possibly has further requirements.
206        /// - `queue` possibly has additional threading requirements.
207        #[unsafe(method(encodeRestorableStateWithCoder:backgroundQueue:))]
208        #[unsafe(method_family = none)]
209        pub unsafe fn encodeRestorableStateWithCoder_backgroundQueue(
210            &self,
211            coder: &NSCoder,
212            queue: &NSOperationQueue,
213        );
214
215        /// # Safety
216        ///
217        /// `coder` possibly has further requirements.
218        #[unsafe(method(restoreStateWithCoder:))]
219        #[unsafe(method_family = none)]
220        pub unsafe fn restoreStateWithCoder(&self, coder: &NSCoder);
221
222        #[unsafe(method(invalidateRestorableState))]
223        #[unsafe(method_family = none)]
224        pub fn invalidateRestorableState(&self);
225
226        #[unsafe(method(restorableStateKeyPaths))]
227        #[unsafe(method_family = none)]
228        pub fn restorableStateKeyPaths(mtm: MainThreadMarker) -> Retained<NSArray<NSString>>;
229
230        #[unsafe(method(allowedClassesForRestorableStateKeyPath:))]
231        #[unsafe(method_family = none)]
232        pub fn allowedClassesForRestorableStateKeyPath(
233            key_path: &NSString,
234            mtm: MainThreadMarker,
235        ) -> Retained<NSArray<AnyClass>>;
236    );
237}