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        /// This is a [weak property][objc2::topics::weak_property].
66        /// Setter for [`delegate`][Self::delegate].
67        #[unsafe(method(setDelegate:))]
68        #[unsafe(method_family = none)]
69        pub unsafe fn setDelegate(
70            &self,
71            delegate: Option<&ProtocolObject<dyn EXHostViewControllerDelegate>>,
72        );
73
74        /// A view that’s used when the view controller has no content to display.
75        #[unsafe(method(placeholderView))]
76        #[unsafe(method_family = none)]
77        pub unsafe fn placeholderView(&self) -> Retained<NSView>;
78
79        /// Setter for [`placeholderView`][Self::placeholderView].
80        #[unsafe(method(setPlaceholderView:))]
81        #[unsafe(method_family = none)]
82        pub unsafe fn setPlaceholderView(&self, placeholder_view: &NSView);
83
84        /// Attempts to connect to the extension over XPC.
85        ///
86        /// - Returns: An object representing the connection.
87        #[unsafe(method(makeXPCConnectionWithError:_))]
88        #[unsafe(method_family = none)]
89        pub unsafe fn makeXPCConnectionWithError(
90            &self,
91        ) -> Result<Retained<NSXPCConnection>, Retained<NSError>>;
92    );
93}
94
95/// Methods declared on superclass `NSViewController`.
96#[cfg(feature = "objc2-app-kit")]
97#[cfg(target_os = "macos")]
98impl EXHostViewController {
99    extern_methods!(
100        #[unsafe(method(initWithNibName:bundle:))]
101        #[unsafe(method_family = init)]
102        pub unsafe fn initWithNibName_bundle(
103            this: Allocated<Self>,
104            nib_name_or_nil: Option<&NSNibName>,
105            nib_bundle_or_nil: Option<&NSBundle>,
106        ) -> Retained<Self>;
107
108        #[unsafe(method(initWithCoder:))]
109        #[unsafe(method_family = init)]
110        pub unsafe fn initWithCoder(
111            this: Allocated<Self>,
112            coder: &NSCoder,
113        ) -> Option<Retained<Self>>;
114    );
115}
116
117/// Methods declared on superclass `NSResponder`.
118#[cfg(feature = "objc2-app-kit")]
119#[cfg(target_os = "macos")]
120impl EXHostViewController {
121    extern_methods!(
122        #[unsafe(method(init))]
123        #[unsafe(method_family = init)]
124        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
125    );
126}
127
128/// Methods declared on superclass `NSObject`.
129#[cfg(feature = "objc2-app-kit")]
130#[cfg(target_os = "macos")]
131impl EXHostViewController {
132    extern_methods!(
133        #[unsafe(method(new))]
134        #[unsafe(method_family = new)]
135        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
136    );
137}
138
139extern_protocol!(
140    /// The delegate for a hosted view controller.
141    ///
142    /// See also [Apple's documentation](https://developer.apple.com/documentation/extensionkit/exhostviewcontrollerdelegate?language=objc)
143    pub unsafe trait EXHostViewControllerDelegate:
144        NSObjectProtocol + MainThreadOnly
145    {
146        #[cfg(feature = "objc2-app-kit")]
147        #[cfg(target_os = "macos")]
148        /// A delegate method the view controller calls when a connection succeeds.
149        ///
150        /// This delegate method gets called when the extension process has launched and
151        /// the remote scene connects. After this delegate method gets called the host
152        /// view controller can establish an XPC connection with the scene in the
153        /// extension process.
154        ///
155        /// - Parameters:
156        /// - viewController: The user interface object from the remote process.
157        #[optional]
158        #[unsafe(method(hostViewControllerDidActivate:))]
159        #[unsafe(method_family = none)]
160        unsafe fn hostViewControllerDidActivate(&self, view_controller: &EXHostViewController);
161
162        #[cfg(feature = "objc2-app-kit")]
163        #[cfg(target_os = "macos")]
164        /// A delegate method the host view controller calls when an extension
165        /// disconnects.
166        ///
167        /// Called when the host view controller stops hosting the remote user
168        /// interface. This can occur when the extension exits or when the view
169        /// controller’s configuration property changes.
170        ///
171        /// - Parameters:
172        /// - viewController: The view controller for the extension that’s disconnecting
173        ///
174        /// - error: An error object containing information about why the object
175        /// disconnected, or `nil` if it’s disconnecting without error.
176        #[optional]
177        #[unsafe(method(hostViewControllerWillDeactivate:error:))]
178        #[unsafe(method_family = none)]
179        unsafe fn hostViewControllerWillDeactivate_error(
180            &self,
181            view_controller: &EXHostViewController,
182            error: Option<&NSError>,
183        );
184    }
185);