Changeset b1397ab in mainline for uspace/app/taskbar-cfg/startmenu.c


Ignore:
Timestamp:
2023-11-09T13:02:16Z (14 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, topic/msim-upgrade, topic/simplify-dev-export
Children:
e0d874b7
Parents:
40eab9f
git-author:
Jiri Svoboda <jiri@…> (2023-11-08 18:01:53)
git-committer:
Jiri Svoboda <jiri@…> (2023-11-09 13:02:16)
Message:

Start menu editor is editing

You can change an entry and it will be saved to the configuration repo.
(Cannot create/delete yet). To see the change in the editor, you need
to restart it. To see the change in the taskbar, you need to restart it.

File:
1 edited

Legend:

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

    r40eab9f rb1397ab  
    292292        smenu_entry_t *entry;
    293293        startmenu_entry_t *smentry;
    294         const char *caption;
    295         const char *cmd;
    296294        errno_t rc;
    297295
    298296        entry = tbarcfg_smenu_first(tbarcfg);
    299297        while (entry != NULL) {
    300                 caption = smenu_entry_get_caption(entry);
    301                 cmd = smenu_entry_get_cmd(entry);
    302 
    303                 rc = startmenu_insert(smenu, caption, cmd, &smentry);
     298                rc = startmenu_insert(smenu, entry, &smentry);
    304299                if (rc != EOK)
    305300                        return rc;
     
    323318        while (lentry != NULL) {
    324319                entry = (startmenu_entry_t *)ui_list_entry_get_arg(lentry);
    325                 free(entry->caption);
    326                 free(entry->cmd);
    327320                free(entry);
    328321                ui_list_entry_delete(lentry);
     
    338331 *
    339332 * @param smenu Start menu configuration tab
    340  * @param caption Entry caption
    341  * @param cmd Command to run
    342  * @param rentry Place to store pointer to new entry or NULL
     333 * @param entry Backing entry
     334 * @param rsmentry Place to store pointer to new entry or NULL
    343335 * @return EOK on success or an error code
    344336 */
    345 errno_t startmenu_insert(startmenu_t *smenu, const char *caption,
    346     const char *cmd, startmenu_entry_t **rentry)
    347 {
    348         startmenu_entry_t *entry;
     337errno_t startmenu_insert(startmenu_t *smenu, smenu_entry_t *entry,
     338    startmenu_entry_t **rsmentry)
     339{
     340        startmenu_entry_t *smentry;
    349341        ui_list_entry_attr_t attr;
    350342        errno_t rc;
    351343
    352         entry = calloc(1, sizeof(startmenu_entry_t));
    353         if (entry == NULL)
     344        smentry = calloc(1, sizeof(startmenu_entry_t));
     345        if (smentry == NULL)
    354346                return ENOMEM;
    355347
    356         entry->startmenu = smenu;
    357         entry->caption = str_dup(caption);
    358         if (entry->caption == NULL) {
    359                 free(entry);
    360                 return ENOMEM;
    361         }
    362 
    363         entry->cmd = str_dup(cmd);
    364         if (entry->caption == NULL) {
    365                 free(entry->caption);
    366                 free(entry);
    367                 return ENOMEM;
    368         }
    369 
     348        smentry->startmenu = smenu;
     349        smentry->entry = entry;
     350
     351        printf("startmenu_insert: smentry=%p entry=%p\n",
     352            smentry, entry);
    370353        ui_list_entry_attr_init(&attr);
    371         attr.caption = caption;
    372         attr.arg = (void *)entry;
    373         rc = ui_list_entry_append(smenu->entries_list, &attr, &entry->lentry);
    374         if (rc != EOK) {
    375                 free(entry->caption);
    376                 free(entry->cmd);
    377                 free(entry);
     354        attr.caption = smenu_entry_get_caption(entry);
     355        attr.arg = (void *)smentry;
     356        rc = ui_list_entry_append(smenu->entries_list, &attr, &smentry->lentry);
     357        if (rc != EOK) {
     358                free(smentry);
    378359                return rc;
    379360        }
    380361
    381         if (rentry != NULL)
    382                 *rentry = entry;
     362        if (rsmentry != NULL)
     363                *rsmentry = smentry;
    383364        return EOK;
    384365}
    385366
     367/** Get selected start menu entry.
     368 *
     369 * @param smenu Start menu
     370 * @return Selected entry
     371 */
     372startmenu_entry_t *startmenu_get_selected(startmenu_t *smenu)
     373{
     374        ui_list_entry_t *entry;
     375
     376        entry = ui_list_get_cursor(smenu->entries_list);
     377        return (startmenu_entry_t *)ui_list_entry_get_arg(entry);
     378}
     379
    386380/** Edit selected menu entry.
    387381 *
     
    391385{
    392386        smeedit_t *smee;
     387        startmenu_entry_t *smentry;
    393388        errno_t rc;
    394389
    395         rc = smeedit_create(smenu, &smee);
     390        smentry = startmenu_get_selected(smenu);
     391
     392        printf("smeedit_create:entry=%p\n", smentry);
     393        rc = smeedit_create(smenu, smentry, &smee);
    396394        if (rc != EOK)
    397395                return;
Note: See TracChangeset for help on using the changeset viewer.