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 unsafe fn delegate(
493 &self,
494 ) -> Option<Retained<ProtocolObject<dyn NSApplicationDelegate>>>;
495
496 #[unsafe(method(setDelegate:))]
499 #[unsafe(method_family = none)]
500 pub fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSApplicationDelegate>>);
501
502 #[unsafe(method(hide:))]
503 #[unsafe(method_family = none)]
504 pub fn hide(&self, sender: Option<&AnyObject>);
505
506 #[unsafe(method(unhide:))]
507 #[unsafe(method_family = none)]
508 pub unsafe fn unhide(&self, sender: Option<&AnyObject>);
509
510 #[unsafe(method(unhideWithoutActivation))]
511 #[unsafe(method_family = none)]
512 pub unsafe fn unhideWithoutActivation(&self);
513
514 #[cfg(feature = "NSWindow")]
515 #[unsafe(method(windowWithWindowNumber:))]
516 #[unsafe(method_family = none)]
517 pub unsafe fn windowWithWindowNumber(
518 &self,
519 window_num: NSInteger,
520 ) -> Option<Retained<NSWindow>>;
521
522 #[cfg(feature = "NSWindow")]
523 #[unsafe(method(mainWindow))]
524 #[unsafe(method_family = none)]
525 pub unsafe fn mainWindow(&self) -> Option<Retained<NSWindow>>;
526
527 #[cfg(feature = "NSWindow")]
528 #[unsafe(method(keyWindow))]
529 #[unsafe(method_family = none)]
530 pub fn keyWindow(&self) -> Option<Retained<NSWindow>>;
531
532 #[unsafe(method(isActive))]
533 #[unsafe(method_family = none)]
534 pub unsafe fn isActive(&self) -> bool;
535
536 #[unsafe(method(isHidden))]
537 #[unsafe(method_family = none)]
538 pub unsafe fn isHidden(&self) -> bool;
539
540 #[unsafe(method(isRunning))]
541 #[unsafe(method_family = none)]
542 pub unsafe fn isRunning(&self) -> bool;
543
544 #[unsafe(method(deactivate))]
545 #[unsafe(method_family = none)]
546 pub unsafe fn deactivate(&self);
547
548 #[deprecated = "This method will be deprecated in a future release. Use NSApp.activate instead."]
551 #[unsafe(method(activateIgnoringOtherApps:))]
552 #[unsafe(method_family = none)]
553 pub fn activateIgnoringOtherApps(&self, ignore_other_apps: bool);
554
555 #[unsafe(method(activate))]
568 #[unsafe(method_family = none)]
569 pub unsafe fn activate(&self);
570
571 #[cfg(feature = "NSRunningApplication")]
572 #[unsafe(method(yieldActivationToApplication:))]
579 #[unsafe(method_family = none)]
580 pub unsafe fn yieldActivationToApplication(&self, application: &NSRunningApplication);
581
582 #[unsafe(method(yieldActivationToApplicationWithBundleIdentifier:))]
591 #[unsafe(method_family = none)]
592 pub unsafe fn yieldActivationToApplicationWithBundleIdentifier(
593 &self,
594 bundle_identifier: &NSString,
595 );
596
597 #[unsafe(method(hideOtherApplications:))]
598 #[unsafe(method_family = none)]
599 pub fn hideOtherApplications(&self, sender: Option<&AnyObject>);
600
601 #[unsafe(method(unhideAllApplications:))]
602 #[unsafe(method_family = none)]
603 pub unsafe fn unhideAllApplications(&self, sender: Option<&AnyObject>);
604
605 #[unsafe(method(finishLaunching))]
606 #[unsafe(method_family = none)]
607 pub unsafe fn finishLaunching(&self);
608
609 #[unsafe(method(run))]
610 #[unsafe(method_family = none)]
611 pub fn run(&self);
612
613 #[cfg(feature = "NSWindow")]
614 #[unsafe(method(runModalForWindow:))]
615 #[unsafe(method_family = none)]
616 pub unsafe fn runModalForWindow(&self, window: &NSWindow) -> NSModalResponse;
617
618 #[unsafe(method(stop:))]
619 #[unsafe(method_family = none)]
620 pub fn stop(&self, sender: Option<&AnyObject>);
621
622 #[unsafe(method(stopModal))]
623 #[unsafe(method_family = none)]
624 pub unsafe fn stopModal(&self);
625
626 #[unsafe(method(stopModalWithCode:))]
627 #[unsafe(method_family = none)]
628 pub unsafe fn stopModalWithCode(&self, return_code: NSModalResponse);
629
630 #[unsafe(method(abortModal))]
631 #[unsafe(method_family = none)]
632 pub unsafe fn abortModal(&self);
633
634 #[cfg(feature = "NSWindow")]
635 #[unsafe(method(modalWindow))]
636 #[unsafe(method_family = none)]
637 pub unsafe fn modalWindow(&self) -> Option<Retained<NSWindow>>;
638
639 #[cfg(feature = "NSWindow")]
640 #[unsafe(method(beginModalSessionForWindow:))]
641 #[unsafe(method_family = none)]
642 pub unsafe fn beginModalSessionForWindow(&self, window: &NSWindow) -> NSModalSession;
643
644 #[unsafe(method(runModalSession:))]
645 #[unsafe(method_family = none)]
646 pub unsafe fn runModalSession(&self, session: NSModalSession) -> NSModalResponse;
647
648 #[unsafe(method(endModalSession:))]
649 #[unsafe(method_family = none)]
650 pub unsafe fn endModalSession(&self, session: NSModalSession);
651
652 #[unsafe(method(terminate:))]
653 #[unsafe(method_family = none)]
654 pub unsafe fn terminate(&self, sender: Option<&AnyObject>);
655
656 #[unsafe(method(requestUserAttention:))]
658 #[unsafe(method_family = none)]
659 pub fn requestUserAttention(&self, request_type: NSRequestUserAttentionType) -> NSInteger;
660
661 #[unsafe(method(cancelUserAttentionRequest:))]
662 #[unsafe(method_family = none)]
663 pub unsafe fn cancelUserAttentionRequest(&self, request: NSInteger);
664
665 #[cfg(all(feature = "NSWindow", feature = "block2"))]
666 #[unsafe(method(enumerateWindowsWithOptions:usingBlock:))]
668 #[unsafe(method_family = none)]
669 pub unsafe fn enumerateWindowsWithOptions_usingBlock(
670 &self,
671 options: NSWindowListOptions,
672 block: &block2::DynBlock<dyn Fn(NonNull<NSWindow>, NonNull<Bool>) + '_>,
673 );
674
675 #[unsafe(method(preventWindowOrdering))]
676 #[unsafe(method_family = none)]
677 pub unsafe fn preventWindowOrdering(&self);
678
679 #[cfg(feature = "NSWindow")]
680 #[unsafe(method(windows))]
681 #[unsafe(method_family = none)]
682 pub fn windows(&self) -> Retained<NSArray<NSWindow>>;
683
684 #[unsafe(method(setWindowsNeedUpdate:))]
685 #[unsafe(method_family = none)]
686 pub unsafe fn setWindowsNeedUpdate(&self, need_update: bool);
687
688 #[unsafe(method(updateWindows))]
689 #[unsafe(method_family = none)]
690 pub unsafe fn updateWindows(&self);
691
692 #[cfg(feature = "NSMenu")]
693 #[unsafe(method(mainMenu))]
694 #[unsafe(method_family = none)]
695 pub unsafe fn mainMenu(&self) -> Option<Retained<NSMenu>>;
696
697 #[cfg(feature = "NSMenu")]
698 #[unsafe(method(setMainMenu:))]
700 #[unsafe(method_family = none)]
701 pub fn setMainMenu(&self, main_menu: Option<&NSMenu>);
702
703 #[cfg(feature = "NSMenu")]
704 #[unsafe(method(helpMenu))]
707 #[unsafe(method_family = none)]
708 pub unsafe fn helpMenu(&self) -> Option<Retained<NSMenu>>;
709
710 #[cfg(feature = "NSMenu")]
711 #[unsafe(method(setHelpMenu:))]
713 #[unsafe(method_family = none)]
714 pub unsafe fn setHelpMenu(&self, help_menu: Option<&NSMenu>);
715
716 #[cfg(feature = "NSImage")]
717 #[unsafe(method(applicationIconImage))]
718 #[unsafe(method_family = none)]
719 pub unsafe fn applicationIconImage(&self) -> Option<Retained<NSImage>>;
720
721 #[cfg(feature = "NSImage")]
722 #[unsafe(method(setApplicationIconImage:))]
724 #[unsafe(method_family = none)]
725 pub unsafe fn setApplicationIconImage(&self, application_icon_image: Option<&NSImage>);
726
727 #[cfg(feature = "NSRunningApplication")]
728 #[unsafe(method(activationPolicy))]
730 #[unsafe(method_family = none)]
731 pub unsafe fn activationPolicy(&self) -> NSApplicationActivationPolicy;
732
733 #[cfg(feature = "NSRunningApplication")]
734 #[unsafe(method(setActivationPolicy:))]
741 #[unsafe(method_family = none)]
742 pub fn setActivationPolicy(&self, activation_policy: NSApplicationActivationPolicy)
743 -> bool;
744
745 #[cfg(feature = "NSDockTile")]
746 #[unsafe(method(dockTile))]
747 #[unsafe(method_family = none)]
748 pub unsafe fn dockTile(&self) -> Retained<NSDockTile>;
749
750 #[unsafe(method(reportException:))]
751 #[unsafe(method_family = none)]
752 pub unsafe fn reportException(&self, exception: &NSException);
753
754 #[unsafe(method(detachDrawingThread:toTarget:withObject:))]
755 #[unsafe(method_family = none)]
756 pub unsafe fn detachDrawingThread_toTarget_withObject(
757 selector: Sel,
758 target: &AnyObject,
759 argument: Option<&AnyObject>,
760 mtm: MainThreadMarker,
761 );
762
763 #[unsafe(method(replyToApplicationShouldTerminate:))]
765 #[unsafe(method_family = none)]
766 pub unsafe fn replyToApplicationShouldTerminate(&self, should_terminate: bool);
767
768 #[unsafe(method(replyToOpenOrPrint:))]
773 #[unsafe(method_family = none)]
774 pub unsafe fn replyToOpenOrPrint(&self, reply: NSApplicationDelegateReply);
775
776 #[unsafe(method(orderFrontCharacterPalette:))]
778 #[unsafe(method_family = none)]
779 pub fn orderFrontCharacterPalette(&self, sender: Option<&AnyObject>);
780
781 #[unsafe(method(presentationOptions))]
785 #[unsafe(method_family = none)]
786 pub fn presentationOptions(&self) -> NSApplicationPresentationOptions;
787
788 #[unsafe(method(setPresentationOptions:))]
790 #[unsafe(method_family = none)]
791 pub fn setPresentationOptions(
792 &self,
793 presentation_options: NSApplicationPresentationOptions,
794 );
795
796 #[unsafe(method(currentSystemPresentationOptions))]
799 #[unsafe(method_family = none)]
800 pub unsafe fn currentSystemPresentationOptions(&self) -> NSApplicationPresentationOptions;
801
802 #[unsafe(method(occlusionState))]
803 #[unsafe(method_family = none)]
804 pub unsafe fn occlusionState(&self) -> NSApplicationOcclusionState;
805
806 #[unsafe(method(isProtectedDataAvailable))]
807 #[unsafe(method_family = none)]
808 pub unsafe fn isProtectedDataAvailable(&self) -> bool;
809 );
810}
811
812#[cfg(feature = "NSResponder")]
814impl NSApplication {
815 extern_methods!(
816 #[unsafe(method(init))]
817 #[unsafe(method_family = init)]
818 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
819
820 #[unsafe(method(initWithCoder:))]
821 #[unsafe(method_family = init)]
822 pub unsafe fn initWithCoder(
823 this: Allocated<Self>,
824 coder: &NSCoder,
825 ) -> Option<Retained<Self>>;
826 );
827}
828
829#[cfg(feature = "NSResponder")]
831impl NSApplication {
832 extern_methods!(
833 #[unsafe(method(new))]
834 #[unsafe(method_family = new)]
835 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
836 );
837}
838
839#[cfg(feature = "NSResponder")]
841impl NSApplication {
842 extern_methods!(
843 #[cfg(feature = "NSAppearance")]
844 #[unsafe(method(appearance))]
845 #[unsafe(method_family = none)]
846 pub unsafe fn appearance(&self) -> Option<Retained<NSAppearance>>;
847
848 #[cfg(feature = "NSAppearance")]
849 #[unsafe(method(setAppearance:))]
851 #[unsafe(method_family = none)]
852 pub fn setAppearance(&self, appearance: Option<&NSAppearance>);
853
854 #[cfg(feature = "NSAppearance")]
855 #[unsafe(method(effectiveAppearance))]
856 #[unsafe(method_family = none)]
857 pub fn effectiveAppearance(&self) -> Retained<NSAppearance>;
858 );
859}
860
861#[cfg(all(feature = "NSAppearance", feature = "NSResponder"))]
862extern_conformance!(
863 unsafe impl NSAppearanceCustomization for NSApplication {}
864);
865
866#[cfg(feature = "NSResponder")]
868impl NSApplication {
869 extern_methods!(
870 #[cfg(feature = "NSEvent")]
871 #[unsafe(method(sendEvent:))]
872 #[unsafe(method_family = none)]
873 pub unsafe fn sendEvent(&self, event: &NSEvent);
874
875 #[cfg(feature = "NSEvent")]
876 #[unsafe(method(postEvent:atStart:))]
877 #[unsafe(method_family = none)]
878 pub fn postEvent_atStart(&self, event: &NSEvent, at_start: bool);
879
880 #[cfg(feature = "NSEvent")]
881 #[unsafe(method(currentEvent))]
882 #[unsafe(method_family = none)]
883 pub fn currentEvent(&self) -> Option<Retained<NSEvent>>;
884
885 #[cfg(feature = "NSEvent")]
886 #[unsafe(method(nextEventMatchingMask:untilDate:inMode:dequeue:))]
887 #[unsafe(method_family = none)]
888 pub unsafe fn nextEventMatchingMask_untilDate_inMode_dequeue(
889 &self,
890 mask: NSEventMask,
891 expiration: Option<&NSDate>,
892 mode: &NSRunLoopMode,
893 deq_flag: bool,
894 ) -> Option<Retained<NSEvent>>;
895
896 #[cfg(feature = "NSEvent")]
897 #[unsafe(method(discardEventsMatchingMask:beforeEvent:))]
898 #[unsafe(method_family = none)]
899 pub unsafe fn discardEventsMatchingMask_beforeEvent(
900 &self,
901 mask: NSEventMask,
902 last_event: Option<&NSEvent>,
903 );
904 );
905}
906
907#[cfg(feature = "NSResponder")]
909impl NSApplication {
910 extern_methods!(
911 #[unsafe(method(sendAction:to:from:))]
912 #[unsafe(method_family = none)]
913 pub unsafe fn sendAction_to_from(
914 &self,
915 action: Sel,
916 target: Option<&AnyObject>,
917 sender: Option<&AnyObject>,
918 ) -> bool;
919
920 #[unsafe(method(targetForAction:))]
921 #[unsafe(method_family = none)]
922 pub unsafe fn targetForAction(&self, action: Sel) -> Option<Retained<AnyObject>>;
923
924 #[unsafe(method(targetForAction:to:from:))]
925 #[unsafe(method_family = none)]
926 pub unsafe fn targetForAction_to_from(
927 &self,
928 action: Sel,
929 target: Option<&AnyObject>,
930 sender: Option<&AnyObject>,
931 ) -> Option<Retained<AnyObject>>;
932
933 #[unsafe(method(tryToPerform:with:))]
934 #[unsafe(method_family = none)]
935 pub unsafe fn tryToPerform_with(&self, action: Sel, object: Option<&AnyObject>) -> bool;
936
937 #[cfg(feature = "NSPasteboard")]
938 #[unsafe(method(validRequestorForSendType:returnType:))]
939 #[unsafe(method_family = none)]
940 pub unsafe fn validRequestorForSendType_returnType(
941 &self,
942 send_type: Option<&NSPasteboardType>,
943 return_type: Option<&NSPasteboardType>,
944 ) -> Option<Retained<AnyObject>>;
945 );
946}
947
948#[cfg(feature = "NSResponder")]
950impl NSApplication {
951 extern_methods!(
952 #[cfg(feature = "NSMenu")]
953 #[unsafe(method(windowsMenu))]
954 #[unsafe(method_family = none)]
955 pub unsafe fn windowsMenu(&self) -> Option<Retained<NSMenu>>;
956
957 #[cfg(feature = "NSMenu")]
958 #[unsafe(method(setWindowsMenu:))]
960 #[unsafe(method_family = none)]
961 pub unsafe fn setWindowsMenu(&self, windows_menu: Option<&NSMenu>);
962
963 #[unsafe(method(arrangeInFront:))]
964 #[unsafe(method_family = none)]
965 pub unsafe fn arrangeInFront(&self, sender: Option<&AnyObject>);
966
967 #[cfg(feature = "NSWindow")]
968 #[unsafe(method(removeWindowsItem:))]
969 #[unsafe(method_family = none)]
970 pub unsafe fn removeWindowsItem(&self, win: &NSWindow);
971
972 #[cfg(feature = "NSWindow")]
973 #[unsafe(method(addWindowsItem:title:filename:))]
974 #[unsafe(method_family = none)]
975 pub unsafe fn addWindowsItem_title_filename(
976 &self,
977 win: &NSWindow,
978 string: &NSString,
979 is_filename: bool,
980 );
981
982 #[cfg(feature = "NSWindow")]
983 #[unsafe(method(changeWindowsItem:title:filename:))]
984 #[unsafe(method_family = none)]
985 pub unsafe fn changeWindowsItem_title_filename(
986 &self,
987 win: &NSWindow,
988 string: &NSString,
989 is_filename: bool,
990 );
991
992 #[cfg(feature = "NSWindow")]
993 #[unsafe(method(updateWindowsItem:))]
994 #[unsafe(method_family = none)]
995 pub unsafe fn updateWindowsItem(&self, win: &NSWindow);
996
997 #[unsafe(method(miniaturizeAll:))]
998 #[unsafe(method_family = none)]
999 pub unsafe fn miniaturizeAll(&self, sender: Option<&AnyObject>);
1000 );
1001}
1002
1003#[cfg(feature = "NSResponder")]
1005impl NSApplication {
1006 extern_methods!(
1007 #[unsafe(method(isFullKeyboardAccessEnabled))]
1011 #[unsafe(method_family = none)]
1012 pub unsafe fn isFullKeyboardAccessEnabled(&self) -> bool;
1013 );
1014}
1015
1016#[repr(transparent)]
1021#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1022pub struct NSApplicationTerminateReply(pub NSUInteger);
1023impl NSApplicationTerminateReply {
1024 #[doc(alias = "NSTerminateCancel")]
1025 pub const TerminateCancel: Self = Self(0);
1026 #[doc(alias = "NSTerminateNow")]
1027 pub const TerminateNow: Self = Self(1);
1028 #[doc(alias = "NSTerminateLater")]
1029 pub const TerminateLater: Self = Self(2);
1030}
1031
1032unsafe impl Encode for NSApplicationTerminateReply {
1033 const ENCODING: Encoding = NSUInteger::ENCODING;
1034}
1035
1036unsafe impl RefEncode for NSApplicationTerminateReply {
1037 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1038}
1039
1040#[repr(transparent)]
1045#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1046pub struct NSApplicationPrintReply(pub NSUInteger);
1047impl NSApplicationPrintReply {
1048 #[doc(alias = "NSPrintingCancelled")]
1049 pub const PrintingCancelled: Self = Self(0);
1050 #[doc(alias = "NSPrintingSuccess")]
1051 pub const PrintingSuccess: Self = Self(1);
1052 #[doc(alias = "NSPrintingReplyLater")]
1053 pub const PrintingReplyLater: Self = Self(2);
1054 #[doc(alias = "NSPrintingFailure")]
1055 pub const PrintingFailure: Self = Self(3);
1056}
1057
1058unsafe impl Encode for NSApplicationPrintReply {
1059 const ENCODING: Encoding = NSUInteger::ENCODING;
1060}
1061
1062unsafe impl RefEncode for NSApplicationPrintReply {
1063 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1064}
1065
1066extern_protocol!(
1067 pub unsafe trait NSApplicationDelegate: NSObjectProtocol + MainThreadOnly {
1069 #[cfg(feature = "NSResponder")]
1070 #[optional]
1079 #[unsafe(method(applicationShouldTerminate:))]
1080 #[unsafe(method_family = none)]
1081 unsafe fn applicationShouldTerminate(
1082 &self,
1083 sender: &NSApplication,
1084 ) -> NSApplicationTerminateReply;
1085
1086 #[cfg(feature = "NSResponder")]
1087 #[optional]
1093 #[unsafe(method(application:openURLs:))]
1094 #[unsafe(method_family = none)]
1095 unsafe fn application_openURLs(&self, application: &NSApplication, urls: &NSArray<NSURL>);
1096
1097 #[cfg(feature = "NSResponder")]
1098 #[optional]
1099 #[unsafe(method(application:openFile:))]
1100 #[unsafe(method_family = none)]
1101 unsafe fn application_openFile(&self, sender: &NSApplication, filename: &NSString) -> bool;
1102
1103 #[cfg(feature = "NSResponder")]
1104 #[optional]
1105 #[unsafe(method(application:openFiles:))]
1106 #[unsafe(method_family = none)]
1107 unsafe fn application_openFiles(
1108 &self,
1109 sender: &NSApplication,
1110 filenames: &NSArray<NSString>,
1111 );
1112
1113 #[cfg(feature = "NSResponder")]
1114 #[optional]
1115 #[unsafe(method(application:openTempFile:))]
1116 #[unsafe(method_family = none)]
1117 unsafe fn application_openTempFile(
1118 &self,
1119 sender: &NSApplication,
1120 filename: &NSString,
1121 ) -> bool;
1122
1123 #[cfg(feature = "NSResponder")]
1124 #[optional]
1125 #[unsafe(method(applicationShouldOpenUntitledFile:))]
1126 #[unsafe(method_family = none)]
1127 unsafe fn applicationShouldOpenUntitledFile(&self, sender: &NSApplication) -> bool;
1128
1129 #[cfg(feature = "NSResponder")]
1130 #[optional]
1131 #[unsafe(method(applicationOpenUntitledFile:))]
1132 #[unsafe(method_family = none)]
1133 unsafe fn applicationOpenUntitledFile(&self, sender: &NSApplication) -> bool;
1134
1135 #[optional]
1136 #[unsafe(method(application:openFileWithoutUI:))]
1137 #[unsafe(method_family = none)]
1138 unsafe fn application_openFileWithoutUI(
1139 &self,
1140 sender: &AnyObject,
1141 filename: &NSString,
1142 ) -> bool;
1143
1144 #[cfg(feature = "NSResponder")]
1145 #[optional]
1146 #[unsafe(method(application:printFile:))]
1147 #[unsafe(method_family = none)]
1148 unsafe fn application_printFile(&self, sender: &NSApplication, filename: &NSString)
1149 -> bool;
1150
1151 #[cfg(all(feature = "NSPrintInfo", feature = "NSResponder"))]
1152 #[optional]
1153 #[unsafe(method(application:printFiles:withSettings:showPrintPanels:))]
1154 #[unsafe(method_family = none)]
1155 unsafe fn application_printFiles_withSettings_showPrintPanels(
1156 &self,
1157 application: &NSApplication,
1158 file_names: &NSArray<NSString>,
1159 print_settings: &NSDictionary<NSPrintInfoAttributeKey, AnyObject>,
1160 show_print_panels: bool,
1161 ) -> NSApplicationPrintReply;
1162
1163 #[cfg(feature = "NSResponder")]
1164 #[optional]
1165 #[unsafe(method(applicationShouldTerminateAfterLastWindowClosed:))]
1166 #[unsafe(method_family = none)]
1167 unsafe fn applicationShouldTerminateAfterLastWindowClosed(
1168 &self,
1169 sender: &NSApplication,
1170 ) -> bool;
1171
1172 #[cfg(feature = "NSResponder")]
1173 #[optional]
1174 #[unsafe(method(applicationShouldHandleReopen:hasVisibleWindows:))]
1175 #[unsafe(method_family = none)]
1176 unsafe fn applicationShouldHandleReopen_hasVisibleWindows(
1177 &self,
1178 sender: &NSApplication,
1179 has_visible_windows: bool,
1180 ) -> bool;
1181
1182 #[cfg(all(feature = "NSMenu", feature = "NSResponder"))]
1183 #[optional]
1184 #[unsafe(method(applicationDockMenu:))]
1185 #[unsafe(method_family = none)]
1186 unsafe fn applicationDockMenu(&self, sender: &NSApplication) -> Option<Retained<NSMenu>>;
1187
1188 #[cfg(feature = "NSResponder")]
1189 #[optional]
1190 #[unsafe(method(application:willPresentError:))]
1191 #[unsafe(method_family = none)]
1192 unsafe fn application_willPresentError(
1193 &self,
1194 application: &NSApplication,
1195 error: &NSError,
1196 ) -> Retained<NSError>;
1197
1198 #[cfg(feature = "NSResponder")]
1199 #[optional]
1200 #[unsafe(method(application:didRegisterForRemoteNotificationsWithDeviceToken:))]
1201 #[unsafe(method_family = none)]
1202 unsafe fn application_didRegisterForRemoteNotificationsWithDeviceToken(
1203 &self,
1204 application: &NSApplication,
1205 device_token: &NSData,
1206 );
1207
1208 #[cfg(feature = "NSResponder")]
1209 #[optional]
1210 #[unsafe(method(application:didFailToRegisterForRemoteNotificationsWithError:))]
1211 #[unsafe(method_family = none)]
1212 unsafe fn application_didFailToRegisterForRemoteNotificationsWithError(
1213 &self,
1214 application: &NSApplication,
1215 error: &NSError,
1216 );
1217
1218 #[cfg(feature = "NSResponder")]
1219 #[optional]
1220 #[unsafe(method(application:didReceiveRemoteNotification:))]
1221 #[unsafe(method_family = none)]
1222 unsafe fn application_didReceiveRemoteNotification(
1223 &self,
1224 application: &NSApplication,
1225 user_info: &NSDictionary<NSString, AnyObject>,
1226 );
1227
1228 #[cfg(feature = "NSResponder")]
1229 #[optional]
1240 #[unsafe(method(applicationSupportsSecureRestorableState:))]
1241 #[unsafe(method_family = none)]
1242 unsafe fn applicationSupportsSecureRestorableState(&self, app: &NSApplication) -> bool;
1243
1244 #[cfg(feature = "NSResponder")]
1245 #[optional]
1248 #[unsafe(method(application:willEncodeRestorableState:))]
1249 #[unsafe(method_family = none)]
1250 unsafe fn application_willEncodeRestorableState(
1251 &self,
1252 app: &NSApplication,
1253 coder: &NSCoder,
1254 );
1255
1256 #[cfg(feature = "NSResponder")]
1257 #[optional]
1260 #[unsafe(method(application:didDecodeRestorableState:))]
1261 #[unsafe(method_family = none)]
1262 unsafe fn application_didDecodeRestorableState(&self, app: &NSApplication, coder: &NSCoder);
1263
1264 #[cfg(feature = "NSResponder")]
1265 #[optional]
1272 #[unsafe(method(application:willContinueUserActivityWithType:))]
1273 #[unsafe(method_family = none)]
1274 unsafe fn application_willContinueUserActivityWithType(
1275 &self,
1276 application: &NSApplication,
1277 user_activity_type: &NSString,
1278 ) -> bool;
1279
1280 #[cfg(all(
1281 feature = "NSResponder",
1282 feature = "NSUserActivity",
1283 feature = "block2"
1284 ))]
1285 #[optional]
1300 #[unsafe(method(application:continueUserActivity:restorationHandler:))]
1301 #[unsafe(method_family = none)]
1302 unsafe fn application_continueUserActivity_restorationHandler(
1303 &self,
1304 application: &NSApplication,
1305 user_activity: &NSUserActivity,
1306 restoration_handler: &block2::DynBlock<
1307 dyn Fn(NonNull<NSArray<ProtocolObject<dyn NSUserActivityRestoring>>>),
1308 >,
1309 ) -> bool;
1310
1311 #[cfg(feature = "NSResponder")]
1312 #[optional]
1315 #[unsafe(method(application:didFailToContinueUserActivityWithType:error:))]
1316 #[unsafe(method_family = none)]
1317 unsafe fn application_didFailToContinueUserActivityWithType_error(
1318 &self,
1319 application: &NSApplication,
1320 user_activity_type: &NSString,
1321 error: &NSError,
1322 );
1323
1324 #[cfg(feature = "NSResponder")]
1325 #[optional]
1328 #[unsafe(method(application:didUpdateUserActivity:))]
1329 #[unsafe(method_family = none)]
1330 unsafe fn application_didUpdateUserActivity(
1331 &self,
1332 application: &NSApplication,
1333 user_activity: &NSUserActivity,
1334 );
1335
1336 #[cfg(all(feature = "NSResponder", feature = "objc2-cloud-kit"))]
1337 #[cfg(target_vendor = "apple")]
1338 #[optional]
1347 #[unsafe(method(application:userDidAcceptCloudKitShareWithMetadata:))]
1348 #[unsafe(method_family = none)]
1349 unsafe fn application_userDidAcceptCloudKitShareWithMetadata(
1350 &self,
1351 application: &NSApplication,
1352 metadata: &CKShareMetadata,
1353 );
1354
1355 #[cfg(feature = "NSResponder")]
1356 #[optional]
1359 #[unsafe(method(application:delegateHandlesKey:))]
1360 #[unsafe(method_family = none)]
1361 unsafe fn application_delegateHandlesKey(
1362 &self,
1363 sender: &NSApplication,
1364 key: &NSString,
1365 ) -> bool;
1366
1367 #[cfg(feature = "NSResponder")]
1368 #[optional]
1374 #[unsafe(method(applicationShouldAutomaticallyLocalizeKeyEquivalents:))]
1375 #[unsafe(method_family = none)]
1376 unsafe fn applicationShouldAutomaticallyLocalizeKeyEquivalents(
1377 &self,
1378 application: &NSApplication,
1379 ) -> bool;
1380
1381 #[optional]
1382 #[unsafe(method(applicationWillFinishLaunching:))]
1383 #[unsafe(method_family = none)]
1384 unsafe fn applicationWillFinishLaunching(&self, notification: &NSNotification);
1385
1386 #[optional]
1387 #[unsafe(method(applicationDidFinishLaunching:))]
1388 #[unsafe(method_family = none)]
1389 unsafe fn applicationDidFinishLaunching(&self, notification: &NSNotification);
1390
1391 #[optional]
1392 #[unsafe(method(applicationWillHide:))]
1393 #[unsafe(method_family = none)]
1394 unsafe fn applicationWillHide(&self, notification: &NSNotification);
1395
1396 #[optional]
1397 #[unsafe(method(applicationDidHide:))]
1398 #[unsafe(method_family = none)]
1399 unsafe fn applicationDidHide(&self, notification: &NSNotification);
1400
1401 #[optional]
1402 #[unsafe(method(applicationWillUnhide:))]
1403 #[unsafe(method_family = none)]
1404 unsafe fn applicationWillUnhide(&self, notification: &NSNotification);
1405
1406 #[optional]
1407 #[unsafe(method(applicationDidUnhide:))]
1408 #[unsafe(method_family = none)]
1409 unsafe fn applicationDidUnhide(&self, notification: &NSNotification);
1410
1411 #[optional]
1412 #[unsafe(method(applicationWillBecomeActive:))]
1413 #[unsafe(method_family = none)]
1414 unsafe fn applicationWillBecomeActive(&self, notification: &NSNotification);
1415
1416 #[optional]
1417 #[unsafe(method(applicationDidBecomeActive:))]
1418 #[unsafe(method_family = none)]
1419 unsafe fn applicationDidBecomeActive(&self, notification: &NSNotification);
1420
1421 #[optional]
1422 #[unsafe(method(applicationWillResignActive:))]
1423 #[unsafe(method_family = none)]
1424 unsafe fn applicationWillResignActive(&self, notification: &NSNotification);
1425
1426 #[optional]
1427 #[unsafe(method(applicationDidResignActive:))]
1428 #[unsafe(method_family = none)]
1429 unsafe fn applicationDidResignActive(&self, notification: &NSNotification);
1430
1431 #[optional]
1432 #[unsafe(method(applicationWillUpdate:))]
1433 #[unsafe(method_family = none)]
1434 unsafe fn applicationWillUpdate(&self, notification: &NSNotification);
1435
1436 #[optional]
1437 #[unsafe(method(applicationDidUpdate:))]
1438 #[unsafe(method_family = none)]
1439 unsafe fn applicationDidUpdate(&self, notification: &NSNotification);
1440
1441 #[optional]
1442 #[unsafe(method(applicationWillTerminate:))]
1443 #[unsafe(method_family = none)]
1444 unsafe fn applicationWillTerminate(&self, notification: &NSNotification);
1445
1446 #[optional]
1447 #[unsafe(method(applicationDidChangeScreenParameters:))]
1448 #[unsafe(method_family = none)]
1449 unsafe fn applicationDidChangeScreenParameters(&self, notification: &NSNotification);
1450
1451 #[optional]
1452 #[unsafe(method(applicationDidChangeOcclusionState:))]
1453 #[unsafe(method_family = none)]
1454 unsafe fn applicationDidChangeOcclusionState(&self, notification: &NSNotification);
1455
1456 #[optional]
1457 #[unsafe(method(applicationProtectedDataWillBecomeUnavailable:))]
1458 #[unsafe(method_family = none)]
1459 unsafe fn applicationProtectedDataWillBecomeUnavailable(
1460 &self,
1461 notification: &NSNotification,
1462 );
1463
1464 #[optional]
1465 #[unsafe(method(applicationProtectedDataDidBecomeAvailable:))]
1466 #[unsafe(method_family = none)]
1467 unsafe fn applicationProtectedDataDidBecomeAvailable(&self, notification: &NSNotification);
1468 }
1469);
1470
1471#[cfg(feature = "NSResponder")]
1473impl NSApplication {
1474 extern_methods!(
1475 #[cfg(feature = "NSMenu")]
1476 #[unsafe(method(servicesMenu))]
1477 #[unsafe(method_family = none)]
1478 pub unsafe fn servicesMenu(&self) -> Option<Retained<NSMenu>>;
1479
1480 #[cfg(feature = "NSMenu")]
1481 #[unsafe(method(setServicesMenu:))]
1483 #[unsafe(method_family = none)]
1484 pub unsafe fn setServicesMenu(&self, services_menu: Option<&NSMenu>);
1485
1486 #[cfg(feature = "NSPasteboard")]
1487 #[unsafe(method(registerServicesMenuSendTypes:returnTypes:))]
1488 #[unsafe(method_family = none)]
1489 pub unsafe fn registerServicesMenuSendTypes_returnTypes(
1490 &self,
1491 send_types: &NSArray<NSPasteboardType>,
1492 return_types: &NSArray<NSPasteboardType>,
1493 );
1494 );
1495}
1496
1497extern_protocol!(
1498 pub unsafe trait NSServicesMenuRequestor: NSObjectProtocol {
1500 #[cfg(feature = "NSPasteboard")]
1501 #[optional]
1502 #[unsafe(method(writeSelectionToPasteboard:types:))]
1503 #[unsafe(method_family = none)]
1504 unsafe fn writeSelectionToPasteboard_types(
1505 &self,
1506 pboard: &NSPasteboard,
1507 types: &NSArray<NSPasteboardType>,
1508 ) -> bool;
1509
1510 #[cfg(feature = "NSPasteboard")]
1511 #[optional]
1512 #[unsafe(method(readSelectionFromPasteboard:))]
1513 #[unsafe(method_family = none)]
1514 unsafe fn readSelectionFromPasteboard(&self, pboard: &NSPasteboard) -> bool;
1515 }
1516);
1517
1518#[cfg(feature = "NSResponder")]
1520impl NSApplication {
1521 extern_methods!(
1522 #[unsafe(method(servicesProvider))]
1523 #[unsafe(method_family = none)]
1524 pub unsafe fn servicesProvider(&self) -> Option<Retained<AnyObject>>;
1525
1526 #[unsafe(method(setServicesProvider:))]
1528 #[unsafe(method_family = none)]
1529 pub unsafe fn setServicesProvider(&self, services_provider: Option<&AnyObject>);
1530 );
1531}
1532
1533pub type NSAboutPanelOptionKey = NSString;
1539
1540extern "C" {
1541 pub static NSAboutPanelOptionCredits: &'static NSAboutPanelOptionKey;
1545}
1546
1547extern "C" {
1548 pub static NSAboutPanelOptionApplicationName: &'static NSAboutPanelOptionKey;
1552}
1553
1554extern "C" {
1555 pub static NSAboutPanelOptionApplicationIcon: &'static NSAboutPanelOptionKey;
1561}
1562
1563extern "C" {
1564 pub static NSAboutPanelOptionVersion: &'static NSAboutPanelOptionKey;
1568}
1569
1570extern "C" {
1571 pub static NSAboutPanelOptionApplicationVersion: &'static NSAboutPanelOptionKey;
1575}
1576
1577#[cfg(feature = "NSResponder")]
1579impl NSApplication {
1580 extern_methods!(
1581 #[unsafe(method(orderFrontStandardAboutPanel:))]
1582 #[unsafe(method_family = none)]
1583 pub unsafe fn orderFrontStandardAboutPanel(&self, sender: Option<&AnyObject>);
1584
1585 #[unsafe(method(orderFrontStandardAboutPanelWithOptions:))]
1586 #[unsafe(method_family = none)]
1587 pub unsafe fn orderFrontStandardAboutPanelWithOptions(
1588 &self,
1589 options_dictionary: &NSDictionary<NSAboutPanelOptionKey, AnyObject>,
1590 );
1591 );
1592}
1593
1594#[cfg(feature = "NSResponder")]
1596impl NSApplication {
1597 extern_methods!(
1598 #[cfg(feature = "NSUserInterfaceLayout")]
1599 #[unsafe(method(userInterfaceLayoutDirection))]
1600 #[unsafe(method_family = none)]
1601 pub unsafe fn userInterfaceLayoutDirection(&self) -> NSUserInterfaceLayoutDirection;
1602 );
1603}
1604
1605#[cfg(feature = "NSResponder")]
1607impl NSApplication {
1608 extern_methods!(
1609 #[unsafe(method(disableRelaunchOnLogin))]
1617 #[unsafe(method_family = none)]
1618 pub unsafe fn disableRelaunchOnLogin(&self);
1619
1620 #[unsafe(method(enableRelaunchOnLogin))]
1621 #[unsafe(method_family = none)]
1622 pub unsafe fn enableRelaunchOnLogin(&self);
1623 );
1624}
1625
1626#[repr(transparent)]
1632#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1633pub struct NSRemoteNotificationType(pub NSUInteger);
1634bitflags::bitflags! {
1635 impl NSRemoteNotificationType: NSUInteger {
1636 #[doc(alias = "NSRemoteNotificationTypeNone")]
1637 const None = 0;
1638 #[doc(alias = "NSRemoteNotificationTypeBadge")]
1639 const Badge = 1<<0;
1640 #[doc(alias = "NSRemoteNotificationTypeSound")]
1641 const Sound = 1<<1;
1642 #[doc(alias = "NSRemoteNotificationTypeAlert")]
1643 const Alert = 1<<2;
1644 }
1645}
1646
1647unsafe impl Encode for NSRemoteNotificationType {
1648 const ENCODING: Encoding = NSUInteger::ENCODING;
1649}
1650
1651unsafe impl RefEncode for NSRemoteNotificationType {
1652 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1653}
1654
1655#[cfg(feature = "NSResponder")]
1657impl NSApplication {
1658 extern_methods!(
1659 #[unsafe(method(registerForRemoteNotifications))]
1660 #[unsafe(method_family = none)]
1661 pub unsafe fn registerForRemoteNotifications(&self);
1662
1663 #[unsafe(method(unregisterForRemoteNotifications))]
1664 #[unsafe(method_family = none)]
1665 pub unsafe fn unregisterForRemoteNotifications(&self);
1666
1667 #[unsafe(method(isRegisteredForRemoteNotifications))]
1669 #[unsafe(method_family = none)]
1670 pub unsafe fn isRegisteredForRemoteNotifications(&self) -> bool;
1671
1672 #[unsafe(method(registerForRemoteNotificationTypes:))]
1675 #[unsafe(method_family = none)]
1676 pub unsafe fn registerForRemoteNotificationTypes(&self, types: NSRemoteNotificationType);
1677
1678 #[unsafe(method(enabledRemoteNotificationTypes))]
1679 #[unsafe(method_family = none)]
1680 pub unsafe fn enabledRemoteNotificationTypes(&self) -> NSRemoteNotificationType;
1681 );
1682}
1683
1684#[cfg(feature = "NSResponder")]
1685impl NSApplication {
1686 #[doc(alias = "NSApplicationMain")]
1688 #[inline]
1689 pub(crate) unsafe fn __main(argc: c_int, argv: NonNull<NonNull<c_char>>) -> c_int {
1690 extern "C-unwind" {
1691 fn NSApplicationMain(argc: c_int, argv: NonNull<NonNull<c_char>>) -> c_int;
1692 }
1693 unsafe { NSApplicationMain(argc, argv) }
1694 }
1695
1696 #[doc(alias = "NSApplicationLoad")]
1699 #[inline]
1700 pub unsafe fn load() -> bool {
1701 extern "C-unwind" {
1702 fn NSApplicationLoad() -> Bool;
1703 }
1704 unsafe { NSApplicationLoad() }.as_bool()
1705 }
1706}
1707
1708#[inline]
1711pub unsafe extern "C-unwind" fn NSShowsServicesMenuItem(item_name: &NSString) -> bool {
1712 extern "C-unwind" {
1713 fn NSShowsServicesMenuItem(item_name: &NSString) -> Bool;
1714 }
1715 unsafe { NSShowsServicesMenuItem(item_name) }.as_bool()
1716}
1717
1718#[inline]
1720pub unsafe extern "C-unwind" fn NSSetShowsServicesMenuItem(
1721 item_name: &NSString,
1722 enabled: bool,
1723) -> NSInteger {
1724 extern "C-unwind" {
1725 fn NSSetShowsServicesMenuItem(item_name: &NSString, enabled: Bool) -> NSInteger;
1726 }
1727 unsafe { NSSetShowsServicesMenuItem(item_name, Bool::new(enabled)) }
1728}
1729
1730extern "C-unwind" {
1731 pub fn NSUpdateDynamicServices();
1734}
1735
1736#[cfg(feature = "NSPasteboard")]
1737#[inline]
1738pub unsafe extern "C-unwind" fn NSPerformService(
1739 item_name: &NSString,
1740 pboard: Option<&NSPasteboard>,
1741) -> bool {
1742 extern "C-unwind" {
1743 fn NSPerformService(item_name: &NSString, pboard: Option<&NSPasteboard>) -> Bool;
1744 }
1745 unsafe { NSPerformService(item_name, pboard) }.as_bool()
1746}
1747
1748pub type NSServiceProviderName = NSString;
1750
1751extern "C-unwind" {
1752 pub fn NSRegisterServicesProvider(provider: Option<&AnyObject>, name: &NSServiceProviderName);
1754}
1755
1756extern "C-unwind" {
1757 pub fn NSUnregisterServicesProvider(name: &NSServiceProviderName);
1758}
1759
1760extern "C" {
1761 pub static NSApplicationDidBecomeActiveNotification: &'static NSNotificationName;
1763}
1764
1765extern "C" {
1766 pub static NSApplicationDidHideNotification: &'static NSNotificationName;
1768}
1769
1770extern "C" {
1771 pub static NSApplicationDidFinishLaunchingNotification: &'static NSNotificationName;
1773}
1774
1775extern "C" {
1776 pub static NSApplicationDidResignActiveNotification: &'static NSNotificationName;
1778}
1779
1780extern "C" {
1781 pub static NSApplicationDidUnhideNotification: &'static NSNotificationName;
1783}
1784
1785extern "C" {
1786 pub static NSApplicationDidUpdateNotification: &'static NSNotificationName;
1788}
1789
1790extern "C" {
1791 pub static NSApplicationWillBecomeActiveNotification: &'static NSNotificationName;
1793}
1794
1795extern "C" {
1796 pub static NSApplicationWillHideNotification: &'static NSNotificationName;
1798}
1799
1800extern "C" {
1801 pub static NSApplicationWillFinishLaunchingNotification: &'static NSNotificationName;
1803}
1804
1805extern "C" {
1806 pub static NSApplicationWillResignActiveNotification: &'static NSNotificationName;
1808}
1809
1810extern "C" {
1811 pub static NSApplicationWillUnhideNotification: &'static NSNotificationName;
1813}
1814
1815extern "C" {
1816 pub static NSApplicationWillUpdateNotification: &'static NSNotificationName;
1818}
1819
1820extern "C" {
1821 pub static NSApplicationWillTerminateNotification: &'static NSNotificationName;
1823}
1824
1825extern "C" {
1826 pub static NSApplicationDidChangeScreenParametersNotification: &'static NSNotificationName;
1828}
1829
1830extern "C" {
1831 pub static NSApplicationProtectedDataWillBecomeUnavailableNotification:
1833 &'static NSNotificationName;
1834}
1835
1836extern "C" {
1837 pub static NSApplicationProtectedDataDidBecomeAvailableNotification:
1839 &'static NSNotificationName;
1840}
1841
1842extern "C" {
1843 pub static NSApplicationLaunchIsDefaultLaunchKey: &'static NSString;
1847}
1848
1849extern "C" {
1850 pub static NSApplicationLaunchUserNotificationKey: &'static NSString;
1854}
1855
1856extern "C" {
1857 pub static NSApplicationLaunchRemoteNotificationKey: &'static NSString;
1861}
1862
1863extern "C" {
1864 pub static NSApplicationDidChangeOcclusionStateNotification: &'static NSNotificationName;
1868}
1869
1870#[deprecated = "Use NSModalResponseStop instead"]
1872pub const NSRunStoppedResponse: c_int = -1000;
1873#[deprecated = "Use NSModalResponseAbort instead"]
1875pub const NSRunAbortedResponse: c_int = -1001;
1876#[deprecated = "Use NSModalResponseContinue instead"]
1878pub const NSRunContinuesResponse: c_int = -1002;
1879
1880#[cfg(feature = "NSResponder")]
1882impl NSApplication {
1883 extern_methods!(
1884 #[cfg(feature = "NSWindow")]
1885 #[deprecated = "Use -[NSWindow beginSheet:completionHandler:] instead"]
1887 #[unsafe(method(runModalForWindow:relativeToWindow:))]
1888 #[unsafe(method_family = none)]
1889 pub unsafe fn runModalForWindow_relativeToWindow(
1890 &self,
1891 window: Option<&NSWindow>,
1892 doc_window: Option<&NSWindow>,
1893 ) -> NSInteger;
1894
1895 #[cfg(feature = "NSWindow")]
1896 #[deprecated = "Use -[NSWindow beginSheet:completionHandler:] instead"]
1898 #[unsafe(method(beginModalSessionForWindow:relativeToWindow:))]
1899 #[unsafe(method_family = none)]
1900 pub unsafe fn beginModalSessionForWindow_relativeToWindow(
1901 &self,
1902 window: Option<&NSWindow>,
1903 doc_window: Option<&NSWindow>,
1904 ) -> NSModalSession;
1905
1906 #[deprecated]
1909 #[unsafe(method(application:printFiles:))]
1910 #[unsafe(method_family = none)]
1911 pub unsafe fn application_printFiles(
1912 &self,
1913 sender: Option<&NSApplication>,
1914 filenames: Option<&NSArray<NSString>>,
1915 );
1916
1917 #[cfg(feature = "NSWindow")]
1918 #[deprecated = "Use -[NSWindow beginSheet:completionHandler:] instead"]
1920 #[unsafe(method(beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:))]
1921 #[unsafe(method_family = none)]
1922 pub unsafe fn beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo(
1923 &self,
1924 sheet: &NSWindow,
1925 doc_window: &NSWindow,
1926 modal_delegate: Option<&AnyObject>,
1927 did_end_selector: Option<Sel>,
1928 context_info: *mut c_void,
1929 );
1930
1931 #[cfg(feature = "NSWindow")]
1932 #[deprecated = "Use -[NSWindow endSheet:] instead"]
1933 #[unsafe(method(endSheet:))]
1934 #[unsafe(method_family = none)]
1935 pub unsafe fn endSheet(&self, sheet: &NSWindow);
1936
1937 #[cfg(feature = "NSWindow")]
1938 #[deprecated = "Use -[NSWindow endSheet:returnCode:] instead"]
1939 #[unsafe(method(endSheet:returnCode:))]
1940 #[unsafe(method_family = none)]
1941 pub unsafe fn endSheet_returnCode(&self, sheet: &NSWindow, return_code: NSInteger);
1942
1943 #[cfg(feature = "NSWindow")]
1944 #[deprecated = "Use -enumerateWindowsWithOptions:usingBlock: instead"]
1945 #[unsafe(method(makeWindowsPerform:inOrder:))]
1946 #[unsafe(method_family = none)]
1947 pub unsafe fn makeWindowsPerform_inOrder(
1948 &self,
1949 selector: Sel,
1950 in_order: bool,
1951 ) -> Option<Retained<NSWindow>>;
1952
1953 #[cfg(feature = "NSGraphicsContext")]
1954 #[deprecated = "This method always returns nil. If you need access to the current drawing context, use [NSGraphicsContext currentContext] inside of a draw operation."]
1956 #[unsafe(method(context))]
1957 #[unsafe(method_family = none)]
1958 pub unsafe fn context(&self) -> Option<Retained<NSGraphicsContext>>;
1959 );
1960}
1961
1962extern "C-unwind" {
1963 #[deprecated = "renamed to `NSApplication::__main`"]
1964 pub fn NSApplicationMain(argc: c_int, argv: NonNull<NonNull<c_char>>) -> c_int;
1965}
1966
1967#[deprecated = "renamed to `NSApplication::load`"]
1968#[inline]
1969pub unsafe extern "C-unwind" fn NSApplicationLoad() -> bool {
1970 extern "C-unwind" {
1971 fn NSApplicationLoad() -> Bool;
1972 }
1973 unsafe { NSApplicationLoad() }.as_bool()
1974}