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


Ignore:
Timestamp:
2024-02-21T20:26:35Z (3 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
95e2967
Parents:
5f3188b8
Message:

Start menu separator entry support

File:
1 edited

Legend:

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

    r5f3188b8 re63e74a  
    5454static void startmenu_delete_entry_clicked(ui_pbutton_t *, void *);
    5555static void startmenu_edit_entry_clicked(ui_pbutton_t *, void *);
     56static void startmenu_sep_entry_clicked(ui_pbutton_t *, void *);
    5657static void startmenu_up_entry_clicked(ui_pbutton_t *, void *);
    5758static void startmenu_down_entry_clicked(ui_pbutton_t *, void *);
     
    7576ui_pbutton_cb_t startmenu_edit_entry_button_cb = {
    7677        .clicked = startmenu_edit_entry_clicked
     78};
     79
     80/** Separator entry button callbacks */
     81ui_pbutton_cb_t startmenu_sep_entry_button_cb = {
     82        .clicked = startmenu_sep_entry_clicked
    7783};
    7884
     
    275281            &startmenu_edit_entry_button_cb, (void *)smenu);
    276282
    277         /* Move entry up button */
    278 
    279         rc = ui_pbutton_create(ui_res, "Up", &smenu->up_entry);
     283        /* Separator entry button */
     284
     285        rc = ui_pbutton_create(ui_res, "Separator", &smenu->sep_entry);
    280286        if (rc != EOK) {
    281287                printf("Error creating button.\n");
     
    285291        if (ui_resource_is_textmode(ui_res)) {
    286292                rect.p0.x = 58;
    287                 rect.p0.y = 12;
     293                rect.p0.y = 11;
    288294                rect.p1.x = 68;
    289                 rect.p1.y = 13;
     295                rect.p1.y = 12;
    290296        } else {
    291297                rect.p0.x = 370;
    292                 rect.p0.y = 190;
     298                rect.p0.y = 170;
    293299                rect.p1.x = 450;
    294                 rect.p1.y = 215;
    295         }
    296 
    297         ui_pbutton_set_rect(smenu->up_entry, &rect);
    298 
    299         rc = ui_fixed_add(smenu->fixed, ui_pbutton_ctl(smenu->up_entry));
     300                rect.p1.y = 195;
     301        }
     302
     303        ui_pbutton_set_rect(smenu->sep_entry, &rect);
     304
     305        rc = ui_fixed_add(smenu->fixed, ui_pbutton_ctl(smenu->sep_entry));
    300306        if (rc != EOK) {
    301307                printf("Error adding control to layout.\n");
     
    303309        }
    304310
    305         ui_pbutton_set_cb(smenu->up_entry,
    306             &startmenu_up_entry_button_cb, (void *)smenu);
    307 
    308         /* Move entry down button */
    309 
    310         rc = ui_pbutton_create(ui_res, "Down", &smenu->down_entry);
     311        ui_pbutton_set_cb(smenu->sep_entry,
     312            &startmenu_sep_entry_button_cb, (void *)smenu);
     313
     314        /* Move entry up button */
     315
     316        rc = ui_pbutton_create(ui_res, "Up", &smenu->up_entry);
    311317        if (rc != EOK) {
    312318                printf("Error creating button.\n");
     
    316322        if (ui_resource_is_textmode(ui_res)) {
    317323                rect.p0.x = 58;
    318                 rect.p0.y = 14;
     324                rect.p0.y = 13;
    319325                rect.p1.x = 68;
    320                 rect.p1.y = 15;
     326                rect.p1.y = 14;
    321327        } else {
    322328                rect.p0.x = 370;
     
    324330                rect.p1.x = 450;
    325331                rect.p1.y = 245;
     332        }
     333
     334        ui_pbutton_set_rect(smenu->up_entry, &rect);
     335
     336        rc = ui_fixed_add(smenu->fixed, ui_pbutton_ctl(smenu->up_entry));
     337        if (rc != EOK) {
     338                printf("Error adding control to layout.\n");
     339                goto error;
     340        }
     341
     342        ui_pbutton_set_cb(smenu->up_entry,
     343            &startmenu_up_entry_button_cb, (void *)smenu);
     344
     345        /* Move entry down button */
     346
     347        rc = ui_pbutton_create(ui_res, "Down", &smenu->down_entry);
     348        if (rc != EOK) {
     349                printf("Error creating button.\n");
     350                goto error;
     351        }
     352
     353        if (ui_resource_is_textmode(ui_res)) {
     354                rect.p0.x = 58;
     355                rect.p0.y = 15;
     356                rect.p1.x = 68;
     357                rect.p1.y = 16;
     358        } else {
     359                rect.p0.x = 370;
     360                rect.p0.y = 250;
     361                rect.p1.x = 450;
     362                rect.p1.y = 275;
    326363        }
    327364
     
    418455        startmenu_entry_t *smentry;
    419456        ui_list_entry_attr_t attr;
     457        bool separator;
    420458        errno_t rc;
    421459
     
    428466
    429467        ui_list_entry_attr_init(&attr);
    430         attr.caption = smenu_entry_get_caption(entry);
     468        separator = smenu_entry_get_separator(entry);
     469        if (separator)
     470                attr.caption = "-- Separator --";
     471        else
     472                attr.caption = smenu_entry_get_caption(entry);
     473
    431474        attr.arg = (void *)smentry;
     475
    432476        rc = ui_list_entry_append(smenu->entries_list, &attr, &smentry->lentry);
    433477        if (rc != EOK) {
     
    473517}
    474518
     519/** Create new separator menu entry.
     520 *
     521 * @param smenu Start menu
     522 */
     523void startmenu_sep_entry(startmenu_t *smenu)
     524{
     525        startmenu_entry_t *smentry = NULL;
     526        smenu_entry_t *entry;
     527        errno_t rc;
     528
     529        rc = smenu_entry_sep_create(smenu->tbarcfg->tbarcfg, &entry);
     530        if (rc != EOK)
     531                return;
     532
     533        (void)startmenu_insert(smenu, entry, &smentry);
     534        (void)ui_control_paint(ui_list_ctl(smenu->entries_list));
     535}
     536
    475537/** Edit selected menu entry.
    476538 *
     
    485547        smentry = startmenu_get_selected(smenu);
    486548        if (smentry == NULL)
     549                return;
     550
     551        /* Do not edit separator entries */
     552        if (smenu_entry_get_separator(smentry->entry))
    487553                return;
    488554
     
    582648}
    583649
    584 /** Up entry button clicked.
     650/** Separator entry button clicked.
    585651 *
    586652 * @param pbutton Push button
    587653 * @param arg Argument (startmenu_t *)
    588654 */
     655static void startmenu_sep_entry_clicked(ui_pbutton_t *pbutton, void *arg)
     656{
     657        startmenu_t *smenu = (startmenu_t *)arg;
     658
     659        (void)pbutton;
     660        startmenu_sep_entry(smenu);
     661}
     662
     663/** Up entry button clicked.
     664 *
     665 * @param pbutton Push button
     666 * @param arg Argument (startmenu_t *)
     667 */
    589668static void startmenu_up_entry_clicked(ui_pbutton_t *pbutton, void *arg)
    590669{
Note: See TracChangeset for help on using the changeset viewer.