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