1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7#[cfg(feature = "objc2-uniform-type-identifiers")]
8#[cfg(target_vendor = "apple")]
9use objc2_uniform_type_identifiers::*;
10
11use crate::*;
12
13#[repr(transparent)]
16#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
17pub struct NSWorkspaceIconCreationOptions(pub NSUInteger);
18bitflags::bitflags! {
19 impl NSWorkspaceIconCreationOptions: NSUInteger {
20 #[doc(alias = "NSExcludeQuickDrawElementsIconCreationOption")]
21 const ExcludeQuickDrawElementsIconCreationOption = 1<<1;
22 #[doc(alias = "NSExclude10_4ElementsIconCreationOption")]
23 const Exclude10_4ElementsIconCreationOption = 1<<2;
24 }
25}
26
27unsafe impl Encode for NSWorkspaceIconCreationOptions {
28 const ENCODING: Encoding = NSUInteger::ENCODING;
29}
30
31unsafe impl RefEncode for NSWorkspaceIconCreationOptions {
32 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
33}
34
35extern_class!(
36 #[unsafe(super(NSObject))]
38 #[derive(Debug, PartialEq, Eq, Hash)]
39 pub struct NSWorkspace;
40);
41
42extern_conformance!(
43 unsafe impl NSObjectProtocol for NSWorkspace {}
44);
45
46impl NSWorkspace {
47 extern_methods!(
48 #[unsafe(method(sharedWorkspace))]
49 #[unsafe(method_family = none)]
50 pub fn sharedWorkspace() -> Retained<NSWorkspace>;
51
52 #[unsafe(method(notificationCenter))]
53 #[unsafe(method_family = none)]
54 pub fn notificationCenter(&self) -> Retained<NSNotificationCenter>;
55
56 #[unsafe(method(openURL:))]
57 #[unsafe(method_family = none)]
58 pub fn openURL(&self, url: &NSURL) -> bool;
59
60 #[cfg(all(feature = "NSRunningApplication", feature = "block2"))]
61 #[unsafe(method(openURL:configuration:completionHandler:))]
62 #[unsafe(method_family = none)]
63 pub fn openURL_configuration_completionHandler(
64 &self,
65 url: &NSURL,
66 configuration: &NSWorkspaceOpenConfiguration,
67 completion_handler: Option<
68 &block2::DynBlock<dyn Fn(*mut NSRunningApplication, *mut NSError)>,
69 >,
70 );
71
72 #[cfg(all(feature = "NSRunningApplication", feature = "block2"))]
73 #[unsafe(method(openURLs:withApplicationAtURL:configuration:completionHandler:))]
74 #[unsafe(method_family = none)]
75 pub fn openURLs_withApplicationAtURL_configuration_completionHandler(
76 &self,
77 urls: &NSArray<NSURL>,
78 application_url: &NSURL,
79 configuration: &NSWorkspaceOpenConfiguration,
80 completion_handler: Option<
81 &block2::DynBlock<dyn Fn(*mut NSRunningApplication, *mut NSError)>,
82 >,
83 );
84
85 #[cfg(all(feature = "NSRunningApplication", feature = "block2"))]
86 #[unsafe(method(openApplicationAtURL:configuration:completionHandler:))]
87 #[unsafe(method_family = none)]
88 pub fn openApplicationAtURL_configuration_completionHandler(
89 &self,
90 application_url: &NSURL,
91 configuration: &NSWorkspaceOpenConfiguration,
92 completion_handler: Option<
93 &block2::DynBlock<dyn Fn(*mut NSRunningApplication, *mut NSError)>,
94 >,
95 );
96
97 #[unsafe(method(selectFile:inFileViewerRootedAtPath:))]
98 #[unsafe(method_family = none)]
99 pub fn selectFile_inFileViewerRootedAtPath(
100 &self,
101 full_path: Option<&NSString>,
102 root_full_path: &NSString,
103 ) -> bool;
104
105 #[unsafe(method(activateFileViewerSelectingURLs:))]
106 #[unsafe(method_family = none)]
107 pub fn activateFileViewerSelectingURLs(&self, file_ur_ls: &NSArray<NSURL>);
108
109 #[unsafe(method(showSearchResultsForQueryString:))]
110 #[unsafe(method_family = none)]
111 pub fn showSearchResultsForQueryString(&self, query_string: &NSString) -> bool;
112
113 #[unsafe(method(noteFileSystemChanged:))]
114 #[unsafe(method_family = none)]
115 pub fn noteFileSystemChanged_(&self, path: &NSString);
116
117 #[unsafe(method(isFilePackageAtPath:))]
118 #[unsafe(method_family = none)]
119 pub fn isFilePackageAtPath(&self, full_path: &NSString) -> bool;
120
121 #[cfg(feature = "NSImage")]
122 #[unsafe(method(iconForFile:))]
123 #[unsafe(method_family = none)]
124 pub fn iconForFile(&self, full_path: &NSString) -> Retained<NSImage>;
125
126 #[cfg(feature = "NSImage")]
127 #[unsafe(method(iconForFiles:))]
128 #[unsafe(method_family = none)]
129 pub fn iconForFiles(&self, full_paths: &NSArray<NSString>) -> Option<Retained<NSImage>>;
130
131 #[cfg(all(feature = "NSImage", feature = "objc2-uniform-type-identifiers"))]
132 #[cfg(target_vendor = "apple")]
133 #[unsafe(method(iconForContentType:))]
134 #[unsafe(method_family = none)]
135 pub fn iconForContentType(&self, content_type: &UTType) -> Retained<NSImage>;
136
137 #[cfg(feature = "NSImage")]
138 #[unsafe(method(setIcon:forFile:options:))]
139 #[unsafe(method_family = none)]
140 pub fn setIcon_forFile_options(
141 &self,
142 image: Option<&NSImage>,
143 full_path: &NSString,
144 options: NSWorkspaceIconCreationOptions,
145 ) -> bool;
146
147 #[unsafe(method(fileLabels))]
148 #[unsafe(method_family = none)]
149 pub fn fileLabels(&self) -> Retained<NSArray<NSString>>;
150
151 #[cfg(feature = "NSColor")]
152 #[unsafe(method(fileLabelColors))]
153 #[unsafe(method_family = none)]
154 pub fn fileLabelColors(&self) -> Retained<NSArray<NSColor>>;
155
156 #[cfg(feature = "block2")]
157 #[unsafe(method(recycleURLs:completionHandler:))]
158 #[unsafe(method_family = none)]
159 pub fn recycleURLs_completionHandler(
160 &self,
161 ur_ls: &NSArray<NSURL>,
162 handler: Option<
163 &block2::DynBlock<dyn Fn(NonNull<NSDictionary<NSURL, NSURL>>, *mut NSError)>,
164 >,
165 );
166
167 #[cfg(feature = "block2")]
168 #[unsafe(method(duplicateURLs:completionHandler:))]
169 #[unsafe(method_family = none)]
170 pub fn duplicateURLs_completionHandler(
171 &self,
172 ur_ls: &NSArray<NSURL>,
173 handler: Option<
174 &block2::DynBlock<dyn Fn(NonNull<NSDictionary<NSURL, NSURL>>, *mut NSError)>,
175 >,
176 );
177
178 #[unsafe(method(getFileSystemInfoForPath:isRemovable:isWritable:isUnmountable:description:type:))]
184 #[unsafe(method_family = none)]
185 pub unsafe fn getFileSystemInfoForPath_isRemovable_isWritable_isUnmountable_description_type(
186 &self,
187 full_path: &NSString,
188 removable_flag: *mut Bool,
189 writable_flag: *mut Bool,
190 unmountable_flag: *mut Bool,
191 description: Option<&mut Option<Retained<NSString>>>,
192 file_system_type: Option<&mut Option<Retained<NSString>>>,
193 ) -> bool;
194
195 #[unsafe(method(unmountAndEjectDeviceAtPath:))]
196 #[unsafe(method_family = none)]
197 pub fn unmountAndEjectDeviceAtPath(&self, path: &NSString) -> bool;
198
199 #[unsafe(method(unmountAndEjectDeviceAtURL:error:_))]
200 #[unsafe(method_family = none)]
201 pub fn unmountAndEjectDeviceAtURL_error(
202 &self,
203 url: &NSURL,
204 ) -> Result<(), Retained<NSError>>;
205
206 #[unsafe(method(extendPowerOffBy:))]
207 #[unsafe(method_family = none)]
208 pub fn extendPowerOffBy(&self, requested: NSInteger) -> NSInteger;
209
210 #[unsafe(method(hideOtherApplications))]
211 #[unsafe(method_family = none)]
212 pub fn hideOtherApplications(&self);
213
214 #[unsafe(method(URLForApplicationWithBundleIdentifier:))]
215 #[unsafe(method_family = none)]
216 pub fn URLForApplicationWithBundleIdentifier(
217 &self,
218 bundle_identifier: &NSString,
219 ) -> Option<Retained<NSURL>>;
220
221 #[unsafe(method(URLsForApplicationsWithBundleIdentifier:))]
222 #[unsafe(method_family = none)]
223 pub fn URLsForApplicationsWithBundleIdentifier(
224 &self,
225 bundle_identifier: &NSString,
226 ) -> Retained<NSArray<NSURL>>;
227
228 #[unsafe(method(URLForApplicationToOpenURL:))]
229 #[unsafe(method_family = none)]
230 pub fn URLForApplicationToOpenURL(&self, url: &NSURL) -> Option<Retained<NSURL>>;
231
232 #[unsafe(method(URLsForApplicationsToOpenURL:))]
233 #[unsafe(method_family = none)]
234 pub fn URLsForApplicationsToOpenURL(&self, url: &NSURL) -> Retained<NSArray<NSURL>>;
235
236 #[cfg(feature = "block2")]
237 #[unsafe(method(setDefaultApplicationAtURL:toOpenContentTypeOfFileAtURL:completionHandler:))]
238 #[unsafe(method_family = none)]
239 pub fn setDefaultApplicationAtURL_toOpenContentTypeOfFileAtURL_completionHandler(
240 &self,
241 application_url: &NSURL,
242 url: &NSURL,
243 completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
244 );
245
246 #[cfg(feature = "block2")]
247 #[unsafe(method(setDefaultApplicationAtURL:toOpenURLsWithScheme:completionHandler:))]
248 #[unsafe(method_family = none)]
249 pub fn setDefaultApplicationAtURL_toOpenURLsWithScheme_completionHandler(
250 &self,
251 application_url: &NSURL,
252 url_scheme: &NSString,
253 completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
254 );
255
256 #[cfg(feature = "block2")]
257 #[unsafe(method(setDefaultApplicationAtURL:toOpenFileAtURL:completionHandler:))]
258 #[unsafe(method_family = none)]
259 pub fn setDefaultApplicationAtURL_toOpenFileAtURL_completionHandler(
260 &self,
261 application_url: &NSURL,
262 url: &NSURL,
263 completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
264 );
265
266 #[cfg(feature = "objc2-uniform-type-identifiers")]
267 #[cfg(target_vendor = "apple")]
268 #[unsafe(method(URLForApplicationToOpenContentType:))]
269 #[unsafe(method_family = none)]
270 pub fn URLForApplicationToOpenContentType(
271 &self,
272 content_type: &UTType,
273 ) -> Option<Retained<NSURL>>;
274
275 #[cfg(feature = "objc2-uniform-type-identifiers")]
276 #[cfg(target_vendor = "apple")]
277 #[unsafe(method(URLsForApplicationsToOpenContentType:))]
278 #[unsafe(method_family = none)]
279 pub fn URLsForApplicationsToOpenContentType(
280 &self,
281 content_type: &UTType,
282 ) -> Retained<NSArray<NSURL>>;
283
284 #[cfg(all(feature = "block2", feature = "objc2-uniform-type-identifiers"))]
285 #[cfg(target_vendor = "apple")]
286 #[unsafe(method(setDefaultApplicationAtURL:toOpenContentType:completionHandler:))]
287 #[unsafe(method_family = none)]
288 pub fn setDefaultApplicationAtURL_toOpenContentType_completionHandler(
289 &self,
290 application_url: &NSURL,
291 content_type: &UTType,
292 completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
293 );
294
295 #[cfg(feature = "NSRunningApplication")]
296 #[unsafe(method(frontmostApplication))]
297 #[unsafe(method_family = none)]
298 pub fn frontmostApplication(&self) -> Option<Retained<NSRunningApplication>>;
299
300 #[cfg(feature = "NSRunningApplication")]
301 #[unsafe(method(menuBarOwningApplication))]
302 #[unsafe(method_family = none)]
303 pub fn menuBarOwningApplication(&self) -> Option<Retained<NSRunningApplication>>;
304 );
305}
306
307impl NSWorkspace {
309 extern_methods!(
310 #[unsafe(method(init))]
311 #[unsafe(method_family = init)]
312 pub fn init(this: Allocated<Self>) -> Retained<Self>;
313
314 #[unsafe(method(new))]
315 #[unsafe(method_family = new)]
316 pub fn new() -> Retained<Self>;
317 );
318}
319
320impl DefaultRetained for NSWorkspace {
321 #[inline]
322 fn default_retained() -> Retained<Self> {
323 Self::new()
324 }
325}
326
327extern_class!(
328 #[unsafe(super(NSObject))]
330 #[derive(Debug, PartialEq, Eq, Hash)]
331 pub struct NSWorkspaceOpenConfiguration;
332);
333
334extern_conformance!(
335 unsafe impl NSCopying for NSWorkspaceOpenConfiguration {}
336);
337
338unsafe impl CopyingHelper for NSWorkspaceOpenConfiguration {
339 type Result = Self;
340}
341
342extern_conformance!(
343 unsafe impl NSObjectProtocol for NSWorkspaceOpenConfiguration {}
344);
345
346impl NSWorkspaceOpenConfiguration {
347 extern_methods!(
348 #[unsafe(method(configuration))]
349 #[unsafe(method_family = none)]
350 pub fn configuration() -> Retained<Self>;
351
352 #[unsafe(method(promptsUserIfNeeded))]
353 #[unsafe(method_family = none)]
354 pub fn promptsUserIfNeeded(&self) -> bool;
355
356 #[unsafe(method(setPromptsUserIfNeeded:))]
358 #[unsafe(method_family = none)]
359 pub fn setPromptsUserIfNeeded(&self, prompts_user_if_needed: bool);
360
361 #[unsafe(method(addsToRecentItems))]
362 #[unsafe(method_family = none)]
363 pub fn addsToRecentItems(&self) -> bool;
364
365 #[unsafe(method(setAddsToRecentItems:))]
367 #[unsafe(method_family = none)]
368 pub fn setAddsToRecentItems(&self, adds_to_recent_items: bool);
369
370 #[unsafe(method(activates))]
371 #[unsafe(method_family = none)]
372 pub fn activates(&self) -> bool;
373
374 #[unsafe(method(setActivates:))]
376 #[unsafe(method_family = none)]
377 pub fn setActivates(&self, activates: bool);
378
379 #[unsafe(method(hides))]
380 #[unsafe(method_family = none)]
381 pub fn hides(&self) -> bool;
382
383 #[unsafe(method(setHides:))]
385 #[unsafe(method_family = none)]
386 pub fn setHides(&self, hides: bool);
387
388 #[unsafe(method(hidesOthers))]
389 #[unsafe(method_family = none)]
390 pub fn hidesOthers(&self) -> bool;
391
392 #[unsafe(method(setHidesOthers:))]
394 #[unsafe(method_family = none)]
395 pub fn setHidesOthers(&self, hides_others: bool);
396
397 #[unsafe(method(isForPrinting))]
398 #[unsafe(method_family = none)]
399 pub fn isForPrinting(&self) -> bool;
400
401 #[unsafe(method(setForPrinting:))]
403 #[unsafe(method_family = none)]
404 pub fn setForPrinting(&self, for_printing: bool);
405
406 #[unsafe(method(createsNewApplicationInstance))]
407 #[unsafe(method_family = none)]
408 pub fn createsNewApplicationInstance(&self) -> bool;
409
410 #[unsafe(method(setCreatesNewApplicationInstance:))]
412 #[unsafe(method_family = none)]
413 pub fn setCreatesNewApplicationInstance(&self, creates_new_application_instance: bool);
414
415 #[unsafe(method(allowsRunningApplicationSubstitution))]
416 #[unsafe(method_family = none)]
417 pub fn allowsRunningApplicationSubstitution(&self) -> bool;
418
419 #[unsafe(method(setAllowsRunningApplicationSubstitution:))]
421 #[unsafe(method_family = none)]
422 pub fn setAllowsRunningApplicationSubstitution(
423 &self,
424 allows_running_application_substitution: bool,
425 );
426
427 #[unsafe(method(arguments))]
428 #[unsafe(method_family = none)]
429 pub fn arguments(&self) -> Retained<NSArray<NSString>>;
430
431 #[unsafe(method(setArguments:))]
435 #[unsafe(method_family = none)]
436 pub fn setArguments(&self, arguments: &NSArray<NSString>);
437
438 #[unsafe(method(environment))]
439 #[unsafe(method_family = none)]
440 pub fn environment(&self) -> Retained<NSDictionary<NSString, NSString>>;
441
442 #[unsafe(method(setEnvironment:))]
446 #[unsafe(method_family = none)]
447 pub fn setEnvironment(&self, environment: &NSDictionary<NSString, NSString>);
448
449 #[unsafe(method(appleEvent))]
450 #[unsafe(method_family = none)]
451 pub fn appleEvent(&self) -> Option<Retained<NSAppleEventDescriptor>>;
452
453 #[unsafe(method(setAppleEvent:))]
455 #[unsafe(method_family = none)]
456 pub fn setAppleEvent(&self, apple_event: Option<&NSAppleEventDescriptor>);
457
458 #[unsafe(method(requiresUniversalLinks))]
459 #[unsafe(method_family = none)]
460 pub fn requiresUniversalLinks(&self) -> bool;
461
462 #[unsafe(method(setRequiresUniversalLinks:))]
464 #[unsafe(method_family = none)]
465 pub fn setRequiresUniversalLinks(&self, requires_universal_links: bool);
466 );
467}
468
469impl NSWorkspaceOpenConfiguration {
471 extern_methods!(
472 #[unsafe(method(init))]
473 #[unsafe(method_family = init)]
474 pub fn init(this: Allocated<Self>) -> Retained<Self>;
475
476 #[unsafe(method(new))]
477 #[unsafe(method_family = new)]
478 pub fn new() -> Retained<Self>;
479 );
480}
481
482impl DefaultRetained for NSWorkspaceOpenConfiguration {
483 #[inline]
484 fn default_retained() -> Retained<Self> {
485 Self::new()
486 }
487}
488
489pub type NSWorkspaceDesktopImageOptionKey = NSString;
492
493extern "C" {
494 pub static NSWorkspaceDesktopImageScalingKey: &'static NSWorkspaceDesktopImageOptionKey;
496}
497
498extern "C" {
499 pub static NSWorkspaceDesktopImageAllowClippingKey: &'static NSWorkspaceDesktopImageOptionKey;
501}
502
503extern "C" {
504 pub static NSWorkspaceDesktopImageFillColorKey: &'static NSWorkspaceDesktopImageOptionKey;
506}
507
508impl NSWorkspace {
510 extern_methods!(
511 #[cfg(feature = "NSScreen")]
512 #[unsafe(method(setDesktopImageURL:forScreen:options:error:_))]
516 #[unsafe(method_family = none)]
517 pub unsafe fn setDesktopImageURL_forScreen_options_error(
518 &self,
519 url: &NSURL,
520 screen: &NSScreen,
521 options: &NSDictionary<NSWorkspaceDesktopImageOptionKey, AnyObject>,
522 ) -> Result<(), Retained<NSError>>;
523
524 #[cfg(feature = "NSScreen")]
525 #[unsafe(method(desktopImageURLForScreen:))]
526 #[unsafe(method_family = none)]
527 pub fn desktopImageURLForScreen(&self, screen: &NSScreen) -> Option<Retained<NSURL>>;
528
529 #[cfg(feature = "NSScreen")]
530 #[unsafe(method(desktopImageOptionsForScreen:))]
531 #[unsafe(method_family = none)]
532 pub fn desktopImageOptionsForScreen(
533 &self,
534 screen: &NSScreen,
535 ) -> Option<Retained<NSDictionary<NSWorkspaceDesktopImageOptionKey, AnyObject>>>;
536 );
537}
538
539#[repr(transparent)]
542#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
543pub struct NSWorkspaceAuthorizationType(pub NSInteger);
544impl NSWorkspaceAuthorizationType {
545 #[doc(alias = "NSWorkspaceAuthorizationTypeCreateSymbolicLink")]
546 pub const CreateSymbolicLink: Self = Self(0);
547 #[doc(alias = "NSWorkspaceAuthorizationTypeSetAttributes")]
548 pub const SetAttributes: Self = Self(1);
549 #[doc(alias = "NSWorkspaceAuthorizationTypeReplaceFile")]
550 pub const ReplaceFile: Self = Self(2);
551}
552
553unsafe impl Encode for NSWorkspaceAuthorizationType {
554 const ENCODING: Encoding = NSInteger::ENCODING;
555}
556
557unsafe impl RefEncode for NSWorkspaceAuthorizationType {
558 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
559}
560
561extern_class!(
562 #[unsafe(super(NSObject))]
564 #[derive(Debug, PartialEq, Eq, Hash)]
565 pub struct NSWorkspaceAuthorization;
566);
567
568extern_conformance!(
569 unsafe impl NSObjectProtocol for NSWorkspaceAuthorization {}
570);
571
572impl NSWorkspaceAuthorization {
573 extern_methods!();
574}
575
576impl NSWorkspaceAuthorization {
578 extern_methods!(
579 #[unsafe(method(init))]
580 #[unsafe(method_family = init)]
581 pub fn init(this: Allocated<Self>) -> Retained<Self>;
582
583 #[unsafe(method(new))]
584 #[unsafe(method_family = new)]
585 pub fn new() -> Retained<Self>;
586 );
587}
588
589impl DefaultRetained for NSWorkspaceAuthorization {
590 #[inline]
591 fn default_retained() -> Retained<Self> {
592 Self::new()
593 }
594}
595
596impl NSWorkspace {
598 extern_methods!(
599 #[cfg(feature = "block2")]
600 #[unsafe(method(requestAuthorizationOfType:completionHandler:))]
601 #[unsafe(method_family = none)]
602 pub fn requestAuthorizationOfType_completionHandler(
603 &self,
604 r#type: NSWorkspaceAuthorizationType,
605 completion_handler: &block2::DynBlock<
606 dyn Fn(*mut NSWorkspaceAuthorization, *mut NSError),
607 >,
608 );
609 );
610}
611
612mod private_NSFileManagerNSWorkspaceAuthorization {
613 pub trait Sealed {}
614}
615
616#[doc(alias = "NSWorkspaceAuthorization")]
618pub unsafe trait NSFileManagerNSWorkspaceAuthorization:
619 ClassType + Sized + private_NSFileManagerNSWorkspaceAuthorization::Sealed
620{
621 extern_methods!(
622 #[unsafe(method(fileManagerWithAuthorization:))]
623 #[unsafe(method_family = none)]
624 fn fileManagerWithAuthorization(authorization: &NSWorkspaceAuthorization)
625 -> Retained<Self>;
626 );
627}
628
629impl private_NSFileManagerNSWorkspaceAuthorization::Sealed for NSFileManager {}
630unsafe impl NSFileManagerNSWorkspaceAuthorization for NSFileManager {}
631
632extern "C" {
633 pub static NSWorkspaceApplicationKey: &'static NSString;
635}
636
637extern "C" {
638 pub static NSWorkspaceWillLaunchApplicationNotification: &'static NSNotificationName;
640}
641
642extern "C" {
643 pub static NSWorkspaceDidLaunchApplicationNotification: &'static NSNotificationName;
645}
646
647extern "C" {
648 pub static NSWorkspaceDidTerminateApplicationNotification: &'static NSNotificationName;
650}
651
652extern "C" {
653 pub static NSWorkspaceDidHideApplicationNotification: &'static NSNotificationName;
655}
656
657extern "C" {
658 pub static NSWorkspaceDidUnhideApplicationNotification: &'static NSNotificationName;
660}
661
662extern "C" {
663 pub static NSWorkspaceDidActivateApplicationNotification: &'static NSNotificationName;
665}
666
667extern "C" {
668 pub static NSWorkspaceDidDeactivateApplicationNotification: &'static NSNotificationName;
670}
671
672extern "C" {
673 pub static NSWorkspaceVolumeLocalizedNameKey: &'static NSString;
675}
676
677extern "C" {
678 pub static NSWorkspaceVolumeURLKey: &'static NSString;
680}
681
682extern "C" {
683 pub static NSWorkspaceVolumeOldLocalizedNameKey: &'static NSString;
685}
686
687extern "C" {
688 pub static NSWorkspaceVolumeOldURLKey: &'static NSString;
690}
691
692extern "C" {
693 pub static NSWorkspaceDidMountNotification: &'static NSNotificationName;
695}
696
697extern "C" {
698 pub static NSWorkspaceDidUnmountNotification: &'static NSNotificationName;
700}
701
702extern "C" {
703 pub static NSWorkspaceWillUnmountNotification: &'static NSNotificationName;
705}
706
707extern "C" {
708 pub static NSWorkspaceDidRenameVolumeNotification: &'static NSNotificationName;
710}
711
712extern "C" {
713 pub static NSWorkspaceWillPowerOffNotification: &'static NSNotificationName;
715}
716
717extern "C" {
718 pub static NSWorkspaceWillSleepNotification: &'static NSNotificationName;
720}
721
722extern "C" {
723 pub static NSWorkspaceDidWakeNotification: &'static NSNotificationName;
725}
726
727extern "C" {
728 pub static NSWorkspaceScreensDidSleepNotification: &'static NSNotificationName;
730}
731
732extern "C" {
733 pub static NSWorkspaceScreensDidWakeNotification: &'static NSNotificationName;
735}
736
737extern "C" {
738 pub static NSWorkspaceSessionDidBecomeActiveNotification: &'static NSNotificationName;
740}
741
742extern "C" {
743 pub static NSWorkspaceSessionDidResignActiveNotification: &'static NSNotificationName;
745}
746
747extern "C" {
748 pub static NSWorkspaceDidChangeFileLabelsNotification: &'static NSNotificationName;
750}
751
752extern "C" {
753 pub static NSWorkspaceActiveSpaceDidChangeNotification: &'static NSNotificationName;
755}
756
757#[deprecated]
759pub type NSWorkspaceFileOperationName = NSString;
761
762#[repr(transparent)]
765#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
766pub struct NSWorkspaceLaunchOptions(pub NSUInteger);
767bitflags::bitflags! {
768 impl NSWorkspaceLaunchOptions: NSUInteger {
769 #[doc(alias = "NSWorkspaceLaunchAndPrint")]
770#[deprecated = "Use -[NSWorkspaceOpenConfiguration setForPrinting:YES] instead."]
771 const AndPrint = 0x00000002;
772 #[doc(alias = "NSWorkspaceLaunchWithErrorPresentation")]
773#[deprecated = "Use -[NSWorkspaceOpenConfiguration setPromptsUserIfNeeded:YES] instead."]
774 const WithErrorPresentation = 0x00000040;
775 #[doc(alias = "NSWorkspaceLaunchInhibitingBackgroundOnly")]
776#[deprecated = "This option does nothing."]
777 const InhibitingBackgroundOnly = 0x00000080;
778 #[doc(alias = "NSWorkspaceLaunchWithoutAddingToRecents")]
779#[deprecated = "Use -[NSWorkspaceOpenConfiguration setAddsToRecentItems:YES] instead."]
780 const WithoutAddingToRecents = 0x00000100;
781 #[doc(alias = "NSWorkspaceLaunchWithoutActivation")]
782#[deprecated = "Use -[NSWorkspaceOpenConfiguration setActivates:NO] instead."]
783 const WithoutActivation = 0x00000200;
784 #[doc(alias = "NSWorkspaceLaunchAsync")]
785#[deprecated = "When using NSWorkspaceOpenConfiguration, all launches are asynchronous."]
786 const Async = 0x00010000;
787 #[doc(alias = "NSWorkspaceLaunchNewInstance")]
788#[deprecated = "Use -[NSWorkspaceOpenConfiguration setCreatesNewApplicationInstance:YES] instead."]
789 const NewInstance = 0x00080000;
790 #[doc(alias = "NSWorkspaceLaunchAndHide")]
791#[deprecated = "Use -[NSWorkspaceOpenConfiguration setHides:YES] instead."]
792 const AndHide = 0x00100000;
793 #[doc(alias = "NSWorkspaceLaunchAndHideOthers")]
794#[deprecated = "Use -[NSWorkspaceOpenConfiguration setHidesOthers:YES] instead."]
795 const AndHideOthers = 0x00200000;
796 #[doc(alias = "NSWorkspaceLaunchDefault")]
797#[deprecated = "Use NSWorkspaceOpenConfiguration instead."]
798 const Default = NSWorkspaceLaunchOptions::Async.0;
799 #[doc(alias = "NSWorkspaceLaunchAllowingClassicStartup")]
800#[deprecated = "The Classic environment is no longer supported."]
801 const AllowingClassicStartup = 0x00020000;
802 #[doc(alias = "NSWorkspaceLaunchPreferringClassic")]
803#[deprecated = "The Classic environment is no longer supported."]
804 const PreferringClassic = 0x00040000;
805 }
806}
807
808unsafe impl Encode for NSWorkspaceLaunchOptions {
809 const ENCODING: Encoding = NSUInteger::ENCODING;
810}
811
812unsafe impl RefEncode for NSWorkspaceLaunchOptions {
813 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
814}
815
816#[deprecated = "Use NSWorkspaceOpenConfiguration instead."]
818pub type NSWorkspaceLaunchConfigurationKey = NSString;
820
821extern "C" {
822 #[deprecated = "Use -[NSWorkspaceOpenConfiguration setAppleEvent:] instead."]
824 pub static NSWorkspaceLaunchConfigurationAppleEvent: &'static NSWorkspaceLaunchConfigurationKey;
825}
826
827extern "C" {
828 #[deprecated = "Use -[NSWorkspaceOpenConfiguration setArguments:] instead."]
830 pub static NSWorkspaceLaunchConfigurationArguments: &'static NSWorkspaceLaunchConfigurationKey;
831}
832
833extern "C" {
834 #[deprecated = "Use -[NSWorkspaceOpenConfiguration setEnvironment:] instead."]
836 pub static NSWorkspaceLaunchConfigurationEnvironment:
837 &'static NSWorkspaceLaunchConfigurationKey;
838}
839
840extern "C" {
841 #[deprecated = "Do not specify an architecutre. When unspecified, the architecture for a new application instance will be determined based on the available architectures in its executable."]
843 pub static NSWorkspaceLaunchConfigurationArchitecture:
844 &'static NSWorkspaceLaunchConfigurationKey;
845}
846
847impl NSWorkspace {
849 extern_methods!(
850 #[deprecated = "Use -[NSWorkspace openURL:] instead."]
851 #[unsafe(method(openFile:))]
852 #[unsafe(method_family = none)]
853 pub fn openFile(&self, full_path: &NSString) -> bool;
854
855 #[deprecated = "Use -[NSWorkspace openURLs:withApplicationAtURL:configuration:completionHandler:] instead."]
856 #[unsafe(method(openFile:withApplication:))]
857 #[unsafe(method_family = none)]
858 pub fn openFile_withApplication(
859 &self,
860 full_path: &NSString,
861 app_name: Option<&NSString>,
862 ) -> bool;
863
864 #[deprecated = "Use -[NSWorkspace openURLs:withApplicationAtURL:configuration:completionHandler:] instead."]
865 #[unsafe(method(openFile:withApplication:andDeactivate:))]
866 #[unsafe(method_family = none)]
867 pub fn openFile_withApplication_andDeactivate(
868 &self,
869 full_path: &NSString,
870 app_name: Option<&NSString>,
871 flag: bool,
872 ) -> bool;
873
874 #[deprecated = "Use -[NSWorkspace openApplicationAtURL:configuration:completionHandler:] instead."]
875 #[unsafe(method(launchApplication:))]
876 #[unsafe(method_family = none)]
877 pub fn launchApplication(&self, app_name: &NSString) -> bool;
878
879 #[cfg(feature = "NSRunningApplication")]
880 #[deprecated = "Use -[NSWorkspace openApplicationAtURL:configuration:completionHandler:] instead."]
884 #[unsafe(method(launchApplicationAtURL:options:configuration:error:_))]
885 #[unsafe(method_family = none)]
886 pub unsafe fn launchApplicationAtURL_options_configuration_error(
887 &self,
888 url: &NSURL,
889 options: NSWorkspaceLaunchOptions,
890 configuration: &NSDictionary<NSWorkspaceLaunchConfigurationKey, AnyObject>,
891 ) -> Result<Retained<NSRunningApplication>, Retained<NSError>>;
892
893 #[cfg(feature = "NSRunningApplication")]
894 #[deprecated = "Use -[NSWorkspace openURL:configuration:completionHandler:] instead."]
898 #[unsafe(method(openURL:options:configuration:error:_))]
899 #[unsafe(method_family = none)]
900 pub unsafe fn openURL_options_configuration_error(
901 &self,
902 url: &NSURL,
903 options: NSWorkspaceLaunchOptions,
904 configuration: &NSDictionary<NSWorkspaceLaunchConfigurationKey, AnyObject>,
905 ) -> Result<Retained<NSRunningApplication>, Retained<NSError>>;
906
907 #[cfg(feature = "NSRunningApplication")]
908 #[deprecated = "Use -[NSWorkspace openURLs:withApplicationAtURL:configuration:completionHandler:] instead."]
912 #[unsafe(method(openURLs:withApplicationAtURL:options:configuration:error:_))]
913 #[unsafe(method_family = none)]
914 pub unsafe fn openURLs_withApplicationAtURL_options_configuration_error(
915 &self,
916 urls: &NSArray<NSURL>,
917 application_url: &NSURL,
918 options: NSWorkspaceLaunchOptions,
919 configuration: &NSDictionary<NSWorkspaceLaunchConfigurationKey, AnyObject>,
920 ) -> Result<Retained<NSRunningApplication>, Retained<NSError>>;
921
922 #[deprecated = "Use -[NSWorkspace openApplicationAtURL:configuration:completionHandler:] instead."]
923 #[unsafe(method(launchApplication:showIcon:autolaunch:))]
924 #[unsafe(method_family = none)]
925 pub fn launchApplication_showIcon_autolaunch(
926 &self,
927 app_name: &NSString,
928 show_icon: bool,
929 autolaunch: bool,
930 ) -> bool;
931
932 #[deprecated = "Use -[NSWorkspace URLForApplicationWithBundleIdentifier:] instead."]
933 #[unsafe(method(fullPathForApplication:))]
934 #[unsafe(method_family = none)]
935 pub fn fullPathForApplication(&self, app_name: &NSString) -> Option<Retained<NSString>>;
936
937 #[deprecated = "Use -[NSWorkspace URLForApplicationWithBundleIdentifier:] instead."]
938 #[unsafe(method(absolutePathForAppBundleWithIdentifier:))]
939 #[unsafe(method_family = none)]
940 pub fn absolutePathForAppBundleWithIdentifier(
941 &self,
942 bundle_identifier: &NSString,
943 ) -> Option<Retained<NSString>>;
944
945 #[deprecated = "Use -[NSWorkspace openApplicationAtURL:configuration:completionHandler:] instead."]
946 #[unsafe(method(launchAppWithBundleIdentifier:options:additionalEventParamDescriptor:launchIdentifier:))]
947 #[unsafe(method_family = none)]
948 pub fn launchAppWithBundleIdentifier_options_additionalEventParamDescriptor_launchIdentifier(
949 &self,
950 bundle_identifier: &NSString,
951 options: NSWorkspaceLaunchOptions,
952 descriptor: Option<&NSAppleEventDescriptor>,
953 identifier: Option<&mut Option<Retained<NSNumber>>>,
954 ) -> bool;
955
956 #[deprecated = "Use -[NSWorkspace openURLs:withApplicationAtURL:configuration:completionHandler:] instead."]
957 #[unsafe(method(openURLs:withAppBundleIdentifier:options:additionalEventParamDescriptor:launchIdentifiers:))]
958 #[unsafe(method_family = none)]
959 pub fn openURLs_withAppBundleIdentifier_options_additionalEventParamDescriptor_launchIdentifiers(
960 &self,
961 urls: &NSArray<NSURL>,
962 bundle_identifier: Option<&NSString>,
963 options: NSWorkspaceLaunchOptions,
964 descriptor: Option<&NSAppleEventDescriptor>,
965 identifiers: Option<&mut Option<Retained<NSArray<NSNumber>>>>,
966 ) -> bool;
967
968 #[deprecated]
969 #[unsafe(method(openTempFile:))]
970 #[unsafe(method_family = none)]
971 pub fn openTempFile(&self, full_path: &NSString) -> bool;
972
973 #[deprecated]
974 #[unsafe(method(findApplications))]
975 #[unsafe(method_family = none)]
976 pub fn findApplications(&self);
977
978 #[deprecated]
979 #[unsafe(method(noteUserDefaultsChanged))]
980 #[unsafe(method_family = none)]
981 pub fn noteUserDefaultsChanged(&self);
982
983 #[cfg(feature = "NSImage")]
984 #[deprecated]
985 #[unsafe(method(slideImage:from:to:))]
986 #[unsafe(method_family = none)]
987 pub fn slideImage_from_to(&self, image: &NSImage, from_point: NSPoint, to_point: NSPoint);
988
989 #[deprecated]
990 #[unsafe(method(checkForRemovableMedia))]
991 #[unsafe(method_family = none)]
992 pub fn checkForRemovableMedia(&self);
993
994 #[deprecated]
995 #[unsafe(method(noteFileSystemChanged))]
996 #[unsafe(method_family = none)]
997 pub fn noteFileSystemChanged(&self);
998
999 #[deprecated]
1000 #[unsafe(method(fileSystemChanged))]
1001 #[unsafe(method_family = none)]
1002 pub fn fileSystemChanged(&self) -> bool;
1003
1004 #[deprecated]
1005 #[unsafe(method(userDefaultsChanged))]
1006 #[unsafe(method_family = none)]
1007 pub fn userDefaultsChanged(&self) -> bool;
1008
1009 #[deprecated]
1010 #[unsafe(method(mountNewRemovableMedia))]
1011 #[unsafe(method_family = none)]
1012 pub fn mountNewRemovableMedia(&self) -> Option<Retained<NSArray>>;
1013
1014 #[deprecated = "Use -[NSWorkspace frontmostApplication] instead."]
1015 #[unsafe(method(activeApplication))]
1016 #[unsafe(method_family = none)]
1017 pub fn activeApplication(&self) -> Option<Retained<NSDictionary>>;
1018
1019 #[deprecated = "Use -[NSFileManager mountedVolumeURLsIncludingResourceValuesForKeys:options:] instead."]
1020 #[unsafe(method(mountedLocalVolumePaths))]
1021 #[unsafe(method_family = none)]
1022 pub fn mountedLocalVolumePaths(&self) -> Option<Retained<NSArray>>;
1023
1024 #[deprecated = "Use -[NSFileManager mountedVolumeURLsIncludingResourceValuesForKeys:options:] instead."]
1025 #[unsafe(method(mountedRemovableMedia))]
1026 #[unsafe(method_family = none)]
1027 pub fn mountedRemovableMedia(&self) -> Option<Retained<NSArray>>;
1028
1029 #[deprecated = "Use -[NSWorkspace runningApplications] instead."]
1030 #[unsafe(method(launchedApplications))]
1031 #[unsafe(method_family = none)]
1032 pub fn launchedApplications(&self) -> Option<Retained<NSArray>>;
1033
1034 #[cfg(all(feature = "NSImage", feature = "NSResponder", feature = "NSView"))]
1035 #[deprecated = "Use -[NSWorkspace openURL:] instead."]
1036 #[unsafe(method(openFile:fromImage:at:inView:))]
1037 #[unsafe(method_family = none)]
1038 pub fn openFile_fromImage_at_inView(
1039 &self,
1040 full_path: &NSString,
1041 image: Option<&NSImage>,
1042 point: NSPoint,
1043 view: Option<&NSView>,
1044 ) -> bool;
1045
1046 #[deprecated]
1051 #[unsafe(method(performFileOperation:source:destination:files:tag:))]
1052 #[unsafe(method_family = none)]
1053 pub unsafe fn performFileOperation_source_destination_files_tag(
1054 &self,
1055 operation: &NSWorkspaceFileOperationName,
1056 source: &NSString,
1057 destination: &NSString,
1058 files: &NSArray,
1059 tag: *mut NSInteger,
1060 ) -> bool;
1061
1062 #[deprecated = "Use -[NSWorkspace URLForApplicationToOpenURL:] to get the URL of an application that will open a given item, or -[NSURL getResourceValue:forKey:error:] with NSURLContentTypeKey to get the type of the given item."]
1063 #[unsafe(method(getInfoForFile:application:type:))]
1064 #[unsafe(method_family = none)]
1065 pub fn getInfoForFile_application_type(
1066 &self,
1067 full_path: &NSString,
1068 app_name: Option<&mut Option<Retained<NSString>>>,
1069 r#type: Option<&mut Option<Retained<NSString>>>,
1070 ) -> bool;
1071
1072 #[cfg(feature = "NSImage")]
1073 #[deprecated = "Use -[NSWorkspace iconForContentType:] instead."]
1074 #[unsafe(method(iconForFileType:))]
1075 #[unsafe(method_family = none)]
1076 pub fn iconForFileType(&self, file_type: &NSString) -> Retained<NSImage>;
1077
1078 #[deprecated = "Use -[NSURL getResourceValue:forKey:error:] with NSURLContentTypeKey instead."]
1079 #[unsafe(method(typeOfFile:error:_))]
1080 #[unsafe(method_family = none)]
1081 pub fn typeOfFile_error(
1082 &self,
1083 absolute_file_path: &NSString,
1084 ) -> Result<Retained<NSString>, Retained<NSError>>;
1085
1086 #[deprecated = "Use UTType.localizedDescription instead."]
1087 #[unsafe(method(localizedDescriptionForType:))]
1088 #[unsafe(method_family = none)]
1089 pub fn localizedDescriptionForType(
1090 &self,
1091 type_name: &NSString,
1092 ) -> Option<Retained<NSString>>;
1093
1094 #[deprecated = "Use UTType.preferredFilenameExtension instead."]
1095 #[unsafe(method(preferredFilenameExtensionForType:))]
1096 #[unsafe(method_family = none)]
1097 pub fn preferredFilenameExtensionForType(
1098 &self,
1099 type_name: &NSString,
1100 ) -> Option<Retained<NSString>>;
1101
1102 #[deprecated = "Use +[UTType typesWithTag:tagClass:conformingToType:] to get a list of candidate types, then check if the input type conforms to any of them."]
1103 #[unsafe(method(filenameExtension:isValidForType:))]
1104 #[unsafe(method_family = none)]
1105 pub fn filenameExtension_isValidForType(
1106 &self,
1107 filename_extension: &NSString,
1108 type_name: &NSString,
1109 ) -> bool;
1110
1111 #[deprecated = "Use -[UTType conformsToType:] instead."]
1112 #[unsafe(method(type:conformsToType:))]
1113 #[unsafe(method_family = none)]
1114 pub fn type_conformsToType(
1115 &self,
1116 first_type_name: &NSString,
1117 second_type_name: &NSString,
1118 ) -> bool;
1119 );
1120}
1121
1122extern "C" {
1123 #[deprecated = "Use -[NSFileManager moveItemAtURL:toURL:error:] instead."]
1125 pub static NSWorkspaceMoveOperation: &'static NSWorkspaceFileOperationName;
1126}
1127
1128extern "C" {
1129 #[deprecated = "Use -[NSFileManager copyItemAtURL:toURL:error:] instead."]
1131 pub static NSWorkspaceCopyOperation: &'static NSWorkspaceFileOperationName;
1132}
1133
1134extern "C" {
1135 #[deprecated = "Use -[NSFileManager linkItemAtURL:toURL:error:] instead."]
1137 pub static NSWorkspaceLinkOperation: &'static NSWorkspaceFileOperationName;
1138}
1139
1140extern "C" {
1141 #[deprecated = "This operation is unimplemented."]
1143 pub static NSWorkspaceCompressOperation: &'static NSWorkspaceFileOperationName;
1144}
1145
1146extern "C" {
1147 #[deprecated = "This operation is unimplemented."]
1149 pub static NSWorkspaceDecompressOperation: &'static NSWorkspaceFileOperationName;
1150}
1151
1152extern "C" {
1153 #[deprecated = "This operation is unimplemented."]
1155 pub static NSWorkspaceEncryptOperation: &'static NSWorkspaceFileOperationName;
1156}
1157
1158extern "C" {
1159 #[deprecated = "This operation is unimplemented."]
1161 pub static NSWorkspaceDecryptOperation: &'static NSWorkspaceFileOperationName;
1162}
1163
1164extern "C" {
1165 #[deprecated = "Use -[NSFileManager removeItemAtURL:error:] instead."]
1167 pub static NSWorkspaceDestroyOperation: &'static NSWorkspaceFileOperationName;
1168}
1169
1170extern "C" {
1171 #[deprecated = "Use -[NSWorkspace recycleURLs:completionHandler:] instead."]
1173 pub static NSWorkspaceRecycleOperation: &'static NSWorkspaceFileOperationName;
1174}
1175
1176extern "C" {
1177 #[deprecated = "Use -[NSWorkspace duplicateURLs:completionHandler:] instead."]
1179 pub static NSWorkspaceDuplicateOperation: &'static NSWorkspaceFileOperationName;
1180}
1181
1182extern "C" {
1183 #[deprecated]
1185 pub static NSWorkspaceDidPerformFileOperationNotification: &'static NSNotificationName;
1186}
1187
1188extern "C" {
1189 #[deprecated]
1191 pub static NSPlainFileType: &'static NSString;
1192}
1193
1194extern "C" {
1195 #[deprecated]
1197 pub static NSDirectoryFileType: &'static NSString;
1198}
1199
1200extern "C" {
1201 #[deprecated]
1203 pub static NSApplicationFileType: &'static NSString;
1204}
1205
1206extern "C" {
1207 #[deprecated]
1209 pub static NSFilesystemFileType: &'static NSString;
1210}
1211
1212extern "C" {
1213 #[deprecated]
1215 pub static NSShellCommandFileType: &'static NSString;
1216}