objc2_app_kit/generated/
NSDocumentController.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_class!(
11    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsdocumentcontroller?language=objc)
12    #[unsafe(super(NSObject))]
13    #[thread_kind = MainThreadOnly]
14    #[derive(Debug, PartialEq, Eq, Hash)]
15    pub struct NSDocumentController;
16);
17
18extern_conformance!(
19    unsafe impl NSCoding for NSDocumentController {}
20);
21
22#[cfg(feature = "NSMenu")]
23extern_conformance!(
24    unsafe impl NSMenuItemValidation for NSDocumentController {}
25);
26
27extern_conformance!(
28    unsafe impl NSObjectProtocol for NSDocumentController {}
29);
30
31#[cfg(feature = "NSUserInterfaceValidation")]
32extern_conformance!(
33    unsafe impl NSUserInterfaceValidations for NSDocumentController {}
34);
35
36impl NSDocumentController {
37    extern_methods!(
38        #[unsafe(method(sharedDocumentController))]
39        #[unsafe(method_family = none)]
40        pub fn sharedDocumentController(mtm: MainThreadMarker) -> Retained<NSDocumentController>;
41
42        #[unsafe(method(init))]
43        #[unsafe(method_family = init)]
44        pub fn init(this: Allocated<Self>) -> Retained<Self>;
45
46        /// # Safety
47        ///
48        /// `coder` possibly has further requirements.
49        #[unsafe(method(initWithCoder:))]
50        #[unsafe(method_family = init)]
51        pub unsafe fn initWithCoder(
52            this: Allocated<Self>,
53            coder: &NSCoder,
54        ) -> Option<Retained<Self>>;
55
56        #[cfg(feature = "NSDocument")]
57        #[unsafe(method(documents))]
58        #[unsafe(method_family = none)]
59        pub fn documents(&self) -> Retained<NSArray<NSDocument>>;
60
61        #[cfg(feature = "NSDocument")]
62        #[unsafe(method(currentDocument))]
63        #[unsafe(method_family = none)]
64        pub fn currentDocument(&self) -> Option<Retained<NSDocument>>;
65
66        #[unsafe(method(currentDirectory))]
67        #[unsafe(method_family = none)]
68        pub fn currentDirectory(&self) -> Option<Retained<NSString>>;
69
70        #[cfg(feature = "NSDocument")]
71        #[unsafe(method(documentForURL:))]
72        #[unsafe(method_family = none)]
73        pub fn documentForURL(&self, url: &NSURL) -> Option<Retained<NSDocument>>;
74
75        #[cfg(all(feature = "NSDocument", feature = "NSResponder", feature = "NSWindow"))]
76        #[unsafe(method(documentForWindow:))]
77        #[unsafe(method_family = none)]
78        pub fn documentForWindow(&self, window: &NSWindow) -> Option<Retained<NSDocument>>;
79
80        #[cfg(feature = "NSDocument")]
81        #[unsafe(method(addDocument:))]
82        #[unsafe(method_family = none)]
83        pub fn addDocument(&self, document: &NSDocument);
84
85        #[cfg(feature = "NSDocument")]
86        #[unsafe(method(removeDocument:))]
87        #[unsafe(method_family = none)]
88        pub fn removeDocument(&self, document: &NSDocument);
89
90        /// # Safety
91        ///
92        /// `sender` should be of the correct type.
93        #[unsafe(method(newDocument:))]
94        #[unsafe(method_family = none)]
95        pub unsafe fn newDocument(&self, sender: Option<&AnyObject>);
96
97        #[cfg(feature = "NSDocument")]
98        #[unsafe(method(openUntitledDocumentAndDisplay:error:_))]
99        #[unsafe(method_family = none)]
100        pub fn openUntitledDocumentAndDisplay_error(
101            &self,
102            display_document: bool,
103        ) -> Result<Retained<NSDocument>, Retained<NSError>>;
104
105        #[cfg(feature = "NSDocument")]
106        #[unsafe(method(makeUntitledDocumentOfType:error:_))]
107        #[unsafe(method_family = none)]
108        pub fn makeUntitledDocumentOfType_error(
109            &self,
110            type_name: &NSString,
111        ) -> Result<Retained<NSDocument>, Retained<NSError>>;
112
113        /// # Safety
114        ///
115        /// `sender` should be of the correct type.
116        #[unsafe(method(openDocument:))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn openDocument(&self, sender: Option<&AnyObject>);
119
120        #[unsafe(method(URLsFromRunningOpenPanel))]
121        #[unsafe(method_family = none)]
122        pub fn URLsFromRunningOpenPanel(&self) -> Option<Retained<NSArray<NSURL>>>;
123
124        #[cfg(all(
125            feature = "NSOpenPanel",
126            feature = "NSPanel",
127            feature = "NSResponder",
128            feature = "NSSavePanel",
129            feature = "NSWindow"
130        ))]
131        #[unsafe(method(runModalOpenPanel:forTypes:))]
132        #[unsafe(method_family = none)]
133        pub fn runModalOpenPanel_forTypes(
134            &self,
135            open_panel: &NSOpenPanel,
136            types: Option<&NSArray<NSString>>,
137        ) -> NSInteger;
138
139        #[cfg(feature = "block2")]
140        #[unsafe(method(beginOpenPanelWithCompletionHandler:))]
141        #[unsafe(method_family = none)]
142        pub fn beginOpenPanelWithCompletionHandler(
143            &self,
144            completion_handler: &block2::DynBlock<dyn Fn(*mut NSArray<NSURL>)>,
145        );
146
147        #[cfg(all(
148            feature = "NSOpenPanel",
149            feature = "NSPanel",
150            feature = "NSResponder",
151            feature = "NSSavePanel",
152            feature = "NSWindow",
153            feature = "block2"
154        ))]
155        #[unsafe(method(beginOpenPanel:forTypes:completionHandler:))]
156        #[unsafe(method_family = none)]
157        pub fn beginOpenPanel_forTypes_completionHandler(
158            &self,
159            open_panel: &NSOpenPanel,
160            in_types: Option<&NSArray<NSString>>,
161            completion_handler: &block2::DynBlock<dyn Fn(NSInteger)>,
162        );
163
164        #[cfg(all(feature = "NSDocument", feature = "block2"))]
165        #[unsafe(method(openDocumentWithContentsOfURL:display:completionHandler:))]
166        #[unsafe(method_family = none)]
167        pub fn openDocumentWithContentsOfURL_display_completionHandler(
168            &self,
169            url: &NSURL,
170            display_document: bool,
171            completion_handler: &block2::DynBlock<dyn Fn(*mut NSDocument, Bool, *mut NSError)>,
172        );
173
174        #[cfg(feature = "NSDocument")]
175        #[unsafe(method(makeDocumentWithContentsOfURL:ofType:error:_))]
176        #[unsafe(method_family = none)]
177        pub fn makeDocumentWithContentsOfURL_ofType_error(
178            &self,
179            url: &NSURL,
180            type_name: &NSString,
181        ) -> Result<Retained<NSDocument>, Retained<NSError>>;
182
183        #[cfg(all(feature = "NSDocument", feature = "block2"))]
184        #[unsafe(method(reopenDocumentForURL:withContentsOfURL:display:completionHandler:))]
185        #[unsafe(method_family = none)]
186        pub fn reopenDocumentForURL_withContentsOfURL_display_completionHandler(
187            &self,
188            url_or_nil: Option<&NSURL>,
189            contents_url: &NSURL,
190            display_document: bool,
191            completion_handler: &block2::DynBlock<dyn Fn(*mut NSDocument, Bool, *mut NSError)>,
192        );
193
194        #[cfg(feature = "NSDocument")]
195        #[unsafe(method(makeDocumentForURL:withContentsOfURL:ofType:error:_))]
196        #[unsafe(method_family = none)]
197        pub fn makeDocumentForURL_withContentsOfURL_ofType_error(
198            &self,
199            url_or_nil: Option<&NSURL>,
200            contents_url: &NSURL,
201            type_name: &NSString,
202        ) -> Result<Retained<NSDocument>, Retained<NSError>>;
203
204        #[unsafe(method(autosavingDelay))]
205        #[unsafe(method_family = none)]
206        pub fn autosavingDelay(&self) -> NSTimeInterval;
207
208        /// Setter for [`autosavingDelay`][Self::autosavingDelay].
209        #[unsafe(method(setAutosavingDelay:))]
210        #[unsafe(method_family = none)]
211        pub fn setAutosavingDelay(&self, autosaving_delay: NSTimeInterval);
212
213        /// # Safety
214        ///
215        /// `sender` should be of the correct type.
216        #[unsafe(method(saveAllDocuments:))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn saveAllDocuments(&self, sender: Option<&AnyObject>);
219
220        #[unsafe(method(hasEditedDocuments))]
221        #[unsafe(method_family = none)]
222        pub fn hasEditedDocuments(&self) -> bool;
223
224        /// # Safety
225        ///
226        /// - `delegate` should be of the correct type.
227        /// - `did_review_all_selector` must be a valid selector.
228        /// - `context_info` must be a valid pointer or null.
229        #[unsafe(method(reviewUnsavedDocumentsWithAlertTitle:cancellable:delegate:didReviewAllSelector:contextInfo:))]
230        #[unsafe(method_family = none)]
231        pub unsafe fn reviewUnsavedDocumentsWithAlertTitle_cancellable_delegate_didReviewAllSelector_contextInfo(
232            &self,
233            title: Option<&NSString>,
234            cancellable: bool,
235            delegate: Option<&AnyObject>,
236            did_review_all_selector: Option<Sel>,
237            context_info: *mut c_void,
238        );
239
240        /// # Safety
241        ///
242        /// - `delegate` should be of the correct type.
243        /// - `did_close_all_selector` must be a valid selector.
244        /// - `context_info` must be a valid pointer or null.
245        #[unsafe(method(closeAllDocumentsWithDelegate:didCloseAllSelector:contextInfo:))]
246        #[unsafe(method_family = none)]
247        pub unsafe fn closeAllDocumentsWithDelegate_didCloseAllSelector_contextInfo(
248            &self,
249            delegate: Option<&AnyObject>,
250            did_close_all_selector: Option<Sel>,
251            context_info: *mut c_void,
252        );
253
254        #[cfg(feature = "NSDocument")]
255        #[unsafe(method(duplicateDocumentWithContentsOfURL:copying:displayName:error:_))]
256        #[unsafe(method_family = none)]
257        pub fn duplicateDocumentWithContentsOfURL_copying_displayName_error(
258            &self,
259            url: &NSURL,
260            duplicate_by_copying: bool,
261            display_name_or_nil: Option<&NSString>,
262        ) -> Result<Retained<NSDocument>, Retained<NSError>>;
263
264        #[unsafe(method(allowsAutomaticShareMenu))]
265        #[unsafe(method_family = none)]
266        pub fn allowsAutomaticShareMenu(&self) -> bool;
267
268        #[cfg(feature = "NSMenuItem")]
269        #[unsafe(method(standardShareMenuItem))]
270        #[unsafe(method_family = none)]
271        pub fn standardShareMenuItem(&self) -> Retained<NSMenuItem>;
272
273        #[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
274        /// # Safety
275        ///
276        /// - `delegate` should be of the correct type.
277        /// - `did_present_selector` must be a valid selector.
278        /// - `context_info` must be a valid pointer or null.
279        #[unsafe(method(presentError:modalForWindow:delegate:didPresentSelector:contextInfo:))]
280        #[unsafe(method_family = none)]
281        pub unsafe fn presentError_modalForWindow_delegate_didPresentSelector_contextInfo(
282            &self,
283            error: &NSError,
284            window: &NSWindow,
285            delegate: Option<&AnyObject>,
286            did_present_selector: Option<Sel>,
287            context_info: *mut c_void,
288        );
289
290        #[unsafe(method(presentError:))]
291        #[unsafe(method_family = none)]
292        pub fn presentError(&self, error: &NSError) -> bool;
293
294        #[unsafe(method(willPresentError:))]
295        #[unsafe(method_family = none)]
296        pub fn willPresentError(&self, error: &NSError) -> Retained<NSError>;
297
298        #[unsafe(method(maximumRecentDocumentCount))]
299        #[unsafe(method_family = none)]
300        pub fn maximumRecentDocumentCount(&self) -> NSUInteger;
301
302        /// # Safety
303        ///
304        /// `sender` should be of the correct type.
305        #[unsafe(method(clearRecentDocuments:))]
306        #[unsafe(method_family = none)]
307        pub unsafe fn clearRecentDocuments(&self, sender: Option<&AnyObject>);
308
309        #[cfg(feature = "NSDocument")]
310        #[unsafe(method(noteNewRecentDocument:))]
311        #[unsafe(method_family = none)]
312        pub fn noteNewRecentDocument(&self, document: &NSDocument);
313
314        #[unsafe(method(noteNewRecentDocumentURL:))]
315        #[unsafe(method_family = none)]
316        pub fn noteNewRecentDocumentURL(&self, url: &NSURL);
317
318        #[unsafe(method(recentDocumentURLs))]
319        #[unsafe(method_family = none)]
320        pub fn recentDocumentURLs(&self) -> Retained<NSArray<NSURL>>;
321
322        #[unsafe(method(defaultType))]
323        #[unsafe(method_family = none)]
324        pub fn defaultType(&self) -> Option<Retained<NSString>>;
325
326        #[unsafe(method(typeForContentsOfURL:error:_))]
327        #[unsafe(method_family = none)]
328        pub fn typeForContentsOfURL_error(
329            &self,
330            url: &NSURL,
331        ) -> Result<Retained<NSString>, Retained<NSError>>;
332
333        #[unsafe(method(documentClassNames))]
334        #[unsafe(method_family = none)]
335        pub fn documentClassNames(&self) -> Retained<NSArray<NSString>>;
336
337        #[unsafe(method(documentClassForType:))]
338        #[unsafe(method_family = none)]
339        pub fn documentClassForType(&self, type_name: &NSString) -> Option<&'static AnyClass>;
340
341        #[unsafe(method(displayNameForType:))]
342        #[unsafe(method_family = none)]
343        pub fn displayNameForType(&self, type_name: &NSString) -> Option<Retained<NSString>>;
344
345        #[cfg(feature = "NSUserInterfaceValidation")]
346        #[unsafe(method(validateUserInterfaceItem:))]
347        #[unsafe(method_family = none)]
348        pub fn validateUserInterfaceItem(
349            &self,
350            item: &ProtocolObject<dyn NSValidatedUserInterfaceItem>,
351        ) -> bool;
352    );
353}
354
355/// Methods declared on superclass `NSObject`.
356impl NSDocumentController {
357    extern_methods!(
358        #[unsafe(method(new))]
359        #[unsafe(method_family = new)]
360        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
361    );
362}
363
364/// NSDeprecated.
365impl NSDocumentController {
366    extern_methods!(
367        #[deprecated = "Use -openDocumentWithContentsOfURL:display:completionHandler: instead"]
368        #[unsafe(method(openDocumentWithContentsOfURL:display:error:_))]
369        #[unsafe(method_family = none)]
370        pub fn openDocumentWithContentsOfURL_display_error(
371            &self,
372            url: &NSURL,
373            display_document: bool,
374        ) -> Result<Retained<AnyObject>, Retained<NSError>>;
375
376        #[deprecated = "Use -reopenDocumentForURL:withContentsOfURL:display:completionHandler: instead"]
377        #[unsafe(method(reopenDocumentForURL:withContentsOfURL:error:_))]
378        #[unsafe(method_family = none)]
379        pub fn reopenDocumentForURL_withContentsOfURL_error(
380            &self,
381            url: Option<&NSURL>,
382            contents_url: &NSURL,
383        ) -> Result<(), Retained<NSError>>;
384
385        #[deprecated]
386        #[unsafe(method(fileExtensionsFromType:))]
387        #[unsafe(method_family = none)]
388        pub fn fileExtensionsFromType(&self, type_name: &NSString) -> Option<Retained<NSArray>>;
389
390        #[deprecated]
391        #[unsafe(method(typeFromFileExtension:))]
392        #[unsafe(method_family = none)]
393        pub fn typeFromFileExtension(
394            &self,
395            file_name_extension_or_hfs_file_type: &NSString,
396        ) -> Option<Retained<NSString>>;
397
398        #[deprecated]
399        #[unsafe(method(documentForFileName:))]
400        #[unsafe(method_family = none)]
401        pub fn documentForFileName(&self, file_name: &NSString) -> Option<Retained<AnyObject>>;
402
403        #[deprecated]
404        #[unsafe(method(fileNamesFromRunningOpenPanel))]
405        #[unsafe(method_family = none)]
406        pub fn fileNamesFromRunningOpenPanel(&self) -> Option<Retained<NSArray>>;
407
408        #[deprecated]
409        #[unsafe(method(makeDocumentWithContentsOfFile:ofType:))]
410        #[unsafe(method_family = none)]
411        pub fn makeDocumentWithContentsOfFile_ofType(
412            &self,
413            file_name: &NSString,
414            r#type: &NSString,
415        ) -> Option<Retained<AnyObject>>;
416
417        /// # Safety
418        ///
419        /// `type` might not allow `None`.
420        #[deprecated]
421        #[unsafe(method(makeDocumentWithContentsOfURL:ofType:))]
422        #[unsafe(method_family = none)]
423        pub unsafe fn makeDocumentWithContentsOfURL_ofType(
424            &self,
425            url: &NSURL,
426            r#type: Option<&NSString>,
427        ) -> Option<Retained<AnyObject>>;
428
429        #[deprecated]
430        #[unsafe(method(makeUntitledDocumentOfType:))]
431        #[unsafe(method_family = none)]
432        pub fn makeUntitledDocumentOfType(&self, r#type: &NSString) -> Option<Retained<AnyObject>>;
433
434        #[deprecated]
435        #[unsafe(method(openDocumentWithContentsOfFile:display:))]
436        #[unsafe(method_family = none)]
437        pub fn openDocumentWithContentsOfFile_display(
438            &self,
439            file_name: &NSString,
440            display: bool,
441        ) -> Option<Retained<AnyObject>>;
442
443        #[deprecated]
444        #[unsafe(method(openDocumentWithContentsOfURL:display:))]
445        #[unsafe(method_family = none)]
446        pub fn openDocumentWithContentsOfURL_display(
447            &self,
448            url: &NSURL,
449            display: bool,
450        ) -> Option<Retained<AnyObject>>;
451
452        #[deprecated]
453        #[unsafe(method(openUntitledDocumentOfType:display:))]
454        #[unsafe(method_family = none)]
455        pub fn openUntitledDocumentOfType_display(
456            &self,
457            r#type: &NSString,
458            display: bool,
459        ) -> Option<Retained<AnyObject>>;
460
461        #[deprecated]
462        #[unsafe(method(setShouldCreateUI:))]
463        #[unsafe(method_family = none)]
464        pub fn setShouldCreateUI(&self, flag: bool);
465
466        #[deprecated]
467        #[unsafe(method(shouldCreateUI))]
468        #[unsafe(method_family = none)]
469        pub fn shouldCreateUI(&self) -> bool;
470    );
471}