-
Notifications
You must be signed in to change notification settings - Fork 149
/
ui_dropdown.c
277 lines (233 loc) · 7.11 KB
/
ui_dropdown.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
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
#include "main.h"
static void dropdown_audio_in_onselect(uint16_t i, const DROPDOWN* dm)
{
DROP_ELEMENT *e = &((DROP_ELEMENT*) dm->userdata)[i];
void *handle = e->handle;
toxaudio_postmessage(AUDIO_SET_INPUT, 0, 0, handle);
}
static void dropdown_audio_out_onselect(uint16_t i, const DROPDOWN* dm)
{
DROP_ELEMENT *e = &((DROP_ELEMENT*) dm->userdata)[i];
void *handle = e->handle;
toxaudio_postmessage(AUDIO_SET_OUTPUT, 0, 0, handle);
}
static void dropdown_video_onselect(uint16_t i, const DROPDOWN* dm)
{
DROP_ELEMENT *e = &((DROP_ELEMENT*) dm->userdata)[i];
void *handle = e->handle;
uint16_t b = 0;
if(!handle && video_preview) {
video_end(0);
video_preview = 0;
b = 1; //tell video thread to stop preview too
} else if((size_t)handle == 1) {
desktopgrab(1);
return;
}
toxvideo_postmessage(VIDEO_SET, b, 0, handle);
}
static void dropdown_dpi_onselect(uint16_t i, const DROPDOWN* UNUSED(dm))
{
ui_scale(i + 1);
}
static void dropdown_language_onselect(uint16_t i, const DROPDOWN* UNUSED(dm))
{
LANG = (UI_LANG_ID)i;
}
static STRING* dropdown_language_ondisplay(uint16_t i, const DROPDOWN* UNUSED(dm))
{
UI_LANG_ID l = (UI_LANG_ID)i;
return SPTRFORLANG(l, STR_LANG_NATIVE_NAME);
}
static void dropdown_filter_onselect(uint16_t i, const DROPDOWN* UNUSED(dm))
{
FILTER = !!i;
}
static void dropdown_proxy_onselect(uint16_t i, const DROPDOWN* UNUSED(dm))
{
if((i != 0) != (options.proxy_type) || i) {
options.proxy_type = (i != 0) ? TOX_PROXY_TYPE_SOCKS5 : TOX_PROXY_TYPE_NONE;
if(i == 2 && options.udp_enabled) {
options.udp_enabled = 0;
dropdown_udp.selected = dropdown_udp.over = 1;
}
memcpy(proxy_address, edit_proxy_ip.data, edit_proxy_ip.length);
proxy_address[edit_proxy_ip.length] = 0;
edit_proxy_port.data[edit_proxy_port.length] = 0;
options.proxy_port = strtol((char*)edit_proxy_port.data, NULL, 0);
tox_settingschanged();
}
}
static void dropdown_ipv6_onselect(uint16_t i, const DROPDOWN* UNUSED(dm))
{
if(!i != options.ipv6_enabled) {
options.ipv6_enabled = !i;
tox_settingschanged();
}
}
static void dropdown_udp_onselect(uint16_t i, const DROPDOWN* UNUSED(dm))
{
if(i == options.udp_enabled) {
options.udp_enabled = !i;
if(!i && dropdown_proxy.selected == 2) {
dropdown_proxy.selected = dropdown_proxy.over = 1;
}
tox_settingschanged();
}
}
static void dropdown_logging_onselect(uint16_t i, const DROPDOWN* UNUSED(dm))
{
logging_enabled = !!i;
}
static void dropdown_theme_onselect(uint16_t i, const DROPDOWN* UNUSED(dm))
{
theme_load(i);
}
static void dropdown_notifications_onselect(uint16_t i, const DROPDOWN* UNUSED(dm))
{
audible_notifications_enabled = !!i;
}
static void dropdown_audio_filtering_onselect(uint16_t i, const DROPDOWN* UNUSED(dm))
{
audio_filtering_enabled = !!i;
}
static void dropdown_close_to_tray_onselect(uint16_t i, const DROPDOWN* UNUSED(dm)){
close_to_tray = i;
debug("Close To Tray. :: %i\n", close_to_tray);
}
static void dropdown_start_in_tray_onselect(uint16_t i, const DROPDOWN* UNUSED(dm)){
start_in_tray = i;
debug("Start in Tray. :: %i\n", start_in_tray);
}
static void dropdown_auto_startup_onselect(uint16_t i, const DROPDOWN* UNUSED(dm)){
auto_startup = i;
launch_at_startup(auto_startup);
debug("Auto startup. :: %i\n", auto_startup);
}
static void dropdown_typing_notes_onselect(const uint16_t i, const DROPDOWN* UNUSED(dm)) {
dont_send_typing_notes = i;
debug("Typing notifications preference: %hu\n", i);
}
static UI_STRING_ID dpidrops[] = {
STR_DPI_TINY,
STR_DPI_NORMAL,
STR_DPI_BIG,
STR_DPI_LARGE,
STR_DPI_HUGE,
};
static UI_STRING_ID filterdrops[] = {
STR_CONTACTS_FILTER_ALL,
STR_CONTACTS_FILTER_ONLINE,
};
static UI_STRING_ID proxydrops[] = {
STR_PROXY_DISABLED,
STR_PROXY_FALLBACK,
STR_PROXY_ALWAYS_USE,
};
static UI_STRING_ID themedrops[] = {
STR_THEME_DEFAULT,
STR_THEME_LIGHT,
STR_THEME_DARK,
STR_THEME_HIGHCONTRAST,
STR_THEME_CUSTOM,
STR_THEME_ZENBURN,
};
static UI_STRING_ID yesnodrops[] = {STR_YES, STR_NO};
static UI_STRING_ID noyesdrops[] = {STR_NO, STR_YES};
static UI_STRING_ID offondrops[] = {STR_OFF, STR_ON};
DROPDOWN dropdown_audio_in = {
.ondisplay = list_dropdown_ondisplay,
.onselect = dropdown_audio_in_onselect
},
dropdown_audio_out = {
.ondisplay = list_dropdown_ondisplay,
.onselect = dropdown_audio_out_onselect
},
dropdown_video = {
.ondisplay = list_dropdown_ondisplay,
.onselect = dropdown_video_onselect,
},
dropdown_dpi = {
.ondisplay = simple_dropdown_ondisplay,
.onselect = dropdown_dpi_onselect,
.dropcount = countof(dpidrops),
.userdata = dpidrops
},
dropdown_language = {
.ondisplay = dropdown_language_ondisplay,
.onselect = dropdown_language_onselect,
.dropcount = LANGS_MAX+1,
},
dropdown_filter = {
.ondisplay = simple_dropdown_ondisplay,
.onselect = dropdown_filter_onselect,
.dropcount = countof(filterdrops),
.style = AUXILIARY_STYLE,
.userdata = filterdrops
},
dropdown_proxy = {
.ondisplay = simple_dropdown_ondisplay,
.onselect = dropdown_proxy_onselect,
.dropcount = countof(proxydrops),
.userdata = proxydrops
},
dropdown_ipv6 = {
.ondisplay = simple_dropdown_ondisplay,
.onselect = dropdown_ipv6_onselect,
.dropcount = countof(yesnodrops),
.userdata = yesnodrops
},
dropdown_udp = {
.ondisplay = simple_dropdown_ondisplay,
.onselect = dropdown_udp_onselect,
.dropcount = countof(yesnodrops),
.userdata = yesnodrops
},
dropdown_logging = {
.ondisplay = simple_dropdown_ondisplay,
.onselect = dropdown_logging_onselect,
.dropcount = countof(noyesdrops),
.userdata = noyesdrops
},
dropdown_theme = {
.ondisplay = simple_dropdown_ondisplay,
.onselect = dropdown_theme_onselect,
.dropcount = countof(themedrops),
.userdata = themedrops
},
dropdown_close_to_tray = {
.ondisplay = simple_dropdown_ondisplay,
.onselect = dropdown_close_to_tray_onselect,
.dropcount = countof(noyesdrops),
.userdata = noyesdrops
},
dropdown_start_in_tray = {
.ondisplay = simple_dropdown_ondisplay,
.onselect = dropdown_start_in_tray_onselect,
.dropcount = countof(noyesdrops),
.userdata = noyesdrops
},
dropdown_auto_startup = {
.ondisplay = simple_dropdown_ondisplay,
.onselect = dropdown_auto_startup_onselect,
.dropcount = countof(noyesdrops),
.userdata = noyesdrops
},
dropdown_audible_notification = {
.ondisplay = simple_dropdown_ondisplay,
.onselect = dropdown_notifications_onselect,
.dropcount = countof(offondrops),
.userdata = offondrops
},
dropdown_typing_notes = {
.ondisplay = simple_dropdown_ondisplay,
.onselect = dropdown_typing_notes_onselect,
.dropcount = countof(yesnodrops),
.userdata = yesnodrops
},
dropdown_audio_filtering = {
.ondisplay = simple_dropdown_ondisplay,
.onselect = dropdown_audio_filtering_onselect,
.dropcount = countof(offondrops),
.userdata = offondrops
};