Changeset b1397ab in mainline for uspace/app/taskbar-cfg/startmenu.c
- Timestamp:
- 2023-11-09T13:02:16Z (14 months ago)
- Branches:
- master, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e0d874b7
- Parents:
- 40eab9f
- git-author:
- Jiri Svoboda <jiri@…> (2023-11-08 18:01:53)
- git-committer:
- Jiri Svoboda <jiri@…> (2023-11-09 13:02:16)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/taskbar-cfg/startmenu.c
r40eab9f rb1397ab 292 292 smenu_entry_t *entry; 293 293 startmenu_entry_t *smentry; 294 const char *caption;295 const char *cmd;296 294 errno_t rc; 297 295 298 296 entry = tbarcfg_smenu_first(tbarcfg); 299 297 while (entry != NULL) { 300 caption = smenu_entry_get_caption(entry); 301 cmd = smenu_entry_get_cmd(entry); 302 303 rc = startmenu_insert(smenu, caption, cmd, &smentry); 298 rc = startmenu_insert(smenu, entry, &smentry); 304 299 if (rc != EOK) 305 300 return rc; … … 323 318 while (lentry != NULL) { 324 319 entry = (startmenu_entry_t *)ui_list_entry_get_arg(lentry); 325 free(entry->caption);326 free(entry->cmd);327 320 free(entry); 328 321 ui_list_entry_delete(lentry); … … 338 331 * 339 332 * @param smenu Start menu configuration tab 340 * @param caption Entry caption 341 * @param cmd Command to run 342 * @param rentry Place to store pointer to new entry or NULL 333 * @param entry Backing entry 334 * @param rsmentry Place to store pointer to new entry or NULL 343 335 * @return EOK on success or an error code 344 336 */ 345 errno_t startmenu_insert(startmenu_t *smenu, const char *caption,346 const char *cmd, startmenu_entry_t **rentry)347 { 348 startmenu_entry_t * entry;337 errno_t startmenu_insert(startmenu_t *smenu, smenu_entry_t *entry, 338 startmenu_entry_t **rsmentry) 339 { 340 startmenu_entry_t *smentry; 349 341 ui_list_entry_attr_t attr; 350 342 errno_t rc; 351 343 352 entry = calloc(1, sizeof(startmenu_entry_t));353 if ( entry == NULL)344 smentry = calloc(1, sizeof(startmenu_entry_t)); 345 if (smentry == NULL) 354 346 return ENOMEM; 355 347 356 entry->startmenu = smenu; 357 entry->caption = str_dup(caption); 358 if (entry->caption == NULL) { 359 free(entry); 360 return ENOMEM; 361 } 362 363 entry->cmd = str_dup(cmd); 364 if (entry->caption == NULL) { 365 free(entry->caption); 366 free(entry); 367 return ENOMEM; 368 } 369 348 smentry->startmenu = smenu; 349 smentry->entry = entry; 350 351 printf("startmenu_insert: smentry=%p entry=%p\n", 352 smentry, entry); 370 353 ui_list_entry_attr_init(&attr); 371 attr.caption = caption; 372 attr.arg = (void *)entry; 373 rc = ui_list_entry_append(smenu->entries_list, &attr, &entry->lentry); 374 if (rc != EOK) { 375 free(entry->caption); 376 free(entry->cmd); 377 free(entry); 354 attr.caption = smenu_entry_get_caption(entry); 355 attr.arg = (void *)smentry; 356 rc = ui_list_entry_append(smenu->entries_list, &attr, &smentry->lentry); 357 if (rc != EOK) { 358 free(smentry); 378 359 return rc; 379 360 } 380 361 381 if (r entry != NULL)382 *r entry =entry;362 if (rsmentry != NULL) 363 *rsmentry = smentry; 383 364 return EOK; 384 365 } 385 366 367 /** Get selected start menu entry. 368 * 369 * @param smenu Start menu 370 * @return Selected entry 371 */ 372 startmenu_entry_t *startmenu_get_selected(startmenu_t *smenu) 373 { 374 ui_list_entry_t *entry; 375 376 entry = ui_list_get_cursor(smenu->entries_list); 377 return (startmenu_entry_t *)ui_list_entry_get_arg(entry); 378 } 379 386 380 /** Edit selected menu entry. 387 381 * … … 391 385 { 392 386 smeedit_t *smee; 387 startmenu_entry_t *smentry; 393 388 errno_t rc; 394 389 395 rc = smeedit_create(smenu, &smee); 390 smentry = startmenu_get_selected(smenu); 391 392 printf("smeedit_create:entry=%p\n", smentry); 393 rc = smeedit_create(smenu, smentry, &smee); 396 394 if (rc != EOK) 397 395 return;
Note:
See TracChangeset
for help on using the changeset viewer.