objc2_collaboration/generated/CBIdentityPicker.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")]
7use objc2_app_kit::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12extern_class!(
13 /// A `CBIdentityPicker` object allows a user to select identities—for
14 /// example, user or group objects—that it wants one or more services or
15 /// shared resources to have access to. An identity picker can be displayed
16 /// either as an application-modal dialog or as a sheet attached to a
17 /// document window. An identity picker returns the selected records to be
18 /// added to access control lists using Collaboration. If a selected record
19 /// is not a user or group identity, then an identity picker prompts the
20 /// user for additional information—such as a password—to promote that
21 /// record to a sharing account.
22 ///
23 /// See also [Apple's documentation](https://developer.apple.com/documentation/collaboration/cbidentitypicker?language=objc)
24 #[unsafe(super(NSObject))]
25 #[derive(Debug, PartialEq, Eq, Hash)]
26 pub struct CBIdentityPicker;
27);
28
29extern_conformance!(
30 unsafe impl NSObjectProtocol for CBIdentityPicker {}
31);
32
33impl CBIdentityPicker {
34 extern_methods!(
35 /// The title of the identity picker.
36 ///
37 /// The value of this property is the title text that appears at the top of the
38 /// panel. By default, the title is "Select a person to share with:".
39 #[unsafe(method(title))]
40 #[unsafe(method_family = none)]
41 pub unsafe fn title(&self) -> Option<Retained<NSString>>;
42
43 /// Setter for [`title`][Self::title].
44 ///
45 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
46 #[unsafe(method(setTitle:))]
47 #[unsafe(method_family = none)]
48 pub unsafe fn setTitle(&self, title: Option<&NSString>);
49
50 /// A Boolean value indicating whether the user is allowed to select multiple
51 /// identities.
52 ///
53 /// The value of this property is
54 /// <doc
55 /// ://com.apple.documentation/documentation/objectivec/yes> if the user can
56 /// select multiple records; otherwise,
57 /// <doc
58 /// ://com.apple.documentation/documentation/objectivec/no>. The default
59 /// value is
60 /// <doc
61 /// ://com.apple.documentation/documentation/objectivec/no>.
62 #[unsafe(method(allowsMultipleSelection))]
63 #[unsafe(method_family = none)]
64 pub unsafe fn allowsMultipleSelection(&self) -> bool;
65
66 /// Setter for [`allowsMultipleSelection`][Self::allowsMultipleSelection].
67 #[unsafe(method(setAllowsMultipleSelection:))]
68 #[unsafe(method_family = none)]
69 pub unsafe fn setAllowsMultipleSelection(&self, allows_multiple_selection: bool);
70
71 /// Runs the receiver as an application-modal dialog.
72 ///
73 /// The receiver may create identities for selected records if necessary.
74 ///
75 /// - Returns: `NSOKButton` if the user selected OK; otherwise,
76 /// `NSCancelButton`.
77 #[unsafe(method(runModal))]
78 #[unsafe(method_family = none)]
79 pub unsafe fn runModal(&self) -> NSInteger;
80
81 #[cfg(feature = "objc2-app-kit")]
82 /// Runs the receiver modally as a sheet attached to a specified window.
83 ///
84 /// The `didEndSelector` parameter is a selector that takes three arguments. The
85 /// corresponding method should have a declaration modeled on the following
86 /// example:
87 ///
88 /// ```swift
89 /// - (void)identityPickerDidEnd:(CBIdentityPicker *)identityPicker returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
90 /// ```
91 ///
92 /// where the `identityPicker` argument is the identity picker object, the
93 /// `returnCode` argument is the button the user clicked, and `contextInfo` is
94 /// the same `contextInfo` argument that was passed in the original message.
95 ///
96 /// - Parameters:
97 /// - window: The parent window for the sheet.
98 ///
99 /// - delegate: The delegate for the modal session.
100 ///
101 /// - didEndSelector: A message sent to the delegate after the user responds but
102 /// before the sheet is dismissed.
103 ///
104 /// - contextInfo: Contextual data passed to the delegate in the
105 /// `didEndSelector` message.
106 ///
107 /// # Safety
108 ///
109 /// - `delegate` should be of the correct type.
110 /// - `did_end_selector` must be a valid selector.
111 /// - `context_info` must be a valid pointer or null.
112 #[deprecated = "Use runModalForWindow:completionHandler: instead."]
113 #[unsafe(method(runModalForWindow:modalDelegate:didEndSelector:contextInfo:))]
114 #[unsafe(method_family = none)]
115 pub unsafe fn runModalForWindow_modalDelegate_didEndSelector_contextInfo(
116 &self,
117 window: &NSWindow,
118 delegate: Option<&AnyObject>,
119 did_end_selector: Option<Sel>,
120 context_info: *mut c_void,
121 );
122
123 #[cfg(all(feature = "block2", feature = "objc2-app-kit"))]
124 /// Runs the identity picker modally as a sheet attached to a specified window.
125 ///
126 /// - Parameters:
127 /// - window: The parent window for the sheet.
128 ///
129 /// - completionHandler: The handler to run after the return value is known, but
130 /// before the sheet is dismissed.
131 #[unsafe(method(runModalForWindow:completionHandler:))]
132 #[unsafe(method_family = none)]
133 pub unsafe fn runModalForWindow_completionHandler(
134 &self,
135 window: &NSWindow,
136 completion_handler: Option<&block2::DynBlock<dyn Fn(NSModalResponse)>>,
137 );
138
139 #[cfg(feature = "CBIdentity")]
140 /// The array of identities (represented by `CBIdentity` objects) selected using
141 /// the identity picker.
142 #[unsafe(method(identities))]
143 #[unsafe(method_family = none)]
144 pub unsafe fn identities(&self) -> Retained<NSArray<CBIdentity>>;
145 );
146}
147
148/// Methods declared on superclass `NSObject`.
149impl CBIdentityPicker {
150 extern_methods!(
151 #[unsafe(method(init))]
152 #[unsafe(method_family = init)]
153 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
154
155 #[unsafe(method(new))]
156 #[unsafe(method_family = new)]
157 pub unsafe fn new() -> Retained<Self>;
158 );
159}