Changes in uspace/lib/ui/src/filedialog.c [12dd36c:e0cf963] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/src/filedialog.c
r12dd36c re0cf963 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 41 41 #include <ui/label.h> 42 42 #include <ui/filedialog.h> 43 #include <ui/filelist.h>44 43 #include <ui/pbutton.h> 45 44 #include <ui/resource.h> … … 54 53 .close = ui_file_dialog_wnd_close, 55 54 .kbd = ui_file_dialog_wnd_kbd 56 };57 58 static void ui_file_dialog_flist_activate_req(ui_file_list_t *, void *);59 static void ui_file_dialog_flist_selected(ui_file_list_t *, void *,60 const char *);61 62 ui_file_list_cb_t ui_file_dialog_flist_cb = {63 .activate_req = ui_file_dialog_flist_activate_req,64 .selected = ui_file_dialog_flist_selected65 55 }; 66 56 … … 106 96 ui_label_t *label = NULL; 107 97 ui_entry_t *entry = NULL; 108 ui_file_list_t *flist = NULL;109 98 ui_pbutton_t *bok = NULL; 110 99 ui_pbutton_t *bcancel = NULL; … … 126 115 wparams.rect.p0.y = 0; 127 116 wparams.rect.p1.x = 40; 128 wparams.rect.p1.y = 20;117 wparams.rect.p1.y = 9; 129 118 } else { 130 119 wparams.rect.p0.x = 0; 131 120 wparams.rect.p0.y = 0; 132 121 wparams.rect.p1.x = 300; 133 wparams.rect.p1.y = 335;122 wparams.rect.p1.y = 135; 134 123 } 135 124 … … 178 167 if (ui_is_textmode(ui)) { 179 168 rect.p0.x = 3; 180 rect.p0.y = 3;169 rect.p0.y = 4; 181 170 rect.p1.x = 37; 182 rect.p1.y = 4;171 rect.p1.y = 5; 183 172 } else { 184 173 rect.p0.x = 10; … … 203 192 entry = NULL; 204 193 205 /* Files label */ 206 rc = ui_label_create(ui_res, "Files:", &label); 207 if (rc != EOK) 208 goto error; 209 210 /* FIXME: Auto layout */ 211 if (ui_is_textmode(ui)) { 212 rect.p0.x = 3; 213 rect.p0.y = 5; 214 rect.p1.x = 17; 215 rect.p1.y = 6; 216 } else { 194 rc = ui_pbutton_create(ui_res, "OK", &bok); 195 if (rc != EOK) 196 goto error; 197 198 ui_pbutton_set_cb(bok, &ui_file_dialog_bok_cb, dialog); 199 200 /* FIXME: Auto layout */ 201 if (ui_is_textmode(ui)) { 217 202 rect.p0.x = 10; 203 rect.p0.y = 6; 204 rect.p1.x = 20; 205 rect.p1.y = 7; 206 } else { 207 rect.p0.x = 55; 218 208 rect.p0.y = 90; 219 rect.p1.x = 190;220 rect.p1.y = 105;221 }222 223 ui_label_set_rect(label, &rect);224 225 rc = ui_fixed_add(fixed, ui_label_ctl(label));226 if (rc != EOK)227 goto error;228 229 label = NULL;230 231 /* File list */232 233 rc = ui_file_list_create(window, false, &flist);234 if (rc != EOK)235 goto error;236 237 /* FIXME: Auto layout */238 if (ui_is_textmode(ui)) {239 rect.p0.x = 3;240 rect.p0.y = 6;241 rect.p1.x = 37;242 rect.p1.y = 16;243 } else {244 rect.p0.x = 10;245 rect.p0.y = 110;246 rect.p1.x = 290;247 rect.p1.y = 280;248 }249 250 ui_file_list_set_rect(flist, &rect);251 ui_file_list_set_cb(flist, &ui_file_dialog_flist_cb, dialog);252 253 rc = ui_fixed_add(fixed, ui_file_list_ctl(flist));254 if (rc != EOK)255 goto error;256 257 dialog->flist = flist;258 flist = NULL;259 260 rc = ui_file_list_read_dir(dialog->flist, ".");261 if (rc != EOK)262 goto error;263 264 /* OK button */265 266 rc = ui_pbutton_create(ui_res, "OK", &bok);267 if (rc != EOK)268 goto error;269 270 ui_pbutton_set_cb(bok, &ui_file_dialog_bok_cb, dialog);271 272 /* FIXME: Auto layout */273 if (ui_is_textmode(ui)) {274 rect.p0.x = 10;275 rect.p0.y = 17;276 rect.p1.x = 20;277 rect.p1.y = 18;278 } else {279 rect.p0.x = 55;280 rect.p0.y = 290;281 209 rect.p1.x = 145; 282 rect.p1.y = 318;210 rect.p1.y = 118; 283 211 } 284 212 … … 294 222 bok = NULL; 295 223 296 /* Cancel button */297 298 224 rc = ui_pbutton_create(ui_res, "Cancel", &bcancel); 299 225 if (rc != EOK) … … 305 231 if (ui_is_textmode(ui)) { 306 232 rect.p0.x = 22; 307 rect.p0.y = 17;233 rect.p0.y = 6; 308 234 rect.p1.x = 32; 309 rect.p1.y = 18;235 rect.p1.y = 7; 310 236 } else { 311 237 rect.p0.x = 155; 312 rect.p0.y = 290;238 rect.p0.y = 90; 313 239 rect.p1.x = 245; 314 rect.p1.y = 318;240 rect.p1.y = 118; 315 241 } 316 242 … … 337 263 if (entry != NULL) 338 264 ui_entry_destroy(entry); 339 if (flist != NULL)340 ui_file_list_destroy(flist);341 265 if (bok != NULL) 342 266 ui_pbutton_destroy(bok); … … 396 320 * 397 321 * @param window Window 398 * @param arg Argument (ui_ file_dialog_t *)322 * @param arg Argument (ui_prompt_dialog_t *) 399 323 * @param event Keyboard event 400 324 */ … … 404 328 ui_file_dialog_t *dialog = (ui_file_dialog_t *) arg; 405 329 const char *fname; 406 ui_evclaim_t claim;407 408 claim = ui_window_def_kbd(window, event);409 if (claim == ui_claimed)410 return;411 330 412 331 if (event->type == KEY_PRESS && … … 427 346 } 428 347 } 429 } 430 431 static void ui_file_dialog_flist_activate_req(ui_file_list_t *flist, void *arg) 432 { 433 ui_file_dialog_t *dialog = (ui_file_dialog_t *) arg; 434 435 ui_file_list_activate(dialog->flist); 436 ui_entry_deactivate(dialog->ename); 437 } 438 439 static void ui_file_dialog_flist_selected(ui_file_list_t *flist, void *arg, 440 const char *fname) 441 { 442 ui_file_dialog_t *dialog = (ui_file_dialog_t *) arg; 443 444 dialog->cb->bok(dialog, dialog->arg, fname); 348 349 ui_window_def_kbd(window, event); 445 350 } 446 351
Note:
See TracChangeset
for help on using the changeset viewer.