Changeset 7aeb52cb in mainline for uspace/app/nav/panel.c
- Timestamp:
- 2021-10-25T00:32:45Z (3 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 01e9991
- Parents:
- f783081
- git-author:
- Jiri Svoboda <jiri@…> (2021-10-16 21:51:33)
- git-committer:
- jxsvoboda <5887334+jxsvoboda@…> (2021-10-25 00:32:45)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nav/panel.c
rf783081 r7aeb52cb 98 98 99 99 rc = gfx_color_new_ega(0x0f, &panel->dir_color); 100 if (rc != EOK) 101 goto error; 102 103 rc = gfx_color_new_ega(0x0a, &panel->svc_color); 100 104 if (rc != EOK) 101 105 goto error; … … 116 120 if (panel->dir_color != NULL) 117 121 gfx_color_delete(panel->dir_color); 122 if (panel->svc_color != NULL) 123 gfx_color_delete(panel->svc_color); 118 124 ui_control_delete(panel->control); 119 125 free(panel); … … 131 137 gfx_color_delete(panel->act_border_color); 132 138 gfx_color_delete(panel->dir_color); 139 gfx_color_delete(panel->svc_color); 133 140 panel_clear_entries(panel); 134 141 ui_control_delete(panel->control); … … 169 176 else if (entry->isdir) 170 177 fmt.color = panel->dir_color; 178 else if (entry->svc != 0) 179 fmt.color = panel->svc_color; 171 180 else 172 181 fmt.color = panel->color; … … 375 384 } 376 385 386 /** Initialize panel entry attributes. 387 * 388 * @param attr Attributes 389 */ 390 void panel_entry_attr_init(panel_entry_attr_t *attr) 391 { 392 memset(attr, 0, sizeof(*attr)); 393 } 394 377 395 /** Destroy panel control. 378 396 * … … 427 445 * 428 446 * @param panel Panel 429 * @param name File name 430 * @param size File size 431 * @param isdir @c true iff the entry is a directory 447 * @param attr Entry attributes 432 448 * @return EOK on success or an error code 433 449 */ 434 errno_t panel_entry_append(panel_t *panel, const char *name, uint64_t size, 435 bool isdir) 450 errno_t panel_entry_append(panel_t *panel, panel_entry_attr_t *attr) 436 451 { 437 452 panel_entry_t *entry; … … 442 457 443 458 entry->panel = panel; 444 entry->name = str_dup( name);459 entry->name = str_dup(attr->name); 445 460 if (entry->name == NULL) { 446 461 free(entry); … … 448 463 } 449 464 450 entry->size = size; 451 entry->isdir = isdir; 465 entry->size = attr->size; 466 entry->isdir = attr->isdir; 467 entry->svc = attr->svc; 452 468 link_initialize(&entry->lentries); 453 469 list_append(&entry->lentries, &panel->entries); … … 469 485 list_remove(&entry->lentries); 470 486 --entry->panel->entries_cnt; 471 free( entry->name);487 free((char *) entry->name); 472 488 free(entry); 473 489 } … … 501 517 char newdir[256]; 502 518 char *ndir = NULL; 519 panel_entry_attr_t attr; 503 520 errno_t rc; 504 521 … … 523 540 if (str_cmp(ndir, "/") != 0) { 524 541 /* Need to add a synthetic up-dir entry */ 525 rc = panel_entry_append(panel, "..", 0, true); 542 panel_entry_attr_init(&attr); 543 attr.name = ".."; 544 attr.isdir = true; 545 546 rc = panel_entry_append(panel, &attr); 526 547 if (rc != EOK) 527 548 goto error; … … 537 558 } 538 559 539 rc = panel_entry_append(panel, dirent->d_name, finfo.size, 540 finfo.is_directory); 560 panel_entry_attr_init(&attr); 561 attr.name = dirent->d_name; 562 attr.size = finfo.size; 563 attr.isdir = finfo.is_directory; 564 attr.svc = finfo.service; 565 566 rc = panel_entry_append(panel, &attr); 541 567 if (rc != EOK) 542 568 goto error;
Note:
See TracChangeset
for help on using the changeset viewer.