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