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"))]
454unsafe impl NSAccessibility for NSApplication {}
455
456#[cfg(all(feature = "NSAccessibilityProtocols", feature = "NSResponder"))]
457unsafe impl NSAccessibilityElementProtocol for NSApplication {}
458
459#[cfg(feature = "NSResponder")]
460unsafe impl NSCoding for NSApplication {}
461
462#[cfg(all(feature = "NSMenu", feature = "NSResponder"))]
463unsafe impl NSMenuItemValidation for NSApplication {}
464
465#[cfg(feature = "NSResponder")]
466unsafe impl NSObjectProtocol for NSApplication {}
467
468#[cfg(all(feature = "NSResponder", feature = "NSUserInterfaceValidation"))]
469unsafe impl NSUserInterfaceValidations for NSApplication {}
470
471#[cfg(feature = "NSResponder")]
472impl NSApplication {
473 extern_methods!(
474 #[unsafe(method(sharedApplication))]
475 #[unsafe(method_family = none)]
476 pub fn sharedApplication(mtm: MainThreadMarker) -> Retained<NSApplication>;
477
478 #[unsafe(method(delegate))]
479 #[unsafe(method_family = none)]
480 pub unsafe fn delegate(
481 &self,
482 ) -> Option<Retained<ProtocolObject<dyn NSApplicationDelegate>>>;
483
484 #[unsafe(method(setDelegate:))]
487 #[unsafe(method_family = none)]
488 pub fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSApplicationDelegate>>);
489
490 #[unsafe(method(hide:))]
491 #[unsafe(method_family = none)]
492 pub fn hide(&self, sender: Option<&AnyObject>);
493
494 #[unsafe(method(unhide:))]
495 #[unsafe(method_family = none)]
496 pub unsafe fn unhide(&self, sender: Option<&AnyObject>);
497
498 #[unsafe(method(unhideWithoutActivation))]
499 #[unsafe(method_family = none)]
500 pub unsafe fn unhideWithoutActivation(&self);
501
502 #[cfg(feature = "NSWindow")]
503 #[unsafe(method(windowWithWindowNumber:))]
504 #[unsafe(method_family = none)]
505 pub unsafe fn windowWithWindowNumber(
506 &self,
507 window_num: NSInteger,
508 ) -> Option<Retained<NSWindow>>;
509
510 #[cfg(feature = "NSWindow")]
511 #[unsafe(method(mainWindow))]
512 #[unsafe(method_family = none)]
513 pub unsafe fn mainWindow(&self) -> Option<Retained<NSWindow>>;
514
515 #[cfg(feature = "NSWindow")]
516 #[unsafe(method(keyWindow))]
517 #[unsafe(method_family = none)]
518 pub fn keyWindow(&self) -> Option<Retained<NSWindow>>;
519
520 #[unsafe(method(isActive))]
521 #[unsafe(method_family = none)]
522 pub unsafe fn isActive(&self) -> bool;
523
524 #[unsafe(method(isHidden))]
525 #[unsafe(method_family = none)]
526 pub unsafe fn isHidden(&self) -> bool;
527
528 #[unsafe(method(isRunning))]
529 #[unsafe(method_family = none)]
530 pub unsafe fn isRunning(&self) -> bool;
531
532 #[unsafe(method(deactivate))]
533 #[unsafe(method_family = none)]
534 pub unsafe fn deactivate(&self);
535
536 #[deprecated = "This method will be deprecated in a future release. Use NSApp.activate instead."]
539 #[unsafe(method(activateIgnoringOtherApps:))]
540 #[unsafe(method_family = none)]
541 pub fn activateIgnoringOtherApps(&self, ignore_other_apps: bool);
542
543 #[unsafe(method(activate))]
556 #[unsafe(method_family = none)]
557 pub unsafe fn activate(&self);
558
559 #[cfg(feature = "NSRunningApplication")]
560 #[unsafe(method(yieldActivationToApplication:))]
567 #[unsafe(method_family = none)]
568 pub unsafe fn yieldActivationToApplication(&self, application: &NSRunningApplication);
569
570 #[unsafe(method(yieldActivationToApplicationWithBundleIdentifier:))]
579 #[unsafe(method_family = none)]
580 pub unsafe fn yieldActivationToApplicationWithBundleIdentifier(
581 &self,
582 bundle_identifier: &NSString,
583 );
584
585 #[unsafe(method(hideOtherApplications:))]
586 #[unsafe(method_family = none)]
587 pub fn hideOtherApplications(&self, sender: Option<&AnyObject>);
588
589 #[unsafe(method(unhideAllApplications:))]
590 #[unsafe(method_family = none)]
591 pub unsafe fn unhideAllApplications(&self, sender: Option<&AnyObject>);
592
593 #[unsafe(method(finishLaunching))]
594 #[unsafe(method_family = none)]
595 pub unsafe fn finishLaunching(&self);
596
597 #[unsafe(method(run))]
598 #[unsafe(method_family = none)]
599 pub fn run(&self);
600
601 #[cfg(feature = "NSWindow")]
602 #[unsafe(method(runModalForWindow:))]
603 #[unsafe(method_family = none)]
604 pub unsafe fn runModalForWindow(&self, window: &NSWindow) -> NSModalResponse;
605
606 #[unsafe(method(stop:))]
607 #[unsafe(method_family = none)]
608 pub fn stop(&self, sender: Option<&AnyObject>);
609
610 #[unsafe(method(stopModal))]
611 #[unsafe(method_family = none)]
612 pub unsafe fn stopModal(&self);
613
614 #[unsafe(method(stopModalWithCode:))]
615 #[unsafe(method_family = none)]
616 pub unsafe fn stopModalWithCode(&self, return_code: NSModalResponse);
617
618 #[unsafe(method(abortModal))]
619 #[unsafe(method_family = none)]
620 pub unsafe fn abortModal(&self);
621
622 #[cfg(feature = "NSWindow")]
623 #[unsafe(method(modalWindow))]
624 #[unsafe(method_family = none)]
625 pub unsafe fn modalWindow(&self) -> Option<Retained<NSWindow>>;
626
627 #[cfg(feature = "NSWindow")]
628 #[unsafe(method(beginModalSessionForWindow:))]
629 #[unsafe(method_family = none)]
630 pub unsafe fn beginModalSessionForWindow(&self, window: &NSWindow) -> NSModalSession;
631
632 #[unsafe(method(runModalSession:))]
633 #[unsafe(method_family = none)]
634 pub unsafe fn runModalSession(&self, session: NSModalSession) -> NSModalResponse;
635
636 #[unsafe(method(endModalSession:))]
637 #[unsafe(method_family = none)]
638 pub unsafe fn endModalSession(&self, session: NSModalSession);
639
640 #[unsafe(method(terminate:))]
641 #[unsafe(method_family = none)]
642 pub unsafe fn terminate(&self, sender: Option<&AnyObject>);
643
644 #[unsafe(method(requestUserAttention:))]
646 #[unsafe(method_family = none)]
647 pub fn requestUserAttention(&self, request_type: NSRequestUserAttentionType) -> NSInteger;
648
649 #[unsafe(method(cancelUserAttentionRequest:))]
650 #[unsafe(method_family = none)]
651 pub unsafe fn cancelUserAttentionRequest(&self, request: NSInteger);
652
653 #[cfg(all(feature = "NSWindow", feature = "block2"))]
654 #[unsafe(method(enumerateWindowsWithOptions:usingBlock:))]
656 #[unsafe(method_family = none)]
657 pub unsafe fn enumerateWindowsWithOptions_usingBlock(
658 &self,
659 options: NSWindowListOptions,
660 block: &block2::Block<dyn Fn(NonNull<NSWindow>, NonNull<Bool>) + '_>,
661 );
662
663 #[unsafe(method(preventWindowOrdering))]
664 #[unsafe(method_family = none)]
665 pub unsafe fn preventWindowOrdering(&self);
666
667 #[cfg(feature = "NSWindow")]
668 #[unsafe(method(windows))]
669 #[unsafe(method_family = none)]
670 pub fn windows(&self) -> Retained<NSArray<NSWindow>>;
671
672 #[unsafe(method(setWindowsNeedUpdate:))]
673 #[unsafe(method_family = none)]
674 pub unsafe fn setWindowsNeedUpdate(&self, need_update: bool);
675
676 #[unsafe(method(updateWindows))]
677 #[unsafe(method_family = none)]
678 pub unsafe fn updateWindows(&self);
679
680 #[cfg(feature = "NSMenu")]
681 #[unsafe(method(mainMenu))]
682 #[unsafe(method_family = none)]
683 pub unsafe fn mainMenu(&self) -> Option<Retained<NSMenu>>;
684
685 #[cfg(feature = "NSMenu")]
686 #[unsafe(method(setMainMenu:))]
688 #[unsafe(method_family = none)]
689 pub fn setMainMenu(&self, main_menu: Option<&NSMenu>);
690
691 #[cfg(feature = "NSMenu")]
692 #[unsafe(method(helpMenu))]
695 #[unsafe(method_family = none)]
696 pub unsafe fn helpMenu(&self) -> Option<Retained<NSMenu>>;
697
698 #[cfg(feature = "NSMenu")]
699 #[unsafe(method(setHelpMenu:))]
701 #[unsafe(method_family = none)]
702 pub unsafe fn setHelpMenu(&self, help_menu: Option<&NSMenu>);
703
704 #[cfg(feature = "NSImage")]
705 #[unsafe(method(applicationIconImage))]
706 #[unsafe(method_family = none)]
707 pub unsafe fn applicationIconImage(&self) -> Option<Retained<NSImage>>;
708
709 #[cfg(feature = "NSImage")]
710 #[unsafe(method(setApplicationIconImage:))]
712 #[unsafe(method_family = none)]
713 pub unsafe fn setApplicationIconImage(&self, application_icon_image: Option<&NSImage>);
714
715 #[cfg(feature = "NSRunningApplication")]
716 #[unsafe(method(activationPolicy))]
718 #[unsafe(method_family = none)]
719 pub unsafe fn activationPolicy(&self) -> NSApplicationActivationPolicy;
720
721 #[cfg(feature = "NSRunningApplication")]
722 #[unsafe(method(setActivationPolicy:))]
729 #[unsafe(method_family = none)]
730 pub fn setActivationPolicy(&self, activation_policy: NSApplicationActivationPolicy)
731 -> bool;
732
733 #[cfg(feature = "NSDockTile")]
734 #[unsafe(method(dockTile))]
735 #[unsafe(method_family = none)]
736 pub unsafe fn dockTile(&self) -> Retained<NSDockTile>;
737
738 #[unsafe(method(reportException:))]
739 #[unsafe(method_family = none)]
740 pub unsafe fn reportException(&self, exception: &NSException);
741
742 #[unsafe(method(detachDrawingThread:toTarget:withObject:))]
743 #[unsafe(method_family = none)]
744 pub unsafe fn detachDrawingThread_toTarget_withObject(
745 selector: Sel,
746 target: &AnyObject,
747 argument: Option<&AnyObject>,
748 mtm: MainThreadMarker,
749 );
750
751 #[unsafe(method(replyToApplicationShouldTerminate:))]
753 #[unsafe(method_family = none)]
754 pub unsafe fn replyToApplicationShouldTerminate(&self, should_terminate: bool);
755
756 #[unsafe(method(replyToOpenOrPrint:))]
761 #[unsafe(method_family = none)]
762 pub unsafe fn replyToOpenOrPrint(&self, reply: NSApplicationDelegateReply);
763
764 #[unsafe(method(orderFrontCharacterPalette:))]
766 #[unsafe(method_family = none)]
767 pub fn orderFrontCharacterPalette(&self, sender: Option<&AnyObject>);
768
769 #[unsafe(method(presentationOptions))]
773 #[unsafe(method_family = none)]
774 pub fn presentationOptions(&self) -> NSApplicationPresentationOptions;
775
776 #[unsafe(method(setPresentationOptions:))]
778 #[unsafe(method_family = none)]
779 pub fn setPresentationOptions(
780 &self,
781 presentation_options: NSApplicationPresentationOptions,
782 );
783
784 #[unsafe(method(currentSystemPresentationOptions))]
787 #[unsafe(method_family = none)]
788 pub unsafe fn currentSystemPresentationOptions(&self) -> NSApplicationPresentationOptions;
789
790 #[unsafe(method(occlusionState))]
791 #[unsafe(method_family = none)]
792 pub unsafe fn occlusionState(&self) -> NSApplicationOcclusionState;
793
794 #[unsafe(method(isProtectedDataAvailable))]
795 #[unsafe(method_family = none)]
796 pub unsafe fn isProtectedDataAvailable(&self) -> bool;
797 );
798}
799
800#[cfg(feature = "NSResponder")]
802impl NSApplication {
803 extern_methods!(
804 #[unsafe(method(init))]
805 #[unsafe(method_family = init)]
806 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
807
808 #[unsafe(method(initWithCoder:))]
809 #[unsafe(method_family = init)]
810 pub unsafe fn initWithCoder(
811 this: Allocated<Self>,
812 coder: &NSCoder,
813 ) -> Option<Retained<Self>>;
814 );
815}
816
817#[cfg(feature = "NSResponder")]
819impl NSApplication {
820 extern_methods!(
821 #[unsafe(method(new))]
822 #[unsafe(method_family = new)]
823 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
824 );
825}
826
827#[cfg(feature = "NSResponder")]
829impl NSApplication {
830 extern_methods!(
831 #[cfg(feature = "NSAppearance")]
832 #[unsafe(method(appearance))]
833 #[unsafe(method_family = none)]
834 pub unsafe fn appearance(&self) -> Option<Retained<NSAppearance>>;
835
836 #[cfg(feature = "NSAppearance")]
837 #[unsafe(method(setAppearance:))]
839 #[unsafe(method_family = none)]
840 pub fn setAppearance(&self, appearance: Option<&NSAppearance>);
841
842 #[cfg(feature = "NSAppearance")]
843 #[unsafe(method(effectiveAppearance))]
844 #[unsafe(method_family = none)]
845 pub fn effectiveAppearance(&self) -> Retained<NSAppearance>;
846 );
847}
848
849#[cfg(all(feature = "NSAppearance", feature = "NSResponder"))]
850unsafe impl NSAppearanceCustomization for NSApplication {}
851
852#[cfg(feature = "NSResponder")]
854impl NSApplication {
855 extern_methods!(
856 #[cfg(feature = "NSEvent")]
857 #[unsafe(method(sendEvent:))]
858 #[unsafe(method_family = none)]
859 pub unsafe fn sendEvent(&self, event: &NSEvent);
860
861 #[cfg(feature = "NSEvent")]
862 #[unsafe(method(postEvent:atStart:))]
863 #[unsafe(method_family = none)]
864 pub fn postEvent_atStart(&self, event: &NSEvent, at_start: bool);
865
866 #[cfg(feature = "NSEvent")]
867 #[unsafe(method(currentEvent))]
868 #[unsafe(method_family = none)]
869 pub fn currentEvent(&self) -> Option<Retained<NSEvent>>;
870
871 #[cfg(feature = "NSEvent")]
872 #[unsafe(method(nextEventMatchingMask:untilDate:inMode:dequeue:))]
873 #[unsafe(method_family = none)]
874 pub unsafe fn nextEventMatchingMask_untilDate_inMode_dequeue(
875 &self,
876 mask: NSEventMask,
877 expiration: Option<&NSDate>,
878 mode: &NSRunLoopMode,
879 deq_flag: bool,
880 ) -> Option<Retained<NSEvent>>;
881
882 #[cfg(feature = "NSEvent")]
883 #[unsafe(method(discardEventsMatchingMask:beforeEvent:))]
884 #[unsafe(method_family = none)]
885 pub unsafe fn discardEventsMatchingMask_beforeEvent(
886 &self,
887 mask: NSEventMask,
888 last_event: Option<&NSEvent>,
889 );
890 );
891}
892
893#[cfg(feature = "NSResponder")]
895impl NSApplication {
896 extern_methods!(
897 #[unsafe(method(sendAction:to:from:))]
898 #[unsafe(method_family = none)]
899 pub unsafe fn sendAction_to_from(
900 &self,
901 action: Sel,
902 target: Option<&AnyObject>,
903 sender: Option<&AnyObject>,
904 ) -> bool;
905
906 #[unsafe(method(targetForAction:))]
907 #[unsafe(method_family = none)]
908 pub unsafe fn targetForAction(&self, action: Sel) -> Option<Retained<AnyObject>>;
909
910 #[unsafe(method(targetForAction:to:from:))]
911 #[unsafe(method_family = none)]
912 pub unsafe fn targetForAction_to_from(
913 &self,
914 action: Sel,
915 target: Option<&AnyObject>,
916 sender: Option<&AnyObject>,
917 ) -> Option<Retained<AnyObject>>;
918
919 #[unsafe(method(tryToPerform:with:))]
920 #[unsafe(method_family = none)]
921 pub unsafe fn tryToPerform_with(&self, action: Sel, object: Option<&AnyObject>) -> bool;
922
923 #[cfg(feature = "NSPasteboard")]
924 #[unsafe(method(validRequestorForSendType:returnType:))]
925 #[unsafe(method_family = none)]
926 pub unsafe fn validRequestorForSendType_returnType(
927 &self,
928 send_type: Option<&NSPasteboardType>,
929 return_type: Option<&NSPasteboardType>,
930 ) -> Option<Retained<AnyObject>>;
931 );
932}
933
934#[cfg(feature = "NSResponder")]
936impl NSApplication {
937 extern_methods!(
938 #[cfg(feature = "NSMenu")]
939 #[unsafe(method(windowsMenu))]
940 #[unsafe(method_family = none)]
941 pub unsafe fn windowsMenu(&self) -> Option<Retained<NSMenu>>;
942
943 #[cfg(feature = "NSMenu")]
944 #[unsafe(method(setWindowsMenu:))]
946 #[unsafe(method_family = none)]
947 pub unsafe fn setWindowsMenu(&self, windows_menu: Option<&NSMenu>);
948
949 #[unsafe(method(arrangeInFront:))]
950 #[unsafe(method_family = none)]
951 pub unsafe fn arrangeInFront(&self, sender: Option<&AnyObject>);
952
953 #[cfg(feature = "NSWindow")]
954 #[unsafe(method(removeWindowsItem:))]
955 #[unsafe(method_family = none)]
956 pub unsafe fn removeWindowsItem(&self, win: &NSWindow);
957
958 #[cfg(feature = "NSWindow")]
959 #[unsafe(method(addWindowsItem:title:filename:))]
960 #[unsafe(method_family = none)]
961 pub unsafe fn addWindowsItem_title_filename(
962 &self,
963 win: &NSWindow,
964 string: &NSString,
965 is_filename: bool,
966 );
967
968 #[cfg(feature = "NSWindow")]
969 #[unsafe(method(changeWindowsItem:title:filename:))]
970 #[unsafe(method_family = none)]
971 pub unsafe fn changeWindowsItem_title_filename(
972 &self,
973 win: &NSWindow,
974 string: &NSString,
975 is_filename: bool,
976 );
977
978 #[cfg(feature = "NSWindow")]
979 #[unsafe(method(updateWindowsItem:))]
980 #[unsafe(method_family = none)]
981 pub unsafe fn updateWindowsItem(&self, win: &NSWindow);
982
983 #[unsafe(method(miniaturizeAll:))]
984 #[unsafe(method_family = none)]
985 pub unsafe fn miniaturizeAll(&self, sender: Option<&AnyObject>);
986 );
987}
988
989#[cfg(feature = "NSResponder")]
991impl NSApplication {
992 extern_methods!(
993 #[unsafe(method(isFullKeyboardAccessEnabled))]
997 #[unsafe(method_family = none)]
998 pub unsafe fn isFullKeyboardAccessEnabled(&self) -> bool;
999 );
1000}
1001
1002#[repr(transparent)]
1007#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1008pub struct NSApplicationTerminateReply(pub NSUInteger);
1009impl NSApplicationTerminateReply {
1010 #[doc(alias = "NSTerminateCancel")]
1011 pub const TerminateCancel: Self = Self(0);
1012 #[doc(alias = "NSTerminateNow")]
1013 pub const TerminateNow: Self = Self(1);
1014 #[doc(alias = "NSTerminateLater")]
1015 pub const TerminateLater: Self = Self(2);
1016}
1017
1018unsafe impl Encode for NSApplicationTerminateReply {
1019 const ENCODING: Encoding = NSUInteger::ENCODING;
1020}
1021
1022unsafe impl RefEncode for NSApplicationTerminateReply {
1023 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1024}
1025
1026#[repr(transparent)]
1031#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1032pub struct NSApplicationPrintReply(pub NSUInteger);
1033impl NSApplicationPrintReply {
1034 #[doc(alias = "NSPrintingCancelled")]
1035 pub const PrintingCancelled: Self = Self(0);
1036 #[doc(alias = "NSPrintingSuccess")]
1037 pub const PrintingSuccess: Self = Self(1);
1038 #[doc(alias = "NSPrintingReplyLater")]
1039 pub const PrintingReplyLater: Self = Self(2);
1040 #[doc(alias = "NSPrintingFailure")]
1041 pub const PrintingFailure: Self = Self(3);
1042}
1043
1044unsafe impl Encode for NSApplicationPrintReply {
1045 const ENCODING: Encoding = NSUInteger::ENCODING;
1046}
1047
1048unsafe impl RefEncode for NSApplicationPrintReply {
1049 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1050}
1051
1052extern_protocol!(
1053 pub unsafe trait NSApplicationDelegate: NSObjectProtocol + MainThreadOnly {
1055 #[cfg(feature = "NSResponder")]
1056 #[optional]
1065 #[unsafe(method(applicationShouldTerminate:))]
1066 #[unsafe(method_family = none)]
1067 unsafe fn applicationShouldTerminate(
1068 &self,
1069 sender: &NSApplication,
1070 ) -> NSApplicationTerminateReply;
1071
1072 #[cfg(feature = "NSResponder")]
1073 #[optional]
1079 #[unsafe(method(application:openURLs:))]
1080 #[unsafe(method_family = none)]
1081 unsafe fn application_openURLs(&self, application: &NSApplication, urls: &NSArray<NSURL>);
1082
1083 #[cfg(feature = "NSResponder")]
1084 #[optional]
1085 #[unsafe(method(application:openFile:))]
1086 #[unsafe(method_family = none)]
1087 unsafe fn application_openFile(&self, sender: &NSApplication, filename: &NSString) -> bool;
1088
1089 #[cfg(feature = "NSResponder")]
1090 #[optional]
1091 #[unsafe(method(application:openFiles:))]
1092 #[unsafe(method_family = none)]
1093 unsafe fn application_openFiles(
1094 &self,
1095 sender: &NSApplication,
1096 filenames: &NSArray<NSString>,
1097 );
1098
1099 #[cfg(feature = "NSResponder")]
1100 #[optional]
1101 #[unsafe(method(application:openTempFile:))]
1102 #[unsafe(method_family = none)]
1103 unsafe fn application_openTempFile(
1104 &self,
1105 sender: &NSApplication,
1106 filename: &NSString,
1107 ) -> bool;
1108
1109 #[cfg(feature = "NSResponder")]
1110 #[optional]
1111 #[unsafe(method(applicationShouldOpenUntitledFile:))]
1112 #[unsafe(method_family = none)]
1113 unsafe fn applicationShouldOpenUntitledFile(&self, sender: &NSApplication) -> bool;
1114
1115 #[cfg(feature = "NSResponder")]
1116 #[optional]
1117 #[unsafe(method(applicationOpenUntitledFile:))]
1118 #[unsafe(method_family = none)]
1119 unsafe fn applicationOpenUntitledFile(&self, sender: &NSApplication) -> bool;
1120
1121 #[optional]
1122 #[unsafe(method(application:openFileWithoutUI:))]
1123 #[unsafe(method_family = none)]
1124 unsafe fn application_openFileWithoutUI(
1125 &self,
1126 sender: &AnyObject,
1127 filename: &NSString,
1128 ) -> bool;
1129
1130 #[cfg(feature = "NSResponder")]
1131 #[optional]
1132 #[unsafe(method(application:printFile:))]
1133 #[unsafe(method_family = none)]
1134 unsafe fn application_printFile(&self, sender: &NSApplication, filename: &NSString)
1135 -> bool;
1136
1137 #[cfg(all(feature = "NSPrintInfo", feature = "NSResponder"))]
1138 #[optional]
1139 #[unsafe(method(application:printFiles:withSettings:showPrintPanels:))]
1140 #[unsafe(method_family = none)]
1141 unsafe fn application_printFiles_withSettings_showPrintPanels(
1142 &self,
1143 application: &NSApplication,
1144 file_names: &NSArray<NSString>,
1145 print_settings: &NSDictionary<NSPrintInfoAttributeKey, AnyObject>,
1146 show_print_panels: bool,
1147 ) -> NSApplicationPrintReply;
1148
1149 #[cfg(feature = "NSResponder")]
1150 #[optional]
1151 #[unsafe(method(applicationShouldTerminateAfterLastWindowClosed:))]
1152 #[unsafe(method_family = none)]
1153 unsafe fn applicationShouldTerminateAfterLastWindowClosed(
1154 &self,
1155 sender: &NSApplication,
1156 ) -> bool;
1157
1158 #[cfg(feature = "NSResponder")]
1159 #[optional]
1160 #[unsafe(method(applicationShouldHandleReopen:hasVisibleWindows:))]
1161 #[unsafe(method_family = none)]
1162 unsafe fn applicationShouldHandleReopen_hasVisibleWindows(
1163 &self,
1164 sender: &NSApplication,
1165 has_visible_windows: bool,
1166 ) -> bool;
1167
1168 #[cfg(all(feature = "NSMenu", feature = "NSResponder"))]
1169 #[optional]
1170 #[unsafe(method(applicationDockMenu:))]
1171 #[unsafe(method_family = none)]
1172 unsafe fn applicationDockMenu(&self, sender: &NSApplication) -> Option<Retained<NSMenu>>;
1173
1174 #[cfg(feature = "NSResponder")]
1175 #[optional]
1176 #[unsafe(method(application:willPresentError:))]
1177 #[unsafe(method_family = none)]
1178 unsafe fn application_willPresentError(
1179 &self,
1180 application: &NSApplication,
1181 error: &NSError,
1182 ) -> Retained<NSError>;
1183
1184 #[cfg(feature = "NSResponder")]
1185 #[optional]
1186 #[unsafe(method(application:didRegisterForRemoteNotificationsWithDeviceToken:))]
1187 #[unsafe(method_family = none)]
1188 unsafe fn application_didRegisterForRemoteNotificationsWithDeviceToken(
1189 &self,
1190 application: &NSApplication,
1191 device_token: &NSData,
1192 );
1193
1194 #[cfg(feature = "NSResponder")]
1195 #[optional]
1196 #[unsafe(method(application:didFailToRegisterForRemoteNotificationsWithError:))]
1197 #[unsafe(method_family = none)]
1198 unsafe fn application_didFailToRegisterForRemoteNotificationsWithError(
1199 &self,
1200 application: &NSApplication,
1201 error: &NSError,
1202 );
1203
1204 #[cfg(feature = "NSResponder")]
1205 #[optional]
1206 #[unsafe(method(application:didReceiveRemoteNotification:))]
1207 #[unsafe(method_family = none)]
1208 unsafe fn application_didReceiveRemoteNotification(
1209 &self,
1210 application: &NSApplication,
1211 user_info: &NSDictionary<NSString, AnyObject>,
1212 );
1213
1214 #[cfg(feature = "NSResponder")]
1215 #[optional]
1226 #[unsafe(method(applicationSupportsSecureRestorableState:))]
1227 #[unsafe(method_family = none)]
1228 unsafe fn applicationSupportsSecureRestorableState(&self, app: &NSApplication) -> bool;
1229
1230 #[cfg(feature = "NSResponder")]
1231 #[optional]
1234 #[unsafe(method(application:willEncodeRestorableState:))]
1235 #[unsafe(method_family = none)]
1236 unsafe fn application_willEncodeRestorableState(
1237 &self,
1238 app: &NSApplication,
1239 coder: &NSCoder,
1240 );
1241
1242 #[cfg(feature = "NSResponder")]
1243 #[optional]
1246 #[unsafe(method(application:didDecodeRestorableState:))]
1247 #[unsafe(method_family = none)]
1248 unsafe fn application_didDecodeRestorableState(&self, app: &NSApplication, coder: &NSCoder);
1249
1250 #[cfg(feature = "NSResponder")]
1251 #[optional]
1258 #[unsafe(method(application:willContinueUserActivityWithType:))]
1259 #[unsafe(method_family = none)]
1260 unsafe fn application_willContinueUserActivityWithType(
1261 &self,
1262 application: &NSApplication,
1263 user_activity_type: &NSString,
1264 ) -> bool;
1265
1266 #[cfg(all(
1267 feature = "NSResponder",
1268 feature = "NSUserActivity",
1269 feature = "block2"
1270 ))]
1271 #[optional]
1286 #[unsafe(method(application:continueUserActivity:restorationHandler:))]
1287 #[unsafe(method_family = none)]
1288 unsafe fn application_continueUserActivity_restorationHandler(
1289 &self,
1290 application: &NSApplication,
1291 user_activity: &NSUserActivity,
1292 restoration_handler: &block2::Block<
1293 dyn Fn(NonNull<NSArray<ProtocolObject<dyn NSUserActivityRestoring>>>),
1294 >,
1295 ) -> bool;
1296
1297 #[cfg(feature = "NSResponder")]
1298 #[optional]
1301 #[unsafe(method(application:didFailToContinueUserActivityWithType:error:))]
1302 #[unsafe(method_family = none)]
1303 unsafe fn application_didFailToContinueUserActivityWithType_error(
1304 &self,
1305 application: &NSApplication,
1306 user_activity_type: &NSString,
1307 error: &NSError,
1308 );
1309
1310 #[cfg(feature = "NSResponder")]
1311 #[optional]
1314 #[unsafe(method(application:didUpdateUserActivity:))]
1315 #[unsafe(method_family = none)]
1316 unsafe fn application_didUpdateUserActivity(
1317 &self,
1318 application: &NSApplication,
1319 user_activity: &NSUserActivity,
1320 );
1321
1322 #[cfg(all(feature = "NSResponder", feature = "objc2-cloud-kit"))]
1323 #[cfg(target_vendor = "apple")]
1324 #[optional]
1333 #[unsafe(method(application:userDidAcceptCloudKitShareWithMetadata:))]
1334 #[unsafe(method_family = none)]
1335 unsafe fn application_userDidAcceptCloudKitShareWithMetadata(
1336 &self,
1337 application: &NSApplication,
1338 metadata: &CKShareMetadata,
1339 );
1340
1341 #[cfg(feature = "NSResponder")]
1342 #[optional]
1345 #[unsafe(method(application:delegateHandlesKey:))]
1346 #[unsafe(method_family = none)]
1347 unsafe fn application_delegateHandlesKey(
1348 &self,
1349 sender: &NSApplication,
1350 key: &NSString,
1351 ) -> bool;
1352
1353 #[cfg(feature = "NSResponder")]
1354 #[optional]
1360 #[unsafe(method(applicationShouldAutomaticallyLocalizeKeyEquivalents:))]
1361 #[unsafe(method_family = none)]
1362 unsafe fn applicationShouldAutomaticallyLocalizeKeyEquivalents(
1363 &self,
1364 application: &NSApplication,
1365 ) -> bool;
1366
1367 #[optional]
1368 #[unsafe(method(applicationWillFinishLaunching:))]
1369 #[unsafe(method_family = none)]
1370 unsafe fn applicationWillFinishLaunching(&self, notification: &NSNotification);
1371
1372 #[optional]
1373 #[unsafe(method(applicationDidFinishLaunching:))]
1374 #[unsafe(method_family = none)]
1375 unsafe fn applicationDidFinishLaunching(&self, notification: &NSNotification);
1376
1377 #[optional]
1378 #[unsafe(method(applicationWillHide:))]
1379 #[unsafe(method_family = none)]
1380 unsafe fn applicationWillHide(&self, notification: &NSNotification);
1381
1382 #[optional]
1383 #[unsafe(method(applicationDidHide:))]
1384 #[unsafe(method_family = none)]
1385 unsafe fn applicationDidHide(&self, notification: &NSNotification);
1386
1387 #[optional]
1388 #[unsafe(method(applicationWillUnhide:))]
1389 #[unsafe(method_family = none)]
1390 unsafe fn applicationWillUnhide(&self, notification: &NSNotification);
1391
1392 #[optional]
1393 #[unsafe(method(applicationDidUnhide:))]
1394 #[unsafe(method_family = none)]
1395 unsafe fn applicationDidUnhide(&self, notification: &NSNotification);
1396
1397 #[optional]
1398 #[unsafe(method(applicationWillBecomeActive:))]
1399 #[unsafe(method_family = none)]
1400 unsafe fn applicationWillBecomeActive(&self, notification: &NSNotification);
1401
1402 #[optional]
1403 #[unsafe(method(applicationDidBecomeActive:))]
1404 #[unsafe(method_family = none)]
1405 unsafe fn applicationDidBecomeActive(&self, notification: &NSNotification);
1406
1407 #[optional]
1408 #[unsafe(method(applicationWillResignActive:))]
1409 #[unsafe(method_family = none)]
1410 unsafe fn applicationWillResignActive(&self, notification: &NSNotification);
1411
1412 #[optional]
1413 #[unsafe(method(applicationDidResignActive:))]
1414 #[unsafe(method_family = none)]
1415 unsafe fn applicationDidResignActive(&self, notification: &NSNotification);
1416
1417 #[optional]
1418 #[unsafe(method(applicationWillUpdate:))]
1419 #[unsafe(method_family = none)]
1420 unsafe fn applicationWillUpdate(&self, notification: &NSNotification);
1421
1422 #[optional]
1423 #[unsafe(method(applicationDidUpdate:))]
1424 #[unsafe(method_family = none)]
1425 unsafe fn applicationDidUpdate(&self, notification: &NSNotification);
1426
1427 #[optional]
1428 #[unsafe(method(applicationWillTerminate:))]
1429 #[unsafe(method_family = none)]
1430 unsafe fn applicationWillTerminate(&self, notification: &NSNotification);
1431
1432 #[optional]
1433 #[unsafe(method(applicationDidChangeScreenParameters:))]
1434 #[unsafe(method_family = none)]
1435 unsafe fn applicationDidChangeScreenParameters(&self, notification: &NSNotification);
1436
1437 #[optional]
1438 #[unsafe(method(applicationDidChangeOcclusionState:))]
1439 #[unsafe(method_family = none)]
1440 unsafe fn applicationDidChangeOcclusionState(&self, notification: &NSNotification);
1441
1442 #[optional]
1443 #[unsafe(method(applicationProtectedDataWillBecomeUnavailable:))]
1444 #[unsafe(method_family = none)]
1445 unsafe fn applicationProtectedDataWillBecomeUnavailable(
1446 &self,
1447 notification: &NSNotification,
1448 );
1449
1450 #[optional]
1451 #[unsafe(method(applicationProtectedDataDidBecomeAvailable:))]
1452 #[unsafe(method_family = none)]
1453 unsafe fn applicationProtectedDataDidBecomeAvailable(&self, notification: &NSNotification);
1454 }
1455);
1456
1457#[cfg(feature = "NSResponder")]
1459impl NSApplication {
1460 extern_methods!(
1461 #[cfg(feature = "NSMenu")]
1462 #[unsafe(method(servicesMenu))]
1463 #[unsafe(method_family = none)]
1464 pub unsafe fn servicesMenu(&self) -> Option<Retained<NSMenu>>;
1465
1466 #[cfg(feature = "NSMenu")]
1467 #[unsafe(method(setServicesMenu:))]
1469 #[unsafe(method_family = none)]
1470 pub unsafe fn setServicesMenu(&self, services_menu: Option<&NSMenu>);
1471
1472 #[cfg(feature = "NSPasteboard")]
1473 #[unsafe(method(registerServicesMenuSendTypes:returnTypes:))]
1474 #[unsafe(method_family = none)]
1475 pub unsafe fn registerServicesMenuSendTypes_returnTypes(
1476 &self,
1477 send_types: &NSArray<NSPasteboardType>,
1478 return_types: &NSArray<NSPasteboardType>,
1479 );
1480 );
1481}
1482
1483extern_protocol!(
1484 pub unsafe trait NSServicesMenuRequestor: NSObjectProtocol {
1486 #[cfg(feature = "NSPasteboard")]
1487 #[optional]
1488 #[unsafe(method(writeSelectionToPasteboard:types:))]
1489 #[unsafe(method_family = none)]
1490 unsafe fn writeSelectionToPasteboard_types(
1491 &self,
1492 pboard: &NSPasteboard,
1493 types: &NSArray<NSPasteboardType>,
1494 ) -> bool;
1495
1496 #[cfg(feature = "NSPasteboard")]
1497 #[optional]
1498 #[unsafe(method(readSelectionFromPasteboard:))]
1499 #[unsafe(method_family = none)]
1500 unsafe fn readSelectionFromPasteboard(&self, pboard: &NSPasteboard) -> bool;
1501 }
1502);
1503
1504#[cfg(feature = "NSResponder")]
1506impl NSApplication {
1507 extern_methods!(
1508 #[unsafe(method(servicesProvider))]
1509 #[unsafe(method_family = none)]
1510 pub unsafe fn servicesProvider(&self) -> Option<Retained<AnyObject>>;
1511
1512 #[unsafe(method(setServicesProvider:))]
1514 #[unsafe(method_family = none)]
1515 pub unsafe fn setServicesProvider(&self, services_provider: Option<&AnyObject>);
1516 );
1517}
1518
1519pub type NSAboutPanelOptionKey = NSString;
1525
1526extern "C" {
1527 pub static NSAboutPanelOptionCredits: &'static NSAboutPanelOptionKey;
1531}
1532
1533extern "C" {
1534 pub static NSAboutPanelOptionApplicationName: &'static NSAboutPanelOptionKey;
1538}
1539
1540extern "C" {
1541 pub static NSAboutPanelOptionApplicationIcon: &'static NSAboutPanelOptionKey;
1547}
1548
1549extern "C" {
1550 pub static NSAboutPanelOptionVersion: &'static NSAboutPanelOptionKey;
1554}
1555
1556extern "C" {
1557 pub static NSAboutPanelOptionApplicationVersion: &'static NSAboutPanelOptionKey;
1561}
1562
1563#[cfg(feature = "NSResponder")]
1565impl NSApplication {
1566 extern_methods!(
1567 #[unsafe(method(orderFrontStandardAboutPanel:))]
1568 #[unsafe(method_family = none)]
1569 pub unsafe fn orderFrontStandardAboutPanel(&self, sender: Option<&AnyObject>);
1570
1571 #[unsafe(method(orderFrontStandardAboutPanelWithOptions:))]
1572 #[unsafe(method_family = none)]
1573 pub unsafe fn orderFrontStandardAboutPanelWithOptions(
1574 &self,
1575 options_dictionary: &NSDictionary<NSAboutPanelOptionKey, AnyObject>,
1576 );
1577 );
1578}
1579
1580#[cfg(feature = "NSResponder")]
1582impl NSApplication {
1583 extern_methods!(
1584 #[cfg(feature = "NSUserInterfaceLayout")]
1585 #[unsafe(method(userInterfaceLayoutDirection))]
1586 #[unsafe(method_family = none)]
1587 pub unsafe fn userInterfaceLayoutDirection(&self) -> NSUserInterfaceLayoutDirection;
1588 );
1589}
1590
1591#[cfg(feature = "NSResponder")]
1593impl NSApplication {
1594 extern_methods!(
1595 #[unsafe(method(disableRelaunchOnLogin))]
1603 #[unsafe(method_family = none)]
1604 pub unsafe fn disableRelaunchOnLogin(&self);
1605
1606 #[unsafe(method(enableRelaunchOnLogin))]
1607 #[unsafe(method_family = none)]
1608 pub unsafe fn enableRelaunchOnLogin(&self);
1609 );
1610}
1611
1612#[repr(transparent)]
1618#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1619pub struct NSRemoteNotificationType(pub NSUInteger);
1620bitflags::bitflags! {
1621 impl NSRemoteNotificationType: NSUInteger {
1622 #[doc(alias = "NSRemoteNotificationTypeNone")]
1623 const None = 0;
1624 #[doc(alias = "NSRemoteNotificationTypeBadge")]
1625 const Badge = 1<<0;
1626 #[doc(alias = "NSRemoteNotificationTypeSound")]
1627 const Sound = 1<<1;
1628 #[doc(alias = "NSRemoteNotificationTypeAlert")]
1629 const Alert = 1<<2;
1630 }
1631}
1632
1633unsafe impl Encode for NSRemoteNotificationType {
1634 const ENCODING: Encoding = NSUInteger::ENCODING;
1635}
1636
1637unsafe impl RefEncode for NSRemoteNotificationType {
1638 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1639}
1640
1641#[cfg(feature = "NSResponder")]
1643impl NSApplication {
1644 extern_methods!(
1645 #[unsafe(method(registerForRemoteNotifications))]
1646 #[unsafe(method_family = none)]
1647 pub unsafe fn registerForRemoteNotifications(&self);
1648
1649 #[unsafe(method(unregisterForRemoteNotifications))]
1650 #[unsafe(method_family = none)]
1651 pub unsafe fn unregisterForRemoteNotifications(&self);
1652
1653 #[unsafe(method(isRegisteredForRemoteNotifications))]
1655 #[unsafe(method_family = none)]
1656 pub unsafe fn isRegisteredForRemoteNotifications(&self) -> bool;
1657
1658 #[unsafe(method(registerForRemoteNotificationTypes:))]
1661 #[unsafe(method_family = none)]
1662 pub unsafe fn registerForRemoteNotificationTypes(&self, types: NSRemoteNotificationType);
1663
1664 #[unsafe(method(enabledRemoteNotificationTypes))]
1665 #[unsafe(method_family = none)]
1666 pub unsafe fn enabledRemoteNotificationTypes(&self) -> NSRemoteNotificationType;
1667 );
1668}
1669
1670extern "C-unwind" {
1671 pub fn NSApplicationMain(argc: c_int, argv: NonNull<NonNull<c_char>>) -> c_int;
1673}
1674
1675#[inline]
1678pub unsafe extern "C-unwind" fn NSApplicationLoad() -> bool {
1679 extern "C-unwind" {
1680 fn NSApplicationLoad() -> Bool;
1681 }
1682 unsafe { NSApplicationLoad() }.as_bool()
1683}
1684
1685#[inline]
1688pub unsafe extern "C-unwind" fn NSShowsServicesMenuItem(item_name: &NSString) -> bool {
1689 extern "C-unwind" {
1690 fn NSShowsServicesMenuItem(item_name: &NSString) -> Bool;
1691 }
1692 unsafe { NSShowsServicesMenuItem(item_name) }.as_bool()
1693}
1694
1695#[inline]
1697pub unsafe extern "C-unwind" fn NSSetShowsServicesMenuItem(
1698 item_name: &NSString,
1699 enabled: bool,
1700) -> NSInteger {
1701 extern "C-unwind" {
1702 fn NSSetShowsServicesMenuItem(item_name: &NSString, enabled: Bool) -> NSInteger;
1703 }
1704 unsafe { NSSetShowsServicesMenuItem(item_name, Bool::new(enabled)) }
1705}
1706
1707extern "C-unwind" {
1708 pub fn NSUpdateDynamicServices();
1711}
1712
1713#[cfg(feature = "NSPasteboard")]
1714#[inline]
1715pub unsafe extern "C-unwind" fn NSPerformService(
1716 item_name: &NSString,
1717 pboard: Option<&NSPasteboard>,
1718) -> bool {
1719 extern "C-unwind" {
1720 fn NSPerformService(item_name: &NSString, pboard: Option<&NSPasteboard>) -> Bool;
1721 }
1722 unsafe { NSPerformService(item_name, pboard) }.as_bool()
1723}
1724
1725pub type NSServiceProviderName = NSString;
1727
1728extern "C-unwind" {
1729 pub fn NSRegisterServicesProvider(provider: Option<&AnyObject>, name: &NSServiceProviderName);
1731}
1732
1733extern "C-unwind" {
1734 pub fn NSUnregisterServicesProvider(name: &NSServiceProviderName);
1735}
1736
1737extern "C" {
1738 pub static NSApplicationDidBecomeActiveNotification: &'static NSNotificationName;
1740}
1741
1742extern "C" {
1743 pub static NSApplicationDidHideNotification: &'static NSNotificationName;
1745}
1746
1747extern "C" {
1748 pub static NSApplicationDidFinishLaunchingNotification: &'static NSNotificationName;
1750}
1751
1752extern "C" {
1753 pub static NSApplicationDidResignActiveNotification: &'static NSNotificationName;
1755}
1756
1757extern "C" {
1758 pub static NSApplicationDidUnhideNotification: &'static NSNotificationName;
1760}
1761
1762extern "C" {
1763 pub static NSApplicationDidUpdateNotification: &'static NSNotificationName;
1765}
1766
1767extern "C" {
1768 pub static NSApplicationWillBecomeActiveNotification: &'static NSNotificationName;
1770}
1771
1772extern "C" {
1773 pub static NSApplicationWillHideNotification: &'static NSNotificationName;
1775}
1776
1777extern "C" {
1778 pub static NSApplicationWillFinishLaunchingNotification: &'static NSNotificationName;
1780}
1781
1782extern "C" {
1783 pub static NSApplicationWillResignActiveNotification: &'static NSNotificationName;
1785}
1786
1787extern "C" {
1788 pub static NSApplicationWillUnhideNotification: &'static NSNotificationName;
1790}
1791
1792extern "C" {
1793 pub static NSApplicationWillUpdateNotification: &'static NSNotificationName;
1795}
1796
1797extern "C" {
1798 pub static NSApplicationWillTerminateNotification: &'static NSNotificationName;
1800}
1801
1802extern "C" {
1803 pub static NSApplicationDidChangeScreenParametersNotification: &'static NSNotificationName;
1805}
1806
1807extern "C" {
1808 pub static NSApplicationProtectedDataWillBecomeUnavailableNotification:
1810 &'static NSNotificationName;
1811}
1812
1813extern "C" {
1814 pub static NSApplicationProtectedDataDidBecomeAvailableNotification:
1816 &'static NSNotificationName;
1817}
1818
1819extern "C" {
1820 pub static NSApplicationLaunchIsDefaultLaunchKey: &'static NSString;
1824}
1825
1826extern "C" {
1827 pub static NSApplicationLaunchUserNotificationKey: &'static NSString;
1831}
1832
1833extern "C" {
1834 pub static NSApplicationLaunchRemoteNotificationKey: &'static NSString;
1838}
1839
1840extern "C" {
1841 pub static NSApplicationDidChangeOcclusionStateNotification: &'static NSNotificationName;
1845}
1846
1847#[deprecated = "Use NSModalResponseStop instead"]
1849pub const NSRunStoppedResponse: c_int = -1000;
1850#[deprecated = "Use NSModalResponseAbort instead"]
1852pub const NSRunAbortedResponse: c_int = -1001;
1853#[deprecated = "Use NSModalResponseContinue instead"]
1855pub const NSRunContinuesResponse: c_int = -1002;
1856
1857#[cfg(feature = "NSResponder")]
1859impl NSApplication {
1860 extern_methods!(
1861 #[cfg(feature = "NSWindow")]
1862 #[deprecated = "Use -[NSWindow beginSheet:completionHandler:] instead"]
1864 #[unsafe(method(runModalForWindow:relativeToWindow:))]
1865 #[unsafe(method_family = none)]
1866 pub unsafe fn runModalForWindow_relativeToWindow(
1867 &self,
1868 window: Option<&NSWindow>,
1869 doc_window: Option<&NSWindow>,
1870 ) -> NSInteger;
1871
1872 #[cfg(feature = "NSWindow")]
1873 #[deprecated = "Use -[NSWindow beginSheet:completionHandler:] instead"]
1875 #[unsafe(method(beginModalSessionForWindow:relativeToWindow:))]
1876 #[unsafe(method_family = none)]
1877 pub unsafe fn beginModalSessionForWindow_relativeToWindow(
1878 &self,
1879 window: Option<&NSWindow>,
1880 doc_window: Option<&NSWindow>,
1881 ) -> NSModalSession;
1882
1883 #[deprecated]
1886 #[unsafe(method(application:printFiles:))]
1887 #[unsafe(method_family = none)]
1888 pub unsafe fn application_printFiles(
1889 &self,
1890 sender: Option<&NSApplication>,
1891 filenames: Option<&NSArray<NSString>>,
1892 );
1893
1894 #[cfg(feature = "NSWindow")]
1895 #[deprecated = "Use -[NSWindow beginSheet:completionHandler:] instead"]
1897 #[unsafe(method(beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:))]
1898 #[unsafe(method_family = none)]
1899 pub unsafe fn beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo(
1900 &self,
1901 sheet: &NSWindow,
1902 doc_window: &NSWindow,
1903 modal_delegate: Option<&AnyObject>,
1904 did_end_selector: Option<Sel>,
1905 context_info: *mut c_void,
1906 );
1907
1908 #[cfg(feature = "NSWindow")]
1909 #[deprecated = "Use -[NSWindow endSheet:] instead"]
1910 #[unsafe(method(endSheet:))]
1911 #[unsafe(method_family = none)]
1912 pub unsafe fn endSheet(&self, sheet: &NSWindow);
1913
1914 #[cfg(feature = "NSWindow")]
1915 #[deprecated = "Use -[NSWindow endSheet:returnCode:] instead"]
1916 #[unsafe(method(endSheet:returnCode:))]
1917 #[unsafe(method_family = none)]
1918 pub unsafe fn endSheet_returnCode(&self, sheet: &NSWindow, return_code: NSInteger);
1919
1920 #[cfg(feature = "NSWindow")]
1921 #[deprecated = "Use -enumerateWindowsWithOptions:usingBlock: instead"]
1922 #[unsafe(method(makeWindowsPerform:inOrder:))]
1923 #[unsafe(method_family = none)]
1924 pub unsafe fn makeWindowsPerform_inOrder(
1925 &self,
1926 selector: Sel,
1927 in_order: bool,
1928 ) -> Option<Retained<NSWindow>>;
1929
1930 #[cfg(feature = "NSGraphicsContext")]
1931 #[deprecated = "This method always returns nil. If you need access to the current drawing context, use [NSGraphicsContext currentContext] inside of a draw operation."]
1933 #[unsafe(method(context))]
1934 #[unsafe(method_family = none)]
1935 pub unsafe fn context(&self) -> Option<Retained<NSGraphicsContext>>;
1936 );
1937}