1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
#[cfg(feature = "block2")]
use block2::*;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_TYPED_EXTENSIBLE_ENUM
pub type NSAppKitVersion = c_double;

extern "C" {
    pub static NSAppKitVersionNumber: NSAppKitVersion;
}

pub static NSAppKitVersionNumber10_0: NSAppKitVersion = 577 as _;

pub static NSAppKitVersionNumber10_1: NSAppKitVersion = 620 as _;

pub static NSAppKitVersionNumber10_2: NSAppKitVersion = 663 as _;

pub static NSAppKitVersionNumber10_2_3: NSAppKitVersion = 663.6 as _;

pub static NSAppKitVersionNumber10_3: NSAppKitVersion = 743 as _;

pub static NSAppKitVersionNumber10_3_2: NSAppKitVersion = 743.14 as _;

pub static NSAppKitVersionNumber10_3_3: NSAppKitVersion = 743.2 as _;

pub static NSAppKitVersionNumber10_3_5: NSAppKitVersion = 743.24 as _;

pub static NSAppKitVersionNumber10_3_7: NSAppKitVersion = 743.33 as _;

pub static NSAppKitVersionNumber10_3_9: NSAppKitVersion = 743.36 as _;

pub static NSAppKitVersionNumber10_4: NSAppKitVersion = 824 as _;

pub static NSAppKitVersionNumber10_4_1: NSAppKitVersion = 824.1 as _;

pub static NSAppKitVersionNumber10_4_3: NSAppKitVersion = 824.23 as _;

pub static NSAppKitVersionNumber10_4_4: NSAppKitVersion = 824.33 as _;

pub static NSAppKitVersionNumber10_4_7: NSAppKitVersion = 824.41 as _;

pub static NSAppKitVersionNumber10_5: NSAppKitVersion = 949 as _;

pub static NSAppKitVersionNumber10_5_2: NSAppKitVersion = 949.27 as _;

pub static NSAppKitVersionNumber10_5_3: NSAppKitVersion = 949.33 as _;

pub static NSAppKitVersionNumber10_6: NSAppKitVersion = 1038 as _;

pub static NSAppKitVersionNumber10_7: NSAppKitVersion = 1138 as _;

pub static NSAppKitVersionNumber10_7_2: NSAppKitVersion = 1138.23 as _;

pub static NSAppKitVersionNumber10_7_3: NSAppKitVersion = 1138.32 as _;

pub static NSAppKitVersionNumber10_7_4: NSAppKitVersion = 1138.47 as _;

pub static NSAppKitVersionNumber10_8: NSAppKitVersion = 1187 as _;

pub static NSAppKitVersionNumber10_9: NSAppKitVersion = 1265 as _;

pub static NSAppKitVersionNumber10_10: NSAppKitVersion = 1343 as _;

pub static NSAppKitVersionNumber10_10_2: NSAppKitVersion = 1344 as _;

pub static NSAppKitVersionNumber10_10_3: NSAppKitVersion = 1347 as _;

pub static NSAppKitVersionNumber10_10_4: NSAppKitVersion = 1348 as _;

pub static NSAppKitVersionNumber10_10_5: NSAppKitVersion = 1348 as _;

pub static NSAppKitVersionNumber10_10_Max: NSAppKitVersion = 1349 as _;

pub static NSAppKitVersionNumber10_11: NSAppKitVersion = 1404 as _;

pub static NSAppKitVersionNumber10_11_1: NSAppKitVersion = 1404.13 as _;

pub static NSAppKitVersionNumber10_11_2: NSAppKitVersion = 1404.34 as _;

pub static NSAppKitVersionNumber10_11_3: NSAppKitVersion = 1404.34 as _;

pub static NSAppKitVersionNumber10_12: NSAppKitVersion = 1504 as _;

pub static NSAppKitVersionNumber10_12_1: NSAppKitVersion = 1504.6 as _;

pub static NSAppKitVersionNumber10_12_2: NSAppKitVersion = 1504.76 as _;

pub static NSAppKitVersionNumber10_13: NSAppKitVersion = 1561 as _;

pub static NSAppKitVersionNumber10_13_1: NSAppKitVersion = 1561.1 as _;

pub static NSAppKitVersionNumber10_13_2: NSAppKitVersion = 1561.2 as _;

pub static NSAppKitVersionNumber10_13_4: NSAppKitVersion = 1561.4 as _;

pub static NSAppKitVersionNumber10_14: NSAppKitVersion = 1671 as _;

pub static NSAppKitVersionNumber10_14_1: NSAppKitVersion = 1671.1 as _;

pub static NSAppKitVersionNumber10_14_2: NSAppKitVersion = 1671.2 as _;

pub static NSAppKitVersionNumber10_14_3: NSAppKitVersion = 1671.3 as _;

pub static NSAppKitVersionNumber10_14_4: NSAppKitVersion = 1671.4 as _;

pub static NSAppKitVersionNumber10_14_5: NSAppKitVersion = 1671.5 as _;

pub static NSAppKitVersionNumber10_15: NSAppKitVersion = 1894 as _;

pub static NSAppKitVersionNumber10_15_1: NSAppKitVersion = 1894.1 as _;

pub static NSAppKitVersionNumber10_15_2: NSAppKitVersion = 1894.2 as _;

pub static NSAppKitVersionNumber10_15_3: NSAppKitVersion = 1894.3 as _;

pub static NSAppKitVersionNumber10_15_4: NSAppKitVersion = 1894.4 as _;

pub static NSAppKitVersionNumber10_15_5: NSAppKitVersion = 1894.5 as _;

pub static NSAppKitVersionNumber10_15_6: NSAppKitVersion = 1894.6 as _;

pub static NSAppKitVersionNumber11_0: NSAppKitVersion = 2022 as _;

pub static NSAppKitVersionNumber11_1: NSAppKitVersion = 2022.2 as _;

pub static NSAppKitVersionNumber11_2: NSAppKitVersion = 2022.3 as _;

pub static NSAppKitVersionNumber11_3: NSAppKitVersion = 2022.4 as _;

pub static NSAppKitVersionNumber11_4: NSAppKitVersion = 2022.5 as _;

