Changeset f2cb80a in mainline for uspace/app/taskbar/tbsmenu.c
- Timestamp:
- 2024-02-23T17:57:23Z (11 months ago)
- Children:
- 192019f
- Parents:
- 86f862c (diff), 90ba06c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- boba-buba <120932204+boba-buba@…> (2024-02-23 17:57:23)
- git-committer:
- GitHub <noreply@…> (2024-02-23 17:57:23)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/taskbar/tbsmenu.c
r86f862c rf2cb80a 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 129 129 tbarcfg_t *tbcfg = NULL; 130 130 smenu_entry_t *sme; 131 bool separator; 131 132 const char *caption; 132 133 const char *cmd; 134 bool terminal; 133 135 errno_t rc; 134 136 … … 139 141 sme = tbarcfg_smenu_first(tbcfg); 140 142 while (sme != NULL) { 141 caption = smenu_entry_get_caption(sme); 142 cmd = smenu_entry_get_cmd(sme); 143 144 rc = tbsmenu_add(tbsmenu, caption, cmd, &tentry); 145 if (rc != EOK) 146 goto error; 143 separator = smenu_entry_get_separator(sme); 144 if (separator == false) { 145 caption = smenu_entry_get_caption(sme); 146 cmd = smenu_entry_get_cmd(sme); 147 terminal = smenu_entry_get_terminal(sme); 148 149 rc = tbsmenu_add(tbsmenu, caption, cmd, terminal, 150 &tentry); 151 if (rc != EOK) 152 goto error; 153 } else { 154 rc = tbsmenu_add_sep(tbsmenu, &tentry); 155 if (rc != EOK) 156 goto error; 157 } 147 158 148 159 (void)tentry; … … 226 237 * @param caption Caption 227 238 * @param cmd Command to run 239 * @param terminal Start in terminal 228 240 * @param entry Start menu entry 229 241 * @return @c EOK on success or an error code 230 242 */ 231 243 errno_t tbsmenu_add(tbsmenu_t *tbsmenu, const char *caption, 232 const char *cmd, tbsmenu_entry_t **rentry)244 const char *cmd, bool terminal, tbsmenu_entry_t **rentry) 233 245 { 234 246 errno_t rc; … … 250 262 goto error; 251 263 } 264 265 entry->terminal = terminal; 252 266 253 267 rc = ui_menu_entry_create(tbsmenu->smenu, caption, "", &entry->mentry); … … 271 285 } 272 286 287 /** Add separator entry to start menu. 288 * 289 * @param tbsmenu Start menu 290 * @param entry Start menu entry 291 * @return @c EOK on success or an error code 292 */ 293 errno_t tbsmenu_add_sep(tbsmenu_t *tbsmenu, tbsmenu_entry_t **rentry) 294 { 295 errno_t rc; 296 tbsmenu_entry_t *entry; 297 298 entry = calloc(1, sizeof(tbsmenu_entry_t)); 299 if (entry == NULL) 300 return ENOMEM; 301 302 rc = ui_menu_entry_sep_create(tbsmenu->smenu, &entry->mentry); 303 if (rc != EOK) 304 goto error; 305 306 ui_menu_entry_set_cb(entry->mentry, tbsmenu_smenu_entry_cb, 307 (void *)entry); 308 309 entry->tbsmenu = tbsmenu; 310 list_append(&entry->lentries, &tbsmenu->entries); 311 *rentry = entry; 312 return EOK; 313 error: 314 free(entry); 315 return rc; 316 } 317 273 318 /** Remove entry from start menu. 274 319 * … … 438 483 } 439 484 485 cmd->argv[cnt] = NULL; 486 440 487 return EOK; 441 488 } … … 465 512 int retval; 466 513 bool suspended; 514 int i; 515 int cnt; 516 char **cp; 517 const char **targv = NULL; 467 518 errno_t rc; 468 519 ui_t *ui; … … 482 533 suspended = true; 483 534 484 rc = task_spawnv(&id, &wait, cmd.argv[0], (const char *const *) 485 cmd.argv); 486 if (rc != EOK) 487 goto error; 535 /* Don't start in terminal if not running in a window */ 536 if (entry->terminal && !ui_is_fullscreen(ui)) { 537 cnt = 0; 538 cp = cmd.argv; 539 while (*cp != NULL) { 540 ++cnt; 541 ++cp; 542 } 543 544 targv = calloc(cnt + 3, sizeof(char **)); 545 if (targv == NULL) 546 goto error; 547 548 targv[0] = "/app/terminal"; 549 targv[1] = "-c"; 550 551 for (i = 0; i <= cnt; i++) { 552 targv[2 + i] = cmd.argv[i]; 553 } 554 555 rc = task_spawnv(&id, &wait, targv[0], targv); 556 if (rc != EOK) 557 goto error; 558 559 free(targv); 560 targv = NULL; 561 } else { 562 rc = task_spawnv(&id, &wait, cmd.argv[0], (const char *const *) 563 cmd.argv); 564 if (rc != EOK) 565 goto error; 566 } 488 567 489 568 rc = task_wait(&wait, &texit, &retval); … … 499 578 return EOK; 500 579 error: 580 if (targv != NULL) 581 free(targv); 501 582 tbsmenu_cmd_fini(&cmd); 502 if (suspended) 503 (void) ui_resume(ui); 583 if (suspended) { 584 rc = ui_resume(ui); 585 if (rc != EOK) { 586 printf("Failed to resume UI.\n"); 587 exit(1); 588 } 589 } 504 590 (void) ui_paint(ui); 505 591 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.