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 #[unsafe(method(setInspectionName:))]
98 #[unsafe(method_family = none)]
99 pub unsafe fn setInspectionName(&self, inspection_name: Option<&NSString>);
100
101 /// A Boolean value indicating whether the action is enabled.
102 #[unsafe(method(isEnabled))]
103 #[unsafe(method_family = none)]
104 pub unsafe fn isEnabled(&self) -> bool;
105
106 #[cfg(feature = "objc2-app-kit")]
107 #[cfg(target_os = "macos")]
108 #[unsafe(method(menuItems))]
109 #[unsafe(method_family = none)]
110 pub unsafe fn menuItems(&self) -> Retained<NSArray<NSMenuItem>>;
111
112 /// A Boolean value indicating whether the action has a popup.
113 ///
114 /// Use this property to check if the action has a popup before attempting to show any popup views.
115 #[unsafe(method(presentsPopup))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn presentsPopup(&self) -> bool;
118
119 #[cfg(feature = "objc2-app-kit")]
120 #[cfg(target_os = "macos")]
121 /// A popover that presents a web view loaded with the popup page for this action, or `nil` if no popup is specified.
122 ///
123 /// This popover contains a view controller with a web view preloaded with the popup page. It automatically adjusts its size to fit
124 /// the web view's content size. The ``presentsPopup`` property should be checked to determine the availability of a popup before using this
125 /// property. Dismissing the popover will close the popup and unload the web view.
126 ///
127 /// See also: presentsPopup
128 #[unsafe(method(popupPopover))]
129 #[unsafe(method_family = none)]
130 pub unsafe fn popupPopover(&self) -> Option<Retained<NSPopover>>;
131
132 #[cfg(all(feature = "WKWebView", feature = "objc2-app-kit"))]
133 #[cfg(target_os = "macos")]
134 /// A web view loaded with the popup page for this action, or `nil` if no popup is specified.
135 ///
136 /// The web view will be preloaded with the popup page upon first access or after it has been unloaded. Use the ``presentsPopup``
137 /// property to determine whether a popup should be displayed before using this property.
138 ///
139 /// See also: presentsPopup
140 #[unsafe(method(popupWebView))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn popupWebView(&self) -> Option<Retained<WKWebView>>;
143
144 /// Triggers the dismissal process of the popup.
145 ///
146 /// Invoke this method to manage the popup's lifecycle, ensuring the web view is unloaded and resources are released once the
147 /// popup closes. This method is automatically called upon the dismissal of the action's ``UIViewController`` or ``NSPopover``. For custom
148 /// scenarios where the popup's lifecycle is manually managed, it must be explicitly invoked to ensure proper closure.
149 #[unsafe(method(closePopup))]
150 #[unsafe(method_family = none)]
151 pub unsafe fn closePopup(&self);
152 );
153}
154
155/// Methods declared on superclass `NSObject`.
156impl WKWebExtensionAction {
157 extern_methods!(
158 #[unsafe(method(new))]
159 #[unsafe(method_family = new)]
160 pub unsafe fn new_class(mtm: MainThreadMarker) -> Retained<Self>;
161 );
162}