Changes in uspace/app/taskbar-cfg/startmenu.c [f87ff8e:e63e74a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/taskbar-cfg/startmenu.c
rf87ff8e re63e74a 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_sep_entry_clicked(ui_pbutton_t *, void *); 57 static void startmenu_up_entry_clicked(ui_pbutton_t *, void *); 58 static void startmenu_down_entry_clicked(ui_pbutton_t *, void *); 56 59 57 60 /** Entry list callbacks */ … … 73 76 ui_pbutton_cb_t startmenu_edit_entry_button_cb = { 74 77 .clicked = startmenu_edit_entry_clicked 78 }; 79 80 /** Separator entry button callbacks */ 81 ui_pbutton_cb_t startmenu_sep_entry_button_cb = { 82 .clicked = startmenu_sep_entry_clicked 83 }; 84 85 /** Move entry up button callbacks */ 86 ui_pbutton_cb_t startmenu_up_entry_button_cb = { 87 .clicked = startmenu_up_entry_clicked 88 }; 89 90 /** Move entry down button callbacks */ 91 ui_pbutton_cb_t startmenu_down_entry_button_cb = { 92 .clicked = startmenu_down_entry_clicked 75 93 }; 76 94 … … 151 169 rect.p0.y = 5; 152 170 rect.p1.x = 56; 153 rect.p1.y = 10;171 rect.p1.y = 20; 154 172 } else { 155 173 rect.p0.x = 20; 156 174 rect.p0.y = 80; 157 175 rect.p1.x = 360; 158 rect.p1.y = 180;176 rect.p1.y = 330; 159 177 } 160 178 … … 263 281 &startmenu_edit_entry_button_cb, (void *)smenu); 264 282 283 /* Separator entry button */ 284 285 rc = ui_pbutton_create(ui_res, "Separator", &smenu->sep_entry); 286 if (rc != EOK) { 287 printf("Error creating button.\n"); 288 goto error; 289 } 290 291 if (ui_resource_is_textmode(ui_res)) { 292 rect.p0.x = 58; 293 rect.p0.y = 11; 294 rect.p1.x = 68; 295 rect.p1.y = 12; 296 } else { 297 rect.p0.x = 370; 298 rect.p0.y = 170; 299 rect.p1.x = 450; 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)); 306 if (rc != EOK) { 307 printf("Error adding control to layout.\n"); 308 goto error; 309 } 310 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); 317 if (rc != EOK) { 318 printf("Error creating button.\n"); 319 goto error; 320 } 321 322 if (ui_resource_is_textmode(ui_res)) { 323 rect.p0.x = 58; 324 rect.p0.y = 13; 325 rect.p1.x = 68; 326 rect.p1.y = 14; 327 } else { 328 rect.p0.x = 370; 329 rect.p0.y = 220; 330 rect.p1.x = 450; 331 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; 363 } 364 365 ui_pbutton_set_rect(smenu->down_entry, &rect); 366 367 rc = ui_fixed_add(smenu->fixed, ui_pbutton_ctl(smenu->down_entry)); 368 if (rc != EOK) { 369 printf("Error adding control to layout.\n"); 370 goto error; 371 } 372 373 ui_pbutton_set_cb(smenu->down_entry, 374 &startmenu_down_entry_button_cb, (void *)smenu); 375 265 376 ui_tab_add(smenu->tab, ui_fixed_ctl(smenu->fixed)); 266 377 … … 268 379 return EOK; 269 380 error: 381 if (smenu->down_entry != NULL) 382 ui_pbutton_destroy(smenu->down_entry); 383 if (smenu->up_entry != NULL) 384 ui_pbutton_destroy(smenu->up_entry); 270 385 if (smenu->delete_entry != NULL) 271 386 ui_pbutton_destroy(smenu->delete_entry); … … 340 455 startmenu_entry_t *smentry; 341 456 ui_list_entry_attr_t attr; 457 bool separator; 342 458 errno_t rc; 343 459 … … 350 466 351 467 ui_list_entry_attr_init(&attr); 352 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 353 474 attr.arg = (void *)smentry; 475 354 476 rc = ui_list_entry_append(smenu->entries_list, &attr, &smentry->lentry); 355 477 if (rc != EOK) { … … 395 517 } 396 518 519 /** Create new separator menu entry. 520 * 521 * @param smenu Start menu 522 */ 523 void 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 397 537 /** Edit selected menu entry. 398 538 * … … 409 549 return; 410 550 551 /* Do not edit separator entries */ 552 if (smenu_entry_get_separator(smentry->entry)) 553 return; 554 411 555 rc = smeedit_create(smenu, smentry, &smee); 412 556 if (rc != EOK) … … 429 573 } 430 574 575 /** Repaint start menu entry list. 576 * 577 * When editing an entry the entry's label might change. We need 578 * to update the list entry caption to reflect that. 579 * 580 * @param smenu Start menu 581 */ 582 void startmenu_repaint(startmenu_t *smenu) 583 { 584 (void) ui_control_paint(ui_list_ctl(smenu->entries_list)); 585 } 586 431 587 /** Entry in entry list is selected. 432 588 * … … 476 632 ui_list_entry_delete(smentry->lentry); 477 633 free(smentry); 478 (void) 634 (void)ui_control_paint(ui_list_ctl(smenu->entries_list)); 479 635 } 480 636 … … 492 648 } 493 649 650 /** Separator entry button clicked. 651 * 652 * @param pbutton Push button 653 * @param arg Argument (startmenu_t *) 654 */ 655 static 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 */ 668 static void startmenu_up_entry_clicked(ui_pbutton_t *pbutton, void *arg) 669 { 670 startmenu_t *smenu = (startmenu_t *)arg; 671 startmenu_entry_t *smentry; 672 errno_t rc; 673 674 (void)pbutton; 675 676 smentry = startmenu_get_selected(smenu); 677 if (smentry == NULL) 678 return; 679 680 rc = smenu_entry_move_up(smentry->entry); 681 if (rc != EOK) 682 return; 683 684 ui_list_entry_move_up(smentry->lentry); 685 686 (void)ui_control_paint(ui_list_ctl(smenu->entries_list)); 687 } 688 689 /** Down entry button clicked. 690 * 691 * @param pbutton Push button 692 * @param arg Argument (startmenu_t *) 693 */ 694 static void startmenu_down_entry_clicked(ui_pbutton_t *pbutton, void *arg) 695 { 696 startmenu_t *smenu = (startmenu_t *)arg; 697 startmenu_entry_t *smentry; 698 errno_t rc; 699 700 (void)pbutton; 701 702 smentry = startmenu_get_selected(smenu); 703 if (smentry == NULL) 704 return; 705 706 rc = smenu_entry_move_up(smentry->entry); 707 if (rc != EOK) 708 return; 709 710 ui_list_entry_move_down(smentry->lentry); 711 712 (void)ui_control_paint(ui_list_ctl(smenu->entries_list)); 713 } 714 494 715 /** @} 495 716 */
Note:
See TracChangeset
for help on using the changeset viewer.