Changeset b1397ab in mainline for uspace/lib/tbarcfg/src/tbarcfg.c
- Timestamp:
- 2023-11-09T13:02:16Z (21 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/lib/tbarcfg/src/tbarcfg.c
r40eab9f rb1397ab 71 71 goto error; 72 72 73 tbcfg->repo = repo; 74 73 75 rnode = sif_get_root(repo); 74 76 nentries = sif_node_first_child(rnode); … … 99 101 } 100 102 101 rc = smenu_entry_create(tbcfg, caption, cmd);103 rc = smenu_entry_create(tbcfg, nentry, caption, cmd); 102 104 if (rc != EOK) 103 105 goto error; … … 122 124 void tbarcfg_close(tbarcfg_t *tbcfg) 123 125 { 126 (void)sif_close(tbcfg->repo); 124 127 } 125 128 … … 176 179 } 177 180 181 /** Set start menu entry caption. 182 * 183 * Note: To make the change visible to others and persistent, 184 * you must call @c smenu_entry_save() 185 * 186 * @param entry Start menu entry 187 * @param caption New caption 188 * @return EOK on success, ENOMEM if out of memory 189 */ 190 errno_t smenu_entry_set_caption(smenu_entry_t *entry, const char *caption) 191 { 192 char *dcap; 193 194 dcap = str_dup(caption); 195 if (dcap == NULL) 196 return ENOMEM; 197 198 free(entry->caption); 199 entry->caption = dcap; 200 return EOK; 201 } 202 203 /** Set start menu entry command. 204 * 205 * Note: To make the change visible to others and persistent, 206 * you must call @c smenu_entry_save() 207 * 208 * @param entry Start menu entry 209 * @param cmd New command 210 * @return EOK on success, ENOMEM if out of memory 211 */ 212 errno_t smenu_entry_set_cmd(smenu_entry_t *entry, const char *cmd) 213 { 214 char *dcmd; 215 216 dcmd = str_dup(cmd); 217 if (dcmd == NULL) 218 return ENOMEM; 219 220 free(entry->cmd); 221 entry->cmd = dcmd; 222 return EOK; 223 } 224 225 /** Save any changes to start menu entry. 226 * 227 * @param entry Start menu entry 228 */ 229 errno_t smenu_entry_save(smenu_entry_t *entry) 230 { 231 sif_trans_t *trans; 232 errno_t rc; 233 234 rc = sif_trans_begin(entry->smenu->repo, &trans); 235 if (rc != EOK) 236 goto error; 237 238 rc = sif_node_set_attr(trans, entry->nentry, "cmd", entry->cmd); 239 if (rc != EOK) 240 goto error; 241 242 rc = sif_node_set_attr(trans, entry->nentry, "caption", entry->caption); 243 if (rc != EOK) 244 goto error; 245 246 rc = sif_trans_end(trans); 247 if (rc != EOK) 248 goto error; 249 250 return EOK; 251 error: 252 if (trans != NULL) 253 sif_trans_abort(trans); 254 return rc; 255 } 256 178 257 /** Create a start menu entry and append it to the start menu (internal). 179 258 * … … 181 260 * 182 261 * @param smenu Start menu 262 * @param nentry Backing SIF node 183 263 * @param caption Caption 184 264 * @param cmd Command to run 185 265 */ 186 errno_t smenu_entry_create(tbarcfg_t *smenu, const char *caption,187 const char *c md)266 errno_t smenu_entry_create(tbarcfg_t *smenu, sif_node_t *nentry, 267 const char *caption, const char *cmd) 188 268 { 189 269 smenu_entry_t *entry; … … 195 275 goto error; 196 276 } 277 278 entry->nentry = nentry; 197 279 198 280 entry->caption = str_dup(caption);
Note:
See TracChangeset
for help on using the changeset viewer.