-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdialog.c
57 lines (49 loc) · 2.42 KB
/
dialog.c
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
// dialog
#include "../uyghur.c"
void native_dialog_inform(Bridge *bridge) {
CString dialogTitle = Bridge_receiveString(bridge);
CString messageContent = Bridge_receiveStringWithDefault(bridge, "");
tinyfd_messageBox(dialogTitle, messageContent, "yes", "info", 0);
Bridge_returnEmpty(bridge);
}
bool native_dialog_confirm(Bridge *bridge) {
CString dialogTitle = Bridge_receiveString(bridge);
CString messageContent = Bridge_receiveStringWithDefault(bridge, "");
bool isYes = tinyfd_messageBox(dialogTitle, messageContent, "yesno", "question", 0) == 1;
Bridge_returnBoolean(bridge, isYes);
}
void native_dialog_input(Bridge *bridge) {
CString dialogTitle = Bridge_receiveString(bridge);
CString defaultText = Bridge_receiveStringWithDefault(bridge, NULL);
CString resultText = tinyfd_inputBox(dialogTitle, "", defaultText);
Bridge_returnString(bridge, resultText);
}
CString native_dialog_select_save(Bridge *bridge) {
CString dialogTitle = Bridge_receiveString(bridge);
CString defaultPath = Bridge_receiveStringWithDefault(bridge, "./");
CString filterRule = Bridge_receiveStringWithDefault(bridge, "*.*");
char const * filterArray[1] = {filterRule};
CString resultPath = tinyfd_saveFileDialog(dialogTitle, defaultPath, 1, filterArray, NULL);
Bridge_returnString(bridge, resultPath);
}
CString native_dialog_select_open(Bridge *bridge) {
CString dialogTitle = Bridge_receiveString(bridge);
CString defaultPath = Bridge_receiveStringWithDefault(bridge, "./");
CString filterRule = Bridge_receiveStringWithDefault(bridge, "*.*");
char const * filterArray[1] = {filterRule};
CString resultPath = tinyfd_openFileDialog(dialogTitle, defaultPath, 1, filterArray, NULL, false);
Bridge_returnString(bridge, resultPath);
}
CString native_dialog_select_folder(Bridge *bridge) {
CString dialogTitle = Bridge_receiveString(bridge);
CString defaultPath = Bridge_receiveStringWithDefault(bridge, "./");
CString resultPath = tinyfd_selectFolderDialog(dialogTitle, defaultPath);
Bridge_returnString(bridge, resultPath);
}
CString native_dialog_select_color(Bridge *bridge) {
CString dialogTitle = Bridge_receiveString(bridge);
CString defaultColor = Bridge_receiveStringWithDefault(bridge, NULL);
unsigned char const _chars[3] = "";
CString resultColor = tinyfd_colorChooser(dialogTitle, defaultColor, _chars, _chars);
Bridge_returnString(bridge, resultColor);
}