Changes in uspace/lib/ui/src/filedialog.c [e0cf963:12dd36c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/src/filedialog.c
re0cf963 r12dd36c 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2024 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> 43 44 #include <ui/pbutton.h> 44 45 #include <ui/resource.h> … … 53 54 .close = ui_file_dialog_wnd_close, 54 55 .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_selected 55 65 }; 56 66 … … 96 106 ui_label_t *label = NULL; 97 107 ui_entry_t *entry = NULL; 108 ui_file_list_t *flist = NULL; 98 109 ui_pbutton_t *bok = NULL; 99 110 ui_pbutton_t *bcancel = NULL; … … 115 126 wparams.rect.p0.y = 0; 116 127 wparams.rect.p1.x = 40; 117 wparams.rect.p1.y = 9;128 wparams.rect.p1.y = 20; 118 129 } else { 119 130 wparams.rect.p0.x = 0; 120 131 wparams.rect.p0.y = 0; 121 132 wparams.rect.p1.x = 300; 122 wparams.rect.p1.y = 135;133 wparams.rect.p1.y = 335; 123 134 } 124 135 … … 167 178 if (ui_is_textmode(ui)) { 168 179 rect.p0.x = 3; 169 rect.p0.y = 4;180 rect.p0.y = 3; 170 181 rect.p1.x = 37; 171 rect.p1.y = 5;182 rect.p1.y = 4; 172 183 } else { 173 184 rect.p0.x = 10; … … 192 203 entry = NULL; 193 204 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 { 217 rect.p0.x = 10; 218 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 194 266 rc = ui_pbutton_create(ui_res, "OK", &bok); 195 267 if (rc != EOK) … … 201 273 if (ui_is_textmode(ui)) { 202 274 rect.p0.x = 10; 203 rect.p0.y = 6;275 rect.p0.y = 17; 204 276 rect.p1.x = 20; 205 rect.p1.y = 7;277 rect.p1.y = 18; 206 278 } else { 207 279 rect.p0.x = 55; 208 rect.p0.y = 90;280 rect.p0.y = 290; 209 281 rect.p1.x = 145; 210 rect.p1.y = 118;282 rect.p1.y = 318; 211 283 } 212 284 … … 222 294 bok = NULL; 223 295 296 /* Cancel button */ 297 224 298 rc = ui_pbutton_create(ui_res, "Cancel", &bcancel); 225 299 if (rc != EOK) … … 231 305 if (ui_is_textmode(ui)) { 232 306 rect.p0.x = 22; 233 rect.p0.y = 6;307 rect.p0.y = 17; 234 308 rect.p1.x = 32; 235 rect.p1.y = 7;309 rect.p1.y = 18; 236 310 } else { 237 311 rect.p0.x = 155; 238 rect.p0.y = 90;312 rect.p0.y = 290; 239 313 rect.p1.x = 245; 240 rect.p1.y = 118;314 rect.p1.y = 318; 241 315 } 242 316 … … 263 337 if (entry != NULL) 264 338 ui_entry_destroy(entry); 339 if (flist != NULL) 340 ui_file_list_destroy(flist); 265 341 if (bok != NULL) 266 342 ui_pbutton_destroy(bok); … … 320 396 * 321 397 * @param window Window 322 * @param arg Argument (ui_ prompt_dialog_t *)398 * @param arg Argument (ui_file_dialog_t *) 323 399 * @param event Keyboard event 324 400 */ … … 328 404 ui_file_dialog_t *dialog = (ui_file_dialog_t *) arg; 329 405 const char *fname; 406 ui_evclaim_t claim; 407 408 claim = ui_window_def_kbd(window, event); 409 if (claim == ui_claimed) 410 return; 330 411 331 412 if (event->type == KEY_PRESS && … … 346 427 } 347 428 } 348 349 ui_window_def_kbd(window, event); 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); 350 445 } 351 446
Note:
See TracChangeset
for help on using the changeset viewer.