Changeset 28ca31ed in mainline for uspace/app/taskbar-cfg/startmenu.c
- Timestamp:
- 2024-02-13T20:13:48Z (16 months ago)
- Branches:
- master
- Children:
- 10657856
- Parents:
- 242e3c3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/taskbar-cfg/startmenu.c
r242e3c3 r28ca31ed 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 54 54 static void startmenu_delete_entry_clicked(ui_pbutton_t *, void *); 55 55 static void startmenu_edit_entry_clicked(ui_pbutton_t *, void *); 56 static void startmenu_up_entry_clicked(ui_pbutton_t *, void *); 57 static void startmenu_down_entry_clicked(ui_pbutton_t *, void *); 56 58 57 59 /** Entry list callbacks */ … … 73 75 ui_pbutton_cb_t startmenu_edit_entry_button_cb = { 74 76 .clicked = startmenu_edit_entry_clicked 77 }; 78 79 /** Move entry up button callbacks */ 80 ui_pbutton_cb_t startmenu_up_entry_button_cb = { 81 .clicked = startmenu_up_entry_clicked 82 }; 83 84 /** Move entry down button callbacks */ 85 ui_pbutton_cb_t startmenu_down_entry_button_cb = { 86 .clicked = startmenu_down_entry_clicked 75 87 }; 76 88 … … 151 163 rect.p0.y = 5; 152 164 rect.p1.x = 56; 153 rect.p1.y = 10;165 rect.p1.y = 20; 154 166 } else { 155 167 rect.p0.x = 20; 156 168 rect.p0.y = 80; 157 169 rect.p1.x = 360; 158 rect.p1.y = 180;170 rect.p1.y = 330; 159 171 } 160 172 … … 263 275 &startmenu_edit_entry_button_cb, (void *)smenu); 264 276 277 /* Move entry up button */ 278 279 rc = ui_pbutton_create(ui_res, "Up", &smenu->up_entry); 280 if (rc != EOK) { 281 printf("Error creating button.\n"); 282 goto error; 283 } 284 285 if (ui_resource_is_textmode(ui_res)) { 286 rect.p0.x = 58; 287 rect.p0.y = 12; 288 rect.p1.x = 68; 289 rect.p1.y = 13; 290 } else { 291 rect.p0.x = 370; 292 rect.p0.y = 190; 293 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 if (rc != EOK) { 301 printf("Error adding control to layout.\n"); 302 goto error; 303 } 304 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 if (rc != EOK) { 312 printf("Error creating button.\n"); 313 goto error; 314 } 315 316 if (ui_resource_is_textmode(ui_res)) { 317 rect.p0.x = 58; 318 rect.p0.y = 14; 319 rect.p1.x = 68; 320 rect.p1.y = 15; 321 } else { 322 rect.p0.x = 370; 323 rect.p0.y = 220; 324 rect.p1.x = 450; 325 rect.p1.y = 245; 326 } 327 328 ui_pbutton_set_rect(smenu->down_entry, &rect); 329 330 rc = ui_fixed_add(smenu->fixed, ui_pbutton_ctl(smenu->down_entry)); 331 if (rc != EOK) { 332 printf("Error adding control to layout.\n"); 333 goto error; 334 } 335 336 ui_pbutton_set_cb(smenu->down_entry, 337 &startmenu_down_entry_button_cb, (void *)smenu); 338 265 339 ui_tab_add(smenu->tab, ui_fixed_ctl(smenu->fixed)); 266 340 … … 268 342 return EOK; 269 343 error: 344 if (smenu->down_entry != NULL) 345 ui_pbutton_destroy(smenu->down_entry); 346 if (smenu->up_entry != NULL) 347 ui_pbutton_destroy(smenu->up_entry); 270 348 if (smenu->delete_entry != NULL) 271 349 ui_pbutton_destroy(smenu->delete_entry); … … 488 566 ui_list_entry_delete(smentry->lentry); 489 567 free(smentry); 490 (void) 568 (void)ui_control_paint(ui_list_ctl(smenu->entries_list)); 491 569 } 492 570 … … 504 582 } 505 583 584 /** Up entry button clicked. 585 * 586 * @param pbutton Push button 587 * @param arg Argument (startmenu_t *) 588 */ 589 static void startmenu_up_entry_clicked(ui_pbutton_t *pbutton, void *arg) 590 { 591 startmenu_t *smenu = (startmenu_t *)arg; 592 startmenu_entry_t *smentry; 593 errno_t rc; 594 595 (void)pbutton; 596 597 smentry = startmenu_get_selected(smenu); 598 if (smentry == NULL) 599 return; 600 601 rc = smenu_entry_move_up(smentry->entry); 602 if (rc != EOK) 603 return; 604 605 ui_list_entry_move_up(smentry->lentry); 606 607 (void)ui_control_paint(ui_list_ctl(smenu->entries_list)); 608 } 609 610 /** Down entry button clicked. 611 * 612 * @param pbutton Push button 613 * @param arg Argument (startmenu_t *) 614 */ 615 static void startmenu_down_entry_clicked(ui_pbutton_t *pbutton, void *arg) 616 { 617 startmenu_t *smenu = (startmenu_t *)arg; 618 startmenu_entry_t *smentry; 619 errno_t rc; 620 621 (void)pbutton; 622 623 smentry = startmenu_get_selected(smenu); 624 if (smentry == NULL) 625 return; 626 627 rc = smenu_entry_move_up(smentry->entry); 628 if (rc != EOK) 629 return; 630 631 ui_list_entry_move_down(smentry->lentry); 632 633 (void)ui_control_paint(ui_list_ctl(smenu->entries_list)); 634 } 635 506 636 /** @} 507 637 */
Note:
See TracChangeset
for help on using the changeset viewer.