pub static NSAppKitVersionNumber11_5: NSAppKitVersion = 2022.6 as _;

pub static NSAppKitVersionNumber12_0: NSAppKitVersion = 2113 as _;

pub static NSAppKitVersionNumber12_1: NSAppKitVersion = 2113.2 as _;

pub static NSAppKitVersionNumber12_2: NSAppKitVersion = 2113.3 as _;

pub static NSAppKitVersionNumber12_3: NSAppKitVersion = 2113.4 as _;

pub static NSAppKitVersionNumber12_4: NSAppKitVersion = 2113.5 as _;

pub static NSAppKitVersionNumber12_5: NSAppKitVersion = 2113.6 as _;

pub static NSAppKitVersionNumber13_0: NSAppKitVersion = 2299 as _;

pub static NSAppKitVersionNumber13_1: NSAppKitVersion = 2299.3 as _;

pub static NSAppKitVersionNumber13_2: NSAppKitVersion = 2299.3 as _;

pub static NSAppKitVersionNumber13_3: NSAppKitVersion = 2299.4 as _;

pub static NSAppKitVersionNumber13_4: NSAppKitVersion = 2299.5 as _;

pub static NSAppKitVersionNumber13_5: NSAppKitVersion = 2299.6 as _;

pub static NSAppKitVersionNumber13_6: NSAppKitVersion = 2299.7 as _;

pub static NSAppKitVersionNumber14_0: NSAppKitVersion = 2487 as _;

pub static NSAppKitVersionNumber14_1: NSAppKitVersion = 2487.2 as _;

extern "C" {
    pub static NSModalPanelRunLoopMode: &'static NSRunLoopMode;
}

extern "C" {
    pub static NSEventTrackingRunLoopMode: &'static NSRunLoopMode;
}

// NS_TYPED_EXTENSIBLE_ENUM
pub type NSModalResponse = NSInteger;

pub static NSModalResponseStop: NSModalResponse = -1000;

pub static NSModalResponseAbort: NSModalResponse = -1001;

pub static NSModalResponseContinue: NSModalResponse = -1002;

pub const NSUpdateWindowsRunLoopOrdering: c_uint = 500000;

// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSApplicationPresentationOptions(pub NSUInteger);
impl NSApplicationPresentationOptions {
    pub const NSApplicationPresentationDefault: Self = Self(0);
    pub const NSApplicationPresentationAutoHideDock: Self = Self(1 << 0);
    pub const NSApplicationPresentationHideDock: Self = Self(1 << 1);
    pub const NSApplicationPresentationAutoHideMenuBar: Self = Self(1 << 2);
    pub const NSApplicationPresentationHideMenuBar: Self = Self(1 << 3);
    pub const NSApplicationPresentationDisableAppleMenu: Self = Self(1 << 4);
    pub const NSApplicationPresentationDisableProcessSwitching: Self = Self(1 << 5);
    pub const NSApplicationPresentationDisableForceQuit: Self = Self(1 << 6);
    pub const NSApplicationPresentationDisableSessionTermination: Self = Self(1 << 7);
    pub const NSApplicationPresentationDisableHideApplication: Self = Self(1 << 8);
    pub const NSApplicationPresentationDisableMenuBarTransparency: Self = Self(1 << 9);
    pub const NSApplicationPresentationFullScreen: Self = Self(1 << 10);
    pub const NSApplicationPresentationAutoHideToolbar: Self = Self(1 << 11);
    pub const NSApplicationPresentationDisableCursorLocationAssistance: Self = Self(1 << 12);
}

unsafe impl Encode for NSApplicationPresentationOptions {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSApplicationPresentationOptions {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSApplicationOcclusionState(pub NSUInteger);
impl NSApplicationOcclusionState {
    #[doc(alias = "NSApplicationOcclusionStateVisible")]
    pub const Visible: Self = Self(1 << 1);
}

unsafe impl Encode for NSApplicationOcclusionState {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSApplicationOcclusionState {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSWindowListOptions(pub NSInteger);
impl NSWindowListOptions {
    pub const NSWindowListOrderedFrontToBack: Self = Self(1 << 0);
}

unsafe impl Encode for NSWindowListOptions {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for NSWindowListOptions {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

pub type NSModalSession = *mut c_void;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSRequestUserAttentionType(pub NSUInteger);
impl NSRequestUserAttentionType {
    pub const NSCriticalRequest: Self = Self(0);
    pub const NSInformationalRequest: Self = Self(10);
}

unsafe impl Encode for NSRequestUserAttentionType {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSRequestUserAttentionType {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSApplicationDelegateReply(pub NSUInteger);
impl NSApplicationDelegateReply {
    #[doc(alias = "NSApplicationDelegateReplySuccess")]
    pub const Success: Self = Self(0);
    #[doc(alias = "NSApplicationDelegateReplyCancel")]
    pub const Cancel: Self = Self(1);
    #[doc(alias = "NSApplicationDelegateReplyFailure")]
    pub const Failure: Self = Self(2);
}

unsafe impl Encode for NSApplicationDelegateReply {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSApplicationDelegateReply {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "NSResponder")]
    pub struct NSApplication;

