Changeset 7aeb52cb in mainline for uspace/app/nav/panel.c


Ignore:
Timestamp:
2021-10-25T00:32:45Z (3 years ago)
Author:
jxsvoboda <5887334+jxsvoboda@…>
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)
Message:

Different color for service-special files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/nav/panel.c

    rf783081 r7aeb52cb  
    9898
    9999        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);
    100104        if (rc != EOK)
    101105                goto error;
     
    116120        if (panel->dir_color != NULL)
    117121                gfx_color_delete(panel->dir_color);
     122        if (panel->svc_color != NULL)
     123                gfx_color_delete(panel->svc_color);
    118124        ui_control_delete(panel->control);
    119125        free(panel);
     
    131137        gfx_color_delete(panel->act_border_color);
    132138        gfx_color_delete(panel->dir_color);
     139        gfx_color_delete(panel->svc_color);
    133140        panel_clear_entries(panel);
    134141        ui_control_delete(panel->control);
     
    169176        else if (entry->isdir)
    170177                fmt.color = panel->dir_color;
     178        else if (entry->svc != 0)
     179                fmt.color = panel->svc_color;
    171180        else
    172181                fmt.color = panel->color;
     
    375384}
    376385
     386/** Initialize panel entry attributes.
     387 *
     388 * @param attr Attributes
     389 */
     390void panel_entry_attr_init(panel_entry_attr_t *attr)
     391{
     392        memset(attr, 0, sizeof(*attr));
     393}
     394
    377395/** Destroy panel control.
    378396 *
     
    427445 *
    428446 * @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
    432448 * @return EOK on success or an error code
    433449 */
    434 errno_t panel_entry_append(panel_t *panel, const char *name, uint64_t size,
    435     bool isdir)
     450errno_t panel_entry_append(panel_t *panel, panel_entry_attr_t *attr)
    436451{
    437452        panel_entry_t *entry;
     
    442457
    443458        entry->panel = panel;
    444         entry->name = str_dup(name);
     459        entry->name = str_dup(attr->name);
    445460        if (entry->name == NULL) {
    446461                free(entry);
     
    448463        }
    449464
    450         entry->size = size;
    451         entry->isdir = isdir;
     465        entry->size = attr->size;
     466        entry->isdir = attr->isdir;
     467        entry->svc = attr->svc;
    452468        link_initialize(&entry->lentries);
    453469        list_append(&entry->lentries, &panel->entries);
     
    469485        list_remove(&entry->lentries);
    470486        --entry->panel->entries_cnt;
    471         free(entry->name);
     487        free((char *) entry->name);
    472488        free(entry);
    473489}
     
    501517        char newdir[256];
    502518        char *ndir = NULL;
     519        panel_entry_attr_t attr;
    503520        errno_t rc;
    504521
     
    523540        if (str_cmp(ndir, "/") != 0) {
    524541                /* 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);
    526547                if (rc != EOK)
    527548                        goto error;
     
    537558                }
    538559
    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);
    541567                if (rc != EOK)
    542568                        goto error;
Note: See TracChangeset for help on using the changeset viewer.