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


Ignore:
Timestamp:
2023-11-09T13:02:16Z (6 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/smeedit.c

    r40eab9f rb1397ab  
    4848};
    4949
     50static void smeedit_ok_clicked(ui_pbutton_t *, void *);
     51static void smeedit_cancel_clicked(ui_pbutton_t *, void *);
     52
     53/** OK button callbacks */
     54ui_pbutton_cb_t smeedit_ok_button_cb = {
     55        .clicked = smeedit_ok_clicked
     56};
     57
     58/** Cancel button callbacks */
     59ui_pbutton_cb_t smeedit_cancel_button_cb = {
     60        .clicked = smeedit_cancel_clicked
     61};
     62
    5063/** Window close button was clicked.
    5164 *
     
    6477 *
    6578 * @param smenu Start menu
     79 * @param smentry Start menu entry to edit or @c NULL if creating
     80 *                a new entry
    6681 * @param rsmee Place to store pointer to new start menu entry edit window
    6782 * @return EOK on success or an error code
    6883 */
    69 errno_t smeedit_create(startmenu_t *smenu, smeedit_t **rsmee)
     84errno_t smeedit_create(startmenu_t *smenu, startmenu_entry_t *smentry,
     85    smeedit_t **rsmee)
    7086{
    7187        ui_wnd_params_t params;
     
    7591        gfx_rect_t rect;
    7692        ui_resource_t *res;
     93        const char *cmd;
     94        const char *caption;
    7795        errno_t rc;
    7896
    7997        ui = smenu->tbarcfg->ui;
     98
     99        if (smentry != NULL) {
     100                cmd = smenu_entry_get_cmd(smentry->entry);
     101                caption = smenu_entry_get_caption(smentry->entry);
     102        } else {
     103                cmd = "";
     104                caption = "";
     105        }
    80106
    81107        smee = calloc(1, sizeof(smeedit_t));
     
    85111        }
    86112
     113        smee->smentry = smentry;
     114
    87115        ui_wnd_params_init(&params);
    88116        params.caption = "Edit Start Menu Entry";
     
    145173        /* Command entry */
    146174
    147         rc = ui_entry_create(window, "foo", &smee->ecmd);
     175        rc = ui_entry_create(window, cmd, &smee->ecmd);
    148176        if (rc != EOK)
    149177                goto error;
     
    199227        /* Caption entry */
    200228
    201         rc = ui_entry_create(window, "bar", &smee->ecaption);
     229        rc = ui_entry_create(window, caption, &smee->ecaption);
    202230        if (rc != EOK)
    203231                goto error;
     
    243271        }
    244272
     273        ui_pbutton_set_cb(smee->bok, &smeedit_ok_button_cb, (void *)smee);
    245274        ui_pbutton_set_rect(smee->bok, &rect);
    246275        ui_pbutton_set_default(smee->bok, true);
     
    271300        }
    272301
     302        ui_pbutton_set_cb(smee->bcancel, &smeedit_cancel_button_cb,
     303            (void *)smee);
    273304        ui_pbutton_set_rect(smee->bcancel, &rect);
    274305
     
    303334}
    304335
     336/** OK button clicked.
     337 *
     338 * @params bok OK button
     339 * @params arg Argument (smeedit_t *)
     340 */
     341static void smeedit_ok_clicked(ui_pbutton_t *bok, void *arg)
     342{
     343        smeedit_t *smee;
     344        const char *cmd;
     345        const char *caption;
     346        errno_t rc;
     347
     348        (void)bok;
     349        smee = (smeedit_t *)arg;
     350
     351        cmd = ui_entry_get_text(smee->ecmd);
     352        caption = ui_entry_get_text(smee->ecaption);
     353
     354        rc = smenu_entry_set_cmd(smee->smentry->entry, cmd);
     355        if (rc != EOK)
     356                return;
     357
     358        smenu_entry_set_caption(smee->smentry->entry, caption);
     359        if (rc != EOK)
     360                return;
     361
     362        (void)smenu_entry_save(smee->smentry->entry);
     363
     364        smeedit_destroy(smee);
     365}
     366
     367/** Cancel button clicked.
     368 *
     369 * @params bok OK button
     370 * @params arg Argument (smeedit_t *)
     371 */
     372static void smeedit_cancel_clicked(ui_pbutton_t *bcancel, void *arg)
     373{
     374        smeedit_t *smee;
     375
     376        (void)bcancel;
     377        smee = (smeedit_t *)arg;
     378        smeedit_destroy(smee);
     379}
     380
    305381/** @}
    306382 */
Note: See TracChangeset for help on using the changeset viewer.