Changes in uspace/app/taskbar-cfg/startmenu.c [e63e74a:f87ff8e] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/taskbar-cfg/startmenu.c
re63e74a rf87ff8e 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2023 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 *);59 56 60 57 /** Entry list callbacks */ … … 76 73 ui_pbutton_cb_t startmenu_edit_entry_button_cb = { 77 74 .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_clicked83 };84 85 /** Move entry up button callbacks */86 ui_pbutton_cb_t startmenu_up_entry_button_cb = {87 .clicked = startmenu_up_entry_clicked88 };89 90 /** Move entry down button callbacks */91 ui_pbutton_cb_t startmenu_down_entry_button_cb = {92 .clicked = startmenu_down_entry_clicked93 75 }; 94 76 … … 169 151 rect.p0.y = 5; 170 152 rect.p1.x = 56; 171 rect.p1.y = 20;153 rect.p1.y = 10; 172 154 } else { 173 155 rect.p0.x = 20; 174 156 rect.p0.y = 80; 175 157 rect.p1.x = 360; 176 rect.p1.y = 330;158 rect.p1.y = 180; 177 159 } 178 160 … … 281 263 &startmenu_edit_entry_button_cb, (void *)smenu); 282 264 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 376 265 ui_tab_add(smenu->tab, ui_fixed_ctl(smenu->fixed)); 377 266 … … 379 268 return EOK; 380 269 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);385 270 if (smenu->delete_entry != NULL) 386 271 ui_pbutton_destroy(smenu->delete_entry); … … 455 340 startmenu_entry_t *smentry; 456 341 ui_list_entry_attr_t attr; 457 bool separator;458 342 errno_t rc; 459 343 … … 466 350 467 351 ui_list_entry_attr_init(&attr); 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 352 attr.caption = smenu_entry_get_caption(entry); 474 353 attr.arg = (void *)smentry; 475 476 354 rc = ui_list_entry_append(smenu->entries_list, &attr, &smentry->lentry); 477 355 if (rc != EOK) { … … 517 395 } 518 396 519 /** Create new separator menu entry.520 *521 * @param smenu Start menu522 */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 537 397 /** Edit selected menu entry. 538 398 * … … 549 409 return; 550 410 551 /* Do not edit separator entries */552 if (smenu_entry_get_separator(smentry->entry))553 return;554 555 411 rc = smeedit_create(smenu, smentry, &smee); 556 412 if (rc != EOK) … … 573 429 } 574 430 575 /** Repaint start menu entry list.576 *577 * When editing an entry the entry's label might change. We need578 * to update the list entry caption to reflect that.579 *580 * @param smenu Start menu581 */582 void startmenu_repaint(startmenu_t *smenu)583 {584 (void) ui_control_paint(ui_list_ctl(smenu->entries_list));585 }586 587 431 /** Entry in entry list is selected. 588 432 * … … 632 476 ui_list_entry_delete(smentry->lentry); 633 477 free(smentry); 634 (void) ui_control_paint(ui_list_ctl(smenu->entries_list));478 (void) ui_control_paint(ui_list_ctl(smenu->entries_list)); 635 479 } 636 480 … … 648 492 } 649 493 650 /** Separator entry button clicked.651 *652 * @param pbutton Push button653 * @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 button666 * @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 button692 * @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 715 494 /** @} 716 495 */
Note:
See TracChangeset
for help on using the changeset viewer.