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