objc2_web_kit/generated/
WKWebExtensionAction.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::*;
9#[cfg(feature = "objc2-core-foundation")]
10use objc2_core_foundation::*;
11use objc2_foundation::*;
12
13use crate::*;
14
15extern_class!(
16    /// A ``WKWebExtensionAction`` object encapsulates the properties for an individual web extension action.
17    ///
18    /// Provides access to action properties such as popup, icon, and title, with tab-specific values.
19    ///
20    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensionaction?language=objc)
21    #[unsafe(super(NSObject))]
22    #[thread_kind = MainThreadOnly]
23    #[derive(Debug, PartialEq, Eq, Hash)]
24    pub struct WKWebExtensionAction;
25);
26
27extern_conformance!(
28    unsafe impl NSObjectProtocol for WKWebExtensionAction {}
29);
30
31impl WKWebExtensionAction {
32    extern_methods!(
33        #[unsafe(method(init))]
34        #[unsafe(method_family = init)]
35        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
36
37        #[unsafe(method(new))]
38        #[unsafe(method_family = new)]
39        pub unsafe fn new(&self) -> Retained<Self>;
40
41        #[cfg(feature = "WKWebExtensionContext")]
42        /// The extension context to which this action is related.
43        #[unsafe(method(webExtensionContext))]
44        #[unsafe(method_family = none)]
45        pub unsafe fn webExtensionContext(&self) -> Option<Retained<WKWebExtensionContext>>;
46
47        #[cfg(feature = "WKWebExtensionTab")]
48        /// The tab that this action is associated with, or `nil` if it is the default action.
49        ///
50        /// When this property is `nil`, it indicates that the action is the default action and not associated with a specific tab.
51        #[unsafe(method(associatedTab))]
52        #[unsafe(method_family = none)]
53        pub unsafe fn associatedTab(
54            &self,
55        ) -> Option<Retained<ProtocolObject<dyn WKWebExtensionTab>>>;
56
57        #[cfg(all(feature = "objc2-app-kit", feature = "objc2-core-foundation"))]
58        #[cfg(target_os = "macos")]
59        #[unsafe(method(iconForSize:))]
60        #[unsafe(method_family = none)]
61        pub unsafe fn iconForSize(&self, size: CGSize) -> Option<Retained<NSImage>>;
62
63        /// The localized display label for the action.
64        #[unsafe(method(label))]
65        #[unsafe(method_family = none)]
66        pub unsafe fn label(&self) -> Retained<NSString>;
67
68        /// The badge text for the action.
69        ///
70        /// Provides the text that appears on the badge for the action. An empty string signifies that no badge should be shown.
71        #[unsafe(method(badgeText))]
72        #[unsafe(method_family = none)]
73        pub unsafe fn badgeText(&self) -> Retained<NSString>;
74
75        /// A Boolean value indicating whether the badge text is unread.
76        ///
77        /// This property is automatically set to `YES` when ``badgeText`` changes and is not empty. If ``badgeText`` becomes empty or the
78        /// popup associated with the action is presented, this property is automatically set to `NO`. Additionally, it should be set to `NO` by the app when the badge
79        /// has been presented to the user. This property is useful for higher-level notification badges when extensions might be hidden behind an action sheet.
80        #[unsafe(method(hasUnreadBadgeText))]
81        #[unsafe(method_family = none)]
82        pub unsafe fn hasUnreadBadgeText(&self) -> bool;
83
84        /// Setter for [`hasUnreadBadgeText`][Self::hasUnreadBadgeText].
85        #[unsafe(method(setHasUnreadBadgeText:))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn setHasUnreadBadgeText(&self, has_unread_badge_text: bool);
88
89        /// The name shown when inspecting the popup web view.
90        ///
91        /// This is the text that will appear when inspecting the popup web view.
92        #[unsafe(method(inspectionName))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn inspectionName(&self) -> Option<Retained<NSString>>;
95
96        /// Setter for [`inspectionName`][Self::inspectionName].
97        ///
98        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
99        #[unsafe(method(setInspectionName:))]
100        #[unsafe(method_family = none)]
101        pub unsafe fn setInspectionName(&self, inspection_name: Option<&NSString>);
102
103        /// A Boolean value indicating whether the action is enabled.
104        #[unsafe(method(isEnabled))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn isEnabled(&self) -> bool;
107
108        #[cfg(feature = "objc2-app-kit")]
109        #[cfg(target_os = "macos")]
110        #[unsafe(method(menuItems))]
111        #[unsafe(method_family = none)]
112        pub unsafe fn menuItems(&self) -> Retained<NSArray<NSMenuItem>>;
113
114        /// A Boolean value indicating whether the action has a popup.
115        ///
116        /// Use this property to check if the action has a popup before attempting to show any popup views.
117        #[unsafe(method(presentsPopup))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn presentsPopup(&self) -> bool;
120
121        #[cfg(feature = "objc2-app-kit")]
122        #[cfg(target_os = "macos")]
123        /// A popover that presents a web view loaded with the popup page for this action, or `nil` if no popup is specified.
124        ///
125        /// This popover contains a view controller with a web view preloaded with the popup page. It automatically adjusts its size to fit
126        /// the web view's content size. The ``presentsPopup`` property should be checked to determine the availability of a popup before using this
127        /// property.  Dismissing the popover will close the popup and unload the web view.
128        ///
129        /// See also: presentsPopup
130        #[unsafe(method(popupPopover))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn popupPopover(&self) -> Option<Retained<NSPopover>>;
133
134        #[cfg(all(feature = "WKWebView", feature = "objc2-app-kit"))]
135        #[cfg(target_os = "macos")]
136        /// A web view loaded with the popup page for this action, or `nil` if no popup is specified.
137        ///
138        /// The web view will be preloaded with the popup page upon first access or after it has been unloaded. Use the ``presentsPopup``
139        /// property to determine whether a popup should be displayed before using this property.
140        ///
141        /// See also: presentsPopup
142        #[unsafe(method(popupWebView))]
143        #[unsafe(method_family = none)]
144        pub unsafe fn popupWebView(&self) -> Option<Retained<WKWebView>>;
145
146        /// Triggers the dismissal process of the popup.
147        ///
148        /// Invoke this method to manage the popup's lifecycle, ensuring the web view is unloaded and resources are released once the
149        /// popup closes. This method is automatically called upon the dismissal of the action's ``UIViewController`` or ``NSPopover``.  For custom
150        /// scenarios where the popup's lifecycle is manually managed, it must be explicitly invoked to ensure proper closure.
151        #[unsafe(method(closePopup))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn closePopup(&self);
154    );
155}
156
157/// Methods declared on superclass `NSObject`.
158impl WKWebExtensionAction {
159    extern_methods!(
160        #[unsafe(method(new))]
161        #[unsafe(method_family = new)]
162        pub unsafe fn new_class(mtm: MainThreadMarker) -> Retained<Self>;
163    );
164}