Changeset 806d761 in mainline for uspace/lib/tbarcfg/src/tbarcfg.c
- Timestamp:
- 2024-02-07T23:44:59Z (11 months ago)
- Branches:
- master
- Children:
- 242e3c3
- Parents:
- 74cb6610
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/tbarcfg/src/tbarcfg.c
r74cb6610 r806d761 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 101 101 * @return EOK on success or an error code 102 102 */ 103 #include <stdio.h> 103 104 errno_t tbarcfg_open(const char *repopath, tbarcfg_t **rtbcfg) 104 105 { … … 110 111 const char *caption; 111 112 const char *cmd; 113 const char *terminal = NULL; 112 114 errno_t rc; 113 115 … … 154 156 } 155 157 156 rc = smenu_entry_new(tbcfg, nentry, caption, cmd, NULL); 158 terminal = sif_node_get_attr(nentry, "terminal"); 159 if (terminal == NULL) 160 terminal = "n"; 161 162 printf("terminal=%s\n", terminal); 163 164 rc = smenu_entry_new(tbcfg, nentry, caption, cmd, 165 str_cmp(terminal, "y") == 0, NULL); 157 166 if (rc != EOK) 158 167 goto error; … … 233 242 /** Get start menu entry command. 234 243 * 235 * @param entr Start menu entry244 * @param entry Start menu entry 236 245 * @return Command to run 237 246 */ … … 239 248 { 240 249 return entry->cmd; 250 } 251 252 /** Get start menu start in terminal flag. 253 * 254 * @param entry Start menu entry 255 * @return Start in terminal flag 256 */ 257 bool smenu_entry_get_terminal(smenu_entry_t *entry) 258 { 259 return entry->terminal; 241 260 } 242 261 … … 285 304 } 286 305 306 /** Set start menu entry start in terminal flag. 307 * 308 * Note: To make the change visible to others and persistent, 309 * you must call @c smenu_entry_save() 310 * 311 * @param entry Start menu entry 312 * @param terminal Start in terminal flag 313 */ 314 void smenu_entry_set_terminal(smenu_entry_t *entry, bool terminal) 315 { 316 entry->terminal = terminal; 317 } 318 287 319 /** Save any changes to start menu entry. 288 320 * … … 303 335 304 336 rc = sif_node_set_attr(trans, entry->nentry, "caption", entry->caption); 337 if (rc != EOK) 338 goto error; 339 340 rc = sif_node_set_attr(trans, entry->nentry, "terminal", 341 entry->terminal ? "y" : "n"); 305 342 if (rc != EOK) 306 343 goto error; … … 325 362 * @param caption Caption 326 363 * @param cmd Command to run 364 * @param terminal Start in terminal 327 365 * @param rentry Place to store pointer to new entry or @c NULL 328 366 */ 329 367 errno_t smenu_entry_new(tbarcfg_t *smenu, sif_node_t *nentry, 330 const char *caption, const char *cmd, smenu_entry_t **rentry)368 const char *caption, const char *cmd, bool terminal, smenu_entry_t **rentry) 331 369 { 332 370 smenu_entry_t *entry; … … 352 390 goto error; 353 391 } 392 393 entry->terminal = terminal; 354 394 355 395 entry->smenu = smenu; … … 391 431 * @param caption Caption 392 432 * @param cmd Command to run 433 * @param terminal Start in terminal 393 434 * @param rentry Place to store pointer to new entry or @c NULL 394 435 */ 395 436 errno_t smenu_entry_create(tbarcfg_t *smenu, const char *caption, 396 const char *cmd, smenu_entry_t **rentry)437 const char *cmd, bool terminal, smenu_entry_t **rentry) 397 438 { 398 439 sif_node_t *nentry; … … 418 459 goto error; 419 460 420 rc = smenu_entry_new(smenu, nentry, caption, cmd, &entry); 461 rc = sif_node_set_attr(trans, nentry, "terminal", terminal ? "y" : "n"); 462 if (rc != EOK) 463 goto error; 464 465 rc = smenu_entry_new(smenu, nentry, caption, cmd, terminal ? "y" : "n", 466 &entry); 421 467 if (rc != EOK) 422 468 goto error;
Note:
See TracChangeset
for help on using the changeset viewer.