1use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7use objc2::__framework_prelude::*;
8#[cfg(feature = "objc2-cloud-kit")]
9#[cfg(target_vendor = "apple")]
10use objc2_cloud_kit::*;
11use objc2_foundation::*;
12
13use crate::*;
14
15pub type NSAppKitVersion = c_double;
18
19extern "C" {
20 pub static NSAppKitVersionNumber: NSAppKitVersion;
22}
23
24pub static NSAppKitVersionNumber10_0: NSAppKitVersion = 577 as _;
26
27pub static NSAppKitVersionNumber10_1: NSAppKitVersion = 620 as _;
29
30pub static NSAppKitVersionNumber10_2: NSAppKitVersion = 663 as _;
32
33pub static NSAppKitVersionNumber10_2_3: NSAppKitVersion = 663.6 as _;
35
36pub static NSAppKitVersionNumber10_3: NSAppKitVersion = 743 as _;
38
39pub static NSAppKitVersionNumber10_3_2: NSAppKitVersion = 743.14 as _;
41
42pub static NSAppKitVersionNumber10_3_3: NSAppKitVersion = 743.2 as _;
44
45pub static NSAppKitVersionNumber10_3_5: NSAppKitVersion = 743.24 as _;
47
48pub static NSAppKitVersionNumber10_3_7: NSAppKitVersion = 743.33 as _;
50
51pub static NSAppKitVersionNumber10_3_9: NSAppKitVersion = 743.36 as _;
53
54pub static NSAppKitVersionNumber10_4: NSAppKitVersion = 824 as _;
56
57pub static NSAppKitVersionNumber10_4_1: NSAppKitVersion = 824.1 as _;
59
60pub static NSAppKitVersionNumber10_4_3: NSAppKitVersion = 824.23 as _;
62
63pub static NSAppKitVersionNumber10_4_4: NSAppKitVersion = 824.33 as _;
65
66pub static NSAppKitVersionNumber10_4_7: NSAppKitVersion = 824.41 as _;
68
69pub static NSAppKitVersionNumber10_5: NSAppKitVersion = 949 as _;
71
72pub static NSAppKitVersionNumber10_5_2: NSAppKitVersion = 949.27 as _;
74
75pub static NSAppKitVersionNumber10_5_3: NSAppKitVersion = 949.33 as _;
77
78pub static NSAppKitVersionNumber10_6: NSAppKitVersion = 1038 as _;
80
81pub static NSAppKitVersionNumber10_7: NSAppKitVersion = 1138 as _;
83
84pub static NSAppKitVersionNumber10_7_2: NSAppKitVersion = 1138.23 as _;
86
87pub static NSAppKitVersionNumber10_7_3: NSAppKitVersion = 1138.32 as _;
89
90pub static NSAppKitVersionNumber10_7_4: NSAppKitVersion = 1138.47 as _;
92
93pub static NSAppKitVersionNumber10_8: NSAppKitVersion = 1187 as _;
95
96pub static NSAppKitVersionNumber10_9: NSAppKitVersion = 1265 as _;
98
99pub static NSAppKitVersionNumber10_10: NSAppKitVersion = 1343 as _;
101
102pub static NSAppKitVersionNumber10_10_2: NSAppKitVersion = 1344 as _;
104
105pub static NSAppKitVersionNumber10_10_3: NSAppKitVersion = 1347 as _;
107
108pub static NSAppKitVersionNumber10_10_4: NSAppKitVersion = 1348 as _;
110
111pub static NSAppKitVersionNumber10_10_5: NSAppKitVersion = 1348 as _;
113
114pub static NSAppKitVersionNumber10_10_Max: NSAppKitVersion = 1349 as _;
116
117pub static NSAppKitVersionNumber10_11: NSAppKitVersion = 1404 as _;
119
120pub static NSAppKitVersionNumber10_11_1: NSAppKitVersion = 1404.13 as _;
122
123pub static NSAppKitVersionNumber10_11_2: NSAppKitVersion = 1404.34 as _;
125
126pub static NSAppKitVersionNumber10_11_3: NSAppKitVersion = 1404.34 as _;
128
129pub static NSAppKitVersionNumber10_12: NSAppKitVersion = 1504 as _;
131
132pub static NSAppKitVersionNumber10_12_1: NSAppKitVersion = 1504.6 as _;
134
135pub static NSAppKitVersionNumber10_12_2: NSAppKitVersion = 1504.76 as _;
137
138pub static NSAppKitVersionNumber10_13: NSAppKitVersion = 1561 as _;
140
141pub static NSAppKitVersionNumber10_13_1: NSAppKitVersion = 1561.1 as _;
143
144pub static NSAppKitVersionNumber10_13_2: NSAppKitVersion = 1561.2 as _;
146
147pub static NSAppKitVersionNumber10_13_4: NSAppKitVersion = 1561.4 as _;
149
150pub static NSAppKitVersionNumber10_14: NSAppKitVersion = 1671 as _;
152
153pub static NSAppKitVersionNumber10_14_1: NSAppKitVersion = 1671.1 as _;
155
156pub static NSAppKitVersionNumber10_14_2: NSAppKitVersion = 1671.2 as _;
158
159pub static NSAppKitVersionNumber10_14_3: NSAppKitVersion = 1671.3 as _;
161
162pub static NSAppKitVersionNumber10_14_4: NSAppKitVersion = 1671.4 as _;
164
165pub static NSAppKitVersionNumber10_14_5: NSAppKitVersion = 1671.5 as _;
167
168pub static NSAppKitVersionNumber10_15: NSAppKitVersion = 1894 as _;
170
171pub static NSAppKitVersionNumber10_15_1: NSAppKitVersion = 1894.1 as _;
173
174pub static NSAppKitVersionNumber10_15_2: NSAppKitVersion = 1894.2 as _;
176
177pub static NSAppKitVersionNumber10_15_3: NSAppKitVersion = 1894.3 as _;
179
180pub static NSAppKitVersionNumber10_15_4: NSAppKitVersion = 1894.4 as _;
182
183pub static NSAppKitVersionNumber10_15_5: NSAppKitVersion = 1894.5 as _;
185
186pub static NSAppKitVersionNumber10_15_6: NSAppKitVersion = 1894.6 as _;
188
189pub static NSAppKitVersionNumber11_0: NSAppKitVersion = 2022 as _;
191
192pub static NSAppKitVersionNumber11_1: NSAppKitVersion = 2022.2 as _;
194
195pub static NSAppKitVersionNumber11_2: NSAppKitVersion = 2022.3 as _;
197
198pub static NSAppKitVersionNumber11_3: NSAppKitVersion = 2022.4 as _;
200
201pub static NSAppKitVersionNumber11_4: NSAppKitVersion = 2022.5 as _;
203
204pub static NSAppKitVersionNumber11_5: NSAppKitVersion = 2022.6 as _;
206
207pub static NSAppKitVersionNumber12_0: NSAppKitVersion = 2113 as _;
209
210pub static NSAppKitVersionNumber12_1: NSAppKitVersion = 2113.2 as _;
212
213pub static NSAppKitVersionNumber12_2: NSAppKitVersion = 2113.3 as _;
215
216pub static NSAppKitVersionNumber12_3: NSAppKitVersion = 2113.4 as _;
218
219pub static NSAppKitVersionNumber12_4: NSAppKitVersion = 2113.5 as _;
221
222pub static NSAppKitVersionNumber12_5: NSAppKitVersion = 2113.6 as _;
224
225pub static NSAppKitVersionNumber13_0: NSAppKitVersion = 2299 as _;
227
228pub static NSAppKitVersionNumber13_1: NSAppKitVersion = 2299.3 as _;
230
231pub static NSAppKitVersionNumber13_2: NSAppKitVersion = 2299.3 as _;
233
234pub static NSAppKitVersionNumber13_3: NSAppKitVersion = 2299.4 as _;
236
237pub static NSAppKitVersionNumber13_4: NSAppKitVersion = 2299.5 as _;
239
240pub static NSAppKitVersionNumber13_5: NSAppKitVersion = 2299.6 as _;
242
243pub static NSAppKitVersionNumber13_6: NSAppKitVersion = 2299.7 as _;
245
246pub static NSAppKitVersionNumber14_0: NSAppKitVersion = 2487 as _;
248
249pub static NSAppKitVersionNumber14_1: NSAppKitVersion = 2487.2 as _;
251
252extern "C" {
253 pub static NSModalPanelRunLoopMode: &'static NSRunLoopMode;
255}
256
257extern "C" {
258 pub static NSEventTrackingRunLoopMode: &'static NSRunLoopMode;
260}
261
262pub type NSModalResponse = NSInteger;
265
266pub static NSModalResponseStop: NSModalResponse = -1000;
270
271pub static NSModalResponseAbort: NSModalResponse = -1001;
273
274pub static NSModalResponseContinue: NSModalResponse = -1002;
276
277pub const NSUpdateWindowsRunLoopOrdering: c_uint = 500000;
279
280#[repr(transparent)]
286#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
287pub struct NSApplicationPresentationOptions(pub NSUInteger);
288bitflags::bitflags! {
289 impl NSApplicationPresentationOptions: NSUInteger {
290 #[doc(alias = "NSApplicationPresentationDefault")]
291 const Default = 0;
292#[doc(alias = "NSApplicationPresentationAutoHideDock")]
294 const AutoHideDock = 1<<0;
295#[doc(alias = "NSApplicationPresentationHideDock")]
297 const HideDock = 1<<1;
298#[doc(alias = "NSApplicationPresentationAutoHideMenuBar")]
300 const AutoHideMenuBar = 1<<2;
301#[doc(alias = "NSApplicationPresentationHideMenuBar")]
303 const HideMenuBar = 1<<3;
304#[doc(alias = "NSApplicationPresentationDisableAppleMenu")]
306 const DisableAppleMenu = 1<<4;
307#[doc(alias = "NSApplicationPresentationDisableProcessSwitching")]
309 const DisableProcessSwitching = 1<<5;
310#[doc(alias = "NSApplicationPresentationDisableForceQuit")]
312 const DisableForceQuit = 1<<6;
313#[doc(alias = "NSApplicationPresentationDisableSessionTermination")]
315 const DisableSessionTermination = 1<<7;
316#[doc(alias = "NSApplicationPresentationDisableHideApplication")]
318 const DisableHideApplication = 1<<8;
319#[doc(alias = "NSApplicationPresentationDisableMenuBarTransparency")]
321 const DisableMenuBarTransparency = 1<<9;
322#[doc(alias = "NSApplicationPresentationFullScreen")]
324 const FullScreen = 1<<10;
325#[doc(alias = "NSApplicationPresentationAutoHideToolbar")]
329 const AutoHideToolbar = 1<<11;
330#[doc(alias = "NSApplicationPresentationDisableCursorLocationAssistance")]
332 const DisableCursorLocationAssistance = 1<<12;
333 }
334}
335
336unsafe impl Encode for NSApplicationPresentationOptions {
337 const ENCODING: Encoding = NSUInteger::ENCODING;
338}
339
340unsafe impl RefEncode for NSApplicationPresentationOptions {
341 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
342}
343
344#[repr(transparent)]
347#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
348pub struct NSApplicationOcclusionState(pub NSUInteger);
349bitflags::bitflags! {
350 impl NSApplicationOcclusionState: NSUInteger {
351#[doc(alias = "NSApplicationOcclusionStateVisible")]
353 const Visible = 1<<1;
354 }
355}
356
357unsafe impl Encode for NSApplicationOcclusionState {
358 const ENCODING: Encoding = NSUInteger::ENCODING;
359}
360
361unsafe impl RefEncode for NSApplicationOcclusionState {
362 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
363}
364
365#[repr(transparent)]
368#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
369pub struct NSWindowListOptions(pub NSInteger);
370bitflags::bitflags! {
371 impl NSWindowListOptions: NSInteger {
372#[doc(alias = "NSWindowListOrderedFrontToBack")]
374 const OrderedFrontToBack = 1<<0;
375 }
376}
377
378unsafe impl Encode for NSWindowListOptions {
379 const ENCODING: Encoding = NSInteger::ENCODING;
380}
381
382unsafe impl RefEncode for NSWindowListOptions {
383 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
384}
385
386#[repr(C)]
388#[derive(Debug)]
389pub struct _NSModalSession {
390 inner: [u8; 0],
391 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
392}
393
394unsafe impl RefEncode for _NSModalSession {
395 const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("_NSModalSession", &[]));
396}
397
398pub type NSModalSession = *mut _NSModalSession;
402
403#[repr(transparent)]
406#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
407pub struct NSRequestUserAttentionType(pub NSUInteger);
408impl NSRequestUserAttentionType {
409 #[doc(alias = "NSCriticalRequest")]
410 pub const CriticalRequest: Self = Self(0);
411 #[doc(alias = "NSInformationalRequest")]
412 pub const InformationalRequest: Self = Self(10);
413}
414
415unsafe impl Encode for NSRequestUserAttentionType {
416 const ENCODING: Encoding = NSUInteger::ENCODING;
417}
418
419unsafe impl RefEncode for NSRequestUserAttentionType {
420 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
421}
422
423#[repr(transparent)]
426#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
427pub struct NSApplicationDelegateReply(pub NSUInteger);
428impl NSApplicationDelegateReply {
429 #[doc(alias = "NSApplicationDelegateReplySuccess")]
430 pub const Success: Self = Self(0);
431 #[doc(alias = "NSApplicationDelegateReplyCancel")]
432 pub const Cancel: Self = Self(1);
433 #[doc(alias = "NSApplicationDelegateReplyFailure")]
434 pub const Failure: Self = Self(2);
435}
436
437unsafe impl Encode for NSApplicationDelegateReply {
438 const ENCODING: Encoding = NSUInteger::ENCODING;
439}
440
441unsafe impl RefEncode for NSApplicationDelegateReply {
442 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
443}
444
445extern_class!(
446 #[unsafe(super(NSResponder, NSObject))]
448 #[derive(Debug, PartialEq, Eq, Hash)]
449 #[cfg(feature = "NSResponder")]
450 pub struct NSApplication;
451);
452
453#[cfg(all(feature = "NSAccessibilityProtocols", feature = "NSResponder"))]
454extern_conformance!(
455 unsafe impl NSAccessibility for NSApplication {}
456);
457
458#[cfg(all(feature = "NSAccessibilityProtocols", feature = "NSResponder"))]
459extern_conformance!(
460 unsafe impl NSAccessibilityElementProtocol for NSApplication {}
461);
462
463#[cfg(feature = "NSResponder")]
464extern_conformance!(
465 unsafe impl NSCoding for NSApplication {}
466);
467
468#[cfg(all(feature = "NSMenu", feature = "NSResponder"))]
469extern_conformance!(
470 unsafe impl NSMenuItemValidation for NSApplication {}
471);
472
473#[cfg(feature = "NSResponder")]
474extern_conformance!(
475 unsafe impl NSObjectProtocol for NSApplication {}
476);
477
478#[cfg(all(feature = "NSResponder", feature = "NSUserInterfaceValidation"))]
479extern_conformance!(
480 unsafe impl NSUserInterfaceValidations for NSApplication {}
481);
482
483#[cfg(feature = "NSResponder")]
484impl NSApplication {
485 extern_methods!(
486 #[unsafe(method(sharedApplication))]
487 #[unsafe(method_family = none)]
488 pub fn sharedApplication(mtm: MainThreadMarker) -> Retained<NSApplication>;
489
490 #[unsafe(method(delegate))]
491 #[unsafe(method_family = none)]
492 pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSApplicationDelegate>>>;
493
494 #[unsafe(method(setDelegate:))]
498 #[unsafe(method_family = none)]
499 pub fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSApplicationDelegate>>);
500
501 #[unsafe(method(hide:))]
502 #[unsafe(method_family = none)]
503 pub fn hide(&self, sender: Option<&AnyObject>);
504
505 #[unsafe(method(unhide:))]
506 #[unsafe(method_family = none)]
507 pub fn unhide(&self, sender: Option<&AnyObject>);
508
509 #[unsafe(method(unhideWithoutActivation))]
510 #[unsafe(method_family = none)]
511 pub fn unhideWithoutActivation(&self);
512
513 #[cfg(feature = "NSWindow")]
514 #[unsafe(method(windowWithWindowNumber:))]
515 #[unsafe(method_family = none)]
516 pub fn windowWithWindowNumber(&self, window_num: NSInteger) -> Option<Retained<NSWindow>>;
517
518 #[cfg(feature = "NSWindow")]
519 #[unsafe(method(mainWindow))]
520 #[unsafe(method_family = none)]
521 pub fn mainWindow(&self) -> Option<Retained<NSWindow>>;
522
523 #[cfg(feature = "NSWindow")]
524 #[unsafe(method(keyWindow))]
525 #[unsafe(method_family = none)]
526 pub fn keyWindow(&self) -> Option<Retained<NSWindow>>;
527
528 #[unsafe(method(isActive))]
529 #[unsafe(method_family = none)]
530 pub fn isActive(&self) -> bool;
531
532 #[unsafe(method(isHidden))]
533 #[unsafe(method_family = none)]
534 pub fn isHidden(&self) -> bool;
535
536 #[unsafe(method(isRunning))]
537 #[unsafe(method_family = none)]
538 pub fn isRunning(&self) -> bool;
539
540 #[unsafe(method(applicationShouldSuppressHighDynamicRangeContent))]
543 #[unsafe(method_family = none)]
544 pub fn applicationShouldSuppressHighDynamicRangeContent(&self) -> bool;
545
546 #[unsafe(method(deactivate))]
547 #[unsafe(method_family = none)]
548 pub fn deactivate(&self);
549
550 #[deprecated = "This method will be deprecated in a future release. Use NSApp.activate instead."]
553 #[unsafe(method(activateIgnoringOtherApps:))]
554 #[unsafe(method_family = none)]
555 pub fn activateIgnoringOtherApps(&self, ignore_other_apps: bool);
556
557 #[unsafe(method(activate))]
570 #[unsafe(method_family = none)]
571 pub fn activate(&self);
572
573 #[cfg(feature = "NSRunningApplication")]
574 #[unsafe(method(yieldActivationToApplication:))]
581 #[unsafe(method_family = none)]
582 pub fn yieldActivationToApplication(&self, application: &NSRunningApplication);
583
584 #[unsafe(method(yieldActivationToApplicationWithBundleIdentifier:))]
593 #[unsafe(method_family = none)]
594 pub fn yieldActivationToApplicationWithBundleIdentifier(
595 &self,
596 bundle_identifier: &NSString,
597 );
598
599 #[unsafe(method(hideOtherApplications:))]
600 #[unsafe(method_family = none)]
601 pub fn hideOtherApplications(&self, sender: Option<&AnyObject>);
602
603 #[unsafe(method(unhideAllApplications:))]
604 #[unsafe(method_family = none)]
605 pub fn unhideAllApplications(&self, sender: Option<&AnyObject>);
606
607 #[unsafe(method(finishLaunching))]
608 #[unsafe(method_family = none)]
609 pub fn finishLaunching(&self);
610
611 #[unsafe(method(run))]
612 #[unsafe(method_family = none)]
613 pub fn run(&self);
614
615 #[cfg(feature = "NSWindow")]
616 #[unsafe(method(runModalForWindow:))]
617 #[unsafe(method_family = none)]
618 pub fn runModalForWindow(&self, window: &NSWindow) -> NSModalResponse;
619
620 #[unsafe(method(stop:))]
621 #[unsafe(method_family = none)]
622 pub fn stop(&self, sender: Option<&AnyObject>);
623
624 #[unsafe(method(stopModal))]
625 #[unsafe(method_family = none)]
626 pub fn stopModal(&self);
627
628 #[unsafe(method(stopModalWithCode:))]
629 #[unsafe(method_family = none)]
630 pub fn stopModalWithCode(&self, return_code: NSModalResponse);
631
632 #[unsafe(method(abortModal))]
633 #[unsafe(method_family = none)]
634 pub fn abortModal(&self);
635
636 #[cfg(feature = "NSWindow")]
637 #[unsafe(method(modalWindow))]
638 #[unsafe(method_family = none)]
639 pub fn modalWindow(&self) -> Option<Retained<NSWindow>>;
640
641 #[cfg(feature = "NSWindow")]
642 #[unsafe(method(beginModalSessionForWindow:))]
643 #[unsafe(method_family = none)]
644 pub fn beginModalSessionForWindow(&self, window: &NSWindow) -> NSModalSession;
645
646 #[unsafe(method(runModalSession:))]
650 #[unsafe(method_family = none)]
651 pub unsafe fn runModalSession(&self, session: NSModalSession) -> NSModalResponse;
652
653 #[unsafe(method(endModalSession:))]
657 #[unsafe(method_family = none)]
658 pub unsafe fn endModalSession(&self, session: NSModalSession);
659
660 #[unsafe(method(terminate:))]
661 #[unsafe(method_family = none)]
662 pub fn terminate(&self, sender: Option<&AnyObject>);
663
664 #[unsafe(method(requestUserAttention:))]
666 #[unsafe(method_family = none)]
667 pub fn requestUserAttention(&self, request_type: NSRequestUserAttentionType) -> NSInteger;
668
669 #[unsafe(method(cancelUserAttentionRequest:))]
670 #[unsafe(method_family = none)]
671 pub fn cancelUserAttentionRequest(&self, request: NSInteger);
672
673 #[cfg(all(feature = "NSWindow", feature = "block2"))]
674 #[unsafe(method(enumerateWindowsWithOptions:usingBlock:))]
676 #[unsafe(method_family = none)]
677 pub fn enumerateWindowsWithOptions_usingBlock(
678 &self,
679 options: NSWindowListOptions,
680 block: &block2::DynBlock<dyn Fn(NonNull<NSWindow>, NonNull<Bool>) + '_>,
681 );
682
683 #[unsafe(method(preventWindowOrdering))]
684 #[unsafe(method_family = none)]
685 pub fn preventWindowOrdering(&self);
686
687 #[cfg(feature = "NSWindow")]
688 #[unsafe(method(windows))]
689 #[unsafe(method_family = none)]
690 pub fn windows(&self) -> Retained<NSArray<NSWindow>>;
691
692 #[unsafe(method(setWindowsNeedUpdate:))]
693 #[unsafe(method_family = none)]
694 pub fn setWindowsNeedUpdate(&self, need_update: bool);
695
696 #[unsafe(method(updateWindows))]
697 #[unsafe(method_family = none)]
698 pub fn updateWindows(&self);
699
700 #[cfg(feature = "NSMenu")]
701 #[unsafe(method(mainMenu))]
702 #[unsafe(method_family = none)]
703 pub fn mainMenu(&self) -> Option<Retained<NSMenu>>;
704
705 #[cfg(feature = "NSMenu")]
706 #[unsafe(method(setMainMenu:))]
708 #[unsafe(method_family = none)]
709 pub fn setMainMenu(&self, main_menu: Option<&NSMenu>);
710
711 #[cfg(feature = "NSMenu")]
712 #[unsafe(method(helpMenu))]
715 #[unsafe(method_family = none)]
716 pub fn helpMenu(&self) -> Option<Retained<NSMenu>>;
717
718 #[cfg(feature = "NSMenu")]
719 #[unsafe(method(setHelpMenu:))]
721 #[unsafe(method_family = none)]
722 pub fn setHelpMenu(&self, help_menu: Option<&NSMenu>);
723
724 #[cfg(feature = "NSImage")]
725 #[unsafe(method(applicationIconImage))]
726 #[unsafe(method_family = none)]
727 pub fn applicationIconImage(&self) -> Option<Retained<NSImage>>;
728
729 #[cfg(feature = "NSImage")]
730 #[unsafe(method(setApplicationIconImage:))]
736 #[unsafe(method_family = none)]
737 pub unsafe fn setApplicationIconImage(&self, application_icon_image: Option<&NSImage>);
738
739 #[cfg(feature = "NSRunningApplication")]
740 #[unsafe(method(activationPolicy))]
742 #[unsafe(method_family = none)]
743 pub fn activationPolicy(&self) -> NSApplicationActivationPolicy;
744
745 #[cfg(feature = "NSRunningApplication")]
746 #[unsafe(method(setActivationPolicy:))]
753 #[unsafe(method_family = none)]
754 pub fn setActivationPolicy(&self, activation_policy: NSApplicationActivationPolicy)
755 -> bool;
756
757 #[cfg(feature = "NSDockTile")]
758 #[unsafe(method(dockTile))]
759 #[unsafe(method_family = none)]
760 pub fn dockTile(&self) -> Retained<NSDockTile>;
761
762 #[unsafe(method(reportException:))]
763 #[unsafe(method_family = none)]
764 pub fn reportException(&self, exception: &NSException);
765
766 #[unsafe(method(detachDrawingThread:toTarget:withObject:))]
772 #[unsafe(method_family = none)]
773 pub unsafe fn detachDrawingThread_toTarget_withObject(
774 selector: Sel,
775 target: &AnyObject,
776 argument: Option<&AnyObject>,
777 mtm: MainThreadMarker,
778 );
779
780 #[unsafe(method(replyToApplicationShouldTerminate:))]
782 #[unsafe(method_family = none)]
783 pub fn replyToApplicationShouldTerminate(&self, should_terminate: bool);
784
785 #[unsafe(method(replyToOpenOrPrint:))]
790 #[unsafe(method_family = none)]
791 pub fn replyToOpenOrPrint(&self, reply: NSApplicationDelegateReply);
792
793 #[unsafe(method(orderFrontCharacterPalette:))]
795 #[unsafe(method_family = none)]
796 pub fn orderFrontCharacterPalette(&self, sender: Option<&AnyObject>);
797
798 #[unsafe(method(presentationOptions))]
802 #[unsafe(method_family = none)]
803 pub fn presentationOptions(&self) -> NSApplicationPresentationOptions;
804
805 #[unsafe(method(setPresentationOptions:))]
807 #[unsafe(method_family = none)]
808 pub fn setPresentationOptions(
809 &self,
810 presentation_options: NSApplicationPresentationOptions,
811 );
812
813 #[unsafe(method(currentSystemPresentationOptions))]
816 #[unsafe(method_family = none)]
817 pub fn currentSystemPresentationOptions(&self) -> NSApplicationPresentationOptions;
818
819 #[unsafe(method(occlusionState))]
820 #[unsafe(method_family = none)]
821 pub fn occlusionState(&self) -> NSApplicationOcclusionState;
822
823 #[unsafe(method(isProtectedDataAvailable))]
824 #[unsafe(method_family = none)]
825 pub fn isProtectedDataAvailable(&self) -> bool;
826 );
827}
828
829#[cfg(feature = "NSResponder")]
831impl NSApplication {
832 extern_methods!(
833 #[unsafe(method(init))]
834 #[unsafe(method_family = init)]
835 pub fn init(this: Allocated<Self>) -> Retained<Self>;
836
837 #[unsafe(method(initWithCoder:))]
841 #[unsafe(method_family = init)]
842 pub unsafe fn initWithCoder(
843 this: Allocated<Self>,
844 coder: &NSCoder,
845 ) -> Option<Retained<Self>>;
846 );
847}
848
849#[cfg(feature = "NSResponder")]
851impl NSApplication {
852 extern_methods!(
853 #[unsafe(method(new))]
854 #[unsafe(method_family = new)]
855 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
856 );
857}
858
859#[cfg(feature = "NSResponder")]
861impl NSApplication {
862 extern_methods!(
863 #[cfg(feature = "NSAppearance")]
864 #[unsafe(method(appearance))]
865 #[unsafe(method_family = none)]
866 pub fn appearance(&self) -> Option<Retained<NSAppearance>>;
867
868 #[cfg(feature = "NSAppearance")]
869 #[unsafe(method(setAppearance:))]
871 #[unsafe(method_family = none)]
872 pub fn setAppearance(&self, appearance: Option<&NSAppearance>);
873
874 #[cfg(feature = "NSAppearance")]
875 #[unsafe(method(effectiveAppearance))]
876 #[unsafe(method_family = none)]
877 pub fn effectiveAppearance(&self) -> Retained<NSAppearance>;
878 );
879}
880
881#[cfg(all(feature = "NSAppearance", feature = "NSResponder"))]
882extern_conformance!(
883 unsafe impl NSAppearanceCustomization for NSApplication {}
884);
885
886#[cfg(feature = "NSResponder")]
888impl NSApplication {
889 extern_methods!(
890 #[cfg(feature = "NSEvent")]
891 #[unsafe(method(sendEvent:))]
892 #[unsafe(method_family = none)]
893 pub fn sendEvent(&self, event: &NSEvent);
894
895 #[cfg(feature = "NSEvent")]
896 #[unsafe(method(postEvent:atStart:))]
897 #[unsafe(method_family = none)]
898 pub fn postEvent_atStart(&self, event: &NSEvent, at_start: bool);
899
900 #[cfg(feature = "NSEvent")]
901 #[unsafe(method(currentEvent))]
902 #[unsafe(method_family = none)]
903 pub fn currentEvent(&self) -> Option<Retained<NSEvent>>;
904
905 #[cfg(feature = "NSEvent")]
906 #[unsafe(method(nextEventMatchingMask:untilDate:inMode:dequeue:))]
907 #[unsafe(method_family = none)]
908 pub fn nextEventMatchingMask_untilDate_inMode_dequeue(
909 &self,
910 mask: NSEventMask,
911 expiration: Option<&NSDate>,
912 mode: &NSRunLoopMode,
913 deq_flag: bool,
914 ) -> Option<Retained<NSEvent>>;
915
916 #[cfg(feature = "NSEvent")]
917 #[unsafe(method(discardEventsMatchingMask:beforeEvent:))]
918 #[unsafe(method_family = none)]
919 pub fn discardEventsMatchingMask_beforeEvent(
920 &self,
921 mask: NSEventMask,
922 last_event: Option<&NSEvent>,
923 );
924 );
925}
926
927#[cfg(feature = "NSResponder")]
929impl NSApplication {
930 extern_methods!(
931 #[unsafe(method(sendAction:to:from:))]
937 #[unsafe(method_family = none)]
938 pub unsafe fn sendAction_to_from(
939 &self,
940 action: Sel,
941 target: Option<&AnyObject>,
942 sender: Option<&AnyObject>,
943 ) -> bool;
944
945 #[unsafe(method(targetForAction:))]
949 #[unsafe(method_family = none)]
950 pub unsafe fn targetForAction(&self, action: Sel) -> Option<Retained<AnyObject>>;
951
952 #[unsafe(method(targetForAction:to:from:))]
958 #[unsafe(method_family = none)]
959 pub unsafe fn targetForAction_to_from(
960 &self,
961 action: Sel,
962 target: Option<&AnyObject>,
963 sender: Option<&AnyObject>,
964 ) -> Option<Retained<AnyObject>>;
965
966 #[unsafe(method(tryToPerform:with:))]
971 #[unsafe(method_family = none)]
972 pub unsafe fn tryToPerform_with(&self, action: Sel, object: Option<&AnyObject>) -> bool;
973
974 #[cfg(feature = "NSPasteboard")]
975 #[unsafe(method(validRequestorForSendType:returnType:))]
976 #[unsafe(method_family = none)]
977 pub fn validRequestorForSendType_returnType(
978 &self,
979 send_type: Option<&NSPasteboardType>,
980 return_type: Option<&NSPasteboardType>,
981 ) -> Option<Retained<AnyObject>>;
982 );
983}
984
985#[cfg(feature = "NSResponder")]
987impl NSApplication {
988 extern_methods!(
989 #[cfg(feature = "NSMenu")]
990 #[unsafe(method(windowsMenu))]
991 #[unsafe(method_family = none)]
992 pub fn windowsMenu(&self) -> Option<Retained<NSMenu>>;
993
994 #[cfg(feature = "NSMenu")]
995 #[unsafe(method(setWindowsMenu:))]
997 #[unsafe(method_family = none)]
998 pub fn setWindowsMenu(&self, windows_menu: Option<&NSMenu>);
999
1000 #[unsafe(method(arrangeInFront:))]
1001 #[unsafe(method_family = none)]
1002 pub fn arrangeInFront(&self, sender: Option<&AnyObject>);
1003
1004 #[cfg(feature = "NSWindow")]
1005 #[unsafe(method(removeWindowsItem:))]
1006 #[unsafe(method_family = none)]
1007 pub fn removeWindowsItem(&self, win: &NSWindow);
1008
1009 #[cfg(feature = "NSWindow")]
1010 #[unsafe(method(addWindowsItem:title:filename:))]
1011 #[unsafe(method_family = none)]
1012 pub fn addWindowsItem_title_filename(
1013 &self,
1014 win: &NSWindow,
1015 string: &NSString,
1016 is_filename: bool,
1017 );
1018
1019 #[cfg(feature = "NSWindow")]
1020 #[unsafe(method(changeWindowsItem:title:filename:))]
1021 #[unsafe(method_family = none)]
1022 pub fn changeWindowsItem_title_filename(
1023 &self,
1024 win: &NSWindow,
1025 string: &NSString,
1026 is_filename: bool,
1027 );
1028
1029 #[cfg(feature = "NSWindow")]
1030 #[unsafe(method(updateWindowsItem:))]
1031 #[unsafe(method_family = none)]
1032 pub fn updateWindowsItem(&self, win: &NSWindow);
1033
1034 #[unsafe(method(miniaturizeAll:))]
1035 #[unsafe(method_family = none)]
1036 pub fn miniaturizeAll(&self, sender: Option<&AnyObject>);
1037 );
1038}
1039
1040#[cfg(feature = "NSResponder")]
1042impl NSApplication {
1043 extern_methods!(
1044 #[unsafe(method(isFullKeyboardAccessEnabled))]
1048 #[unsafe(method_family = none)]
1049 pub fn isFullKeyboardAccessEnabled(&self) -> bool;
1050 );
1051}
1052
1053#[repr(transparent)]
1058#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1059pub struct NSApplicationTerminateReply(pub NSUInteger);
1060impl NSApplicationTerminateReply {
1061 #[doc(alias = "NSTerminateCancel")]
1062 pub const TerminateCancel: Self = Self(0);
1063 #[doc(alias = "NSTerminateNow")]
1064 pub const TerminateNow: Self = Self(1);
1065 #[doc(alias = "NSTerminateLater")]
1066 pub const TerminateLater: Self = Self(2);
1067}
1068
1069unsafe impl Encode for NSApplicationTerminateReply {
1070 const ENCODING: Encoding = NSUInteger::ENCODING;
1071}
1072
1073unsafe impl RefEncode for NSApplicationTerminateReply {
1074 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1075}
1076
1077#[repr(transparent)]
1082#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1083pub struct NSApplicationPrintReply(pub NSUInteger);
1084impl NSApplicationPrintReply {
1085 #[doc(alias = "NSPrintingCancelled")]
1086 pub const PrintingCancelled: Self = Self(0);
1087 #[doc(alias = "NSPrintingSuccess")]
1088 pub const PrintingSuccess: Self = Self(1);
1089 #[doc(alias = "NSPrintingReplyLater")]
1090 pub const PrintingReplyLater: Self = Self(2);
1091 #[doc(alias = "NSPrintingFailure")]
1092 pub const PrintingFailure: Self = Self(3);
1093}
1094
1095unsafe impl Encode for NSApplicationPrintReply {
1096 const ENCODING: Encoding = NSUInteger::ENCODING;
1097}
1098
1099unsafe impl RefEncode for NSApplicationPrintReply {
1100 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1101}
1102
1103extern_protocol!(
1104 pub unsafe trait NSApplicationDelegate: NSObjectProtocol + MainThreadOnly {
1106 #[cfg(feature = "NSResponder")]
1107 #[optional]
1116 #[unsafe(method(applicationShouldTerminate:))]
1117 #[unsafe(method_family = none)]
1118 fn applicationShouldTerminate(&self, sender: &NSApplication)
1119 -> NSApplicationTerminateReply;
1120
1121 #[cfg(feature = "NSResponder")]
1122 #[optional]
1128 #[unsafe(method(application:openURLs:))]
1129 #[unsafe(method_family = none)]
1130 fn application_openURLs(&self, application: &NSApplication, urls: &NSArray<NSURL>);
1131
1132 #[cfg(feature = "NSResponder")]
1133 #[optional]
1134 #[unsafe(method(application:openFile:))]
1135 #[unsafe(method_family = none)]
1136 fn application_openFile(&self, sender: &NSApplication, filename: &NSString) -> bool;
1137
1138 #[cfg(feature = "NSResponder")]
1139 #[optional]
1140 #[unsafe(method(application:openFiles:))]
1141 #[unsafe(method_family = none)]
1142 fn application_openFiles(&self, sender: &NSApplication, filenames: &NSArray<NSString>);
1143
1144 #[cfg(feature = "NSResponder")]
1145 #[optional]
1146 #[unsafe(method(application:openTempFile:))]
1147 #[unsafe(method_family = none)]
1148 fn application_openTempFile(&self, sender: &NSApplication, filename: &NSString) -> bool;
1149
1150 #[cfg(feature = "NSResponder")]
1151 #[optional]
1152 #[unsafe(method(applicationShouldOpenUntitledFile:))]
1153 #[unsafe(method_family = none)]
1154 fn applicationShouldOpenUntitledFile(&self, sender: &NSApplication) -> bool;
1155
1156 #[cfg(feature = "NSResponder")]
1157 #[optional]
1158 #[unsafe(method(applicationOpenUntitledFile:))]
1159 #[unsafe(method_family = none)]
1160 fn applicationOpenUntitledFile(&self, sender: &NSApplication) -> bool;
1161
1162 #[optional]
1166 #[unsafe(method(application:openFileWithoutUI:))]
1167 #[unsafe(method_family = none)]
1168 unsafe fn application_openFileWithoutUI(
1169 &self,
1170 sender: &AnyObject,
1171 filename: &NSString,
1172 ) -> bool;
1173
1174 #[cfg(feature = "NSResponder")]
1175 #[optional]
1176 #[unsafe(method(application:printFile:))]
1177 #[unsafe(method_family = none)]
1178 fn application_printFile(&self, sender: &NSApplication, filename: &NSString) -> bool;
1179
1180 #[cfg(all(feature = "NSPrintInfo", feature = "NSResponder"))]
1181 #[optional]
1185 #[unsafe(method(application:printFiles:withSettings:showPrintPanels:))]
1186 #[unsafe(method_family = none)]
1187 unsafe fn application_printFiles_withSettings_showPrintPanels(
1188 &self,
1189 application: &NSApplication,
1190 file_names: &NSArray<NSString>,
1191 print_settings: &NSDictionary<NSPrintInfoAttributeKey, AnyObject>,
1192 show_print_panels: bool,
1193 ) -> NSApplicationPrintReply;
1194
1195 #[cfg(feature = "NSResponder")]
1196 #[optional]
1197 #[unsafe(method(applicationShouldTerminateAfterLastWindowClosed:))]
1198 #[unsafe(method_family = none)]
1199 fn applicationShouldTerminateAfterLastWindowClosed(&self, sender: &NSApplication) -> bool;
1200
1201 #[cfg(feature = "NSResponder")]
1202 #[optional]
1203 #[unsafe(method(applicationShouldHandleReopen:hasVisibleWindows:))]
1204 #[unsafe(method_family = none)]
1205 fn applicationShouldHandleReopen_hasVisibleWindows(
1206 &self,
1207 sender: &NSApplication,
1208 has_visible_windows: bool,
1209 ) -> bool;
1210
1211 #[cfg(all(feature = "NSMenu", feature = "NSResponder"))]
1212 #[optional]
1213 #[unsafe(method(applicationDockMenu:))]
1214 #[unsafe(method_family = none)]
1215 fn applicationDockMenu(&self, sender: &NSApplication) -> Option<Retained<NSMenu>>;
1216
1217 #[cfg(feature = "NSResponder")]
1218 #[optional]
1219 #[unsafe(method(application:willPresentError:))]
1220 #[unsafe(method_family = none)]
1221 fn application_willPresentError(
1222 &self,
1223 application: &NSApplication,
1224 error: &NSError,
1225 ) -> Retained<NSError>;
1226
1227 #[cfg(feature = "NSResponder")]
1228 #[optional]
1229 #[unsafe(method(application:didRegisterForRemoteNotificationsWithDeviceToken:))]
1230 #[unsafe(method_family = none)]
1231 fn application_didRegisterForRemoteNotificationsWithDeviceToken(
1232 &self,
1233 application: &NSApplication,
1234 device_token: &NSData,
1235 );
1236
1237 #[cfg(feature = "NSResponder")]
1238 #[optional]
1239 #[unsafe(method(application:didFailToRegisterForRemoteNotificationsWithError:))]
1240 #[unsafe(method_family = none)]
1241 fn application_didFailToRegisterForRemoteNotificationsWithError(
1242 &self,
1243 application: &NSApplication,
1244 error: &NSError,
1245 );
1246
1247 #[cfg(feature = "NSResponder")]
1248 #[optional]
1252 #[unsafe(method(application:didReceiveRemoteNotification:))]
1253 #[unsafe(method_family = none)]
1254 unsafe fn application_didReceiveRemoteNotification(
1255 &self,
1256 application: &NSApplication,
1257 user_info: &NSDictionary<NSString, AnyObject>,
1258 );
1259
1260 #[cfg(feature = "NSResponder")]
1261 #[optional]
1272 #[unsafe(method(applicationSupportsSecureRestorableState:))]
1273 #[unsafe(method_family = none)]
1274 fn applicationSupportsSecureRestorableState(&self, app: &NSApplication) -> bool;
1275
1276 #[cfg(feature = "NSResponder")]
1277 #[optional]
1284 #[unsafe(method(application:willEncodeRestorableState:))]
1285 #[unsafe(method_family = none)]
1286 unsafe fn application_willEncodeRestorableState(
1287 &self,
1288 app: &NSApplication,
1289 coder: &NSCoder,
1290 );
1291
1292 #[cfg(feature = "NSResponder")]
1293 #[optional]
1300 #[unsafe(method(application:didDecodeRestorableState:))]
1301 #[unsafe(method_family = none)]
1302 unsafe fn application_didDecodeRestorableState(&self, app: &NSApplication, coder: &NSCoder);
1303
1304 #[cfg(feature = "NSResponder")]
1305 #[optional]
1312 #[unsafe(method(application:willContinueUserActivityWithType:))]
1313 #[unsafe(method_family = none)]
1314 fn application_willContinueUserActivityWithType(
1315 &self,
1316 application: &NSApplication,
1317 user_activity_type: &NSString,
1318 ) -> bool;
1319
1320 #[cfg(all(
1321 feature = "NSResponder",
1322 feature = "NSUserActivity",
1323 feature = "block2"
1324 ))]
1325 #[optional]
1340 #[unsafe(method(application:continueUserActivity:restorationHandler:))]
1341 #[unsafe(method_family = none)]
1342 fn application_continueUserActivity_restorationHandler(
1343 &self,
1344 application: &NSApplication,
1345 user_activity: &NSUserActivity,
1346 restoration_handler: &block2::DynBlock<
1347 dyn Fn(NonNull<NSArray<ProtocolObject<dyn NSUserActivityRestoring>>>),
1348 >,
1349 ) -> bool;
1350
1351 #[cfg(feature = "NSResponder")]
1352 #[optional]
1355 #[unsafe(method(application:didFailToContinueUserActivityWithType:error:))]
1356 #[unsafe(method_family = none)]
1357 fn application_didFailToContinueUserActivityWithType_error(
1358 &self,
1359 application: &NSApplication,
1360 user_activity_type: &NSString,
1361 error: &NSError,
1362 );
1363
1364 #[cfg(feature = "NSResponder")]
1365 #[optional]
1368 #[unsafe(method(application:didUpdateUserActivity:))]
1369 #[unsafe(method_family = none)]
1370 fn application_didUpdateUserActivity(
1371 &self,
1372 application: &NSApplication,
1373 user_activity: &NSUserActivity,
1374 );
1375
1376 #[cfg(all(feature = "NSResponder", feature = "objc2-cloud-kit"))]
1377 #[cfg(target_vendor = "apple")]
1378 #[optional]
1387 #[unsafe(method(application:userDidAcceptCloudKitShareWithMetadata:))]
1388 #[unsafe(method_family = none)]
1389 fn application_userDidAcceptCloudKitShareWithMetadata(
1390 &self,
1391 application: &NSApplication,
1392 metadata: &CKShareMetadata,
1393 );
1394
1395 #[cfg(feature = "NSResponder")]
1396 #[optional]
1399 #[unsafe(method(application:delegateHandlesKey:))]
1400 #[unsafe(method_family = none)]
1401 fn application_delegateHandlesKey(&self, sender: &NSApplication, key: &NSString) -> bool;
1402
1403 #[cfg(feature = "NSResponder")]
1404 #[optional]
1410 #[unsafe(method(applicationShouldAutomaticallyLocalizeKeyEquivalents:))]
1411 #[unsafe(method_family = none)]
1412 fn applicationShouldAutomaticallyLocalizeKeyEquivalents(
1413 &self,
1414 application: &NSApplication,
1415 ) -> bool;
1416
1417 #[optional]
1418 #[unsafe(method(applicationWillFinishLaunching:))]
1419 #[unsafe(method_family = none)]
1420 fn applicationWillFinishLaunching(&self, notification: &NSNotification);
1421
1422 #[optional]
1423 #[unsafe(method(applicationDidFinishLaunching:))]
1424 #[unsafe(method_family = none)]
1425 fn applicationDidFinishLaunching(&self, notification: &NSNotification);
1426
1427 #[optional]
1428 #[unsafe(method(applicationWillHide:))]
1429 #[unsafe(method_family = none)]
1430 fn applicationWillHide(&self, notification: &NSNotification);
1431
1432 #[optional]
1433 #[unsafe(method(applicationDidHide:))]
1434 #[unsafe(method_family = none)]
1435 fn applicationDidHide(&self, notification: &NSNotification);
1436
1437 #[optional]
1438 #[unsafe(method(applicationWillUnhide:))]
1439 #[unsafe(method_family = none)]
1440 fn applicationWillUnhide(&self, notification: &NSNotification);
1441
1442 #[optional]
1443 #[unsafe(method(applicationDidUnhide:))]
1444 #[unsafe(method_family = none)]
1445 fn applicationDidUnhide(&self, notification: &NSNotification);
1446
1447 #[optional]
1448 #[unsafe(method(applicationWillBecomeActive:))]
1449 #[unsafe(method_family = none)]
1450 fn applicationWillBecomeActive(&self, notification: &NSNotification);
1451
1452 #[optional]
1453 #[unsafe(method(applicationDidBecomeActive:))]
1454 #[unsafe(method_family = none)]
1455 fn applicationDidBecomeActive(&self, notification: &NSNotification);
1456
1457 #[optional]
1458 #[unsafe(method(applicationWillResignActive:))]
1459 #[unsafe(method_family = none)]
1460 fn applicationWillResignActive(&self, notification: &NSNotification);
1461
1462 #[optional]
1463 #[unsafe(method(applicationDidResignActive:))]
1464 #[unsafe(method_family = none)]
1465 fn applicationDidResignActive(&self, notification: &NSNotification);
1466
1467 #[optional]
1468 #[unsafe(method(applicationWillUpdate:))]
1469 #[unsafe(method_family = none)]
1470 fn applicationWillUpdate(&self, notification: &NSNotification);
1471
1472 #[optional]
1473 #[unsafe(method(applicationDidUpdate:))]
1474 #[unsafe(method_family = none)]
1475 fn applicationDidUpdate(&self, notification: &NSNotification);
1476
1477 #[optional]
1478 #[unsafe(method(applicationWillTerminate:))]
1479 #[unsafe(method_family = none)]
1480 fn applicationWillTerminate(&self, notification: &NSNotification);
1481
1482 #[optional]
1483 #[unsafe(method(applicationDidChangeScreenParameters:))]
1484 #[unsafe(method_family = none)]
1485 fn applicationDidChangeScreenParameters(&self, notification: &NSNotification);
1486
1487 #[optional]
1488 #[unsafe(method(applicationDidChangeOcclusionState:))]
1489 #[unsafe(method_family = none)]
1490 fn applicationDidChangeOcclusionState(&self, notification: &NSNotification);
1491
1492 #[optional]
1493 #[unsafe(method(applicationProtectedDataWillBecomeUnavailable:))]
1494 #[unsafe(method_family = none)]
1495 fn applicationProtectedDataWillBecomeUnavailable(&self, notification: &NSNotification);
1496
1497 #[optional]
1498 #[unsafe(method(applicationProtectedDataDidBecomeAvailable:))]
1499 #[unsafe(method_family = none)]
1500 fn applicationProtectedDataDidBecomeAvailable(&self, notification: &NSNotification);
1501 }
1502);
1503
1504#[cfg(feature = "NSResponder")]
1506impl NSApplication {
1507 extern_methods!(
1508 #[cfg(feature = "NSMenu")]
1509 #[unsafe(method(servicesMenu))]
1510 #[unsafe(method_family = none)]
1511 pub fn servicesMenu(&self) -> Option<Retained<NSMenu>>;
1512
1513 #[cfg(feature = "NSMenu")]
1514 #[unsafe(method(setServicesMenu:))]
1516 #[unsafe(method_family = none)]
1517 pub fn setServicesMenu(&self, services_menu: Option<&NSMenu>);
1518
1519 #[cfg(feature = "NSPasteboard")]
1520 #[unsafe(method(registerServicesMenuSendTypes:returnTypes:))]
1521 #[unsafe(method_family = none)]
1522 pub fn registerServicesMenuSendTypes_returnTypes(
1523 &self,
1524 send_types: &NSArray<NSPasteboardType>,
1525 return_types: &NSArray<NSPasteboardType>,
1526 );
1527 );
1528}
1529
1530extern_protocol!(
1531 pub unsafe trait NSServicesMenuRequestor: NSObjectProtocol {
1533 #[cfg(feature = "NSPasteboard")]
1534 #[optional]
1535 #[unsafe(method(writeSelectionToPasteboard:types:))]
1536 #[unsafe(method_family = none)]
1537 fn writeSelectionToPasteboard_types(
1538 &self,
1539 pboard: &NSPasteboard,
1540 types: &NSArray<NSPasteboardType>,
1541 ) -> bool;
1542
1543 #[cfg(feature = "NSPasteboard")]
1544 #[optional]
1545 #[unsafe(method(readSelectionFromPasteboard:))]
1546 #[unsafe(method_family = none)]
1547 fn readSelectionFromPasteboard(&self, pboard: &NSPasteboard) -> bool;
1548 }
1549);
1550
1551#[cfg(feature = "NSResponder")]
1553impl NSApplication {
1554 extern_methods!(
1555 #[unsafe(method(servicesProvider))]
1556 #[unsafe(method_family = none)]
1557 pub fn servicesProvider(&self) -> Option<Retained<AnyObject>>;
1558
1559 #[unsafe(method(setServicesProvider:))]
1565 #[unsafe(method_family = none)]
1566 pub unsafe fn setServicesProvider(&self, services_provider: Option<&AnyObject>);
1567 );
1568}
1569
1570pub type NSAboutPanelOptionKey = NSString;
1576
1577extern "C" {
1578 pub static NSAboutPanelOptionCredits: &'static NSAboutPanelOptionKey;
1582}
1583
1584extern "C" {
1585 pub static NSAboutPanelOptionApplicationName: &'static NSAboutPanelOptionKey;
1589}
1590
1591extern "C" {
1592 pub static NSAboutPanelOptionApplicationIcon: &'static NSAboutPanelOptionKey;
1598}
1599
1600extern "C" {
1601 pub static NSAboutPanelOptionVersion: &'static NSAboutPanelOptionKey;
1605}
1606
1607extern "C" {
1608 pub static NSAboutPanelOptionApplicationVersion: &'static NSAboutPanelOptionKey;
1612}
1613
1614#[cfg(feature = "NSResponder")]
1616impl NSApplication {
1617 extern_methods!(
1618 #[unsafe(method(orderFrontStandardAboutPanel:))]
1619 #[unsafe(method_family = none)]
1620 pub fn orderFrontStandardAboutPanel(&self, sender: Option<&AnyObject>);
1621
1622 #[unsafe(method(orderFrontStandardAboutPanelWithOptions:))]
1626 #[unsafe(method_family = none)]
1627 pub unsafe fn orderFrontStandardAboutPanelWithOptions(
1628 &self,
1629 options_dictionary: &NSDictionary<NSAboutPanelOptionKey, AnyObject>,
1630 );
1631 );
1632}
1633
1634#[cfg(feature = "NSResponder")]
1636impl NSApplication {
1637 extern_methods!(
1638 #[cfg(feature = "NSUserInterfaceLayout")]
1639 #[unsafe(method(userInterfaceLayoutDirection))]
1640 #[unsafe(method_family = none)]
1641 pub fn userInterfaceLayoutDirection(&self) -> NSUserInterfaceLayoutDirection;
1642 );
1643}
1644
1645#[cfg(feature = "NSResponder")]
1647impl NSApplication {
1648 extern_methods!(
1649 #[unsafe(method(disableRelaunchOnLogin))]
1657 #[unsafe(method_family = none)]
1658 pub fn disableRelaunchOnLogin(&self);
1659
1660 #[unsafe(method(enableRelaunchOnLogin))]
1661 #[unsafe(method_family = none)]
1662 pub fn enableRelaunchOnLogin(&self);
1663 );
1664}
1665
1666#[repr(transparent)]
1672#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1673pub struct NSRemoteNotificationType(pub NSUInteger);
1674bitflags::bitflags! {
1675 impl NSRemoteNotificationType: NSUInteger {
1676 #[doc(alias = "NSRemoteNotificationTypeNone")]
1677 const None = 0;
1678 #[doc(alias = "NSRemoteNotificationTypeBadge")]
1679 const Badge = 1<<0;
1680 #[doc(alias = "NSRemoteNotificationTypeSound")]
1681 const Sound = 1<<1;
1682 #[doc(alias = "NSRemoteNotificationTypeAlert")]
1683 const Alert = 1<<2;
1684 }
1685}
1686
1687unsafe impl Encode for NSRemoteNotificationType {
1688 const ENCODING: Encoding = NSUInteger::ENCODING;
1689}
1690
1691unsafe impl RefEncode for NSRemoteNotificationType {
1692 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1693}
1694
1695#[cfg(feature = "NSResponder")]
1697impl NSApplication {
1698 extern_methods!(
1699 #[unsafe(method(registerForRemoteNotifications))]
1700 #[unsafe(method_family = none)]
1701 pub fn registerForRemoteNotifications(&self);
1702
1703 #[unsafe(method(unregisterForRemoteNotifications))]
1704 #[unsafe(method_family = none)]
1705 pub fn unregisterForRemoteNotifications(&self);
1706
1707 #[unsafe(method(isRegisteredForRemoteNotifications))]
1709 #[unsafe(method_family = none)]
1710 pub fn isRegisteredForRemoteNotifications(&self) -> bool;
1711
1712 #[unsafe(method(registerForRemoteNotificationTypes:))]
1715 #[unsafe(method_family = none)]
1716 pub fn registerForRemoteNotificationTypes(&self, types: NSRemoteNotificationType);
1717
1718 #[unsafe(method(enabledRemoteNotificationTypes))]
1719 #[unsafe(method_family = none)]
1720 pub fn enabledRemoteNotificationTypes(&self) -> NSRemoteNotificationType;
1721 );
1722}
1723
1724#[cfg(feature = "NSResponder")]
1725impl NSApplication {
1726 #[doc(alias = "NSApplicationMain")]
1732 #[inline]
1733 pub(crate) unsafe fn __main(argc: c_int, argv: NonNull<NonNull<c_char>>) -> c_int {
1734 extern "C-unwind" {
1735 fn NSApplicationMain(argc: c_int, argv: NonNull<NonNull<c_char>>) -> c_int;
1736 }
1737 unsafe { NSApplicationMain(argc, argv) }
1738 }
1739
1740 #[doc(alias = "NSApplicationLoad")]
1743 #[inline]
1744 pub fn load() -> bool {
1745 extern "C-unwind" {
1746 fn NSApplicationLoad() -> Bool;
1747 }
1748 unsafe { NSApplicationLoad() }.as_bool()
1749 }
1750}
1751
1752#[inline]
1755pub extern "C-unwind" fn NSShowsServicesMenuItem(item_name: &NSString) -> bool {
1756 extern "C-unwind" {
1757 fn NSShowsServicesMenuItem(item_name: &NSString) -> Bool;
1758 }
1759 unsafe { NSShowsServicesMenuItem(item_name) }.as_bool()
1760}
1761
1762#[inline]
1764pub extern "C-unwind" fn NSSetShowsServicesMenuItem(
1765 item_name: &NSString,
1766 enabled: bool,
1767) -> NSInteger {
1768 extern "C-unwind" {
1769 fn NSSetShowsServicesMenuItem(item_name: &NSString, enabled: Bool) -> NSInteger;
1770 }
1771 unsafe { NSSetShowsServicesMenuItem(item_name, Bool::new(enabled)) }
1772}
1773
1774#[inline]
1777pub extern "C-unwind" fn NSUpdateDynamicServices() {
1778 extern "C-unwind" {
1779 fn NSUpdateDynamicServices();
1780 }
1781 unsafe { NSUpdateDynamicServices() }
1782}
1783
1784#[cfg(feature = "NSPasteboard")]
1785#[inline]
1786pub extern "C-unwind" fn NSPerformService(
1787 item_name: &NSString,
1788 pboard: Option<&NSPasteboard>,
1789) -> bool {
1790 extern "C-unwind" {
1791 fn NSPerformService(item_name: &NSString, pboard: Option<&NSPasteboard>) -> Bool;
1792 }
1793 unsafe { NSPerformService(item_name, pboard) }.as_bool()
1794}
1795
1796pub type NSServiceProviderName = NSString;
1798
1799extern "C-unwind" {
1800 pub fn NSRegisterServicesProvider(provider: Option<&AnyObject>, name: &NSServiceProviderName);
1806}
1807
1808#[inline]
1809pub extern "C-unwind" fn NSUnregisterServicesProvider(name: &NSServiceProviderName) {
1810 extern "C-unwind" {
1811 fn NSUnregisterServicesProvider(name: &NSServiceProviderName);
1812 }
1813 unsafe { NSUnregisterServicesProvider(name) }
1814}
1815
1816extern "C" {
1817 pub static NSApplicationDidBecomeActiveNotification: &'static NSNotificationName;
1819}
1820
1821extern "C" {
1822 pub static NSApplicationDidHideNotification: &'static NSNotificationName;
1824}
1825
1826extern "C" {
1827 pub static NSApplicationDidFinishLaunchingNotification: &'static NSNotificationName;
1829}
1830
1831extern "C" {
1832 pub static NSApplicationDidResignActiveNotification: &'static NSNotificationName;
1834}
1835
1836extern "C" {
1837 pub static NSApplicationDidUnhideNotification: &'static NSNotificationName;
1839}
1840
1841extern "C" {
1842 pub static NSApplicationDidUpdateNotification: &'static NSNotificationName;
1844}
1845
1846extern "C" {
1847 pub static NSApplicationWillBecomeActiveNotification: &'static NSNotificationName;
1849}
1850
1851extern "C" {
1852 pub static NSApplicationWillHideNotification: &'static NSNotificationName;
1854}
1855
1856extern "C" {
1857 pub static NSApplicationWillFinishLaunchingNotification: &'static NSNotificationName;
1859}
1860
1861extern "C" {
1862 pub static NSApplicationWillResignActiveNotification: &'static NSNotificationName;
1864}
1865
1866extern "C" {
1867 pub static NSApplicationWillUnhideNotification: &'static NSNotificationName;
1869}
1870
1871extern "C" {
1872 pub static NSApplicationWillUpdateNotification: &'static NSNotificationName;
1874}
1875
1876extern "C" {
1877 pub static NSApplicationWillTerminateNotification: &'static NSNotificationName;
1879}
1880
1881extern "C" {
1882 pub static NSApplicationDidChangeScreenParametersNotification: &'static NSNotificationName;
1884}
1885
1886extern "C" {
1887 pub static NSApplicationProtectedDataWillBecomeUnavailableNotification:
1889 &'static NSNotificationName;
1890}
1891
1892extern "C" {
1893 pub static NSApplicationProtectedDataDidBecomeAvailableNotification:
1895 &'static NSNotificationName;
1896}
1897
1898extern "C" {
1899 pub static NSApplicationShouldBeginSuppressingHighDynamicRangeContentNotification:
1901 &'static NSNotificationName;
1902}
1903
1904extern "C" {
1905 pub static NSApplicationShouldEndSuppressingHighDynamicRangeContentNotification:
1907 &'static NSNotificationName;
1908}
1909
1910extern "C" {
1911 pub static NSApplicationLaunchIsDefaultLaunchKey: &'static NSString;
1915}
1916
1917extern "C" {
1918 pub static NSApplicationLaunchUserNotificationKey: &'static NSString;
1922}
1923
1924extern "C" {
1925 #[deprecated]
1929 pub static NSApplicationLaunchRemoteNotificationKey: &'static NSString;
1930}
1931
1932extern "C" {
1933 pub static NSApplicationDidChangeOcclusionStateNotification: &'static NSNotificationName;
1937}
1938
1939#[deprecated = "Use NSModalResponseStop instead"]
1941pub const NSRunStoppedResponse: c_int = -1000;
1942#[deprecated = "Use NSModalResponseAbort instead"]
1944pub const NSRunAbortedResponse: c_int = -1001;
1945#[deprecated = "Use NSModalResponseContinue instead"]
1947pub const NSRunContinuesResponse: c_int = -1002;
1948
1949#[cfg(feature = "NSResponder")]
1951impl NSApplication {
1952 extern_methods!(
1953 #[cfg(feature = "NSWindow")]
1954 #[deprecated = "Use -[NSWindow beginSheet:completionHandler:] instead"]
1961 #[unsafe(method(runModalForWindow:relativeToWindow:))]
1962 #[unsafe(method_family = none)]
1963 pub unsafe fn runModalForWindow_relativeToWindow(
1964 &self,
1965 window: Option<&NSWindow>,
1966 doc_window: Option<&NSWindow>,
1967 ) -> NSInteger;
1968
1969 #[cfg(feature = "NSWindow")]
1970 #[deprecated = "Use -[NSWindow beginSheet:completionHandler:] instead"]
1977 #[unsafe(method(beginModalSessionForWindow:relativeToWindow:))]
1978 #[unsafe(method_family = none)]
1979 pub unsafe fn beginModalSessionForWindow_relativeToWindow(
1980 &self,
1981 window: Option<&NSWindow>,
1982 doc_window: Option<&NSWindow>,
1983 ) -> NSModalSession;
1984
1985 #[deprecated]
1993 #[unsafe(method(application:printFiles:))]
1994 #[unsafe(method_family = none)]
1995 pub unsafe fn application_printFiles(
1996 &self,
1997 sender: Option<&NSApplication>,
1998 filenames: Option<&NSArray<NSString>>,
1999 );
2000
2001 #[cfg(feature = "NSWindow")]
2002 #[deprecated = "Use -[NSWindow beginSheet:completionHandler:] instead"]
2010 #[unsafe(method(beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:))]
2011 #[unsafe(method_family = none)]
2012 pub unsafe fn beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo(
2013 &self,
2014 sheet: &NSWindow,
2015 doc_window: &NSWindow,
2016 modal_delegate: Option<&AnyObject>,
2017 did_end_selector: Option<Sel>,
2018 context_info: *mut c_void,
2019 );
2020
2021 #[cfg(feature = "NSWindow")]
2022 #[deprecated = "Use -[NSWindow endSheet:] instead"]
2023 #[unsafe(method(endSheet:))]
2024 #[unsafe(method_family = none)]
2025 pub fn endSheet(&self, sheet: &NSWindow);
2026
2027 #[cfg(feature = "NSWindow")]
2028 #[deprecated = "Use -[NSWindow endSheet:returnCode:] instead"]
2029 #[unsafe(method(endSheet:returnCode:))]
2030 #[unsafe(method_family = none)]
2031 pub fn endSheet_returnCode(&self, sheet: &NSWindow, return_code: NSInteger);
2032
2033 #[cfg(feature = "NSWindow")]
2034 #[deprecated = "Use -enumerateWindowsWithOptions:usingBlock: instead"]
2038 #[unsafe(method(makeWindowsPerform:inOrder:))]
2039 #[unsafe(method_family = none)]
2040 pub unsafe fn makeWindowsPerform_inOrder(
2041 &self,
2042 selector: Sel,
2043 in_order: bool,
2044 ) -> Option<Retained<NSWindow>>;
2045
2046 #[cfg(feature = "NSGraphicsContext")]
2047 #[deprecated = "This method always returns nil. If you need access to the current drawing context, use [NSGraphicsContext currentContext] inside of a draw operation."]
2049 #[unsafe(method(context))]
2050 #[unsafe(method_family = none)]
2051 pub fn context(&self) -> Option<Retained<NSGraphicsContext>>;
2052 );
2053}
2054
2055extern "C-unwind" {
2056 #[deprecated = "renamed to `NSApplication::__main`"]
2057 pub fn NSApplicationMain(argc: c_int, argv: NonNull<NonNull<c_char>>) -> c_int;
2058}
2059
2060#[deprecated = "renamed to `NSApplication::load`"]
2061#[inline]
2062pub extern "C-unwind" fn NSApplicationLoad() -> bool {
2063 extern "C-unwind" {
2064 fn NSApplicationLoad() -> Bool;
2065 }
2066 unsafe { NSApplicationLoad() }.as_bool()
2067}