    #[cfg(feature = "NSResponder")]
    unsafe impl ClassType for NSApplication {
        #[inherits(NSObject)]
        type Super = NSResponder;
        type Mutability = MainThreadOnly;
    }
);

#[cfg(all(feature = "NSAccessibilityProtocols", feature = "NSResponder"))]
unsafe impl NSAccessibility for NSApplication {}

#[cfg(all(feature = "NSAccessibilityProtocols", feature = "NSResponder"))]
unsafe impl NSAccessibilityElementProtocol for NSApplication {}

#[cfg(feature = "NSResponder")]
unsafe impl NSCoding for NSApplication {}

#[cfg(all(feature = "NSMenu", feature = "NSResponder"))]
unsafe impl NSMenuItemValidation for NSApplication {}

#[cfg(feature = "NSResponder")]
unsafe impl NSObjectProtocol for NSApplication {}

#[cfg(all(feature = "NSResponder", feature = "NSUserInterfaceValidation"))]
unsafe impl NSUserInterfaceValidations for NSApplication {}

extern_methods!(
    #[cfg(feature = "NSResponder")]
    unsafe impl NSApplication {
        #[method_id(@__retain_semantics Other sharedApplication)]
        pub fn sharedApplication(mtm: MainThreadMarker) -> Id<NSApplication>;

        #[method_id(@__retain_semantics Other delegate)]
        pub unsafe fn delegate(&self) -> Option<Id<ProtocolObject<dyn NSApplicationDelegate>>>;

        #[method(setDelegate:)]
        pub fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSApplicationDelegate>>);

        #[method(hide:)]
        pub fn hide(&self, sender: Option<&AnyObject>);

        #[method(unhide:)]
        pub unsafe fn unhide(&self, sender: Option<&AnyObject>);

        #[method(unhideWithoutActivation)]
        pub unsafe fn unhideWithoutActivation(&self);

        #[cfg(feature = "NSWindow")]
        #[method_id(@__retain_semantics Other windowWithWindowNumber:)]
        pub unsafe fn windowWithWindowNumber(&self, window_num: NSInteger) -> Option<Id<NSWindow>>;

        #[cfg(feature = "NSWindow")]
        #[method_id(@__retain_semantics Other mainWindow)]
        pub unsafe fn mainWindow(&self) -> Option<Id<NSWindow>>;

        #[cfg(feature = "NSWindow")]
        #[method_id(@__retain_semantics Other keyWindow)]
        pub fn keyWindow(&self) -> Option<Id<NSWindow>>;

        #[method(isActive)]
        pub unsafe fn isActive(&self) -> bool;

        #[method(isHidden)]
        pub unsafe fn isHidden(&self) -> bool;

        #[method(isRunning)]
        pub unsafe fn isRunning(&self) -> bool;

        #[method(deactivate)]
        pub unsafe fn deactivate(&self);

        #[deprecated = "This method will be deprecated in a future release. Use NSApp.activate instead."]
        #[method(activateIgnoringOtherApps:)]
        pub fn activateIgnoringOtherApps(&self, flag: bool);

        #[method(activate)]
        pub unsafe fn activate(&self);

        #[cfg(feature = "NSRunningApplication")]
        #[method(yieldActivationToApplication:)]
        pub unsafe fn yieldActivationToApplication(&self, application: &NSRunningApplication);

        #[method(yieldActivationToApplicationWithBundleIdentifier:)]
        pub unsafe fn yieldActivationToApplicationWithBundleIdentifier(
            &self,
            bundle_identifier: &NSString,
        );

        #[method(hideOtherApplications:)]
        pub fn hideOtherApplications(&self, sender: Option<&AnyObject>);

        #[method(unhideAllApplications:)]
        pub unsafe fn unhideAllApplications(&self, sender: Option<&AnyObject>);

        #[method(finishLaunching)]
        pub unsafe fn finishLaunching(&self);

        #[method(run)]
        pub unsafe fn run(&self);

        #[cfg(feature = "NSWindow")]
        #[method(runModalForWindow:)]
        pub unsafe fn runModalForWindow(&self, window: &NSWindow) -> NSModalResponse;

        #[method(stop:)]
        pub fn stop(&self, sender: Option<&AnyObject>);

        #[method(stopModal)]
        pub unsafe fn stopModal(&self);

        #[method(stopModalWithCode:)]
        pub unsafe fn stopModalWithCode(&self, return_code: NSModalResponse);

        #[method(abortModal)]
        pub unsafe fn abortModal(&self);

        #[cfg(feature = "NSWindow")]
        #[method_id(@__retain_semantics Other modalWindow)]
        pub unsafe fn modalWindow(&self) -> Option<Id<NSWindow>>;

        #[cfg(feature = "NSWindow")]
        #[method(beginModalSessionForWindow:)]
        pub unsafe fn beginModalSessionForWindow(&self, window: &NSWindow) -> NSModalSession;

        #[method(runModalSession:)]
        pub unsafe fn runModalSession(&self, session: NSModalSession) -> NSModalResponse;

        #[method(endModalSession:)]
        pub unsafe fn endModalSession(&self, session: NSModalSession);

        #[method(terminate:)]
        pub unsafe fn terminate(&self, sender: Option<&AnyObject>);

        #[method(requestUserAttention:)]
        pub fn requestUserAttention(&self, request_type: NSRequestUserAttentionType) -> NSInteger;

        #[method(cancelUserAttentionRequest:)]
        pub unsafe fn cancelUserAttentionRequest(&self, request: NSInteger);

        #[cfg(all(feature = "NSWindow", feature = "block2"))]
        #[method(enumerateWindowsWithOptions:usingBlock:)]
        pub unsafe fn enumerateWindowsWithOptions_usingBlock(
            &self,
            options: NSWindowListOptions,
            block: &Block<dyn Fn(NonNull<NSWindow>, NonNull<Bool>) + '_>,
        );

        #[method(preventWindowOrdering)]
        pub unsafe fn preventWindowOrdering(&self);

        #[cfg(feature = "NSWindow")]
        #[method_id(@__retain_semantics Other windows)]
        pub fn windows(&self) -> Id<NSArray<NSWindow>>;

        #[method(setWindowsNeedUpdate:)]
        pub unsafe fn setWindowsNeedUpdate(&self, need_update: bool);

        #[method(updateWindows)]
        pub unsafe fn updateWindows(&self);

        #[cfg(feature = "NSMenu")]
        #[method_id(@__retain_semantics Other mainMenu)]
        pub unsafe fn mainMenu(&self) -> Option<Id<NSMenu>>;

        #[cfg(feature = "NSMenu")]
        #[method(setMainMenu:)]
        pub fn setMainMenu(&self, main_menu: Option<&NSMenu>);

        #[cfg(feature = "NSMenu")]
        #[method_id(@__retain_semantics Other helpMenu)]
        pub unsafe fn helpMenu(&self) -> Option<Id<NSMenu>>;

        #[cfg(feature = "NSMenu")]
        #[method(setHelpMenu:)]
        pub unsafe fn setHelpMenu(&self, help_menu: Option<&NSMenu>);

        #[cfg(feature = "NSImage")]
        #[method_id(@__retain_semantics Other applicationIconImage)]
        pub unsafe fn applicationIconImage(&self) -> Option<Id<NSImage>>;

        #[cfg(feature = "NSImage")]
        #[method(setApplicationIconImage:)]
        pub unsafe fn setApplicationIconImage(&self, application_icon_image: Option<&NSImage>);

        #[cfg(feature = "NSRunningApplication")]
        #[method(activationPolicy)]
        pub unsafe fn activationPolicy(&self) -> NSApplicationActivationPolicy;

        #[cfg(feature = "NSRunningApplication")]
        #[method(setActivationPolicy:)]
        pub fn setActivationPolicy(&self, activation_policy: NSApplicationActivationPolicy)
            -> bool;

        #[cfg(feature = "NSDockTile")]
        #[method_id(@__retain_semantics Other dockTile)]
        pub unsafe fn dockTile(&self) -> Id<NSDockTile>;

        #[method(reportException:)]
        pub unsafe fn reportException(&self, exception: &NSException);

        #[method(detachDrawingThread:toTarget:withObject:)]
        pub unsafe fn detachDrawingThread_toTarget_withObject(
            selector: Sel,
            target: &AnyObject,
            argument: Option<&AnyObject>,
            mtm: MainThreadMarker,
        );

        #[method(replyToApplicationShouldTerminate:)]
        pub unsafe fn replyToApplicationShouldTerminate(&self, should_terminate: bool);

        #[method(replyToOpenOrPrint:)]
        pub unsafe fn replyToOpenOrPrint(&self, reply: NSApplicationDelegateReply);

        #[method(orderFrontCharacterPalette:)]
        pub fn orderFrontCharacterPalette(&self, sender: Option<&AnyObject>);

        #[method(presentationOptions)]
        pub fn presentationOptions(&self) -> NSApplicationPresentationOptions;

        #[method(setPresentationOptions:)]
        pub fn setPresentationOptions(
            &self,
            presentation_options: NSApplicationPresentationOptions,
        );

        #[method(currentSystemPresentationOptions)]
        pub unsafe fn currentSystemPresentationOptions(&self) -> NSApplicationPresentationOptions;

        #[method(occlusionState)]
        pub unsafe fn occlusionState(&self) -> NSApplicationOcclusionState;

        #[method(isProtectedDataAvailable)]
        pub unsafe fn isProtectedDataAvailable(&self) -> bool;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSResponder`
    #[cfg(feature = "NSResponder")]
    unsafe impl NSApplication {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;

        #[method_id(@__retain_semantics Init initWithCoder:)]
        pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Option<Id<Self>>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    #[cfg(feature = "NSResponder")]
    unsafe impl NSApplication {
        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Id<Self>;
    }
);

extern_methods!(
    /// NSAppearanceCustomization
    #[cfg(feature = "NSResponder")]
    unsafe impl NSApplication {
        #[cfg(feature = "NSAppearance")]
        #[method_id(@__retain_semantics Other appearance)]
        pub unsafe fn appearance(&self) -> Option<Id<NSAppearance>>;

        #[cfg(feature = "NSAppearance")]
        #[method(setAppearance:)]
        pub fn setAppearance(&self, appearance: Option<&NSAppearance>);

        #[cfg(feature = "NSAppearance")]
        #[method_id(@__retain_semantics Other effectiveAppearance)]
        pub fn effectiveAppearance(&self) -> Id<NSAppearance>;
    }
);

#[cfg(all(feature = "NSAppearance", feature = "NSResponder"))]
unsafe impl NSAppearanceCustomization for NSApplication {}

extern_methods!(
    /// NSEvent
    #[cfg(feature = "NSResponder")]
    unsafe impl NSApplication {
        #[cfg(feature = "NSEvent")]
        #[method(sendEvent:)]
        pub unsafe fn sendEvent(&self, event: &NSEvent);

        #[cfg(feature = "NSEvent")]
        #[method(postEvent:atStart:)]
        pub fn postEvent_atStart(&self, event: &NSEvent, flag: bool);

        #[cfg(feature = "NSEvent")]
        #[method_id(@__retain_semantics Other currentEvent)]
        pub fn currentEvent(&self) -> Option<Id<NSEvent>>;

        #[cfg(feature = "NSEvent")]
        #[method_id(@__retain_semantics Other nextEventMatchingMask:untilDate:inMode:dequeue:)]
        pub unsafe fn nextEventMatchingMask_untilDate_inMode_dequeue(
            &self,
            mask: NSEventMask,
            expiration: Option<&NSDate>,
            mode: &NSRunLoopMode,
            deq_flag: bool,
        ) -> Option<Id<NSEvent>>;

        #[cfg(feature = "NSEvent")]
        #[method(discardEventsMatchingMask:beforeEvent:)]
        pub unsafe fn discardEventsMatchingMask_beforeEvent(
            &self,
            mask: NSEventMask,
            last_event: Option<&NSEvent>,
        );
    }
);

extern_methods!(
    /// NSResponder
    #[cfg(feature = "NSResponder")]
    unsafe impl NSApplication {
        #[method(sendAction:to:from:)]
        pub unsafe fn sendAction_to_from(
            &self,
            action: Sel,
            target: Option<&AnyObject>,
            sender: Option<&AnyObject>,
        ) -> bool;

        #[method_id(@__retain_semantics Other targetForAction:)]
        pub unsafe fn targetForAction(&self, action: Sel) -> Option<Id<AnyObject>>;

        #[method_id(@__retain_semantics Other targetForAction:to:from:)]
        pub unsafe fn targetForAction_to_from(
            &self,
            action: Sel,
            target: Option<&AnyObject>,
            sender: Option<&AnyObject>,
        ) -> Option<Id<AnyObject>>;

        #[method(tryToPerform:with:)]
        pub unsafe fn tryToPerform_with(&self, action: Sel, object: Option<&AnyObject>) -> bool;

        #[cfg(feature = "NSPasteboard")]
        #[method_id(@__retain_semantics Other validRequestorForSendType:returnType:)]
        pub unsafe fn validRequestorForSendType_returnType(
            &self,
            send_type: Option<&NSPasteboardType>,
            return_type: Option<&NSPasteboardType>,
        ) -> Option<Id<AnyObject>>;
    }
);

extern_methods!(
    /// NSWindowsMenu
    #[cfg(feature = "NSResponder")]
    unsafe impl NSApplication {
        #[cfg(feature = "NSMenu")]
        #[method_id(@__retain_semantics Other windowsMenu)]
        pub unsafe fn windowsMenu(&self) -> Option<Id<NSMenu>>;

        #[cfg(feature = "NSMenu")]
        #[method(setWindowsMenu:)]
        pub unsafe fn setWindowsMenu(&self, windows_menu: Option<&NSMenu>);

        #[method(arrangeInFront:)]
        pub unsafe fn arrangeInFront(&self, sender: Option<&AnyObject>);

        #[cfg(feature = "NSWindow")]
        #[method(removeWindowsItem:)]
        pub unsafe fn removeWindowsItem(&self, win: &NSWindow);

        #[cfg(feature = "NSWindow")]
        #[method(addWindowsItem:title:filename:)]
        pub unsafe fn addWindowsItem_title_filename(
            &self,
            win: &NSWindow,
            string: &NSString,
            is_filename: bool,
        );

        #[cfg(feature = "NSWindow")]
        #[method(changeWindowsItem:title:filename:)]
        pub unsafe fn changeWindowsItem_title_filename(
            &self,
            win: &NSWindow,
            string: &NSString,
            is_filename: bool,
        );

        #[cfg(feature = "NSWindow")]
        #[method(updateWindowsItem:)]
        pub unsafe fn updateWindowsItem(&self, win: &NSWindow);

        #[method(miniaturizeAll:)]
        pub unsafe fn miniaturizeAll(&self, sender: Option<&AnyObject>);
    }
);

extern_methods!(
    /// NSFullKeyboardAccess
    #[cfg(feature = "NSResponder")]
    unsafe impl NSApplication {
        #[method(isFullKeyboardAccessEnabled)]
        pub unsafe fn isFullKeyboardAccessEnabled(&self) -> bool;
    }
);

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSApplicationTerminateReply(pub NSUInteger);
impl NSApplicationTerminateReply {
    pub const NSTerminateCancel: Self = Self(0);
    pub const NSTerminateNow: Self = Self(1);
    pub const NSTerminateLater: Self = Self(2);
}

unsafe impl Encode for NSApplicationTerminateReply {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSApplicationTerminateReply {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSApplicationPrintReply(pub NSUInteger);
impl NSApplicationPrintReply {
    pub const NSPrintingCancelled: Self = Self(0);
    pub const NSPrintingSuccess: Self = Self(1);
    pub const NSPrintingReplyLater: Self = Self(2);
    pub const NSPrintingFailure: Self = Self(3);
}

unsafe impl Encode for NSApplicationPrintReply {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSApplicationPrintReply {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_protocol!(
    pub unsafe trait NSApplicationDelegate: NSObjectProtocol + IsMainThreadOnly {
        #[cfg(feature = "NSResponder")]
        #[optional]
        #[method(applicationShouldTerminate:)]
        unsafe fn applicationShouldTerminate(
            &self,
            sender: &NSApplication,
        ) -> NSApplicationTerminateReply;

        #[cfg(feature = "NSResponder")]
        #[optional]
        #[method(application:openURLs:)]
        unsafe fn application_openURLs(&self, application: &NSApplication, urls: &NSArray<NSURL>);

        #[cfg(feature = "NSResponder")]
        #[optional]
        #[method(application:openFile:)]
        unsafe fn application_openFile(&self, sender: &NSApplication, filename: &NSString) -> bool;

        #[cfg(feature = "NSResponder")]
        #[optional]
        #[method(application:openFiles:)]
        unsafe fn application_openFiles(
            &self,
            sender: &NSApplication,
            filenames: &NSArray<NSString>,
        );

        #[cfg(feature = "NSResponder")]
        #[optional]
        #[method(application:openTempFile:)]
        unsafe fn application_openTempFile(
            &self,
            sender: &NSApplication,
            filename: &NSString,
        ) -> bool;

        #[cfg(feature = "NSResponder")]
        #[optional]
        #[method(applicationShouldOpenUntitledFile:)]
        unsafe fn applicationShouldOpenUntitledFile(&self, sender: &NSApplication) -> bool;

        #[cfg(feature = "NSResponder")]
        #[optional]
        #[method(applicationOpenUntitledFile:)]
        unsafe fn applicationOpenUntitledFile(&self, sender: &NSApplication) -> bool;

        #[optional]
        #[method(application:openFileWithoutUI:)]
        unsafe fn application_openFileWithoutUI(
            &self,
            sender: &AnyObject,
            filename: &NSString,
        ) -> bool;

        #[cfg(feature = "NSResponder")]
        #[optional]
        #[method(application:printFile:)]
        unsafe fn application_printFile(&self, sender: &NSApplication, filename: &NSString)
            -> bool;

        #[cfg(all(feature = "NSPrintInfo", feature = "NSResponder"))]
        #[optional]
        #[method(application:printFiles:withSettings:showPrintPanels:)]
        unsafe fn application_printFiles_withSettings_showPrintPanels(
            &self,
            application: &NSApplication,
            file_names: &NSArray<NSString>,
            print_settings: &NSDictionary<NSPrintInfoAttributeKey, AnyObject>,
            show_print_panels: bool,
        ) -> NSApplicationPrintReply;

        #[cfg(feature = "NSResponder")]
        #[optional]
        #[method(applicationShouldTerminateAfterLastWindowClosed:)]
        unsafe fn applicationShouldTerminateAfterLastWindowClosed(
            &self,
            sender: &NSApplication,
        ) -> bool;

        #[cfg(feature = "NSResponder")]
        #[optional]
        #[method(applicationShouldHandleReopen:hasVisibleWindows:)]
        unsafe fn applicationShouldHandleReopen_hasVisibleWindows(
            &self,
            sender: &NSApplication,
            flag: bool,
        ) -> bool;

        #[cfg(all(feature = "NSMenu", feature = "NSResponder"))]
        #[optional]
        #[method_id(@__retain_semantics Other applicationDockMenu:)]
        unsafe fn applicationDockMenu(&self, sender: &NSApplication) -> Option<Id<NSMenu>>;

        #[cfg(feature = "NSResponder")]
        #[optional]
        #[method_id(@__retain_semantics Other application:willPresentError:)]
        unsafe fn application_willPresentError(
            &self,
            application: &NSApplication,
            error: &NSError,
        ) -> Id<NSError>;

        #[cfg(feature = "NSResponder")]
        #[optional]
        #[method(application:didRegisterForRemoteNotificationsWithDeviceToken:)]
        unsafe fn application_didRegisterForRemoteNotificationsWithDeviceToken(
            &self,
            application: &NSApplication,
            device_token: &NSData,
        );

        #[cfg(feature = "NSResponder")]
        #[optional]
        #[method(application:didFailToRegisterForRemoteNotificationsWithError:)]
        unsafe fn application_didFailToRegisterForRemoteNotificationsWithError(
            &self,
            application: &NSApplication,
            error: &NSError,
        );

        #[cfg(feature = "NSResponder")]
        #[optional]
        #[method(application:didReceiveRemoteNotification:)]
        unsafe fn application_didReceiveRemoteNotification(
            &self,
            application: &NSApplication,
            user_info: &NSDictionary<NSString, AnyObject>,
        );

        #[cfg(feature = "NSResponder")]
        #[optional]
        #[method(applicationSupportsSecureRestorableState:)]
        unsafe fn applicationSupportsSecureRestorableState(&self, app: &NSApplication) -> bool;

        #[cfg(feature = "NSResponder")]
        #[optional]
        #[method(application:willEncodeRestorableState:)]
        unsafe fn application_willEncodeRestorableState(
            &self,
            app: &NSApplication,
            coder: &NSCoder,
        );

        #[cfg(feature = "NSResponder")]
        #[optional]
        #[method(application:didDecodeRestorableState:)]
        unsafe fn application_didDecodeRestorableState(&self, app: &NSApplication, coder: &NSCoder);

        #[cfg(feature = "NSResponder")]
        #[optional]
        #[method(application:willContinueUserActivityWithType:)]
        unsafe fn application_willContinueUserActivityWithType(
            &self,
            application: &NSApplication,
            user_activity_type: &NSString,
        ) -> bool;

        #[cfg(all(
            feature = "NSResponder",
            feature = "NSUserActivity",
            feature = "block2"
        ))]
        #[optional]
        #[method(application:continueUserActivity:restorationHandler:)]
        unsafe fn application_continueUserActivity_restorationHandler(
            &self,
            application: &NSApplication,
            user_activity: &NSUserActivity,
            restoration_handler: &Block<
                dyn Fn(NonNull<NSArray<ProtocolObject<dyn NSUserActivityRestoring>>>),
            >,
        ) -> bool;

        #[cfg(feature = "NSResponder")]
        #[optional]
        #[method(application:didFailToContinueUserActivityWithType:error:)]
        unsafe fn application_didFailToContinueUserActivityWithType_error(
            &self,
            application: &NSApplication,
            user_activity_type: &NSString,
            error: &NSError,
        );

        #[cfg(feature = "NSResponder")]
        #[optional]
        #[method(application:didUpdateUserActivity:)]
        unsafe fn application_didUpdateUserActivity(
            &self,
            application: &NSApplication,
            user_activity: &NSUserActivity,
        );

        #[cfg(feature = "NSResponder")]
        #[optional]
        #[method(application:delegateHandlesKey:)]
        unsafe fn application_delegateHandlesKey(
            &self,
            sender: &NSApplication,
            key: &NSString,
        ) -> bool;

        #[cfg(feature = "NSResponder")]
        #[optional]
        #[method(applicationShouldAutomaticallyLocalizeKeyEquivalents:)]
        unsafe fn applicationShouldAutomaticallyLocalizeKeyEquivalents(
            &self,
            application: &NSApplication,
        ) -> bool;

        #[optional]
        #[method(applicationWillFinishLaunching:)]
        unsafe fn applicationWillFinishLaunching(&self, notification: &NSNotification);

        #[optional]
        #[method(applicationDidFinishLaunching:)]
        unsafe fn applicationDidFinishLaunching(&self, notification: &NSNotification);

        #[optional]
        #[method(applicationWillHide:)]
        unsafe fn applicationWillHide(&self, notification: &NSNotification);

        #[optional]
        #[method(applicationDidHide:)]
        unsafe fn applicationDidHide(&self, notification: &NSNotification);

        #[optional]
        #[method(applicationWillUnhide:)]
        unsafe fn applicationWillUnhide(&self, notification: &NSNotification);

        #[optional]
        #[method(applicationDidUnhide:)]
        unsafe fn applicationDidUnhide(&self, notification: &NSNotification);

        #[optional]
        #[method(applicationWillBecomeActive:)]
        unsafe fn applicationWillBecomeActive(&self, notification: &NSNotification);

        #[optional]
        #[method(applicationDidBecomeActive:)]
        unsafe fn applicationDidBecomeActive(&self, notification: &NSNotification);

        #[optional]
        #[method(applicationWillResignActive:)]
        unsafe fn applicationWillResignActive(&self, notification: &NSNotification);

        #[optional]
        #[method(applicationDidResignActive:)]
        unsafe fn applicationDidResignActive(&self, notification: &NSNotification);

        #[optional]
        #[method(applicationWillUpdate:)]
        unsafe fn applicationWillUpdate(&self, notification: &NSNotification);

        #[optional]
        #[method(applicationDidUpdate:)]
        unsafe fn applicationDidUpdate(&self, notification: &NSNotification);

        #[optional]
        #[method(applicationWillTerminate:)]
        unsafe fn applicationWillTerminate(&self, notification: &NSNotification);

        #[optional]
        #[method(applicationDidChangeScreenParameters:)]
        unsafe fn applicationDidChangeScreenParameters(&self, notification: &NSNotification);

        #[optional]
        #[method(applicationDidChangeOcclusionState:)]
        unsafe fn applicationDidChangeOcclusionState(&self, notification: &NSNotification);

        #[optional]
        #[method(applicationProtectedDataWillBecomeUnavailable:)]
        unsafe fn applicationProtectedDataWillBecomeUnavailable(
            &self,
            notification: &NSNotification,
        );

        #[optional]
        #[method(applicationProtectedDataDidBecomeAvailable:)]
        unsafe fn applicationProtectedDataDidBecomeAvailable(&self, notification: &NSNotification);
    }

    unsafe impl ProtocolType for dyn NSApplicationDelegate {}
);

extern_methods!(
    /// NSServicesMenu
    #[cfg(feature = "NSResponder")]
    unsafe impl NSApplication {
        #[cfg(feature = "NSMenu")]
        #[method_id(@__retain_semantics Other servicesMenu)]
        pub unsafe fn servicesMenu(&self) -> Option<Id<NSMenu>>;

        #[cfg(feature = "NSMenu")]
        #[method(setServicesMenu:)]
        pub unsafe fn setServicesMenu(&self, services_menu: Option<&NSMenu>);

        #[cfg(feature = "NSPasteboard")]
        #[method(registerServicesMenuSendTypes:returnTypes:)]
        pub unsafe fn registerServicesMenuSendTypes_returnTypes(
            &self,
            send_types: &NSArray<NSPasteboardType>,
            return_types: &NSArray<NSPasteboardType>,
        );
    }
);

extern_protocol!(
    pub unsafe trait NSServicesMenuRequestor: NSObjectProtocol {
        #[cfg(feature = "NSPasteboard")]
        #[optional]
        #[method(writeSelectionToPasteboard:types:)]
        unsafe fn writeSelectionToPasteboard_types(
            &self,
            pboard: &NSPasteboard,
            types: &NSArray<NSPasteboardType>,
        ) -> bool;

        #[cfg(feature = "NSPasteboard")]
        #[optional]
        #[method(readSelectionFromPasteboard:)]
        unsafe fn readSelectionFromPasteboard(&self, pboard: &NSPasteboard) -> bool;
    }

    unsafe impl ProtocolType for dyn NSServicesMenuRequestor {}
);

extern_methods!(
    /// NSServicesHandling
    #[cfg(feature = "NSResponder")]
    unsafe impl NSApplication {
        #[method_id(@__retain_semantics Other servicesProvider)]
        pub unsafe fn servicesProvider(&self) -> Option<Id<AnyObject>>;

        #[method(setServicesProvider:)]
        pub unsafe fn setServicesProvider(&self, services_provider: Option<&AnyObject>);
    }
);

// NS_TYPED_ENUM
pub type NSAboutPanelOptionKey = NSString;

extern "C" {
    pub static NSAboutPanelOptionCredits: &'static NSAboutPanelOptionKey;
}

extern "C" {
    pub static NSAboutPanelOptionApplicationName: &'static NSAboutPanelOptionKey;
}

extern "C" {
    pub static NSAboutPanelOptionApplicationIcon: &'static NSAboutPanelOptionKey;
}

extern "C" {
    pub static NSAboutPanelOptionVersion: &'static NSAboutPanelOptionKey;
}

extern "C" {
    pub static NSAboutPanelOptionApplicationVersion: &'static NSAboutPanelOptionKey;
}

extern_methods!(
    /// NSStandardAboutPanel
    #[cfg(feature = "NSResponder")]
    unsafe impl NSApplication {
        #[method(orderFrontStandardAboutPanel:)]
        pub unsafe fn orderFrontStandardAboutPanel(&self, sender: Option<&AnyObject>);

        #[method(orderFrontStandardAboutPanelWithOptions:)]
        pub unsafe fn orderFrontStandardAboutPanelWithOptions(
            &self,
            options_dictionary: &NSDictionary<NSAboutPanelOptionKey, AnyObject>,
        );
    }
);

extern_methods!(
    /// NSApplicationLayoutDirection
    #[cfg(feature = "NSResponder")]
    unsafe impl NSApplication {
        #[cfg(feature = "NSUserInterfaceLayout")]
        #[method(userInterfaceLayoutDirection)]
        pub unsafe fn userInterfaceLayoutDirection(&self) -> NSUserInterfaceLayoutDirection;
    }
);

extern_methods!(
    /// NSRestorableUserInterface
    #[cfg(feature = "NSResponder")]
    unsafe impl NSApplication {
        #[method(disableRelaunchOnLogin)]
        pub unsafe fn disableRelaunchOnLogin(&self);

        #[method(enableRelaunchOnLogin)]
        pub unsafe fn enableRelaunchOnLogin(&self);
    }
);

// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSRemoteNotificationType(pub NSUInteger);
impl NSRemoteNotificationType {
    #[doc(alias = "NSRemoteNotificationTypeNone")]
    pub const None: Self = Self(0);
    #[doc(alias = "NSRemoteNotificationTypeBadge")]
    pub const Badge: Self = Self(1 << 0);
    #[doc(alias = "NSRemoteNotificationTypeSound")]
    pub const Sound: Self = Self(1 << 1);
    #[doc(alias = "NSRemoteNotificationTypeAlert")]
    pub const Alert: Self = Self(1 << 2);
}

unsafe impl Encode for NSRemoteNotificationType {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSRemoteNotificationType {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_methods!(
    /// NSRemoteNotifications
    #[cfg(feature = "NSResponder")]
    unsafe impl NSApplication {
        #[method(registerForRemoteNotifications)]
        pub unsafe fn registerForRemoteNotifications(&self);

        #[method(unregisterForRemoteNotifications)]
        pub unsafe fn unregisterForRemoteNotifications(&self);

        #[method(isRegisteredForRemoteNotifications)]
        pub unsafe fn isRegisteredForRemoteNotifications(&self) -> bool;

        #[method(registerForRemoteNotificationTypes:)]
        pub unsafe fn registerForRemoteNotificationTypes(&self, types: NSRemoteNotificationType);

        #[method(enabledRemoteNotificationTypes)]
        pub unsafe fn enabledRemoteNotificationTypes(&self) -> NSRemoteNotificationType;
    }
);

extern "C" {
    pub fn NSApplicationMain(argc: c_int, argv: NonNull<NonNull<c_char>>) -> c_int;
}

extern "C" {
    pub fn NSApplicationLoad() -> Bool;
}

extern "C" {
    pub fn NSShowsServicesMenuItem(item_name: &NSString) -> Bool;
}

extern "C" {
    pub fn NSSetShowsServicesMenuItem(item_name: &NSString, enabled: Bool) -> NSInteger;
}

extern "C" {
    pub fn NSUpdateDynamicServices();
}

extern "C" {
    #[cfg(feature = "NSPasteboard")]
    pub fn NSPerformService(item_name: &NSString, pboard: Option<&NSPasteboard>) -> Bool;
}

pub type NSServiceProviderName = NSString;

extern "C" {
    pub fn NSRegisterServicesProvider(provider: Option<&AnyObject>, name: &NSServiceProviderName);
}

extern "C" {
    pub fn NSUnregisterServicesProvider(name: &NSServiceProviderName);
}

extern "C" {
    pub static NSApplicationDidBecomeActiveNotification: &'static NSNotificationName;
}

extern "C" {
    pub static NSApplicationDidHideNotification: &'static NSNotificationName;
}

extern "C" {
    pub static NSApplicationDidFinishLaunchingNotification: &'static NSNotificationName;
}

extern "C" {
    pub static NSApplicationDidResignActiveNotification: &'static NSNotificationName;
}

extern "C" {
    pub static NSApplicationDidUnhideNotification: &'static NSNotificationName;
}

extern "C" {
    pub static NSApplicationDidUpdateNotification: &'static NSNotificationName;
}

extern "C" {
    pub static NSApplicationWillBecomeActiveNotification: &'static NSNotificationName;
}

extern "C" {
    pub static NSApplicationWillHideNotification: &'static NSNotificationName;
}

extern "C" {
    pub static NSApplicationWillFinishLaunchingNotification: &'static NSNotificationName;
}

extern "C" {
    pub static NSApplicationWillResignActiveNotification: &'static NSNotificationName;
}

extern "C" {
    pub static NSApplicationWillUnhideNotification: &'static NSNotificationName;
}

extern "C" {
    pub static NSApplicationWillUpdateNotification: &'static NSNotificationName;
}

extern "C" {
    pub static NSApplicationWillTerminateNotification: &'static NSNotificationName;
}

extern "C" {
    pub static NSApplicationDidChangeScreenParametersNotification: &'static NSNotificationName;
}

extern "C" {
    pub static NSApplicationProtectedDataWillBecomeUnavailableNotification:
        &'static NSNotificationName;
}

extern "C" {
    pub static NSApplicationProtectedDataDidBecomeAvailableNotification:
        &'static NSNotificationName;
}

extern "C" {
    pub static NSApplicationLaunchIsDefaultLaunchKey: &'static NSString;
}

extern "C" {
    pub static NSApplicationLaunchUserNotificationKey: &'static NSString;
}

extern "C" {
    pub static NSApplicationLaunchRemoteNotificationKey: &'static NSString;
}

extern "C" {
    pub static NSApplicationDidChangeOcclusionStateNotification: &'static NSNotificationName;
}

#[deprecated = "Use NSModalResponseStop instead"]
pub const NSRunStoppedResponse: c_int = -1000;
#[deprecated = "Use NSModalResponseAbort instead"]
pub const NSRunAbortedResponse: c_int = -1001;
#[deprecated = "Use NSModalResponseContinue instead"]
pub const NSRunContinuesResponse: c_int = -1002;

extern_methods!(
    /// NSDeprecated
    #[cfg(feature = "NSResponder")]
    unsafe impl NSApplication {
        #[cfg(feature = "NSWindow")]
        #[deprecated = "Use -[NSWindow beginSheet:completionHandler:] instead"]
        #[method(runModalForWindow:relativeToWindow:)]
        pub unsafe fn runModalForWindow_relativeToWindow(
            &self,
            window: Option<&NSWindow>,
            doc_window: Option<&NSWindow>,
        ) -> NSInteger;

        #[cfg(feature = "NSWindow")]
        #[deprecated = "Use -[NSWindow beginSheet:completionHandler:] instead"]
        #[method(beginModalSessionForWindow:relativeToWindow:)]
        pub unsafe fn beginModalSessionForWindow_relativeToWindow(
            &self,
            window: Option<&NSWindow>,
            doc_window: Option<&NSWindow>,
        ) -> NSModalSession;

        #[deprecated]
        #[method(application:printFiles:)]
        pub unsafe fn application_printFiles(
            &self,
            sender: Option<&NSApplication>,
            filenames: Option<&NSArray<NSString>>,
        );

        #[cfg(feature = "NSWindow")]
        #[deprecated = "Use -[NSWindow beginSheet:completionHandler:] instead"]
        #[method(beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:)]
        pub unsafe fn beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo(
            &self,
            sheet: &NSWindow,
            doc_window: &NSWindow,
            modal_delegate: Option<&AnyObject>,
            did_end_selector: Option<Sel>,
            context_info: *mut c_void,
        );

        #[cfg(feature = "NSWindow")]
        #[deprecated = "Use -[NSWindow endSheet:] instead"]
        #[method(endSheet:)]
        pub unsafe fn endSheet(&self, sheet: &NSWindow);

        #[cfg(feature = "NSWindow")]
        #[deprecated = "Use -[NSWindow endSheet:returnCode:] instead"]
        #[method(endSheet:returnCode:)]
        pub unsafe fn endSheet_returnCode(&self, sheet: &NSWindow, return_code: NSInteger);

        #[cfg(feature = "NSWindow")]
        #[deprecated = "Use -enumerateWindowsWithOptions:usingBlock: instead"]
        #[method_id(@__retain_semantics Other makeWindowsPerform:inOrder:)]
        pub unsafe fn makeWindowsPerform_inOrder(
            &self,
            selector: Sel,
            flag: bool,
        ) -> Option<Id<NSWindow>>;

        #[cfg(feature = "NSGraphicsContext")]
        #[deprecated = "This method always returns nil. If you need access to the current drawing context, use [NSGraphicsContext currentContext] inside of a draw operation."]
        #[method_id(@__retain_semantics Other context)]
        pub unsafe fn context(&self) -> Option<Id<NSGraphicsContext>>;
    }
);