objc2_extension_kit/generated/
EXHostViewController.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::*;
6#[cfg(feature = "objc2-app-kit")]
7#[cfg(target_os = "macos")]
8use objc2_app_kit::*;
9use objc2_foundation::*;
10
11use crate::*;
12
13extern_class!(
14    /// A view controller that hosts remote views provided by an extension.
15    ///
16    /// See also [Apple's documentation](https://developer.apple.com/documentation/extensionkit/exhostviewcontroller?language=objc)
17    #[unsafe(super(NSViewController, NSResponder, NSObject))]
18    #[derive(Debug, PartialEq, Eq, Hash)]
19    #[cfg(feature = "objc2-app-kit")]
20    #[cfg(target_os = "macos")]
21    pub struct EXHostViewController;
22);
23
24#[cfg(feature = "objc2-app-kit")]
25#[cfg(target_os = "macos")]
26extern_conformance!(
27    unsafe impl NSCoding for EXHostViewController {}
28);
29
30#[cfg(feature = "objc2-app-kit")]
31#[cfg(target_os = "macos")]
32extern_conformance!(
33    unsafe impl NSEditor for EXHostViewController {}
34);
35
36#[cfg(feature = "objc2-app-kit")]
37#[cfg(target_os = "macos")]
38extern_conformance!(
39    unsafe impl NSObjectProtocol for EXHostViewController {}
40);
41
42#[cfg(feature = "objc2-app-kit")]
43#[cfg(target_os = "macos")]
44extern_conformance!(
45    unsafe impl NSSeguePerforming for EXHostViewController {}
46);
47
48#[cfg(feature = "objc2-app-kit")]
49#[cfg(target_os = "macos")]
50extern_conformance!(
51    unsafe impl NSUserInterfaceItemIdentification for EXHostViewController {}
52);
53
54#[cfg(feature = "objc2-app-kit")]
55#[cfg(target_os = "macos")]
56impl EXHostViewController {
57    extern_methods!(
58        /// The connection delegate.
59        #[unsafe(method(delegate))]
60        #[unsafe(method_family = none)]
61        pub unsafe fn delegate(
62            &self,
63        ) -> Option<Retained<ProtocolObject<dyn EXHostViewControllerDelegate>>>;
64
65        /// Setter for [`delegate`][Self::delegate].
66        ///
67        /// This is a [weak property][objc2::topics::weak_property].
68        #[unsafe(method(setDelegate:))]
69        #[unsafe(method_family = none)]
70        pub unsafe fn setDelegate(
71            &self,
72            delegate: Option<&ProtocolObject<dyn EXHostViewControllerDelegate>>,
73        );
74
75        /// A view that’s used when the view controller has no content to display.
76        #[unsafe(method(placeholderView))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn placeholderView(&self) -> Retained<NSView>;
79
80        /// Setter for [`placeholderView`][Self::placeholderView].
81        #[unsafe(method(setPlaceholderView:))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn setPlaceholderView(&self, placeholder_view: &NSView);
84
85        /// Attempts to connect to the extension over XPC.
86        ///
87        /// - Returns: An object representing the connection.
88        #[unsafe(method(makeXPCConnectionWithError:_))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn makeXPCConnectionWithError(
91            &self,
92        ) -> Result<Retained<NSXPCConnection>, Retained<NSError>>;
93    );
94}
95
96/// Methods declared on superclass `NSViewController`.
97#[cfg(feature = "objc2-app-kit")]
98#[cfg(target_os = "macos")]
99impl EXHostViewController {
100    extern_methods!(
101        #[unsafe(method(initWithNibName:bundle:))]
102        #[unsafe(method_family = init)]
103        pub unsafe fn initWithNibName_bundle(
104            this: Allocated<Self>,
105            nib_name_or_nil: Option<&NSNibName>,
106            nib_bundle_or_nil: Option<&NSBundle>,
107        ) -> Retained<Self>;
108
109        /// # Safety
110        ///
111        /// `coder` possibly has further requirements.
112        #[unsafe(method(initWithCoder:))]
113        #[unsafe(method_family = init)]
114        pub unsafe fn initWithCoder(
115            this: Allocated<Self>,
116            coder: &NSCoder,
117        ) -> Option<Retained<Self>>;
118    );
119}
120
121/// Methods declared on superclass `NSResponder`.
122#[cfg(feature = "objc2-app-kit")]
123#[cfg(target_os = "macos")]
124impl EXHostViewController {
125    extern_methods!(
126        #[unsafe(method(init))]
127        #[unsafe(method_family = init)]
128        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
129    );
130}
131
132/// Methods declared on superclass `NSObject`.
133#[cfg(feature = "objc2-app-kit")]
134#[cfg(target_os = "macos")]
135impl EXHostViewController {
136    extern_methods!(
137        #[unsafe(method(new))]
138        #[unsafe(method_family = new)]
139        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
140    );
141}
142
143extern_protocol!(
144    /// The delegate for a hosted view controller.
145    ///
146    /// See also [Apple's documentation](https://developer.apple.com/documentation/extensionkit/exhostviewcontrollerdelegate?language=objc)
147    pub unsafe trait EXHostViewControllerDelegate:
148        NSObjectProtocol + MainThreadOnly
149    {
150        #[cfg(feature = "objc2-app-kit")]
151        #[cfg(target_os = "macos")]
152        /// A delegate method the view controller calls when a connection succeeds.
153        ///
154        /// This delegate method gets called when the extension process has launched and
155        /// the remote scene connects. After this delegate method gets called the host
156        /// view controller can establish an XPC connection with the scene in the
157        /// extension process.
158        ///
159        /// - Parameters:
160        /// - viewController: The user interface object from the remote process.
161        #[optional]
162        #[unsafe(method(hostViewControllerDidActivate:))]
163        #[unsafe(method_family = none)]
164        unsafe fn hostViewControllerDidActivate(&self, view_controller: &EXHostViewController);
165
166        #[cfg(feature = "objc2-app-kit")]
167        #[cfg(target_os = "macos")]
168        /// A delegate method the host view controller calls when an extension
169        /// disconnects.
170        ///
171        /// Called when the host view controller stops hosting the remote user
172        /// interface. This can occur when the extension exits or when the view
173        /// controller’s configuration property changes.
174        ///
175        /// - Parameters:
176        /// - viewController: The view controller for the extension that’s disconnecting
177        ///
178        /// - error: An error object containing information about why the object
179        /// disconnected, or `nil` if it’s disconnecting without error.
180        #[optional]
181        #[unsafe(method(hostViewControllerWillDeactivate:error:))]
182        #[unsafe(method_family = none)]
183        unsafe fn hostViewControllerWillDeactivate_error(
184            &self,
185            view_controller: &EXHostViewController,
186            error: Option<&NSError>,
187        );
188    }
189);