Debian Codegraph @

.cargo/vendor/core-foundation-sys/src/user_notification.rs

raw
1 // Copyright 2023 The Servo Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10 use std::os::raw::c_void;
11
12 use crate::base::{CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeID, SInt32};
13 use crate::date::CFTimeInterval;
14 use crate::dictionary::CFDictionaryRef;
15 use crate::runloop::CFRunLoopSourceRef;
16 use crate::string::CFStringRef;
17 use crate::url::CFURLRef;
18
19 #[repr(C)]
20 pub struct __CFUserNotification(c_void);
21
22 pub type CFUserNotificationCallBack =
23 extern "C" fn(userNotification: CFUserNotificationRef, responseFlags: CFOptionFlags);
24 pub type CFUserNotificationRef = *mut __CFUserNotification;
25
26 /* Alert Levels */
27 pub const kCFUserNotificationStopAlertLevel: CFOptionFlags = 0;
28 pub const kCFUserNotificationNoteAlertLevel: CFOptionFlags = 1;
29 pub const kCFUserNotificationCautionAlertLevel: CFOptionFlags = 2;
30 pub const kCFUserNotificationPlainAlertLevel: CFOptionFlags = 3;
31
32 /* Response Codes */
33 pub const kCFUserNotificationDefaultResponse: CFOptionFlags = 0;
34 pub const kCFUserNotificationAlternateResponse: CFOptionFlags = 1;
35 pub const kCFUserNotificationOtherResponse: CFOptionFlags = 2;
36 pub const kCFUserNotificationCancelResponse: CFOptionFlags = 3;
37
38 /* Button Flags */
39 pub const kCFUserNotificationNoDefaultButtonFlag: CFOptionFlags = 1usize << 5;
40 pub const kCFUserNotificationUseRadioButtonsFlag: CFOptionFlags = 1usize << 6;
41
42 #[inline(always)]
43 pub fn CFUserNotificationCheckBoxChecked(i: CFIndex) -> CFOptionFlags {
44 (1u32 << (8 + i)) as CFOptionFlags
45 }
46
47 #[inline(always)]
48 pub fn CFUserNotificationSecureTextField(i: CFIndex) -> CFOptionFlags {
49 (1u32 << (16 + i)) as CFOptionFlags
50 }
51
52 #[inline(always)]
53 pub fn CFUserNotificationPopUpSelection(n: CFIndex) -> CFOptionFlags {
54 (n << 24) as CFOptionFlags
55 }
56
57 extern "C" {
58 /*
59 * CFUserNotification.h
60 */
61
62 /* Dialog Description Keys */
63 pub static kCFUserNotificationIconURLKey: CFStringRef;
64 pub static kCFUserNotificationSoundURLKey: CFStringRef;
65 pub static kCFUserNotificationLocalizationURLKey: CFStringRef;
66 pub static kCFUserNotificationAlertHeaderKey: CFStringRef;
67 pub static kCFUserNotificationAlertMessageKey: CFStringRef;
68 pub static kCFUserNotificationDefaultButtonTitleKey: CFStringRef;
69 pub static kCFUserNotificationAlternateButtonTitleKey: CFStringRef;
70 pub static kCFUserNotificationOtherButtonTitleKey: CFStringRef;
71 pub static kCFUserNotificationProgressIndicatorValueKey: CFStringRef;
72 pub static kCFUserNotificationPopUpTitlesKey: CFStringRef;
73 pub static kCFUserNotificationTextFieldTitlesKey: CFStringRef;
74 pub static kCFUserNotificationCheckBoxTitlesKey: CFStringRef;
75 pub static kCFUserNotificationTextFieldValuesKey: CFStringRef;
76 pub static kCFUserNotificationPopUpSelectionKey: CFStringRef;
77 pub static kCFUserNotificationAlertTopMostKey: CFStringRef;
78 pub static kCFUserNotificationKeyboardTypesKey: CFStringRef;
79
80 /* CFUserNotification Miscellaneous Functions */
81 pub fn CFUserNotificationCancel(userNotification: CFUserNotificationRef) -> SInt32;
82 pub fn CFUserNotificationCreate(
83 allocator: CFAllocatorRef,
84 timeout: CFTimeInterval,
85 flags: CFOptionFlags,
86 error: *mut SInt32,
87 dictionary: CFDictionaryRef,
88 ) -> CFUserNotificationRef;
89 pub fn CFUserNotificationCreateRunLoopSource(
90 allocator: CFAllocatorRef,
91 userNotification: CFUserNotificationRef,
92 callout: CFUserNotificationCallBack,
93 order: CFIndex,
94 ) -> CFRunLoopSourceRef;
95 pub fn CFUserNotificationDisplayAlert(
96 timeout: CFTimeInterval,
97 flags: CFOptionFlags,
98 iconURL: CFURLRef,
99 soundURL: CFURLRef,
100 localizationURL: CFURLRef,
101 alertHeader: CFStringRef,
102 alertMessage: CFStringRef,
103 defaultButtonTitle: CFStringRef,
104 alternateButtonTitle: CFStringRef,
105 otherButtonTitle: CFStringRef,
106 responseFlags: *mut CFOptionFlags,
107 ) -> SInt32;
108 pub fn CFUserNotificationDisplayNotice(
109 timeout: CFTimeInterval,
110 flags: CFOptionFlags,
111 iconURL: CFURLRef,
112 soundURL: CFURLRef,
113 localizationURL: CFURLRef,
114 alertHeader: CFStringRef,
115 alertMessage: CFStringRef,
116 defaultButtonTitle: CFStringRef,
117 ) -> SInt32;
118 pub fn CFUserNotificationGetTypeID() -> CFTypeID;
119 pub fn CFUserNotificationGetResponseDictionary(
120 userNotification: CFUserNotificationRef,
121 ) -> CFDictionaryRef;
122 pub fn CFUserNotificationGetResponseValue(
123 userNotification: CFUserNotificationRef,
124 key: CFStringRef,
125 idx: CFIndex,
126 ) -> CFStringRef;
127 pub fn CFUserNotificationReceiveResponse(
128 userNotification: CFUserNotificationRef,
129 timeout: CFTimeInterval,
130 responseFlags: *mut CFOptionFlags,
131 ) -> SInt32;
132 pub fn CFUserNotificationUpdate(
133 userNotification: CFUserNotificationRef,
134 timeout: CFTimeInterval,
135 flags: CFOptionFlags,
136 dictionary: CFDictionaryRef,
137 ) -> SInt32;
138 }