Changeset 5e758e4 in mainline


Ignore:
Timestamp:
2023-11-19T12:22:11Z (13 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, topic/simplify-dev-export
Children:
69935a8
Parents:
e8a6279f
Message:

When start menu entry is edited, editor list needs updating

We need to update the entry caption in the UI list to reflect
any changes made while the entry was being edited.

Location:
uspace
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/taskbar-cfg/smeedit.c

    re8a6279f r5e758e4  
    4141#include "taskbar-cfg.h"
    4242#include "smeedit.h"
     43#include "startmenu.h"
    4344
    4445static void wnd_close(ui_window_t *, void *);
     
    111112        }
    112113
     114        smee->startmenu = smenu;
    113115        smee->smentry = smentry;
    114116
     
    361363
    362364        (void)smenu_entry_save(smee->smentry->entry);
    363 
     365        startmenu_entry_update(smee->smentry);
    364366        smeedit_destroy(smee);
    365367}
  • uspace/app/taskbar-cfg/startmenu.c

    re8a6279f r5e758e4  
    398398}
    399399
     400/** Update start menu entry caption.
     401 *
     402 * When editing an entry the entry's label might change. We need
     403 * to update the list entry caption to reflect that.
     404 *
     405 * @param entry Start menu entry
     406 */
     407errno_t startmenu_entry_update(startmenu_entry_t *entry)
     408{
     409        return ui_list_entry_set_caption(entry->lentry,
     410            smenu_entry_get_caption(entry->entry));
     411}
     412
    400413/** Entry in entry list is selected.
    401414 *
  • uspace/app/taskbar-cfg/startmenu.h

    re8a6279f r5e758e4  
    4848extern startmenu_entry_t *startmenu_get_selected(startmenu_t *);
    4949extern void startmenu_edit(startmenu_t *);
     50extern errno_t startmenu_entry_update(startmenu_entry_t *);
    5051
    5152#endif
  • uspace/lib/ui/include/ui/list.h

    re8a6279f r5e758e4  
    6060extern void *ui_list_entry_get_arg(ui_list_entry_t *);
    6161extern ui_list_t *ui_list_entry_get_list(ui_list_entry_t *);
     62extern errno_t ui_list_entry_set_caption(ui_list_entry_t *, const char *);
    6263extern size_t ui_list_entries_cnt(ui_list_t *);
    6364extern errno_t ui_list_sort(ui_list_t *);
  • uspace/lib/ui/src/list.c

    re8a6279f r5e758e4  
    800800}
    801801
     802/** Change list entry caption.
     803 *
     804 * @param entry UI list entry
     805 * @param caption New caption
     806 *
     807 * @return EOK on success, ENOMEM if out of memory
     808 */
     809errno_t ui_list_entry_set_caption(ui_list_entry_t *entry, const char *caption)
     810{
     811        char *dcaption;
     812
     813        dcaption = str_dup(caption);
     814        if (dcaption == NULL)
     815                return ENOMEM;
     816
     817        free(entry->caption);
     818        entry->caption = dcaption;
     819
     820        (void)ui_list_entry_paint(entry, ui_list_entry_get_idx(entry));
     821        return EOK;
     822}
     823
    802824/** Clear UI list entry list.
    803825 *
  • uspace/lib/ui/test/list.c

    re8a6279f r5e758e4  
    10391039}
    10401040
     1041/** ui_list_entry_set_caption() sets entry captino */
     1042PCUT_TEST(entry_set_caption)
     1043{
     1044        ui_t *ui;
     1045        ui_window_t *window;
     1046        ui_wnd_params_t params;
     1047        ui_list_t *list;
     1048        ui_list_entry_attr_t attr;
     1049        ui_list_entry_t *entry;
     1050        errno_t rc;
     1051
     1052        rc = ui_create_disp(NULL, &ui);
     1053        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     1054
     1055        ui_wnd_params_init(&params);
     1056        params.caption = "Test";
     1057
     1058        rc = ui_window_create(ui, &params, &window);
     1059        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     1060
     1061        rc = ui_list_create(window, true, &list);
     1062        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     1063
     1064        ui_list_entry_attr_init(&attr);
     1065
     1066        /* Append entry and get pointer to it */
     1067        attr.caption = "a";
     1068        attr.arg = (void *)1;
     1069        entry = NULL;
     1070        rc = ui_list_entry_append(list, &attr, &entry);
     1071        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     1072        PCUT_ASSERT_NOT_NULL(entry);
     1073
     1074        /* Change caption */
     1075        rc = ui_list_entry_set_caption(entry, "b");
     1076        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     1077        PCUT_ASSERT_STR_EQUALS("b", entry->caption);
     1078
     1079        ui_list_destroy(list);
     1080        ui_window_destroy(window);
     1081        ui_destroy(ui);
     1082}
     1083
    10411084/** ui_list_entries_cnt() returns the number of entries */
    10421085PCUT_TEST(entries_cnt)
Note: See TracChangeset for help on using the changeset viewer.